1318 investigate how to switch images between light and dark mode #1326
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.
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,Dynamically rendering SVG's for the homepage, this does not decrease the bundle size, see internal notes.gatsby-plugin-image
does not support SVG at this timeComponentGallery
- dynamically serves the correct image by changing thesrc
valueComponentGuidance
- in theMDX
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 usinggatsby-plugin-image
TEST THE CHANGES
HomePage
'Developer' image changes on theme switchRelated issue
#1318