@sproutsocial/seeds-react-menu 1.9.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +10 -0
- package/dist/esm/index.js +47 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ListboxToggleButton.tsx +44 -1
- package/src/SingleSelectMenu/SingleSelectMenu.stories.tsx +50 -0
package/package.json
CHANGED
|
@@ -9,11 +9,49 @@ import { useMenuToggleContext } from "./MenuContext";
|
|
|
9
9
|
export interface TypeListboxToggleButtonProps
|
|
10
10
|
extends TypeMenuToggleButtonProps {
|
|
11
11
|
invalid?: boolean;
|
|
12
|
+
size?: "small" | "default" | "large";
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export const StyledListboxToggleButton = styled(
|
|
15
16
|
MenuToggleButton
|
|
16
17
|
)<TypeListboxToggleButtonProps>`
|
|
18
|
+
background-color: ${(props) => props.theme.colors.form.background.base};
|
|
19
|
+
border: 1px solid ${(props) => props.theme.colors.form.border.base};
|
|
20
|
+
border-radius: ${(props) => props.theme.radii[500]};
|
|
21
|
+
transition: border-color ${(props) => props.theme.duration.fast}
|
|
22
|
+
${(props) => props.theme.easing.ease_in},
|
|
23
|
+
box-shadow ${(props) => props.theme.duration.fast}
|
|
24
|
+
${(props) => props.theme.easing.ease_in};
|
|
25
|
+
font-weight: ${(props) => props.theme.fontWeights.normal};
|
|
26
|
+
&:active {
|
|
27
|
+
transform: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
padding: ${(props) => {
|
|
31
|
+
switch (props.size) {
|
|
32
|
+
case "large":
|
|
33
|
+
return `${props.theme.space[400]} ${props.theme.space[400]} ${props.theme.space[400]} ${props.theme.space[400]}`;
|
|
34
|
+
|
|
35
|
+
case "small":
|
|
36
|
+
return `${props.theme.space[200]} ${props.theme.space[200]} ${props.theme.space[200]} ${props.theme.space[200]}`;
|
|
37
|
+
|
|
38
|
+
case "default":
|
|
39
|
+
default:
|
|
40
|
+
return `${props.theme.space[300]} ${props.theme.space[300]} ${props.theme.space[300]} ${props.theme.space[300]}`;
|
|
41
|
+
}
|
|
42
|
+
}};
|
|
43
|
+
font-size: ${(props) => {
|
|
44
|
+
switch (props.size) {
|
|
45
|
+
case "large":
|
|
46
|
+
return props.theme.typography[300].fontSize;
|
|
47
|
+
|
|
48
|
+
case "small":
|
|
49
|
+
case "default":
|
|
50
|
+
default:
|
|
51
|
+
return props.theme.typography[200].fontSize;
|
|
52
|
+
}
|
|
53
|
+
}};
|
|
54
|
+
|
|
17
55
|
${(props) =>
|
|
18
56
|
props.invalid &&
|
|
19
57
|
css`
|
|
@@ -49,11 +87,16 @@ const StyledInnerButton = styled.div`
|
|
|
49
87
|
|
|
50
88
|
export const ListboxToggleButton = ({
|
|
51
89
|
children,
|
|
90
|
+
size = "default",
|
|
52
91
|
...buttonProps
|
|
53
92
|
}: TypeListboxToggleButtonProps) => {
|
|
54
93
|
const { isOpen } = useMenuToggleContext();
|
|
55
94
|
return (
|
|
56
|
-
<StyledListboxToggleButton
|
|
95
|
+
<StyledListboxToggleButton
|
|
96
|
+
appearance="unstyled"
|
|
97
|
+
size={size}
|
|
98
|
+
{...buttonProps}
|
|
99
|
+
>
|
|
57
100
|
<StyledInnerButton>
|
|
58
101
|
{children}
|
|
59
102
|
<StyledChevron $isOpen={isOpen} invalid={buttonProps.invalid}>
|
|
@@ -274,3 +274,53 @@ export const SingleSelectMenuWithCustomEmpty: Story = {
|
|
|
274
274
|
);
|
|
275
275
|
},
|
|
276
276
|
};
|
|
277
|
+
|
|
278
|
+
export const SingleSelectMenuSmallSize: Story = {
|
|
279
|
+
name: "Small Size",
|
|
280
|
+
render: ({ inputType, ...args }) => {
|
|
281
|
+
return (
|
|
282
|
+
<SingleSelectMenu
|
|
283
|
+
itemToString={(item) => (item ? TEST_BOOKS[item.index].title : "")}
|
|
284
|
+
menuToggleElement={
|
|
285
|
+
<StorybookMenuToggleButton buttonProps={{ size: "small" }} />
|
|
286
|
+
}
|
|
287
|
+
{...(args as object)}
|
|
288
|
+
>
|
|
289
|
+
<MenuContent>
|
|
290
|
+
<MenuGroup id="books">
|
|
291
|
+
{TEST_BOOKS.map(({ id, title }) => (
|
|
292
|
+
<MenuItem key={id} id={id} inputType={inputType}>
|
|
293
|
+
{title}
|
|
294
|
+
</MenuItem>
|
|
295
|
+
))}
|
|
296
|
+
</MenuGroup>
|
|
297
|
+
</MenuContent>
|
|
298
|
+
</SingleSelectMenu>
|
|
299
|
+
);
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const SingleSelectMenuLargeSize: Story = {
|
|
304
|
+
name: "Large Size",
|
|
305
|
+
render: ({ inputType, ...args }) => {
|
|
306
|
+
return (
|
|
307
|
+
<SingleSelectMenu
|
|
308
|
+
itemToString={(item) => (item ? TEST_BOOKS[item.index].title : "")}
|
|
309
|
+
menuToggleElement={
|
|
310
|
+
<StorybookMenuToggleButton buttonProps={{ size: "large" }} />
|
|
311
|
+
}
|
|
312
|
+
{...(args as object)}
|
|
313
|
+
>
|
|
314
|
+
<MenuContent>
|
|
315
|
+
<MenuGroup id="books">
|
|
316
|
+
{TEST_BOOKS.map(({ id, title }) => (
|
|
317
|
+
<MenuItem key={id} id={id} inputType={inputType}>
|
|
318
|
+
{title}
|
|
319
|
+
</MenuItem>
|
|
320
|
+
))}
|
|
321
|
+
</MenuGroup>
|
|
322
|
+
</MenuContent>
|
|
323
|
+
</SingleSelectMenu>
|
|
324
|
+
);
|
|
325
|
+
},
|
|
326
|
+
};
|