@altinn/altinn-components 0.4.1 → 0.5.1
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/.storybook/StoryDecorator.tsx +1 -1
- package/.storybook/main.ts +3 -4
- package/.storybook/preview.tsx +28 -0
- package/CHANGELOG.md +14 -0
- package/biome.jsonc +1 -1
- package/lib/components/Attachment/AttachmentLink.stories.ts +1 -1
- package/lib/components/Attachment/AttachmentList.stories.ts +1 -1
- package/lib/components/Button/Button.tsx +13 -10
- package/lib/components/Button/ButtonBase.tsx +1 -1
- package/lib/components/Button/ButtonIcon.tsx +16 -0
- package/lib/components/Button/ButtonLabel.tsx +18 -0
- package/lib/components/Button/Buttons.stories.tsx +64 -0
- package/lib/components/Button/ComboButton.tsx +9 -7
- package/lib/components/Button/IconButton.stories.tsx +47 -0
- package/lib/components/Button/IconButton.tsx +15 -5
- package/lib/components/Button/button.module.css +5 -46
- package/lib/components/Button/buttonBase.module.css +55 -23
- package/lib/components/Button/buttonIcon.module.css +17 -0
- package/lib/components/Button/buttonLabel.module.css +17 -0
- package/lib/components/Button/comboButton.module.css +15 -65
- package/lib/components/Button/iconButton.module.css +21 -4
- package/lib/components/Button/index.ts +2 -0
- package/lib/components/ContextMenu/ContextMenu.stories.ts +49 -0
- package/lib/components/ContextMenu/ContextMenu.tsx +12 -20
- package/lib/components/ContextMenu/ContextMenuBase.tsx +33 -0
- package/lib/components/Dialog/Dialog.stories.ts +12 -5
- package/lib/components/Dialog/Dialog.tsx +2 -0
- package/lib/components/Dialog/DialogGroup.tsx +24 -0
- package/lib/components/Dialog/DialogList.stories.ts +14 -10
- package/lib/components/Dialog/DialogList.tsx +26 -11
- package/lib/components/Dialog/DialogListItem.tsx +12 -2
- package/lib/components/Dialog/DialogListItemBase.tsx +4 -2
- package/lib/components/Dialog/DialogNav.stories.ts +5 -5
- package/lib/components/Dialog/DialogNav.tsx +2 -6
- package/lib/components/Dialog/DialogSelect.tsx +1 -1
- package/lib/components/Dialog/dialogGroup.module.css +35 -0
- package/lib/components/Dropdown/Backdrop.tsx +4 -3
- package/lib/components/Dropdown/DrawerBase.tsx +5 -2
- package/lib/components/Dropdown/DrawerBody.tsx +12 -0
- package/lib/components/Dropdown/DrawerButton.tsx +17 -0
- package/lib/components/Dropdown/DrawerFooter.tsx +12 -0
- package/lib/components/Dropdown/DrawerHeader.tsx +19 -0
- package/lib/components/Dropdown/DrawerOrDropdown.tsx +29 -0
- package/lib/components/Dropdown/DropdownBase.tsx +17 -2
- package/lib/components/Dropdown/backdrop.module.css +3 -0
- package/lib/components/Dropdown/drawerBase.module.css +9 -0
- package/lib/components/Dropdown/drawerBody.module.css +5 -0
- package/lib/components/Dropdown/drawerButton.module.css +6 -0
- package/lib/components/Dropdown/drawerFooter.module.css +13 -0
- package/lib/components/Dropdown/drawerHeader.module.css +17 -0
- package/lib/components/Dropdown/drawerOrDropdown.module.css +19 -0
- package/lib/components/Dropdown/dropdownBase.module.css +20 -4
- package/lib/components/Dropdown/index.ts +7 -1
- package/lib/components/Footer/footerMenu.module.css +5 -0
- package/lib/components/GlobalMenu/AccountButton.tsx +29 -0
- package/lib/components/GlobalMenu/AccountMenu.stories.tsx +65 -0
- package/lib/components/GlobalMenu/AccountMenu.tsx +73 -0
- package/lib/components/GlobalMenu/BackButton.tsx +10 -0
- package/lib/components/GlobalMenu/GlobalMenu.stories.tsx +112 -121
- package/lib/components/GlobalMenu/GlobalMenu.tsx +41 -89
- package/lib/components/GlobalMenu/GlobalMenuBase.tsx +22 -0
- package/lib/components/GlobalMenu/LogoutButton.tsx +19 -0
- package/lib/components/GlobalMenu/globalMenuBase.module.css +39 -0
- package/lib/components/GlobalMenu/index.tsx +1 -1
- package/lib/components/GlobalMenu/logoutButton.module.css +9 -0
- package/lib/components/Header/{Header.stories.ts → Header.stories.tsx} +79 -20
- package/lib/components/Header/Header.tsx +25 -38
- package/lib/components/Header/HeaderBase.tsx +7 -3
- package/lib/components/Header/header.module.css +10 -42
- package/lib/components/Header/headerBase.module.css +43 -0
- package/lib/components/Header/headerButton.module.css +1 -0
- package/lib/components/Layout/Layout.stories.tsx +77 -38
- package/lib/components/Layout/Layout.tsx +5 -3
- package/lib/components/Layout/LayoutBase.tsx +3 -2
- package/lib/components/Layout/layoutBase.module.css +11 -0
- package/lib/components/Layout/layoutBody.module.css +1 -0
- package/lib/components/LayoutAction/ActionHeader.tsx +1 -1
- package/lib/components/LayoutAction/ActionMenu.tsx +2 -4
- package/lib/components/LayoutAction/actionMenu.module.css +3 -0
- package/lib/components/List/List.stories.tsx +43 -0
- package/lib/components/List/List.tsx +6 -6
- package/lib/components/List/ListBase.tsx +6 -6
- package/lib/components/List/ListItem.tsx +4 -1
- package/lib/components/List/ListItemBase.tsx +20 -4
- package/lib/components/List/listBase.module.css +3 -3
- package/lib/components/List/listItemBase.module.css +4 -0
- package/lib/components/Menu/Menu.stories.ts +46 -46
- package/lib/components/Menu/Menu.tsx +3 -102
- package/lib/components/Menu/MenuBase.tsx +47 -3
- package/lib/components/Menu/MenuItem.tsx +8 -4
- package/lib/components/Menu/MenuItemBase.tsx +15 -2
- package/lib/components/Menu/MenuItems.stories.ts +438 -0
- package/lib/components/Menu/MenuItems.tsx +96 -0
- package/lib/components/Menu/MenuOption.tsx +4 -1
- package/lib/components/Menu/index.ts +1 -1
- package/lib/components/Menu/menu.module.css +2 -3
- package/lib/components/Menu/menuBase.module.css +25 -0
- package/lib/components/Menu/menuItemBase.module.css +11 -5
- package/lib/components/Menu/menuItemLabel.module.css +11 -1
- package/lib/components/Menu/menuSearch.module.css +1 -0
- package/lib/components/Meta/MetaItemBase.tsx +1 -1
- package/lib/components/Meta/MetaItemLabel.tsx +1 -1
- package/lib/components/Meta/MetaItemMedia.tsx +1 -1
- package/lib/components/Page/PageBase.tsx +14 -0
- package/lib/components/Page/PageHeader.tsx +21 -0
- package/lib/components/Page/PageHeaderMedia.tsx +25 -0
- package/lib/components/Page/SectionBase.tsx +52 -0
- package/lib/components/Page/SectionFooter.tsx +15 -0
- package/lib/components/Page/SectionHeader.tsx +16 -0
- package/lib/components/Page/index.ts +5 -0
- package/lib/components/Page/pageHeader.module.css +5 -0
- package/lib/components/Page/sectionBase.module.css +82 -0
- package/lib/components/Page/sectionFooter.module.css +8 -0
- package/lib/components/Page/sectionHeader.module.css +9 -0
- package/lib/components/RootProvider/RootProvider.tsx +43 -7
- package/lib/components/Searchbar/Autocomplete.stories.tsx +77 -0
- package/lib/components/Searchbar/Autocomplete.tsx +44 -0
- package/lib/components/Searchbar/AutocompleteBase.tsx +16 -0
- package/lib/components/Searchbar/AutocompleteGroup.tsx +17 -0
- package/lib/components/Searchbar/AutocompleteItem.tsx +23 -0
- package/lib/components/Searchbar/SearchField.tsx +78 -0
- package/lib/components/Searchbar/Searchbar.stories.tsx +151 -0
- package/lib/components/Searchbar/Searchbar.tsx +18 -0
- package/lib/components/Searchbar/SearchbarBase.tsx +23 -0
- package/lib/components/Searchbar/autocompleteBase.module.css +17 -0
- package/lib/components/Searchbar/autocompleteGroup.module.css +3 -0
- package/lib/components/Searchbar/autocompleteItem.module.css +19 -0
- package/lib/components/Searchbar/index.ts +1 -0
- package/lib/components/Searchbar/searchField.module.css +54 -0
- package/lib/components/Searchbar/searchbarBase.module.css +20 -0
- package/lib/components/Toolbar/Toolbar.stories.tsx +10 -10
- package/lib/components/Toolbar/Toolbar.tsx +28 -10
- package/lib/components/Toolbar/ToolbarAdd.tsx +6 -5
- package/lib/components/Toolbar/ToolbarBase.tsx +5 -20
- package/lib/components/Toolbar/ToolbarButton.tsx +1 -1
- package/lib/components/Toolbar/ToolbarFilter.tsx +11 -6
- package/lib/components/Toolbar/ToolbarMenu.tsx +8 -7
- package/lib/components/Toolbar/ToolbarOptions.stories.ts +5 -5
- package/lib/components/Toolbar/ToolbarOptions.tsx +34 -21
- package/lib/components/Toolbar/toolbarAdd.module.css +7 -0
- package/lib/components/Toolbar/toolbarBase.module.css +19 -0
- package/lib/components/Toolbar/toolbarButton.module.css +1 -1
- package/lib/components/Toolbar/toolbarFilter.module.css +25 -0
- package/lib/components/Toolbar/toolbarMenu.module.css +7 -0
- package/lib/components/Typography/Heading.tsx +23 -0
- package/lib/components/Typography/Typography.tsx +8 -5
- package/lib/components/Typography/heading.module.css +21 -0
- package/lib/components/Typography/index.ts +1 -0
- package/lib/components/Typography/typography.module.css +8 -0
- package/lib/components/index.ts +2 -0
- package/lib/hooks/index.ts +3 -0
- package/lib/{components/Menu → hooks}/useEscapeKey.ts +2 -2
- package/lib/hooks/useMenu.tsx +80 -0
- package/lib/index.ts +1 -0
- package/lib/stories/Color/MenuItem.stories.tsx +43 -0
- package/lib/stories/Color/Swatches.stories.tsx +19 -0
- package/lib/stories/Color/Swatches.tsx +42 -0
- package/lib/stories/Color/colors.json +62 -0
- package/lib/stories/Color/swatches.module.css +14 -0
- package/lib/stories/Inbox/BookmarksPage.tsx +52 -0
- package/lib/stories/Inbox/DialogPage.tsx +15 -0
- package/lib/stories/Inbox/Inbox.stories.tsx +55 -0
- package/lib/stories/Inbox/Inbox.tsx +12 -0
- package/lib/stories/Inbox/InboxLayout.tsx +50 -0
- package/lib/stories/Inbox/InboxPage.tsx +50 -0
- package/lib/stories/Inbox/InboxProvider.tsx +136 -0
- package/lib/stories/Inbox/InboxSection.tsx +39 -0
- package/lib/stories/Inbox/InboxToolbar.tsx +94 -0
- package/lib/stories/Inbox/ProfilePage.tsx +35 -0
- package/lib/stories/Inbox/SettingsPage.tsx +19 -0
- package/lib/stories/Inbox/accounts/accounts.ts +24 -0
- package/lib/stories/Inbox/accounts/index.ts +1 -0
- package/lib/stories/Inbox/actionMenu.ts +24 -0
- package/lib/stories/Inbox/dialogs/brreg-completed.json +35 -0
- package/lib/stories/Inbox/dialogs/brreg-draft.json +45 -0
- package/lib/stories/Inbox/dialogs/index.ts +10 -0
- package/lib/stories/Inbox/dialogs/skatt-2023.json +33 -0
- package/lib/stories/Inbox/groupBy.ts +19 -0
- package/lib/stories/Inbox/inboxSection.module.css +19 -0
- package/lib/stories/Inbox/index.ts +15 -0
- package/lib/stories/Inbox/layout/footer.ts +27 -0
- package/lib/stories/Inbox/layout/header.ts +11 -0
- package/lib/stories/Inbox/layout/index.ts +3 -0
- package/lib/stories/Inbox/layout/menu.ts +64 -0
- package/package.json +15 -13
- package/tsconfig.json +7 -2
- package/lib/components/Header/HeaderSearch.stories.ts +0 -20
- package/lib/components/Header/HeaderSearch.tsx +0 -44
- package/lib/components/Header/headerSearch.module.css +0 -30
- package/lib/components/Menu/MenuGroup.tsx +0 -18
- package/lib/components/Menu/__menuItem.module.css +0 -130
- package/lib/components/Toolbar/toolbar.module.css +0 -43
- /package/lib/components/ContextMenu/{contextMenu.module.css → contextMenuBase.module.css} +0 -0
- /package/lib/{components/Menu → hooks}/useClickOutside.ts +0 -0
|
@@ -19,7 +19,7 @@ export const StoryDecorator = ({
|
|
|
19
19
|
return (
|
|
20
20
|
<RootProvider>
|
|
21
21
|
<div className={styles.preview} data-theme={theme}>
|
|
22
|
-
<div className={styles.component}>{children}</div>
|
|
22
|
+
<div id="story-in-story-decorator-root" className={styles.component}>{children}</div>
|
|
23
23
|
<span className={styles.tag} data-tag={state}>
|
|
24
24
|
{state}
|
|
25
25
|
</span>
|
package/.storybook/main.ts
CHANGED
|
@@ -8,14 +8,13 @@ const config: StorybookConfig = {
|
|
|
8
8
|
"@storybook/addon-essentials",
|
|
9
9
|
"@storybook/addon-themes",
|
|
10
10
|
"@chromatic-com/storybook",
|
|
11
|
-
"@storybook/addon-interactions"
|
|
11
|
+
"@storybook/addon-interactions",
|
|
12
|
+
"@storybook/addon-a11y"
|
|
12
13
|
],
|
|
13
14
|
framework: {
|
|
14
15
|
name: "@storybook/react-vite",
|
|
15
16
|
options: {},
|
|
16
17
|
},
|
|
17
|
-
docs: {
|
|
18
|
-
autodocs: "tag",
|
|
19
|
-
},
|
|
18
|
+
docs: {},
|
|
20
19
|
};
|
|
21
20
|
export default config;
|
package/.storybook/preview.tsx
CHANGED
|
@@ -2,9 +2,35 @@ import { withThemeByDataAttribute } from "@storybook/addon-themes";
|
|
|
2
2
|
import { Preview, StoryFn } from "@storybook/react";
|
|
3
3
|
import { StoryDecorator } from "./StoryDecorator";
|
|
4
4
|
import "../lib/css/global.css";
|
|
5
|
+
import {A11yParameters} from "@storybook/addon-a11y";
|
|
6
|
+
import { Rule, getRules } from "axe-core";
|
|
7
|
+
|
|
5
8
|
/** @type { import('@storybook/react').Preview } */
|
|
9
|
+
|
|
10
|
+
const enabledTags = [
|
|
11
|
+
"wcag2a",
|
|
12
|
+
"wcag2aa",
|
|
13
|
+
"wcag21a",
|
|
14
|
+
"wcag21aa",
|
|
15
|
+
"wcag22aa",
|
|
16
|
+
"best-practice",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const enabledRules: Rule[] = getRules(enabledTags).map((ruleMetadata) => ({
|
|
20
|
+
id: ruleMetadata.ruleId,
|
|
21
|
+
enabled: true
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const a11y: A11yParameters = {
|
|
25
|
+
config: {
|
|
26
|
+
rules: enabledRules,
|
|
27
|
+
},
|
|
28
|
+
element: '#story-in-story-decorator-root',
|
|
29
|
+
};
|
|
30
|
+
|
|
6
31
|
const preview: Preview = {
|
|
7
32
|
parameters: {
|
|
33
|
+
a11y,
|
|
8
34
|
controls: {
|
|
9
35
|
matchers: {
|
|
10
36
|
color: /(background|color)$/i,
|
|
@@ -32,4 +58,6 @@ const preview: Preview = {
|
|
|
32
58
|
}),
|
|
33
59
|
],
|
|
34
60
|
};
|
|
61
|
+
|
|
62
|
+
|
|
35
63
|
export default preview;
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.1](https://github.com/Altinn/altinn-components/compare/v0.5.0...v0.5.1) (2024-11-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* add log out button and refactoring of global menu ([#50](https://github.com/Altinn/altinn-components/issues/50)) ([0fc8bfa](https://github.com/Altinn/altinn-components/commit/0fc8bfaa0feb113624da9e740aed54d61de15d4c))
|
|
9
|
+
|
|
10
|
+
## [0.5.0](https://github.com/Altinn/altinn-components/compare/v0.4.1...v0.5.0) (2024-11-15)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* search bar ([#45](https://github.com/Altinn/altinn-components/issues/45)) ([cc908e0](https://github.com/Altinn/altinn-components/commit/cc908e05957783adf97b94d5e196bf9722523471))
|
|
16
|
+
|
|
3
17
|
## [0.4.1](https://github.com/Altinn/altinn-components/compare/v0.4.0...v0.4.1) (2024-11-11)
|
|
4
18
|
|
|
5
19
|
|
package/biome.jsonc
CHANGED
|
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
2
2
|
import { AttachmentLink } from './AttachmentLink';
|
|
3
3
|
|
|
4
4
|
const meta = {
|
|
5
|
-
title: 'Attachment/AttachmentLink',
|
|
5
|
+
title: 'Atoms/Attachment/AttachmentLink',
|
|
6
6
|
component: AttachmentLink,
|
|
7
7
|
tags: ['autodocs'],
|
|
8
8
|
parameters: {},
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
|
-
import {
|
|
2
|
+
import type { IconName } from '../Icon';
|
|
3
3
|
import { ButtonBase, type ButtonBaseProps } from './ButtonBase';
|
|
4
|
+
import { ButtonIcon } from './ButtonIcon';
|
|
5
|
+
import { ButtonLabel } from './ButtonLabel';
|
|
4
6
|
import styles from './button.module.css';
|
|
5
7
|
|
|
6
8
|
export interface ButtonProps extends Partial<ButtonBaseProps> {
|
|
@@ -10,22 +12,27 @@ export interface ButtonProps extends Partial<ButtonBaseProps> {
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export const Button = ({
|
|
15
|
+
variant = 'solid',
|
|
16
|
+
color = 'primary',
|
|
13
17
|
size = 'md',
|
|
14
18
|
reverse = false,
|
|
15
19
|
selected = false,
|
|
16
20
|
icon,
|
|
17
21
|
href,
|
|
18
22
|
children,
|
|
23
|
+
className,
|
|
19
24
|
loading,
|
|
20
25
|
...rest
|
|
21
26
|
}: ButtonProps) => {
|
|
22
27
|
if (loading) {
|
|
23
28
|
return (
|
|
24
29
|
<ButtonBase
|
|
30
|
+
variant={variant}
|
|
31
|
+
color={color}
|
|
25
32
|
size={size}
|
|
26
33
|
selected={selected}
|
|
27
34
|
href={href}
|
|
28
|
-
className={cx(styles.button, { [styles.reverse]: reverse })}
|
|
35
|
+
className={cx(styles.button, { [styles.reverse]: reverse }, className)}
|
|
29
36
|
{...rest}
|
|
30
37
|
disabled
|
|
31
38
|
>
|
|
@@ -38,20 +45,16 @@ export const Button = ({
|
|
|
38
45
|
|
|
39
46
|
return (
|
|
40
47
|
<ButtonBase
|
|
48
|
+
variant={variant}
|
|
49
|
+
color={color}
|
|
41
50
|
size={size}
|
|
42
51
|
selected={selected}
|
|
43
52
|
href={href}
|
|
44
53
|
className={cx(styles.button, { [styles.reverse]: reverse })}
|
|
45
54
|
{...rest}
|
|
46
55
|
>
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
</span>
|
|
50
|
-
{icon && (
|
|
51
|
-
<span className={styles.icon} data-size={size}>
|
|
52
|
-
<Icon name={icon} />
|
|
53
|
-
</span>
|
|
54
|
-
)}
|
|
56
|
+
<ButtonLabel size={size}>{children}</ButtonLabel>
|
|
57
|
+
{icon && <ButtonIcon size={size} icon={icon} />}
|
|
55
58
|
</ButtonBase>
|
|
56
59
|
);
|
|
57
60
|
};
|
|
@@ -4,7 +4,7 @@ import type { ElementType, ReactNode } from 'react';
|
|
|
4
4
|
import styles from './buttonBase.module.css';
|
|
5
5
|
|
|
6
6
|
export type ButtonVariant = 'solid' | 'outline' | 'dotted' | 'text';
|
|
7
|
-
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
export type ButtonSize = 'sm' | 'md' | 'lg' | 'custom';
|
|
8
8
|
export type ButtonColor = 'primary' | 'secondary';
|
|
9
9
|
|
|
10
10
|
export interface ButtonBaseProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Icon, type IconName } from '../Icon';
|
|
2
|
+
import type { ButtonSize } from './ButtonBase';
|
|
3
|
+
import styles from './buttonIcon.module.css';
|
|
4
|
+
|
|
5
|
+
export interface ButtonIconProps {
|
|
6
|
+
icon: IconName;
|
|
7
|
+
size: ButtonSize;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const ButtonIcon = ({ size, icon }: ButtonIconProps) => {
|
|
11
|
+
return (
|
|
12
|
+
<span className={styles.icon} data-size={size}>
|
|
13
|
+
<Icon name={icon} />
|
|
14
|
+
</span>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { ButtonSize } from './ButtonBase';
|
|
4
|
+
import styles from './buttonLabel.module.css';
|
|
5
|
+
|
|
6
|
+
export interface ButtonLabelProps {
|
|
7
|
+
size: ButtonSize;
|
|
8
|
+
className?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ButtonLabel = ({ className, size, children }: ButtonLabelProps) => {
|
|
13
|
+
return (
|
|
14
|
+
<span className={cx(styles.label, className)} data-size={size}>
|
|
15
|
+
{children}
|
|
16
|
+
</span>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Button, ComboButton, IconButton, MetaItem } from '../';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Atoms/Button/Buttons',
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
parameters: {},
|
|
8
|
+
args: {
|
|
9
|
+
color: 'primary',
|
|
10
|
+
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
color: {
|
|
13
|
+
control: 'radio',
|
|
14
|
+
options: ['primary', 'secondary'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
|
|
22
|
+
const sizes = ['sm', 'md', 'lg'];
|
|
23
|
+
const variants = ['solid', 'outline', 'dotted', 'text'];
|
|
24
|
+
|
|
25
|
+
export const VariantsAndSizes = (args: Story) => {
|
|
26
|
+
return (
|
|
27
|
+
<div style={{ display: 'flex', flexDirection: 'column', rowGap: '1rem' }}>
|
|
28
|
+
{variants?.map((variant) => {
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
key={variant}
|
|
32
|
+
style={{
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'column',
|
|
35
|
+
rowGap: '1rem',
|
|
36
|
+
alignItems: 'start',
|
|
37
|
+
justifyContent: 'space-between',
|
|
38
|
+
width: '100%',
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<MetaItem>{variant}</MetaItem>
|
|
42
|
+
{sizes?.map((size) => {
|
|
43
|
+
return (
|
|
44
|
+
<div key={size} style={{ display: 'flex', alignItems: 'center', columnGap: '1rem' }}>
|
|
45
|
+
<IconButton {...args} icon="x-mark" variant={variant} size={size} />
|
|
46
|
+
<Button {...args} reverse variant={variant} icon="arrow-left" size={size}>
|
|
47
|
+
Button
|
|
48
|
+
</Button>
|
|
49
|
+
<Button {...args} variant={variant} icon="arrow-right" size={size}>
|
|
50
|
+
Button
|
|
51
|
+
</Button>
|
|
52
|
+
<ComboButton {...args} variant={variant} icon="chevron-down" size={size}>
|
|
53
|
+
ComboButton
|
|
54
|
+
</ComboButton>
|
|
55
|
+
<MetaItem>{size}</MetaItem>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
})}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
})}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
2
|
import type { MouseEventHandler } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import type { IconName } from '../Icon';
|
|
4
4
|
import { ButtonBase, type ButtonBaseProps } from './ButtonBase';
|
|
5
|
+
import { ButtonIcon } from './ButtonIcon';
|
|
6
|
+
import { ButtonLabel } from './ButtonLabel';
|
|
5
7
|
|
|
6
8
|
import styles from './comboButton.module.css';
|
|
7
9
|
|
|
@@ -13,9 +15,9 @@ export interface ComboButtonProps extends Omit<ButtonBaseProps, 'onClick'> {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export const ComboButton = ({
|
|
16
|
-
size = 'md',
|
|
17
18
|
variant = 'solid',
|
|
18
|
-
color,
|
|
19
|
+
color = 'primary',
|
|
20
|
+
size = 'md',
|
|
19
21
|
selected = false,
|
|
20
22
|
icon,
|
|
21
23
|
children,
|
|
@@ -32,12 +34,12 @@ export const ComboButton = ({
|
|
|
32
34
|
selected={selected}
|
|
33
35
|
className={cx(styles.button, className)}
|
|
34
36
|
>
|
|
35
|
-
<ButtonBase size={size} onClick={onIconClick} className={styles.
|
|
36
|
-
<
|
|
37
|
+
<ButtonBase size={size} onClick={onIconClick} className={styles.secondary}>
|
|
38
|
+
<ButtonIcon icon={icon} size={size} />
|
|
37
39
|
</ButtonBase>
|
|
38
40
|
<span data-size={size} className={styles.divider} />
|
|
39
|
-
<ButtonBase size={size} onClick={onLabelClick} className={styles.
|
|
40
|
-
{children}
|
|
41
|
+
<ButtonBase size={size} onClick={onLabelClick} className={styles.primary}>
|
|
42
|
+
<ButtonLabel size={size}>{children}</ButtonLabel>
|
|
41
43
|
</ButtonBase>
|
|
42
44
|
</ButtonBase>
|
|
43
45
|
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { MetaItem } from '../Meta';
|
|
3
|
+
import { IconButton } from './IconButton';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Atoms/Button/IconButton',
|
|
7
|
+
component: IconButton,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
parameters: {},
|
|
10
|
+
args: {
|
|
11
|
+
children: 'IconButton',
|
|
12
|
+
icon: 'x-mark',
|
|
13
|
+
size: 'sm',
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<typeof IconButton>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
args: {},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const sizes = ['sm', 'md', 'lg'];
|
|
25
|
+
const variants = ['outline', 'solid', 'dotted', 'text'];
|
|
26
|
+
|
|
27
|
+
export const Sizes = (args) => {
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ display: 'flex', columnGap: '1rem', justifyContent: 'space-between', width: '100%' }}>
|
|
30
|
+
{variants?.map((variant) => {
|
|
31
|
+
return (
|
|
32
|
+
<div key={variant} style={{ display: 'flex', flexDirection: 'column', columnGap: '1rem' }}>
|
|
33
|
+
<MetaItem>{variant}</MetaItem>
|
|
34
|
+
{sizes?.map((size) => {
|
|
35
|
+
return (
|
|
36
|
+
<div key={size}>
|
|
37
|
+
<IconButton {...args} variant={variant} size={size} />
|
|
38
|
+
<MetaItem>{size}</MetaItem>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
})}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
})}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import type { MouseEventHandler } from 'react';
|
|
3
|
+
import type { IconName } from '../Icon';
|
|
4
|
+
import { ButtonBase } from './ButtonBase';
|
|
5
|
+
import type { ButtonColor, ButtonSize, ButtonVariant } from './ButtonBase';
|
|
6
|
+
import { ButtonIcon } from './ButtonIcon';
|
|
4
7
|
import styles from './iconButton.module.css';
|
|
5
8
|
|
|
6
9
|
interface IconButtonProps {
|
|
@@ -9,13 +12,20 @@ interface IconButtonProps {
|
|
|
9
12
|
size?: ButtonSize;
|
|
10
13
|
variant?: ButtonVariant;
|
|
11
14
|
className?: string;
|
|
12
|
-
onClick?:
|
|
15
|
+
onClick?: MouseEventHandler;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
export const IconButton = ({
|
|
18
|
+
export const IconButton = ({
|
|
19
|
+
variant = 'solid',
|
|
20
|
+
color = 'primary',
|
|
21
|
+
size = 'md',
|
|
22
|
+
icon,
|
|
23
|
+
className,
|
|
24
|
+
onClick,
|
|
25
|
+
}: IconButtonProps) => {
|
|
16
26
|
return (
|
|
17
27
|
<ButtonBase variant={variant} color={color} size={size} className={cx(styles.button, className)} onClick={onClick}>
|
|
18
|
-
<
|
|
28
|
+
<ButtonIcon icon={icon} size={size} />
|
|
19
29
|
</ButtonBase>
|
|
20
30
|
);
|
|
21
31
|
};
|
|
@@ -1,63 +1,22 @@
|
|
|
1
1
|
.button {
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
|
+
column-gap: 0.125em;
|
|
5
|
+
border-radius: 2px;
|
|
4
6
|
}
|
|
5
7
|
|
|
6
8
|
.reverse {
|
|
7
9
|
flex-direction: row-reverse;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
.label {
|
|
11
|
-
line-height: 1rem;
|
|
12
|
-
font-weight: 600;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.icon {
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: center;
|
|
18
|
-
justify-content: center;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/* sm 36 */
|
|
22
|
-
|
|
23
12
|
.button[data-size="sm"] {
|
|
24
|
-
|
|
25
|
-
padding: 0 6px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.label[data-size="sm"] {
|
|
29
|
-
font-size: 0.875rem;
|
|
30
|
-
padding: 9px 4px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.icon[data-size="sm"] {
|
|
34
|
-
font-size: 1.25rem;
|
|
13
|
+
padding: 0 0.375rem;
|
|
35
14
|
}
|
|
36
15
|
|
|
37
|
-
/* md 44 */
|
|
38
|
-
|
|
39
16
|
.button[data-size="md"] {
|
|
40
|
-
|
|
41
|
-
padding: 9px 6px;
|
|
17
|
+
padding: 0 0.5rem;
|
|
42
18
|
}
|
|
43
19
|
|
|
44
|
-
.label[data-size="md"] {
|
|
45
|
-
font-size: 1rem;
|
|
46
|
-
padding: 4px 4px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.icon[data-size="md"] {
|
|
50
|
-
font-size: 1.5rem;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* lg 56 */
|
|
54
|
-
|
|
55
20
|
.button[data-size="lg"] {
|
|
56
|
-
|
|
57
|
-
padding: 9px 6px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.label[data-size="lg"] {
|
|
61
|
-
font-size: 1.125rem;
|
|
62
|
-
padding: 10px;
|
|
21
|
+
padding: 0 0.625rem;
|
|
63
22
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
-moz-osx-font-smoothing: inherit;
|
|
22
22
|
|
|
23
23
|
/* Corrects inability to style clickable `input` types in iOS */
|
|
24
|
-
|
|
24
|
+
appearance: none;
|
|
25
25
|
|
|
26
26
|
/* user select none */
|
|
27
27
|
user-select: none;
|
|
@@ -45,7 +45,19 @@
|
|
|
45
45
|
border-color: var(--theme-base-active);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
.button[data-size="sm"] {
|
|
49
|
+
height: 2.25rem; /* sm 36 */
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.button[data-size="md"] {
|
|
53
|
+
height: 2.75rem; /* md 44 */
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.button[data-size="lg"] {
|
|
57
|
+
height: 3.5rem; /* lg 56 */
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* primary solid */
|
|
49
61
|
|
|
50
62
|
.button[data-variant="solid"] {
|
|
51
63
|
border-color: var(--theme-base-default);
|
|
@@ -53,44 +65,52 @@
|
|
|
53
65
|
color: white;
|
|
54
66
|
}
|
|
55
67
|
|
|
56
|
-
|
|
68
|
+
.button[data-variant="solid"]:hover {
|
|
69
|
+
border-color: var(--theme-base-hover);
|
|
70
|
+
background-color: var(--theme-base-hover);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.button[data-variant="solid"]:active {
|
|
74
|
+
border-color: var(--theme-base-active);
|
|
75
|
+
background-color: var(--theme-base-active);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* primary outline, dotted + text */
|
|
79
|
+
|
|
80
|
+
.button[data-variant="outline"],
|
|
81
|
+
.button[data-variant="dotted"] {
|
|
82
|
+
border-color: var(--theme-base-default);
|
|
83
|
+
}
|
|
57
84
|
|
|
58
85
|
.button[data-variant="outline"] {
|
|
59
86
|
border-style: solid;
|
|
60
87
|
}
|
|
61
88
|
|
|
62
|
-
/* dotted */
|
|
63
|
-
|
|
64
89
|
.button[data-variant="dotted"] {
|
|
65
90
|
border-style: dotted;
|
|
66
91
|
}
|
|
67
92
|
|
|
68
|
-
/* text */
|
|
69
|
-
|
|
70
93
|
.button[data-variant="text"] {
|
|
71
94
|
border-color: transparent;
|
|
72
95
|
}
|
|
73
96
|
|
|
74
|
-
.button[
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
.button[data-variant="outline"]:hover,
|
|
98
|
+
.button[data-variant="dotted"]:hover,
|
|
99
|
+
.button[data-variant="text"]:hover {
|
|
100
|
+
background-color: var(--theme-surface-default);
|
|
77
101
|
}
|
|
78
102
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
.button[data-
|
|
82
|
-
|
|
103
|
+
.button[data-variant="outline"]:active,
|
|
104
|
+
.button[data-variant="dotted"]:active,
|
|
105
|
+
.button[data-variant="text"]:active {
|
|
106
|
+
background-color: var(--theme-surface-active);
|
|
83
107
|
}
|
|
84
108
|
|
|
85
|
-
|
|
86
|
-
border-color: var(--theme-base-hover);
|
|
87
|
-
}
|
|
109
|
+
/* selected */
|
|
88
110
|
|
|
89
|
-
.button[
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
background-color: var(--theme-base-default);
|
|
93
|
-
color: white;
|
|
111
|
+
.button[aria-selected="true"] {
|
|
112
|
+
background-color: var(--theme-background-subtle);
|
|
113
|
+
color: var(--theme-text-default);
|
|
94
114
|
}
|
|
95
115
|
|
|
96
116
|
/* secondary color */
|
|
@@ -103,8 +123,20 @@
|
|
|
103
123
|
border-color: var(--theme-surface-hover);
|
|
104
124
|
}
|
|
105
125
|
|
|
106
|
-
.button[data-color="secondary"][data-variant="solid"],
|
|
107
126
|
.button[data-color="secondary"][data-variant="solid"] {
|
|
108
127
|
border-color: var(--theme-surface-default);
|
|
109
128
|
background-color: var(--theme-surface-default);
|
|
110
129
|
}
|
|
130
|
+
|
|
131
|
+
.button[data-color="secondary"][data-variant="solid"]:hover {
|
|
132
|
+
border-color: var(--theme-surface-hover);
|
|
133
|
+
background-color: var(--theme-surface-hover);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.button[data-color="secondary"][data-variant="solid"]:active,
|
|
137
|
+
.button[data-color="secondary"][data-variant="outline"]:active,
|
|
138
|
+
.button[data-color="secondary"][data-variant="dotted"]:active,
|
|
139
|
+
.button[data-color="secondary"][data-variant="text"]:active {
|
|
140
|
+
border-color: var(--theme-surface-active);
|
|
141
|
+
background-color: var(--theme-surface-active);
|
|
142
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.icon {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.icon[data-size="sm"] {
|
|
8
|
+
font-size: 1.25rem;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.icon[data-size="md"] {
|
|
12
|
+
font-size: 1.5rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.icon[data-size="lg"] {
|
|
16
|
+
font-size: 1.625rem;
|
|
17
|
+
}
|