Skip to content
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

Dashboard menu styles #905

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/Dashboard/Menu/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export const DashboardMenuItem = ({
as={route ? ReactRouterLink : undefined}
to={route ? generatePath(route) : undefined}
onClick={hasChildren ? onToggle : undefined}
isActive={isActive} // Set active state
isActive={hasChildren ? (isOpen ? true : false) : false} // Set active state
elboletaire marked this conversation as resolved.
Show resolved Hide resolved
justifyContent='start'
variant='transparent'
variant={isActive && !hasChildren ? 'underline' : 'transparent'}
w='full'
colorScheme='gray'
leftIcon={icon ? <Icon as={icon} /> : undefined}
rightIcon={hasChildren ? isOpen ? <ChevronUpIcon /> : <ChevronDownIcon /> : undefined}
mb={hasChildren && 1}
>
{label}
</Button>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Dashboard/Menu/Options.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Collapse, useDisclosure } from '@chakra-ui/react'
import { Box, Collapse } from '@chakra-ui/react'
import { OrganizationName } from '@vocdoni/chakra-components'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
Expand All @@ -19,7 +19,6 @@ export const DashboardMenuOptions = () => {
const { t } = useTranslation()
const location = useLocation()
const [openSection, setOpenSection] = useState<string | null>(null)
const { isOpen, onOpen, onClose } = useDisclosure()

const menuItems: MenuItem[] = [
// {
Expand Down Expand Up @@ -83,7 +82,8 @@ export const DashboardMenuOptions = () => {

return (
<Box>
<OrganizationName color='text.secondary' mb={2.5} />
<OrganizationName mb={2} px={3.5} />

{menuItems.map((item, index) => (
<Box key={index}>
{item.children ? (
Expand Down
53 changes: 46 additions & 7 deletions src/theme/components/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ const outline = defineStyle((props) => {
const transparent = defineStyle((props) => {
const { colorScheme } = props
return {
color: colorScheme === 'gray' ? 'button.variant.common.color.light' : `${colorScheme}.700`,
color: colorScheme === 'gray' ? 'black' : `${colorScheme}.700`,

_hover: {
bgColor: colorScheme === 'gray' ? 'button.variant.common.hover.bg.light' : `${colorScheme}.50`,
_active: {
bgColor: colorScheme === 'gray' ? 'gray.200' : `${colorScheme}.50`,

color: colorScheme === 'gray' ? 'button.variant.common.color.light' : `${colorScheme}.800`,
_dark: {
bgColor: colorScheme === 'gray' ? 'gray.700' : `${colorScheme}.50`,
},
},

_hover: {
bgColor: colorScheme === 'gray' ? 'gray.200' : `${colorScheme}.50`,

_disabled: {
color: 'button.variant.common.disabled.color.light',
Expand All @@ -98,8 +104,7 @@ const transparent = defineStyle((props) => {
},

_dark: {
bgColor: colorScheme === 'gray' ? 'button.variant.common.hover.bg.dark' : `${colorScheme}.50`,
color: colorScheme === 'gray' ? 'button.variant.common.color.dark' : `${colorScheme}.800`,
bgColor: colorScheme === 'gray' ? 'gray.700' : `${colorScheme}.50`,
},
},
_disabled: {
Expand All @@ -110,7 +115,7 @@ const transparent = defineStyle((props) => {
},

_dark: {
color: colorScheme === 'gray' ? 'button.variant.common.color_gray_dark' : `${colorScheme}.700`,
color: colorScheme === 'gray' ? 'white' : `${colorScheme}.700`,
},
}
})
Expand Down Expand Up @@ -150,6 +155,39 @@ const link = defineStyle((props) => {
}
})

const underline = defineStyle((props) => {
const { colorScheme } = props
return {
color: colorScheme === 'gray' ? 'black' : `${colorScheme}.700`,
textDecoration: 'underline',

_hover: {
bgColor: colorScheme === 'gray' ? 'gray.200' : `${colorScheme}.50`,

_disabled: {
color: 'button.variant.common.disabled.color.light',
_dark: {
color: 'button.variant.common.disabled.color.dark',
},
},

_dark: {
bgColor: colorScheme === 'gray' ? 'gray.700' : `${colorScheme}.50`,
},
},
_disabled: {
color: 'button.variant.common.disabled.color.light',
_dark: {
color: 'button.variant.common.disabled.color.dark',
},
},

_dark: {
color: colorScheme === 'gray' ? 'white' : `${colorScheme}.700`,
},
}
})

const sizes = {
xl2: defineStyle({
px: '22px',
Expand Down Expand Up @@ -195,6 +233,7 @@ export const Button = defineStyleConfig({
outline,
transparent,
link,
underline,
},
sizes,
defaultProps: {
Expand Down