-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link/Button: serious style overhaul using
sx
+ usages + Menu fixes (#…
…368) * refactor: rework Link/Button styles with sx * Button/Link: `invertColors`, `disabled`, `active` style unification + wrapper for paddings * refactor: rework Footer styles with sx * rework Authentication with sx and use Button/Link with invertColors * refactor: move and rename Authentication/Authentication -> MenuMain/BottomButtons * small fix: wrapped text in Problem buttons enlarging other buttons * rework MenuMain using our Links * fix comment typo * unrelated: theme font fallback * MenuMain - remove unused styles
- Loading branch information
1 parent
a40ae31
commit fbf4226
Showing
18 changed files
with
213 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
import {Typography, TypographyProps} from '@mui/material' | ||
import clsx from 'clsx' | ||
import {Box, SxProps, Theme, Typography, TypographyProps} from '@mui/material' | ||
import {ButtonHTMLAttributes, FC, ReactNode} from 'react' | ||
|
||
import styles from './Clickable.module.scss' | ||
import {buttonTextSx, getButtonWrapperSx} from './buttonStyles' | ||
|
||
type ButtonProps = { | ||
onClick?: () => void | ||
disabled?: boolean | ||
children: ReactNode | ||
variant?: TypographyProps['variant'] | ||
invertColors?: boolean | ||
sx?: SxProps<Theme> | ||
textSx?: SxProps<Theme> | ||
} & Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> | ||
|
||
export const Button: FC<ButtonProps> = ({children, onClick, disabled, type, variant}) => { | ||
export const Button: FC<ButtonProps> = ({children, onClick, disabled, type, variant, invertColors, sx, textSx}) => { | ||
return ( | ||
<Typography | ||
variant={variant ?? 'button3'} | ||
// tento wrapper je tu kvoli lepsej kontrole paddingov atd. | ||
<Box | ||
component="button" | ||
onClick={onClick} | ||
className={clsx(styles.actionButton, disabled && styles.disabled)} | ||
disabled={disabled} | ||
type={type} | ||
sx={{ | ||
...getButtonWrapperSx({invertColors, disabled}), | ||
...sx, | ||
}} | ||
> | ||
{children} | ||
</Typography> | ||
<Typography | ||
variant={variant ?? 'button3'} | ||
sx={{ | ||
...buttonTextSx, | ||
...textSx, | ||
}} | ||
> | ||
{children} | ||
</Typography> | ||
</Box> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,56 @@ | ||
import {SxProps, Theme, Typography, TypographyProps} from '@mui/material' | ||
import clsx from 'clsx' | ||
import {Box, SxProps, Theme, Typography, TypographyProps} from '@mui/material' | ||
import NextLink from 'next/link' | ||
import {ComponentProps, FC, ReactNode} from 'react' | ||
|
||
import styles from './Clickable.module.scss' | ||
import {buttonTextSx, getButtonWrapperSx} from './buttonStyles' | ||
|
||
type LinkProps = { | ||
href?: string | ||
disabled?: boolean | ||
children: ReactNode | ||
variant?: TypographyProps['variant'] | ||
invertColors?: boolean | ||
active?: boolean | ||
sx?: SxProps<Theme> | ||
textSx?: SxProps<Theme> | ||
} & Pick<ComponentProps<typeof NextLink>, 'target'> | ||
|
||
export const Link: FC<LinkProps> = ({children, href, disabled, target, variant, sx}) => { | ||
export const Link: FC<LinkProps> = ({children, href, disabled, target, variant, invertColors, active, sx, textSx}) => { | ||
// https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link | ||
return disabled ? ( | ||
<Typography | ||
variant={variant ?? 'button3'} | ||
component="a" | ||
className={clsx(styles.actionButton, styles.disabled)} | ||
aria-disabled | ||
role="link" | ||
sx={sx} | ||
sx={{ | ||
...getButtonWrapperSx({invertColors, disabled, active}), | ||
...buttonTextSx, | ||
...sx, | ||
}} | ||
> | ||
{children} | ||
</Typography> | ||
) : ( | ||
<Typography | ||
variant={variant ?? 'button3'} | ||
// tento wrapper je tu kvoli lepsej kontrole paddingov atd. | ||
<Box | ||
component={NextLink} | ||
href={href ?? ''} | ||
target={target} | ||
className={clsx(styles.actionButton)} | ||
sx={sx} | ||
sx={{ | ||
...getButtonWrapperSx({invertColors, disabled, active}), | ||
...sx, | ||
}} | ||
> | ||
{children} | ||
</Typography> | ||
<Typography | ||
variant={variant ?? 'button3'} | ||
sx={{ | ||
...buttonTextSx, | ||
...textSx, | ||
}} | ||
> | ||
{children} | ||
</Typography> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {SxProps, Theme} from '@mui/material' | ||
|
||
export const getButtonWrapperSx = ({ | ||
invertColors, | ||
disabled, | ||
active, | ||
}: { | ||
invertColors?: boolean | ||
disabled?: boolean | ||
active?: boolean | ||
}) => { | ||
const invert = !!invertColors !== !!active | ||
|
||
return { | ||
display: 'flex', | ||
cursor: disabled ? 'default' : 'pointer', | ||
// reset default <button> styles | ||
padding: 0, | ||
border: 0, | ||
// nakoniec to nemusi byt napisane cez CSS vars, ale mame takto moznost napr. referovat farby v children elementoch | ||
bgcolor: 'var(--bgcolor)', | ||
color: 'var(--color)', | ||
borderColor: 'var(--color)', | ||
'--bgcolor': invert ? 'black' : 'white', | ||
'--color': disabled ? '#ccc' : invert ? 'white' : 'black', | ||
'&:hover': active | ||
? {} | ||
: { | ||
'--bgcolor': disabled ? '#ccc' : invert ? 'white' : 'black', | ||
'--color': disabled ? 'white' : invert ? 'black' : 'white', | ||
}, | ||
} satisfies SxProps<Theme> | ||
} | ||
|
||
export const buttonTextSx = { | ||
mx: '10px', | ||
mb: '4px', | ||
borderBottom: '5px solid', | ||
} satisfies SxProps<Theme> |
16 changes: 0 additions & 16 deletions
16
src/components/PageLayout/Authentication/Authentication.module.scss
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/components/PageLayout/Authentication/Authentication.module.scss.d.ts
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
src/components/PageLayout/Authentication/Authentication.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.