mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-19 10:28:33 +00:00
refactor(web/context): move inline styling to createStyles
This commit is contained in:
1 parent
36d11444fa
commit
a0ebec5877
2 files changed
+77
-16
No files matched your search
@@ -23,11 +23,17 @@ const useStyles = createStyles((theme, params: { disabled?: boolean }) => ({
|
||||
color: params.disabled ? theme.colors.dark[3] : theme.colors.dark[0],
|
||||
whiteSpace: 'pre-wrap',
|
||||
},
|
||||
button: {
|
||||
height: 'fit-content',
|
||||
width: '100%',
|
||||
padding: 10,
|
||||
},
|
||||
iconImage: {
|
||||
maxWidth: '25px',
|
||||
},
|
||||
description: {
|
||||
color: params.disabled ? theme.colors.dark[3] : theme.colors.dark[2],
|
||||
fontSize: 12,
|
||||
},
|
||||
dropdown: {
|
||||
padding: 10,
|
||||
@@ -37,6 +43,29 @@ const useStyles = createStyles((theme, params: { disabled?: boolean }) => ({
|
||||
width: 'fit-content',
|
||||
border: 'none',
|
||||
},
|
||||
buttonStack: {
|
||||
gap: 4,
|
||||
flex: '1',
|
||||
},
|
||||
buttonGroup: {
|
||||
gap: 4,
|
||||
flexWrap: 'nowrap',
|
||||
},
|
||||
buttonIconContainer: {
|
||||
width: 25,
|
||||
height: 25,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
buttonTitleText: {
|
||||
overflowWrap: 'break-word',
|
||||
},
|
||||
buttonArrowContainer: {
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
width: 25,
|
||||
height: 25,
|
||||
},
|
||||
}));
|
||||
|
||||
const ContextButton: React.FC<{
|
||||
@@ -58,16 +87,14 @@ const ContextButton: React.FC<{
|
||||
classNames={{ inner: classes.inner, label: classes.label }}
|
||||
onClick={() => (!button.disabled ? (button.menu ? openMenu(button.menu) : clickContext(buttonKey)) : null)}
|
||||
variant="default"
|
||||
h="fit-content"
|
||||
p={10}
|
||||
fullWidth
|
||||
className={classes.button}
|
||||
disabled={button.disabled}
|
||||
>
|
||||
<Group position="apart" w="100%" noWrap>
|
||||
<Stack spacing={4} style={{ flex: '1' }}>
|
||||
<Group spacing={8} noWrap>
|
||||
<Stack className={classes.buttonStack}>
|
||||
<Group className={classes.buttonGroup}>
|
||||
{button?.icon && (
|
||||
<Stack w={25} h={25} justify="center" align="center">
|
||||
<Stack className={classes.buttonIconContainer}>
|
||||
{typeof button.icon === 'string' && isIconUrl(button.icon) ? (
|
||||
<img src={button.icon} className={classes.iconImage} alt="Missing img" />
|
||||
) : (
|
||||
@@ -80,12 +107,12 @@ const ContextButton: React.FC<{
|
||||
)}
|
||||
</Stack>
|
||||
)}
|
||||
<Text sx={{ overflowWrap: 'break-word' }}>
|
||||
<Text className={classes.buttonTitleText}>
|
||||
<ReactMarkdown>{button.title || buttonKey}</ReactMarkdown>
|
||||
</Text>
|
||||
</Group>
|
||||
{button.description && (
|
||||
<Text size={12} className={classes.description}>
|
||||
<Text className={classes.description}>
|
||||
<ReactMarkdown>{button.description}</ReactMarkdown>
|
||||
</Text>
|
||||
)}
|
||||
@@ -94,7 +121,7 @@ const ContextButton: React.FC<{
|
||||
)}
|
||||
</Stack>
|
||||
{(button.menu || button.arrow) && button.arrow !== false && (
|
||||
<Stack justify="center" w={25} h={25} align="center">
|
||||
<Stack className={classes.buttonArrowContainer}>
|
||||
<FontAwesomeIcon icon="chevron-right" fixedWidth />
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user