mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add list/grid switcher to the dropdown in compact
This commit is contained in:
parent
3b132490c9
commit
d998db65d8
2 changed files with 30 additions and 8 deletions
|
|
@ -6,14 +6,19 @@ import { currentThemeName, updateTheme } from '../../lib/themeUpdater'
|
|||
import { AvatarDropdown } from '../elements/AvatarDropdown'
|
||||
import { Button } from '../elements/Button'
|
||||
import { Dropdown, DropdownOption } from '../elements/DropdownElements'
|
||||
import { HStack, VStack } from '../elements/LayoutPrimitives'
|
||||
import { Box, HStack, VStack } from '../elements/LayoutPrimitives'
|
||||
import { Separator } from '../elements/Separator'
|
||||
import { StyledText } from '../elements/StyledText'
|
||||
import { DropdownMenu } from '../patterns/DropdownMenu'
|
||||
import { ThemeId } from '../tokens/stitches.config'
|
||||
import { LayoutType } from './homeFeed/HomeFeedContainer'
|
||||
|
||||
type PrimaryDropdownProps = {
|
||||
children?: ReactNode
|
||||
showThemeSection: boolean
|
||||
|
||||
layout?: LayoutType
|
||||
updateLayout?: (layout: LayoutType) => void
|
||||
}
|
||||
|
||||
export type HeaderDropdownAction =
|
||||
|
|
@ -32,12 +37,6 @@ export function PrimaryDropdown(props: PrimaryDropdownProps): JSX.Element {
|
|||
const { viewerData } = useGetViewerQuery()
|
||||
const router = useRouter()
|
||||
|
||||
const [currentTheme, setCurrentTheme] = useState(currentThemeName())
|
||||
|
||||
const isDark = useMemo(() => {
|
||||
return currentTheme === 'Dark' || currentTheme === 'Darker'
|
||||
}, [currentTheme])
|
||||
|
||||
const headerDropdownActionHandler = useCallback(
|
||||
(action: HeaderDropdownAction) => {
|
||||
switch (action) {
|
||||
|
|
@ -86,6 +85,25 @@ export function PrimaryDropdown(props: PrimaryDropdownProps): JSX.Element {
|
|||
<ThemeSection />
|
||||
</VStack>
|
||||
)}
|
||||
{props.layout == 'LIST_LAYOUT' && (
|
||||
<DropdownOption
|
||||
onSelect={() =>
|
||||
props.updateLayout && props.updateLayout('GRID_LAYOUT')
|
||||
}
|
||||
title="Switch to Grid"
|
||||
/>
|
||||
)}
|
||||
{props.layout == 'GRID_LAYOUT' && (
|
||||
<>
|
||||
<DropdownOption
|
||||
onSelect={() =>
|
||||
props.updateLayout && props.updateLayout('LIST_LAYOUT')
|
||||
}
|
||||
title="Switch to List"
|
||||
/>
|
||||
<Box css={{ height: '10px' }}></Box>
|
||||
</>
|
||||
)}
|
||||
<DropdownOption
|
||||
onSelect={() => headerDropdownActionHandler('navigate-to-install')}
|
||||
title="Install"
|
||||
|
|
|
|||
|
|
@ -423,7 +423,11 @@ function ControlButtonBox(props: ControlButtonBoxProps): JSX.Element {
|
|||
color={theme.colors.graySolid.toString()}
|
||||
/>
|
||||
</Button>
|
||||
<PrimaryDropdown showThemeSection={true} />
|
||||
<PrimaryDropdown
|
||||
showThemeSection={true}
|
||||
layout={props.layout}
|
||||
updateLayout={props.updateLayout}
|
||||
/>
|
||||
</HStack>
|
||||
</>
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue