Skip to content

Commit

Permalink
💄 DOP-4658 side nav now handles dark mode (#1127)
Browse files Browse the repository at this point in the history
Co-authored-by: Caesar Bell <[email protected]>
  • Loading branch information
caesarbell and Caesar Bell authored Jun 12, 2024
1 parent 2c9b31e commit 7f4db7c
Show file tree
Hide file tree
Showing 13 changed files with 371 additions and 232 deletions.
226 changes: 125 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@leafygreen-ui/search-input": "^2.1.4",
"@leafygreen-ui/segmented-control": "^8.0.0",
"@leafygreen-ui/select": "^7.0.0",
"@leafygreen-ui/side-nav": "^10.0.0",
"@leafygreen-ui/side-nav": "^14.1.3",
"@leafygreen-ui/table": "^6.1.0",
"@leafygreen-ui/tabs": "^11.2.0",
"@leafygreen-ui/text-area": "^6.1.0",
Expand Down
13 changes: 3 additions & 10 deletions src/components/Card/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withPrefix, navigate } from 'gatsby';
import { navigate } from 'gatsby';
import styled from '@emotion/styled';
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
import LeafyGreenCard from '@leafygreen-ui/card';
Expand All @@ -12,6 +12,7 @@ import ConditionalWrapper from '../ConditionalWrapper';
import Link from '../Link';
import Tag from '../Tag';
import { isRelativeUrl } from '../../utils/is-relative-url';
import { getSuitableIcon } from '../../utils/get-suitable-icon';

const cardBaseStyles = css`
display: flex;
Expand Down Expand Up @@ -157,15 +158,7 @@ const Card = ({
isLanding && !isLargeIconStyle ? landingStyles : '', // must come after other styles to override
];

let iconSrc;

if (icon) {
const isPath = icon.includes('/');
const getIcon = `${icon}${darkMode ? '_inverse' : ''}`;
const imageUrl = `https://webimages.mongodb.com/_com_assets/icons/${getIcon}.svg`;

iconSrc = isPath ? (darkMode && iconDark ? withPrefix(iconDark) : withPrefix(icon)) : imageUrl;
}
const iconSrc = getSuitableIcon(icon, iconDark, darkMode);

return (
<LeafyGreenCard className={cx(styling)} onClick={url ? () => onCardClick(url) : undefined}>
Expand Down
11 changes: 8 additions & 3 deletions src/components/Sidenav/DocsHomeButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { SideNavItem } from '@leafygreen-ui/side-nav';
import Icon from '@leafygreen-ui/icon';
import { css as LeafyCSS, cx } from '@leafygreen-ui/emotion';
Expand All @@ -10,29 +11,33 @@ import { titleStyle } from './styles/sideNavItem';

const homeLinkStyle = LeafyCSS`
span {
color: ${palette.gray.dark1};
color: var(--color);
font-weight: 400;
display: flex;
gap: 6px;
svg {
height: 17px;
color: ${palette.gray.dark2};
}
}
`;

const DocsHomeButton = () => {
const DocsHomeButton = ({ darkMode }) => {
return (
<SideNavItem
className={cx(titleStyle, sideNavItemBasePadding, homeLinkStyle)}
as={Link}
href={baseUrl()}
hideExternalIcon={true}
style={{ '--color': darkMode ? palette.gray.light1 : palette.gray.dark1 }}
>
<Icon glyph="Home"></Icon>
Docs Home
</SideNavItem>
);
};

DocsHomeButton.propTypes = {
darkMode: PropTypes.bool,
};

export default DocsHomeButton;
Loading

0 comments on commit 7f4db7c

Please sign in to comment.