Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/issue 30 home page #57

Merged
merged 68 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
64b36c3
recent post component
thescientist13 Jun 3, 2024
2ee75e2
hero banner iterations
thescientist13 Jun 6, 2024
2a6d44f
formatting
thescientist13 Jun 6, 2024
5e734e5
WIP walkthrough section setup
thescientist13 Jun 10, 2024
b508f5b
css modules implementation refactoring
thescientist13 Jun 10, 2024
eed1592
misc walkthrough SSR refactor
thescientist13 Jun 10, 2024
865576b
walkthrough layout styling WIP
thescientist13 Jun 11, 2024
8482ae2
fix lint
thescientist13 Jun 17, 2024
e68bfb6
misc styling
thescientist13 Jun 17, 2024
b38d306
hover styling for walk through
thescientist13 Jun 17, 2024
f11e368
scaffolding out addition home page sections
thescientist13 Jun 17, 2024
b9d8fa1
favor init package greenwood starter command
thescientist13 Jun 24, 2024
438db1b
card emphasis styling
thescientist13 Jun 24, 2024
7c3f202
active selection
thescientist13 Jun 24, 2024
c38ea61
run anywhere platform icon boxes
thescientist13 Jun 25, 2024
4af6740
formatting
thescientist13 Jun 25, 2024
70e7900
styling and content for build with friends section
thescientist13 Jun 30, 2024
30fd2cc
restore fill on github icon SVG
thescientist13 Jun 30, 2024
9a56d8a
misc copy and styling tweaks
thescientist13 Jun 30, 2024
459b94d
why greenwood skeleton
thescientist13 Jul 1, 2024
e00deae
misc sections styling
thescientist13 Jul 1, 2024
0c10170
getting started CTA content
thescientist13 Jul 1, 2024
055153f
breakpoint responsiveness
thescientist13 Jul 1, 2024
56c4e41
adjust text
thescientist13 Jul 3, 2024
a6eddff
walkthrough code box nav styling
thescientist13 Jul 3, 2024
84a0bb3
misc responsiveness
thescientist13 Jul 6, 2024
4da45b8
general mobile and responsivess styling refinements
thescientist13 Jul 8, 2024
c2b7d1f
re-patch post rebase
thescientist13 Jul 11, 2024
bf5ba73
rename walkthrough to capabilities
thescientist13 Jul 14, 2024
5fabcf4
first content drafting for all sections
thescientist13 Jul 14, 2024
b08cf81
handle scoping and naming of repeated selector names
thescientist13 Jul 16, 2024
c5b6f35
WIP meeting review feedback, responsiveness tweaks, and copy content …
thescientist13 Jul 21, 2024
567ebbe
css modules overlapping classnames bug tweak
thescientist13 Jul 21, 2024
46e7124
global link styling
thescientist13 Jul 21, 2024
4f121be
finish up design feedback
thescientist13 Jul 21, 2024
17e02da
formatting
thescientist13 Jul 21, 2024
c0f549c
remove icons
thescientist13 Aug 5, 2024
457e3b0
unused styles cleanup
thescientist13 Aug 5, 2024
08d148e
refine why greenwood responsive styles
thescientist13 Aug 11, 2024
6d5a66f
final styling for copy to clipboard feature
thescientist13 Aug 12, 2024
edb7b7f
tweak platform name box styles
thescientist13 Aug 12, 2024
a14f011
patch getElementById in wc-compiler
thescientist13 Aug 12, 2024
37cdc80
filter css modules to only local files
thescientist13 Aug 12, 2024
64c92fa
formatting
thescientist13 Aug 12, 2024
2e61d78
fade in capabilities snippets
thescientist13 Aug 12, 2024
f9b57a3
scrollbar styling
thescientist13 Aug 12, 2024
a55e589
capabilities SVG styling
thescientist13 Aug 12, 2024
9adda75
bump and patch greenwood 0.30.0-alpha.5
thescientist13 Aug 12, 2024
163abab
formatting and linting
thescientist13 Aug 12, 2024
dbfcaf4
apply typography and font sizing style feedback
thescientist13 Aug 13, 2024
660d67f
link styling
thescientist13 Aug 13, 2024
c9c8ada
add open props to build with friends
thescientist13 Aug 14, 2024
35c1dc4
style run anywhere platform name pills hover styles
thescientist13 Aug 14, 2024
7c45d60
hero banner button link hover tweaks
thescientist13 Aug 14, 2024
93461f5
markdown formatting indentation refinements
thescientist13 Aug 18, 2024
2c16995
revert usage of import attributes to raw CSS
thescientist13 Aug 18, 2024
2b1c966
appropriate heading sequence
thescientist13 Aug 18, 2024
b62b5fa
misc cross browser styling tweaks
thescientist13 Aug 18, 2024
c304a71
design system usage consistency and using more classnames
thescientist13 Aug 18, 2024
c0d1184
linking and styling
thescientist13 Aug 18, 2024
ecd8b42
add platform links
thescientist13 Aug 18, 2024
9605754
stackblitz and getting started links
thescientist13 Aug 18, 2024
82a353f
fix code snippet
thescientist13 Aug 21, 2024
df460c9
misc link style tweaks
thescientist13 Aug 21, 2024
3073ecf
hero banner and latest post home page resizing to better use whitespa…
thescientist13 Aug 25, 2024
4ec20ad
wrap home page snippets animiation in prefers reduced motion media query
thescientist13 Aug 25, 2024
a0e59e3
align button hover background color to match
thescientist13 Aug 25, 2024
e409146
remove side border from why greenwood section
thescientist13 Aug 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ This would emit the following generated HTML

#### Interactive Components (Declarative Shadow DOM)

For interactive components that would require client side interactivity, like for event handlers, these component should be authored rendering into a Shadow Root with [Declarative Shadow DOM](https://developer.chrome.com/docs/css-ui/declarative-shadow-dom) and using [Constructable Stylesheets](https://web.dev/articles/constructable-stylesheets).
For interactive components that would require client side interactivity, like event handlers, these components should be authored rendering into a Shadow Root using [Declarative Shadow DOM](https://developer.chrome.com/docs/css-ui/declarative-shadow-dom) and with Greenwood's [raw plugin](https://github.com/ProjectEvergreen/greenwood/tree/master/packages/plugin-import-raw).

<details>
Ideally we would be using <a href="https://web.dev/articles/constructable-stylesheets">Constructable Stylesheets and Import Attributes</a> but CSS Import Attributes are <a href="https://github.com/ProjectEvergreen/www.greenwoodjs.dev/pull/57#issuecomment-2295349811">not baseline yet</a>. 😞
</details>

```css
/* card.css */
Expand All @@ -115,7 +119,7 @@ For interactive components that would require client side interactivity, like fo
```

```js
import sheet from "./card.css" with { type: "css" };
import styles from "./card.css?type=raw";

export default class Card extends HTMLElement {
selectItem() {
Expand All @@ -130,6 +134,9 @@ export default class Card extends HTMLElement {

template.innerHTML = `
<div class="card">
<style>
${styles}
</style>
<h3>${title}</h3>
<img src="${thumbnail}" alt="${title}" loading="lazy" width="100%">
<button>View Item Details</button>
Expand All @@ -139,7 +146,6 @@ export default class Card extends HTMLElement {
this.shadowRoot.appendChild(template.content.cloneNode(true));
}

this.shadowRoot.adoptedStylesheets = [sheet];
this.shadowRoot?.querySelector("button").addEventListener("click", this.selectItem.bind(this));
}
}
Expand Down
2 changes: 1 addition & 1 deletion greenwood.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { greenwoodPluginCssModules } from "./plugin-css-modules.js";

export default {
prerender: true,
plugins: [greenwoodPluginImportRaw(), greenwoodPluginCssModules()],
plugins: [greenwoodPluginCssModules(), greenwoodPluginImportRaw()],
markdown: {
plugins: ["@mapbox/rehype-prism"],
},
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions patches/wc-compiler+0.14.0.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
diff --git a/node_modules/wc-compiler/src/dom-shim.js b/node_modules/wc-compiler/src/dom-shim.js
index be289a3..dd4692a 100644
index be289a3..db07eb9 100644
--- a/node_modules/wc-compiler/src/dom-shim.js
+++ b/node_modules/wc-compiler/src/dom-shim.js
@@ -102,6 +102,9 @@ class ShadowRoot extends DocumentFragment {
@@ -83,6 +83,9 @@ class Document extends Node {
createDocumentFragment(html) {
return new DocumentFragment(html);
}
+
+ querySelector() { }
+ querySelectorAll() { }
}

// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
@@ -102,6 +105,10 @@ class ShadowRoot extends DocumentFragment {
super();
this.mode = options.mode || 'closed';
this.adoptedStyleSheets = [];
+ // TODO not sure if this is the right base class for these?
+ this.querySelector = noop;
+ this.querySelectorAll = noop;
+ this.getElementById = noop;
}
}

179 changes: 113 additions & 66 deletions plugin-css-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
const { value = "" } = source;

// console.log({ value, specifiers });
// TODO bare specifiers support?

Check warning on line 40 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO bare specifiers support?'

Check warning on line 40 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO bare specifiers support?'
if (
value.endsWith(".module.css") &&
specifiers.length === 1 &&
Expand All @@ -52,6 +52,7 @@
let scopedCssContents = cssContents;

const ast = parse(cssContents, {
// positions: true,
onParseError(error) {
console.log(error.formattedMessage);
},
Expand All @@ -66,21 +67,41 @@
if (node.children?.head?.data?.type === "Selector") {
if (node.children?.head?.data?.children?.head?.data?.type === "ClassSelector") {
const { name } = node.children.head.data.children.head.data;

const scopedClassName = `${scope}-${hash}-${name}`;
classNameMap[name] = scopedClassName;

scopedCssContents = scopedCssContents.replace(
`\.${name}`,
`\.${scopedClassName}`,
);
/*
* bit of a hacky solution since as we are walking class names one at a time, if we have multiple uses of .heading (for example)
* then by the end we could have .my-component-111-header.my-component-111-header.etc, since we want to replace all instances (e.g. the g flag in Regex)
*
* csstree supports loc so we _could_ target the class replacement down to start / end points, but that unfortunately slows things down a lot
*/
// TODO this is a pretty ugly find / replace technique...

Check warning on line 79 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO this is a pretty ugly find /...'

Check warning on line 79 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO this is a pretty ugly find /...'
// will definitely want to refactor and test this well
if (
scopedCssContents.indexOf(`.${scopedClassName} `) < 0 &&
scopedCssContents.indexOf(`.${scopedClassName} {`) < 0
) {
scopedCssContents = scopedCssContents.replace(
new RegExp(String.raw`.${name} `, "g"),
`.${scope}-${hash}-${name} `,
);
scopedCssContents = scopedCssContents.replace(
new RegExp(String.raw`.${name},`, "g"),
`.${scope}-${hash}-${name},`,
);
scopedCssContents = scopedCssContents.replace(
new RegExp(String.raw`.${name}:`, "g"),
`.${scope}-${hash}-${name}:`,
);
}
}
}
}
},
});

// TODO could we convert this module into an instance of CSSStylesheet to grab values?

Check warning on line 104 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO could we convert this module into...'

Check warning on line 104 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO could we convert this module into...'
// https://web.dev/articles/constructable-stylesheets
// or just use postcss-modules plugin?
const cssModulesMap = getCssModulesMap(compilation);
Expand Down Expand Up @@ -137,7 +158,7 @@
}

async shouldResolve(url) {
return url.pathname.endsWith("module.css");
return url.protocol === "file:" && url.pathname.endsWith("module.css");
}

async resolve(url) {
Expand All @@ -159,78 +180,104 @@
return new Request(matchedUrl);
}

async shouldServe(url) {
// async shouldIntercept(url) {
// console.log('css modules intercept', { url });
// const { pathname, protocol } = url;
// const mapKey = `${protocol}//${pathname}`;
// // // console.log(this.compilation.context.scratchDir)
// // // console.log(new URL('./__css-modules-map.json', this.compilation.context.scratchDir));
// const cssModulesMap = getCssModulesMap(this.compilation);
// // console.log("shouldServer", { cssModulesMap, url });
// return protocol === "file:" && pathname.endsWith(this.extensions[0]) && cssModulesMap[mapKey];
// }

// async intercept(url) {
// console.log('css modules intercept', { url });
// const { pathname, protocol } = url;
// const mapKey = `${protocol}//${pathname}`;
// const cssModulesMap = getCssModulesMap(this.compilation);
// // console.log("@@@@@@", { url, cssModulesMap });
// const cssModule = `export default ${JSON.stringify(cssModulesMap[mapKey].module)}`;

// // console.log("@@@@@@", { cssModule });
// return new Response(cssModule, {
// headers: {
// "Content-Type": this.contentType,
// },
// });
// }

// this happens "first" as the HTML is returned, to find viable references to CSS Modules
// better way than just checking for /?
async shouldIntercept(url) {
const { pathname, protocol } = url;
const mapKey = `${protocol}//${pathname}`;
// // console.log(this.compilation.context.scratchDir)
// // console.log(new URL('./__css-modules-map.json', this.compilation.context.scratchDir));
const cssModulesMap = getCssModulesMap(this.compilation);
// console.log("shouldServer", { cssModulesMap, url });
return protocol === "file:" && pathname.endsWith(this.extensions[0]) && cssModulesMap[mapKey];

return (
url.pathname.endsWith("/") ||
(protocol === "file:" && pathname.endsWith(this.extensions[0]) && cssModulesMap[mapKey])
);
}

async serve(url) {
async intercept(url, request, response) {
const { pathname, protocol } = url;
const mapKey = `${protocol}//${pathname}`;
const cssModulesMap = getCssModulesMap(this.compilation);
// console.log("@@@@@@", { url, cssModulesMap });
const cssModule = `export default ${JSON.stringify(cssModulesMap[mapKey].module)}`;

// console.log("@@@@@@", { cssModule });
return new Response(cssModule, {
headers: {
"Content-Type": this.contentType,
},
});
}

// this happens "first" as the HTML is returned, to find viable references to CSS Modules
// better way than just checking for /?
async shouldIntercept(url) {
return url.pathname.endsWith("/");
}

async intercept(url, request, response) {
const body = await response.text();
const dom = htmlparser.parse(body, { script: true });
const scripts = dom.querySelectorAll("head script");
const sheets = []; // TODO use a map here?

for (const script of scripts) {
const type = script.getAttribute("type");
const src = script.getAttribute("src");
if (src && ["module", "module-shim"].includes(type)) {
// console.log("check this file for CSS Modules", src);
// await resolveForRelativeUrl(new URL(src, import.meta.url this.compilation.context.userWorkspace)
const scriptUrl = new URL(
`./${src.replace(/\.\.\//g, "").replace(/\.\//g, "")}`,
this.compilation.context.userWorkspace,
);
walkAllImportsForCssModules(scriptUrl, sheets, this.compilation);
if (url.pathname.endsWith("/")) {
const body = await response.text();
const dom = htmlparser.parse(body, { script: true });
const scripts = dom.querySelectorAll("head script");
const sheets = []; // TODO use a map here?

Check warning on line 232 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO use a map here?'

Check warning on line 232 in plugin-css-modules.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO use a map here?'

for (const script of scripts) {
const type = script.getAttribute("type");
const src = script.getAttribute("src");
if (src && ["module", "module-shim"].includes(type)) {
// console.log("check this file for CSS Modules", src);
// await resolveForRelativeUrl(new URL(src, import.meta.url this.compilation.context.userWorkspace)
const scriptUrl = new URL(
`./${src.replace(/\.\.\//g, "").replace(/\.\//g, "")}`,
this.compilation.context.userWorkspace,
);
walkAllImportsForCssModules(scriptUrl, sheets, this.compilation);
}
}
}

const cssModulesMap = getCssModulesMap(this.compilation);
// console.log({ cssModulesMap });

// for(const cssModule of cssModulesMap) {
// // console.log({ cssModule });
// }
Object.keys(cssModulesMap).forEach((key) => {
sheets.push(cssModulesMap[key].contents);
});

const newBody = body.replace(
"</head>",
`
<style>
${sheets.join("\n")}
</style>
</head>
`,
);
const cssModulesMap = getCssModulesMap(this.compilation);
// console.log({ cssModulesMap });

// for(const cssModule of cssModulesMap) {
// // console.log({ cssModule });
// }
Object.keys(cssModulesMap).forEach((key) => {
sheets.push(cssModulesMap[key].contents);
});

const newBody = body.replace(
"</head>",
`
<style>
${sheets.join("\n")}
</style>
</head>
`,
);

return new Response(newBody);
return new Response(newBody);
} else if (
url.pathname.endsWith("/") ||
(protocol === "file:" && pathname.endsWith(this.extensions[0]) && cssModulesMap[mapKey])
) {
const cssModule = `export default ${JSON.stringify(cssModulesMap[mapKey].module)}`;

return new Response(cssModule, {
headers: {
"Content-Type": this.contentType,
},
});
}
}

async shouldOptimize(url, response) {
Expand Down
10 changes: 5 additions & 5 deletions src/assets/api-routes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions src/assets/build-ssg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/assets/html.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading