-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: restructure site theme styles and components #241
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
Open
david-on-github
wants to merge
27
commits into
master
Choose a base branch
from
david/css-refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
62deb84
Convert theme swizzles to TS, restructure CSS into partials, and poli…
david-on-github 0dea3fa
update h4 font size
david-on-github 31ed6b0
Restyle admonitions, details, and tables; add internal styleguide
david-on-github eaa05c2
Remove unused inlined GitHub icon component
david-on-github 3c0122d
Map greys onto the brand ramp; rework admonition colour and contrast
david-on-github 04c70ad
Share tip's fill with info, fix icon contrast, chevron for the versio…
david-on-github 71ba3e3
Token hygiene: green primary shades, brand text roles, unitless zeros
david-on-github 9549d8a
Use the rem() helper consistently across the partials
david-on-github 95221d8
Trim the comments in the SCSS partials
david-on-github 6a9d35e
Trim SCSS comments further; sticky collapse button; darker note fill
david-on-github 8022687
Split the junk-drawer partials; rename utils to functions
david-on-github e5333a7
Refresh the styleguide's token references
david-on-github 2e57f69
Hide the ToC below 1200px instead of squeezing three columns
david-on-github b68aadf
Hide the whole ToC column below 1200px; align the shell to the content
david-on-github 87c5d73
Fix light-mode contrast on brand green/warning/muted-text tokens
david-on-github 53c5a4f
Fix homepage/navbar/footer/sidebar gutter alignment and misc UI issues
david-on-github 3f80dd8
Update static/robots.txt
david-on-github c7303cd
Add a mobile ToC dropdown and tidy the mobile chrome
david-on-github cbd1d8a
Drop the unused changelog sidebar reordering
david-on-github 5a64b7a
Rework the navbar controls and separate accent from state
david-on-github dac6c0c
Move the version picker into the product it applies to
david-on-github d3a04d7
Size the mobile header icons as touch targets
david-on-github 74004fc
Match the sidebar back button's type to the rows below it
david-on-github f265c72
Show each styleguide example's own markdown
david-on-github 35344c2
Self-host the fonts instead of loading them from Google
david-on-github 0c401ee
Address the review findings that hold up
david-on-github 135bf69
Track package-lock.json
david-on-github File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| # Dependencies | ||
| /node_modules | ||
| package-lock.json | ||
|
|
||
| # Production | ||
| /build | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Sidebar for the internal styleguide docs instance. Kept separate from | ||
| // sidebars.js so the styleguide pages don't get picked up by the autogenerated | ||
| // sidebars the product instances share. | ||
| export default { | ||
| styleguideSidebar: [ | ||
| { | ||
| type: 'autogenerated', | ||
| dirName: '.', | ||
| }, | ||
| ], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Styling for the metastring reference table in components.mdx, kept as a CSS | ||
| // module beside the page rather than a partial in src/css: the styleguide is | ||
| // internal, and a table that reads as reference material isn't a pattern the | ||
| // product docs should inherit. The leading underscore keeps Docusaurus from | ||
| // treating the file as a doc page. | ||
|
|
||
| .optionsTable { | ||
| // Denser rows than the site default, which is set for prose-length cells: | ||
| // --ifm-table-cell-padding is 0.75rem 1rem in variables.scss. Set on the | ||
| // wrapper so th and td both follow it, and _tables.scss keeps zeroing the | ||
| // outer edges of the first and last columns. | ||
| --ifm-table-cell-padding: 0.375rem 1rem; | ||
|
|
||
| // Short option names against long descriptions: both a step down from body | ||
| // copy, the descriptions further still, since they're the bulk of the table. | ||
| table { | ||
| font-size: 0.875rem; | ||
| } | ||
|
|
||
| td:last-child { | ||
| font-size: 0.6875rem; // 11px | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,303 @@ | ||
| --- | ||
| title: Design tokens | ||
| sidebar_position: 3 | ||
| description: Every custom property declared in variables.scss, rendered as swatches. | ||
| --- | ||
|
|
||
| <head> | ||
| <meta name="robots" content="noindex, nofollow" /> | ||
| </head> | ||
|
|
||
| {/* Styled inline rather than with classes: this page is internal, and anything it puts in a stylesheet ships to every product page too. */} | ||
|
|
||
| export const Swatch = ({ name, from }) => ( | ||
| <div style={{ display: "flex", alignItems: "center", gap: "0.75rem", padding: "0.3rem 0", minWidth: 0 }}> | ||
| <span | ||
| aria-hidden="true" | ||
| style={{ | ||
| width: "2.25rem", | ||
| height: "2.25rem", | ||
| flexShrink: 0, | ||
| borderRadius: "6px", | ||
| background: `var(${name})`, | ||
| border: "1px solid var(--ifm-color-emphasis-300)", | ||
| }} | ||
| /> | ||
| <div style={{ minWidth: 0 }}> | ||
| <code style={{ fontSize: "0.75rem", wordBreak: "break-all" }}>{name}</code> | ||
| {from && ( | ||
| <div style={{ fontSize: "0.7rem", opacity: 0.6, marginTop: "0.15rem", wordBreak: "break-all" }}> | ||
| ↳ {from} | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
|
|
||
| export const Swatches = ({ names }) => ( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: a neat way of exposing them! 🤸 |
||
| <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(240px, 1fr))", gap: "0.25rem 1.5rem", marginBottom: "1.5rem" }}> | ||
| {names.map((n) => { | ||
| const [name, from] = Array.isArray(n) ? n : [n, null]; | ||
| return <Swatch key={name} name={name} from={from} />; | ||
| })} | ||
| </div> | ||
| ); | ||
|
|
||
| Every colour token declared in `src/css/variables.scss`. Each swatch shows the token's real value, so switching the theme updates the whole page. Spacing, type and sizing tokens are in the table at the end. | ||
|
|
||
| Some tokens are aliases: they point at another token rather than holding a colour themselves. When that's the case, the token it points at is listed underneath, after a `↳`. | ||
|
|
||
| A token can point at different things in each theme. Those are written `light / dark`. A `—` on one side means the token is not an alias in that theme; it holds a value of its own, either an Infima default we haven't changed or a one-off colour with no brand token behind it. | ||
|
|
||
| ## Brand | ||
|
|
||
| `--src-amber` is the LensVM product accent, reused as the semantic warning colour, a deliberate departure from the brand's "keep accents isolated to their contexts" guidance. | ||
|
|
||
| <Swatches names={[ | ||
| "--src-primary", | ||
| "--src-highlight", | ||
| "--src-red", | ||
| "--src-amber", | ||
| ]} /> | ||
|
|
||
| ## Brand color scales | ||
|
|
||
| The green and grey ramps from the Source brand system, using the brand's own step numbers. | ||
|
|
||
| `--src-green-400` is the same colour as `--src-primary`. In light mode, `--ifm-color-primary` and its shades all resolve through `--src-green-*`. | ||
|
|
||
| Every grey in the site resolves back to this grey ramp. The mapping onto Infima's `--ifm-color-gray-*` happens in `variables.scss`. `--src-gray-50` has no Infima slot and is currently unused. | ||
|
|
||
| <Swatches names={[ | ||
| "--src-green-50", | ||
| "--src-green-100", | ||
| "--src-green-200", | ||
| "--src-green-300", | ||
| "--src-green-400", | ||
| "--src-green-500", | ||
| "--src-green-600", | ||
| "--src-green-700", | ||
| "--src-green-800", | ||
| "--src-green-900", | ||
| ]} /> | ||
|
|
||
| <Swatches names={[ | ||
| "--src-white", | ||
| "--src-gray-50", | ||
| "--src-gray-100", | ||
| "--src-gray-200", | ||
| "--src-gray-300", | ||
| "--src-gray-400", | ||
| "--src-gray-500", | ||
| "--src-gray-600", | ||
| "--src-gray-700", | ||
| "--src-gray-800", | ||
| "--src-gray-900", | ||
| "--src-ink", | ||
| "--src-obsidian", | ||
| "--src-black", | ||
| ]} /> | ||
|
|
||
| ## Interaction overlays | ||
|
|
||
| These are translucent, so the swatches below show the page background through them. | ||
|
|
||
| The sidebar menu and the tab bar share them. They are kept separate from Infima's `--ifm-hover-overlay`, which stays at 5% and is used by breadcrumbs, dropdowns, pagination and pills. | ||
|
|
||
| <Swatches names={["--src-hover-overlay", "--src-active-overlay"]} /> | ||
|
|
||
| ## Infima primary | ||
|
|
||
| `--ifm-color-primary` is `--src-green-500` in light and `--src-highlight` in dark. | ||
|
|
||
| Light mode uses the darker step because the brand green itself, `--src-primary`, reaches only 2.8:1 on white. Text needs 4.5:1. | ||
|
|
||
| The `-dark` through `-lightest` variants are each a step on the brand's green scale, not a ramp generated from the base colour. Infima uses `-dark` and `-darker` for the hover and active states on `.button--primary`. | ||
|
|
||
| <Swatches names={[ | ||
| ["--ifm-color-primary", "--src-green-500 / --src-highlight"], | ||
| ["--ifm-color-primary-dark", "--src-green-600"], | ||
| ["--ifm-color-primary-darker", "--src-green-700"], | ||
| ["--ifm-color-primary-darkest", "--src-green-800"], | ||
| ["--ifm-color-primary-light", "--src-green-400"], | ||
| ["--ifm-color-primary-lighter", "--src-green-300"], | ||
| ["--ifm-color-primary-lightest", "--src-green-200"], | ||
| ]} /> | ||
|
|
||
| ## Surfaces and text | ||
|
|
||
| <Swatches names={[ | ||
| ["--ifm-background-color", "— / --src-black"], | ||
| ["--ifm-background-surface-color", "— / --src-black"], | ||
| ["--ifm-font-color-base", "--ifm-color-emphasis-900"], | ||
| "--ifm-color-content-secondary", | ||
| ["--ifm-menu-color", "--ifm-color-emphasis-700 / --ifm-color-emphasis-600"], | ||
| ["--ifm-menu-color-active", "--ifm-color-primary"], | ||
| ["--ifm-footer-background-color", "— / --src-black"], | ||
| ["--ifm-table-border-color", "--ifm-color-emphasis-200"], | ||
| ["--src-text-muted", "--src-gray-500 / —"], | ||
| ["--src-text-subtitle", "--src-gray-600 / —"], | ||
| ["--docs-title-border", "--src-gray-200 / --src-gray-900"], | ||
| ["--ifm-hr-background-color", "--ifm-color-emphasis-300 / --ifm-color-emphasis-200"], | ||
| ["--menu-indicator-color", "--src-gray-300"], | ||
| ["--ifm-scrollbar-thumb-background-color", "--ifm-color-emphasis-400 / --ifm-color-emphasis-300"], | ||
| ]} /> | ||
|
|
||
| ## Infima gray ramp | ||
|
|
||
| A straight alias onto the brand neutrals, identical in both themes; this is the single mapping that the emphasis scale below is built from. | ||
|
|
||
| <Swatches names={[ | ||
| ["--ifm-color-gray-0", "--src-white"], | ||
| ["--ifm-color-gray-100", "--src-gray-100"], | ||
| ["--ifm-color-gray-200", "--src-gray-200"], | ||
| ["--ifm-color-gray-300", "--src-gray-300"], | ||
| ["--ifm-color-gray-400", "--src-gray-400"], | ||
| ["--ifm-color-gray-500", "--src-gray-500"], | ||
| ["--ifm-color-gray-600", "--src-gray-600"], | ||
| ["--ifm-color-gray-700", "--src-gray-700"], | ||
| ["--ifm-color-gray-800", "--src-gray-800"], | ||
| ["--ifm-color-gray-900", "--src-gray-900"], | ||
| ["--ifm-color-gray-1000", "--src-obsidian"], | ||
| ]} /> | ||
|
|
||
| ## Emphasis scale | ||
|
|
||
| The ramp used for borders and fills, aliased onto the grey ramp above. | ||
|
|
||
| It is **inverted** in dark mode, so each step points at the opposite end of the grey ramp: `emphasis-0` is `gray-0` in light and `gray-1000` in dark. `emphasis-500` is the midpoint and lands on `gray-500` either way. `emphasis-200` is the step the partials use most. | ||
|
|
||
| <Swatches names={[ | ||
| ["--ifm-color-emphasis-0", "--ifm-color-gray-0 / --ifm-color-gray-1000"], | ||
| ["--ifm-color-emphasis-100", "--ifm-color-gray-100 / --ifm-color-gray-900"], | ||
| ["--ifm-color-emphasis-200", "--ifm-color-gray-200 / --ifm-color-gray-800"], | ||
| ["--ifm-color-emphasis-300", "--ifm-color-gray-300 / --ifm-color-gray-700"], | ||
| ["--ifm-color-emphasis-400", "--ifm-color-gray-400 / --ifm-color-gray-600"], | ||
| ["--ifm-color-emphasis-500", "--ifm-color-gray-500"], | ||
| ["--ifm-color-emphasis-600", "--ifm-color-gray-600 / --ifm-color-gray-400"], | ||
| ["--ifm-color-emphasis-700", "--ifm-color-gray-700 / --ifm-color-gray-300"], | ||
| ["--ifm-color-emphasis-800", "--ifm-color-gray-800 / --ifm-color-gray-200"], | ||
| ["--ifm-color-emphasis-900", "--ifm-color-gray-900 / --ifm-color-gray-100"], | ||
| ["--ifm-color-emphasis-1000", "--ifm-color-gray-1000 / --ifm-color-gray-0"], | ||
| ]} /> | ||
|
|
||
| ## Cards | ||
|
|
||
| Declared globally but only consumed by `src/pages/index.module.scss`, so these apply to the homepage rather than to docs. | ||
|
|
||
| <Swatches names={["--card-color", ["--card-border-color", "--src-gray-200 / —"]]} /> | ||
|
|
||
| ## Alerts and admonitions | ||
|
|
||
| Each admonition variant is drawn with one of Infima's alert colour families, so the families below are what `:::note` and friends actually resolve through: | ||
|
|
||
| | Admonition | Alert family | | ||
| | --- | --- | | ||
| | `:::note` | `--secondary` | | ||
| | `:::tip` | `--success` | | ||
| | `:::info` | `--info` | | ||
| | `:::warning` and `:::caution` | `--warning` | | ||
| | `:::danger` | `--danger` | | ||
|
|
||
| Info uses tip's fill. Warning and danger take their accent from a brand colour, but keep Infima's own contrast pairs, which differ per theme. | ||
|
|
||
| <Swatches names={[ | ||
| "--ifm-color-info-dark", | ||
| "--ifm-color-info-darker", | ||
| "--ifm-color-info-darkest", | ||
| ["--ifm-color-info-contrast-background", "--ifm-color-success-contrast-background"], | ||
| ["--ifm-color-info-contrast-foreground", "--src-black / --src-white"], | ||
| "--ifm-color-success-contrast-background", | ||
| ["--ifm-color-secondary-dark", "--src-gray-300"], | ||
| ["--ifm-color-secondary-contrast-background", "--src-gray-100 / --src-obsidian"], | ||
| ["--ifm-color-secondary-contrast-foreground", "--src-gray-800 / --src-white"], | ||
| ["--ifm-color-warning", "--src-amber"], | ||
| ["--ifm-color-warning-dark", "--src-amber"], | ||
| "--ifm-color-warning-contrast-background", | ||
| "--ifm-color-warning-contrast-foreground", | ||
| ["--ifm-color-danger", "--src-red"], | ||
| ["--ifm-color-danger-dark", "--src-red"], | ||
| "--ifm-color-danger-contrast-background", | ||
| "--ifm-color-danger-contrast-foreground", | ||
| "--ifm-alert-border-color", | ||
| ]} /> | ||
|
|
||
| ## Code blocks | ||
|
|
||
| <Swatches names={[ | ||
| "--code-foreground", | ||
| ["--code-background", "--src-gray-100 / --src-gray-900"], | ||
| ["--ifm-code-background", "--src-gray-200"], | ||
| ["--code-highlight-color", "— / --src-ink"], | ||
| ["--codeblock-title-border", "--src-gray-300 / —"], | ||
| ["--codeblock-valid-border", "--src-primary"], | ||
| ["--codeblock-invalid-border", "--src-red"], | ||
| ["--codeblock-highlighted-line-background", "--src-gray-200 / —"], | ||
| ]} /> | ||
|
|
||
| ## Syntax tokens | ||
|
|
||
| <Swatches names={[ | ||
| "--code-token-keyword", | ||
| "--code-token-constant", | ||
| "--code-token-string", | ||
| "--code-token-comment", | ||
| "--code-token-parameter", | ||
| "--code-token-function", | ||
| "--code-token-string-expression", | ||
| "--code-token-punctuation", | ||
| "--code-token-link", | ||
| "--code-token-number", | ||
| "--code-token-property", | ||
| ]} /> | ||
|
|
||
| ## Feedback widget | ||
|
|
||
| pushfeedback's own variables, overridden in `variables.scss`. See `src/css/_feedback.scss` for the `::part()` rules that reach into its shadow DOM. | ||
|
|
||
| <Swatches names={[ | ||
| ["--feedback-background", "--code-background"], | ||
| ["--feedback-primary-color", "--src-black / --ifm-font-color-base"], | ||
| ["--feedback-button-dark-bg-color", "--feedback-background"], | ||
| ["--feedback-button-dark-text-color", "--feedback-primary-color"], | ||
| ]} /> | ||
|
|
||
| ## Non-color tokens | ||
|
|
||
| | Token | Value | Used for | | ||
| | --- | --- | --- | | ||
| | `--root-wrapper-width` | `110rem` | Max width of navbar, footer, and main wrapper | | ||
| | `--doc-sidebar-width` | `18.75rem` | Doc sidebar width | | ||
| | `--h1-base-font-size` | `2.25rem` | Shared `h1` size token | | ||
| | `--ifm-h4-font-size` | `1.313rem` | Heading level 4 | | ||
| | `--ifm-font-size-base` | `1rem` | Body copy | | ||
| | `--ifm-font-weight-bold` | `800` | Bold text | | ||
| | `--ifm-leading-desktop` | `1.75` | Line height multiplier | | ||
| | `--ifm-navbar-height` | `80px` | Navbar height | | ||
| | `--ifm-global-radius` | `0rem` | Global corner radius | | ||
| | `--ifm-code-border-radius` | `0.375rem` | Inline code, code blocks, admonitions | | ||
| | `--ifm-alert-border-left-width` | `1px` | Admonition border (matches the other sides) | | ||
| | `--ifm-container-width-xl` | `1400px` | Wide container breakpoint | | ||
|
|
||
| ## Fonts | ||
|
|
||
| <div style={{ marginBottom: "1.5rem" }}> | ||
| <p style={{ fontFamily: "var(--ifm-heading-font-family)", fontSize: "2rem", margin: "0 0 0.25rem" }}> | ||
| Funnel Display for headings | ||
| </p> | ||
| <code style={{ fontSize: "0.75rem" }}>--ifm-heading-font-family</code> | ||
| </div> | ||
|
|
||
| <div style={{ marginBottom: "1.5rem" }}> | ||
| <p style={{ fontFamily: "var(--ifm-font-family-base)", fontSize: "1.25rem", margin: "0 0 0.25rem" }}> | ||
| Inter for body copy | ||
| </p> | ||
| <code style={{ fontSize: "0.75rem" }}>--ifm-font-family-base</code> | ||
| </div> | ||
|
|
||
| <div> | ||
| <p style={{ fontFamily: "var(--ifm-font-family-monospace)", fontSize: "1.25rem", margin: "0 0 0.25rem" }}> | ||
| Monospace for code | ||
| </p> | ||
| <code style={{ fontSize: "0.75rem" }}>--ifm-font-family-monospace</code> | ||
| </div> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.