Skip to content

Commit

Permalink
Move dark mode button to tip level settings instead of hiding it in t…
Browse files Browse the repository at this point in the history
…he settings popover.
  • Loading branch information
markrickert committed Dec 3, 2023
1 parent 4b1af36 commit 5b3998a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
18 changes: 18 additions & 0 deletions src/components/common/DarkModeButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import { Button as AntdButton, Tooltip } from 'antd'
import styled from '@emotion/styled'

const Button = styled(AntdButton)`
width: 32px;
padding: 0;
`

const DarkModeButton = ({ isDarkMode, ...props }) => {
return (
<Tooltip placement="bottomLeft" title="Toggle Light/Dark Mode">
<Button {...props}>{isDarkMode ? '🌙' : '☀️'}</Button>
</Tooltip>
)
}

export { DarkModeButton }
6 changes: 0 additions & 6 deletions src/components/common/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ const Settings = ({
packageName,
language,
onChangePackageNameAndLanguage,
isDarkMode,
toggleDarkMode,
}) => {
const [popoverVisibility, setVisibility] = useState(false)
const [newPackageName, setNewPackageName] = useState(packageName)
Expand Down Expand Up @@ -104,10 +102,6 @@ const Settings = ({
</PackagesGroupContainer>
</Radio.Group>
</PlatformsContainer>
<h5>Theme:</h5>
<Button onClick={toggleDarkMode}>
{isDarkMode ? 'Dark' : 'Light'}
</Button>
</>
}
trigger="click"
Expand Down
5 changes: 4 additions & 1 deletion src/components/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
PACKAGE_NAMES,
} from '../../constants'
import { TroubleshootingGuidesButton } from '../common/TroubleshootingGuidesButton'
import { DarkModeButton } from '../common/DarkModeButton'
import { updateURL } from '../../utils/update-url'
import { deviceSizes } from '../../utils/device-sizes'
import { lightTheme, darkTheme } from '../../theme'
Expand Down Expand Up @@ -243,8 +244,10 @@ const Home = () => {
handlePackageNameAndLanguageChange
}
language={language}
/>
<DarkModeButton
isDarkMode={isDarkMode}
toggleDarkMode={toggleDarkMode}
onClick={toggleDarkMode}
/>
</SettingsContainer>
</HeaderContainer>
Expand Down

0 comments on commit 5b3998a

Please sign in to comment.