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

1318 investigate how to switch images between light and dark mode #1326

Draft
wants to merge 4 commits into
base: v3.0.0/develop
Choose a base branch
from

Conversation

gd2910
Copy link
Contributor

@gd2910 gd2910 commented Jan 21, 2025

EXAMPLE PR - DO NOT MERGE

Summary of the changes

Three commits give examples on how to change images (.svg, .png, .jpg) based on the currently used theme.

  • HomePage - uses React lazy and suspense to serve the SVG, gatsby-plugin-image does not support SVG at this time Dynamically rendering SVG's for the homepage, this does not decrease the bundle size, see internal notes.
  • ComponentGallery - dynamically serves the correct image by changing the src value
  • ComponentGuidance - in the MDX using a <DoDontCaution /> component it now takes an array of two strings to the light and dark image, the <DoDontCaution /> handles the image logic based on theme using gatsby-plugin-image

TEST THE CHANGES

  • The HomePage 'Developer' image changes on theme switch
  • The 'Accordion' image in the component gallery changes on theme switch
  • The first guidance image in the 'Accordion' component changes on theme switch

Related issue

#1318

Copy link

Image changes based on theme for the component gallery section

1318
@gd2910 gd2910 force-pushed the 1318-investigate-how-to-switch-images-between-light-and-dark-mode branch from c12222f to 62d70f9 Compare January 21, 2025 15:50
image change based on theme in the component guidance section

1318
@gd2910 gd2910 force-pushed the 1318-investigate-how-to-switch-images-between-light-and-dark-mode branch from 62d70f9 to f453284 Compare January 22, 2025 12:35
SVG change based on theme in the Home Page section

1318
unrelated fixes after prettier sweep
@gd2910 gd2910 force-pushed the 1318-investigate-how-to-switch-images-between-light-and-dark-mode branch from f453284 to c86e2c7 Compare January 23, 2025 12:25
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.

1 participant