-
Notifications
You must be signed in to change notification settings - Fork 36
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
💄 DOP-4658 side nav now handles dark mode #1127
Changes from 1 commit
8b08a17
e31ecee
18505df
0e72dce
dea8100
6e1da98
663b388
eec92e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. Love this. Thanks! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { withPrefix } from 'gatsby'; | ||
|
||
/** | ||
* | ||
* @param {boolean} isDarkMode | ||
* @param {boolean} iconDark | ||
* @param {string} icon | ||
* @returns {string} | ||
*/ | ||
export const getSuitableIcon = (isDarkMode, iconDark, icon) => { | ||
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. thanks so much for adding this and putting it into the Card component as well! one super miniscule nit is that I feel like the order of the parameters would make more sense as 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. @mayaraman19 good call on that, icon would be the prominent param, which I can see your case for it coming first. I will make the change. Thank you for your feedback on that. |
||
if (icon) { | ||
const isPath = icon.startsWith('/'); | ||
const getIcon = `${icon}${isDarkMode ? '_inverse' : ''}`; | ||
const imageUrl = `https://webimages.mongodb.com/_com_assets/icons/${getIcon}.svg`; | ||
|
||
return isPath ? (isDarkMode && iconDark ? withPrefix(iconDark) : withPrefix(icon)) : imageUrl; | ||
} | ||
|
||
return ''; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can change this to a
const
now that it's a beautiful one-liner