Skip to content

Commit

Permalink
DOP-5044: deprecated sites dark mode dropdown direction fixed (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs authored Oct 3, 2024
1 parent f25dc0d commit f37a095
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/ActionBar/ActionBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import DarkModeDropdown from './DarkModeDropdown';
import SearchInput from './SearchInput';
import { ActionBarSearchContainer, ActionsBox, actionBarStyling, getContainerStyling, overlineStyling } from './styles';

const DEPRECATED_PROJECTS = ['atlas-app-services', 'datalake', 'realm'];
export const DEPRECATED_PROJECTS = ['atlas-app-services', 'datalake', 'realm'];

const ActionBar = ({ template, slug, sidenav, ...props }) => {
const url = isBrowser ? window.location.href : null;
Expand Down
5 changes: 4 additions & 1 deletion src/components/ActionBar/DarkModeDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { DarkModeContext } from '../../context/dark-mode-context';
import { theme } from '../../theme/docsTheme';
import IconDarkmode from '../icons/DarkMode';
import useScreenSize from '../../hooks/useScreenSize';
import useSnootyMetadata from '../../utils/use-snooty-metadata';
import DarkModeGuideCue from './DarkModeGuideCue';
import { DEPRECATED_PROJECTS } from './ActionBar';

const iconStyling = css`
display: block;
Expand All @@ -31,6 +33,7 @@ const darkModeSvgStyle = {
};

const DarkModeDropdown = () => {
const metadata = useSnootyMetadata();
const dropdownRef = useRef();

// not using dark mode from LG/provider here to account for case of 'system' dark theme
Expand All @@ -47,7 +50,7 @@ const DarkModeDropdown = () => {
);

const { isTabletOrMobile } = useScreenSize();
const justify = isTabletOrMobile ? 'start' : 'end';
const justify = isTabletOrMobile || DEPRECATED_PROJECTS.includes(metadata.project) ? 'start' : 'end';

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions src/components/ActionBar/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ export const ActionsBox = styled('div')`
column-gap: ${theme.size.default};
position: relative;
top: 0;
padding: 0 ${theme.size.large} 0 ${theme.size.medium};
margin: 0 ${theme.size.large} 0 ${theme.size.medium};
justify-self: flex-end;
grid-column: -2/-1;
@media ${theme.screenSize.upToLarge} {
padding-right: ${theme.size.medium};
margin-right: ${theme.size.medium};
}
@media ${theme.screenSize.upToMedium} {
padding-left: ${theme.size.small};
margin-left: ${theme.size.small};
column-gap: ${theme.size.small};
}
`;
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/DarkModeDropdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { render, act } from '@testing-library/react';
import LeafyGreenProvider from '@leafygreen-ui/leafygreen-provider';
import { DarkModeContext } from '../../src/context/dark-mode-context';
import * as snootyMetadata from '../../src/utils/use-snooty-metadata';
import * as MediaHooks from '../../src/hooks/use-media';
import DarkModeDropdown from '../../src/components/ActionBar/DarkModeDropdown';

Expand All @@ -14,6 +15,11 @@ const setDarkModePref = jest.fn((value) => {
darkModePref = value;
});

// mock useSnootyMetadata
jest.spyOn(snootyMetadata, 'default').mockImplementation(() => ({
project: 'landing',
}));

// mock useMedia
jest.spyOn(MediaHooks, 'default').mockImplementation(() => ({}));

Expand Down

0 comments on commit f37a095

Please sign in to comment.