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

feat(www): Add gatsby-plugin-theme-ui, dark theme MVP #18027

Merged
merged 98 commits into from
Oct 8, 2019
Merged

Conversation

fk
Copy link
Contributor

@fk fk commented Oct 1, 2019

Haaaaaacktooooobeeeer!
🍂⚗️📐🔦🧰🧹🔨🙃

This PR (draft) puts www on gatsby-plugin-theme-ui 🔌, adding a "dark mode" 🌙 along the way. It's fairly functional already (and builds ;-)), but not without a few rough edges —both visible, and below the surface.

image

image

image

image

Basic questions (IMO ;-)) …

  • Do we even want .org on theme-ui? 😛
  • If so, do we want to ship the initial version with or without dark mode?
    The current state of the dark theme is usable, but MVP.

… and a few 🙄 notes on where this is at:

  • add gatsby-plugin-theme-ui using the sx prop along the custom pragma comment
    • ditch utils/presets in favor of src/gatsby-plugin-theme-ui, which now is our single (and currently pretty ugly) shadowed source of truth
    • no need for wrap-root-element anymore in www/gatsby-ssr.jssrc/gatsby-plugin-theme-ui/components instead
    • refactor a lot of CSS to use sx, so most token imports (from the removed utils/presets) are gone
      • still importing a couple tokens here and there, now from src/gatsby-plugin-theme-ui—(mostly) mediaQueries
      • didn't opt in to the theme-ui responsive styles array for now; not against it, just a bit scared ;-)
  • move global styles out of utils/typography to utils/styles/global and break those into chunks (Prism tokens, code block styles and language badges)—I'm not attached to the new location though; both things simply helped refactoring
  • add a first shot at a dark theme
    • adjust styles and assets for dark mode
      • layer model component
      • algolia docsearch dropdown
      • homepage-logo-banner logo colors
      • feedback widget
      • homepage section
      • newsletter components
        • default
        • homepage
      • Showcase and Starters
        • modal
        • share menu (along the way/easier: ditch the share menu "themes" (orange for starter, purple for showcase items))
      • /features
      • mobile navigation icons — realigned all icons currently in use: 6950d67 .
        image .
        image
      • sidebars
        • docs
        • showcase (sites/starters)
        • plugin search
    • add that dark mode switch to the main navigation—kudos to our friends at narative.co and to and Aaron Iker
    • find out why using theme-ui's useCustomProperties errors edit: updating theme-ui helped
    • fix /guidelines/*.* pages
      • remove utils/guidelines/theme
      • remove utils/guidelines/theme-inverted (used in /guidelines/typography)—one dark mode is enough ;-)
    • remove emotion-theming
  • extend tokens from gatsby-design-tokens to
  • refactor colors.ui
    • rename colors.ui.border.subtle -> colors.ui.border
  • along the way…
    • consolidate various "screen-reader-only" CSS styles (clip: rect(0, 0, 0, 0)) in utils/styles — rule of three easy ;-)
    • consolidate 3️⃣ skip-nav-links + styles in component
    • tidy avatar component, use it in template-contributor-page
    • increase main navigation "social links" icon sizes, make them calmer
    • fiddle around with main navigation search form UI (WIP)—keep it expanded where possible for larger screens, and always expand it for mobile
    • make the blog post headers a little more interesting
    • increase whitespace below breadcrumbs path
    • remove a bunch of WebkitFontSmoothing: antialiased—we switched to using it on html some time ago
    • a11y improvements:
      • adjust token colors for (Prism) syntax highlighting to comply to WCAG 2.0 AA standard contrast ratios (tried to test quite a bit using random code from the docs, but didn't go the whole mile and set up proper examples to test)
      • fix "Edit this page on GitHub" link color contrast

image

Now and / or later…

  • port theme changes and additions to gatsby-design-tokens, and give the new tokens (and their names) a good second look, consolidate
  • if possible, switch our custom syntax highlighting implementation to the "theme-ui way" (cc @DSchau)
  • improve showcase/starter sidebar and item/card styles—dark mode shows a lot of its issues
  • maybe try to use Typography.js' styles only for the "main content"

Related Issues

#8789 — Documentation Dark Theme

fk added 23 commits July 20, 2019 03:01
# Conflicts:
#	www/src/components/code-block/index.js
#	www/src/utils/typography.js
# Conflicts:
#	www/src/components/copy.js
#	www/src/utils/copy-to-clipboard.js
# Conflicts:
#	www/src/assets/icons/svg-defs.js
#	www/src/components/diagram.js
#	www/src/components/evaluation-table-section-header-bottom.js
#	www/src/components/evaluation-table.js
#	www/src/components/homepage/homepage-features.js
#	www/src/components/navigation-mobile.js
#	www/src/components/navigation.js
#	www/src/components/used-by.js
#	www/src/pages/plugins.js
#	www/src/views/showcase/featured-sites.js
# Conflicts:
#	www/src/components/container.js
#	www/src/templates/template-blog-post.js
#	www/src/utils/presets.js
#	www/src/utils/typography.js
# Conflicts:
#	www/package.json
#	www/src/pages/blog/tags.js
#	www/src/templates/tags.js
#	www/src/templates/template-blog-list.js
#	www/src/templates/template-docs-markdown.js
#	www/wrap-root-element.js
# Conflicts:
#	packages/gatsby-design-tokens/src/colors.js
#	www/package.json
#	www/src/components/chart.js
#	www/src/components/docs-table-of-contents.js
#	www/src/components/evaluation-cell.js
#	www/src/components/evaluation-table-section-header-bottom.js
#	www/src/components/features/evaluation-table-section-header-top.js
#	www/src/components/features/evaluation-table-section-title.js
#	www/src/components/features/evaluation-table.js
#	www/src/components/layout.js
#	www/src/components/navigation-mobile.js
#	www/src/components/plugin-searchbar-body.js
#	www/src/components/search-form.js
#	www/src/components/sidebar/accordion.js
#	www/src/components/sidebar/section-title.js
#	www/src/components/sidebar/sticky-responsive-sidebar.js
#	www/src/pages/features.js
#	www/src/templates/template-blog-list.js
#	www/src/templates/template-blog-post.js
#	www/src/templates/template-creator-details.js
#	www/src/utils/sidebar/create-link.js
#	www/src/views/shared/styles.js
#	www/src/views/shared/thumbnail.js
#	www/src/views/showcase/featured-sites.js
#	www/src/views/showcase/showcase-list.js
# Conflicts:
#	www/src/utils/typography.js
@fk fk changed the title www x gatsby-plugin-theme-ui feat(www): Add gatsby-plugin-theme-ui Oct 1, 2019
@fk fk requested review from a team as code owners October 6, 2019 23:55
@t2ca
Copy link
Contributor

t2ca commented Oct 7, 2019

Wow!

@fk
Copy link
Contributor Author

fk commented Oct 7, 2019

@jletey
Copy link
Contributor

jletey commented Oct 7, 2019

Preview (with a subset of "Showcase" sites): https://5d9b0aeb7cf4dd9d42c83261--relaxed-saha-83a4fd.netlify.com/

@fk If I may, I've noticed on the deployed site that the moon/sun icon isn't aligned with the other icons in the header

Light Dark
Shot 2019-10-07 at 14 28 58 Shot 2019-10-07 at 14 28 52

I think it has something to do with varying sizes of the icons.

@fk
Copy link
Contributor Author

fk commented Oct 7, 2019

@johnletey Sure you may! Thank you for taking the time! 🤗

the moon/sun icon isn't aligned with the other icons in the header

Thanks for calling that out, the switch button needs a little nudge indeed! 🙏
Will take care of that later today!

Thanks again @johnletey for pointing this out! 🤗

This also fixes the `MoonMask" animation, brings back the default `:focus` outline, and roughly compensates for the additional whitespace of this "icon button" in relation to its "social icon" siblings.
m-allanson
m-allanson previously approved these changes Oct 8, 2019
Copy link
Contributor

@m-allanson m-allanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dark mode 🎉🌃🌟 As you noted, there are some areas that need more work but overall I think this is looking excellent. Let's merge?

Looking on webpagetest (and ignoring the First Byte Time), it seems like this includes 15Kb less for Document Complete, and 1Kb extra for Fully Loaded.

@fk
Copy link
Contributor Author

fk commented Oct 8, 2019

Looking on webpagetest (and ignoring the First Byte Time), it seems like this includes 15Kb less for Document Complete, and 1Kb extra for Fully Loaded.

🎉 Unexpected good news?!
Lemme get that thing ready to :shipit:

@gillkyle
Copy link
Contributor

gillkyle commented Oct 8, 2019

Can't wait to see this merged!

# Conflicts:
#	www/src/components/prev-and-next.js
#	www/src/utils/typography.js
@fk
Copy link
Contributor Author

fk commented Oct 8, 2019

🚨Almost mandatory YT link: https://www.youtube.com/watch?v=tm6x0q2INSs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants