Skip to content

Commit 020afd7

Browse files
authored
feat: size prop in menu item (#27)
1 parent 3c30e66 commit 020afd7

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

src/components/menu/MenuItem.css.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const ContainerHover = createVar();
1313
const ContainerActive = createVar();
1414
const ContainerLine = createVar();
1515
const OnContainer = createVar();
16+
const UIBeforeAfterSpace = createVar();
1617

1718
const getVariant = (variant: ContainerColor): ComplexStyleRule => ({
1819
vars: {
@@ -29,12 +30,9 @@ export const MenuItem = recipe({
2930
DefaultReset,
3031
{
3132
width: "100%",
32-
height: toRem(40),
33-
padding: `0 ${config.space.S400}`,
3433
display: "flex",
3534
alignItems: "center",
3635
justifyContent: "start",
37-
gap: config.space.S200,
3836
cursor: "pointer",
3937
backgroundColor: Container,
4038
color: OnContainer,
@@ -50,10 +48,10 @@ export const MenuItem = recipe({
5048
backgroundColor: ContainerActive,
5149
},
5250
"&[data-ui-before=true]": {
53-
paddingLeft: config.space.S300,
51+
paddingLeft: UIBeforeAfterSpace,
5452
},
5553
"&[data-ui-after=true]": {
56-
paddingRight: config.space.S300,
54+
paddingRight: UIBeforeAfterSpace,
5755
},
5856
},
5957
},
@@ -71,10 +69,29 @@ export const MenuItem = recipe({
7169
Warning: getVariant("Warning"),
7270
Critical: getVariant("Critical"),
7371
},
72+
size: {
73+
"300": {
74+
vars: {
75+
[UIBeforeAfterSpace]: config.space.S200,
76+
},
77+
height: toRem(32),
78+
gap: config.space.S100,
79+
padding: `0 ${config.space.S300}`,
80+
},
81+
"400": {
82+
vars: {
83+
[UIBeforeAfterSpace]: config.space.S300,
84+
},
85+
height: toRem(40),
86+
gap: config.space.S200,
87+
padding: `0 ${config.space.S400}`,
88+
},
89+
},
7490
radii: RadiiVariant,
7591
},
7692
defaultVariants: {
7793
variant: "Surface",
94+
size: "400",
7895
radii: "0",
7996
},
8097
});

src/components/menu/MenuItem.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@ type MenuItemProps = {
1010

1111
export const MenuItem = as<"button", MenuItemProps & css.MenuItemVariants>(
1212
(
13-
{ as: AsMenuItem = "button", className, variant, radii, before, after, children, ...props },
13+
{
14+
as: AsMenuItem = "button",
15+
className,
16+
variant,
17+
size,
18+
radii,
19+
before,
20+
after,
21+
children,
22+
...props
23+
},
1424
ref
1525
) => (
1626
<AsMenuItem
17-
className={classNames(css.MenuItem({ variant, radii }), className)}
27+
className={classNames(css.MenuItem({ variant, size, radii }), className)}
1828
data-ui-before={before ? true : undefined}
1929
data-ui-after={after ? true : undefined}
2030
{...props}

0 commit comments

Comments
 (0)