@developer-overheid-nl/don-register-components 1.3.0 → 1.6.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/CHANGELOG.md +170 -118
- package/LICENSE.md +291 -291
- package/README.md +20 -20
- package/package.json +10 -8
- package/src/Introduction.mdx +31 -0
- package/src/alert/Alert.stories.tsx +57 -0
- package/src/alert/Alert.tsx +19 -19
- package/src/alert/styles.module.css +3 -3
- package/src/alignBox/AlignBox.stories.tsx +84 -0
- package/src/alignBox/AlignBox.tsx +114 -114
- package/src/alignBox/styles.module.css +110 -110
- package/src/amountLabel/AmountLabel.stories.tsx +28 -0
- package/src/amountLabel/AmountLabel.tsx +21 -16
- package/src/amountLabel/styles.module.css +11 -11
- package/src/analytics/PiwikPro.tsx +94 -94
- package/src/analytics/index.ts +1 -1
- package/src/article/Article.stories.tsx +53 -0
- package/src/article/Article.tsx +10 -10
- package/src/badgeList/BadgeList.tsx +34 -34
- package/src/badgeList/styles.module.css +37 -37
- package/src/block/Block.stories.tsx +58 -0
- package/src/block/Block.tsx +35 -35
- package/src/block/styles.module.css +29 -29
- package/src/button/Button.stories.tsx +56 -0
- package/src/button/Button.tsx +3 -3
- package/src/button/ButtonAction.stories.tsx +62 -0
- package/src/button/ButtonAction.tsx +51 -0
- package/src/cardAsLink/CardAsLink.stories.tsx +81 -0
- package/src/cardAsLink/CardAsLink.tsx +21 -21
- package/src/cardAsLink/styles.module.css +23 -23
- package/src/cardsList/CardsList.tsx +56 -54
- package/src/cardsList/styles.module.css +18 -19
- package/src/client.ts +7 -7
- package/src/container/Container.stories.tsx +21 -0
- package/src/container/Container.tsx +10 -10
- package/src/container/styles.module.css +28 -28
- package/src/copyButton/CopyButton.stories.tsx +41 -0
- package/src/copyButton/CopyButton.tsx +45 -39
- package/src/copyButton/styles.module.css +13 -13
- package/src/dataBadgeLink/DataBadgeLink.stories.tsx +137 -0
- package/src/dataBadgeLink/DataBadgeLink.tsx +59 -53
- package/src/dataBadgeLink/styles.module.css +89 -89
- package/src/dataSummary/DataSummary.tsx +22 -22
- package/src/dataSummary/DataSummaryItem.tsx +21 -21
- package/src/dataSummary/styles.module.css +75 -75
- package/src/facetFilters/FacetFilters.stories.tsx +93 -0
- package/src/facetFilters/FacetFilters.tsx +424 -367
- package/src/facetFilters/styles.module.css +3 -3
- package/src/fieldset/FieldSet.stories.tsx +45 -0
- package/src/fieldset/FieldSet.tsx +3 -3
- package/src/filters/Filters.stories.tsx +45 -0
- package/src/filters/Filters.tsx +116 -116
- package/src/filters/styles.module.css +26 -26
- package/src/footer/Footer.stories.tsx +127 -0
- package/src/footer/Footer.tsx +81 -76
- package/src/footer/styles.module.css +103 -103
- package/src/formFieldCheckboxGroup/FormFieldCheckboxGroup.stories.tsx +48 -0
- package/src/formFieldCheckboxGroup/FormFieldCheckboxGroup.tsx +16 -16
- package/src/formFieldCheckboxGroup/styles.module.css +5 -5
- package/src/formFieldCheckboxOption/FormFieldCheckboxOption.stories.tsx +61 -0
- package/src/formFieldCheckboxOption/FormFieldCheckboxOption.tsx +26 -26
- package/src/formFieldCheckboxOption/styles.module.css +22 -22
- package/src/formFieldLabel/FormFieldLabel.stories.tsx +21 -0
- package/src/formFieldLabel/FormFieldLabel.tsx +23 -23
- package/src/formFieldRadioGroup/FormFieldRadioGroup.stories.tsx +57 -0
- package/src/formFieldRadioGroup/FormFieldRadioGroup.tsx +13 -13
- package/src/formFieldRadioGroup/styles.module.css +5 -5
- package/src/formFieldRadioOption/FormFieldRadioOption.stories.tsx +48 -0
- package/src/formFieldRadioOption/FormFieldRadioOption.tsx +75 -75
- package/src/formFieldRadioOption/styles.module.css +49 -49
- package/src/formFieldSwitch/FormFieldSwitch.stories.tsx +61 -0
- package/src/formFieldSwitch/FormFieldSwitch.tsx +82 -79
- package/src/formFieldSwitch/styles.module.css +32 -32
- package/src/formFieldTextInput/FormFieldTextInput.stories.tsx +45 -0
- package/src/formFieldTextInput/FormFieldTextInput.tsx +3 -3
- package/src/grid/Grid.stories.tsx +37 -0
- package/src/grid/Grid.tsx +48 -0
- package/src/grid/styles.module.css +24 -0
- package/src/header/Header.stories.tsx +54 -0
- package/src/header/Header.tsx +137 -137
- package/src/header/styles.module.css +71 -71
- package/src/heading/Heading.stories.tsx +60 -0
- package/src/heading/Heading.tsx +15 -15
- package/src/headingGroup/HeadingGroup.stories.tsx +57 -0
- package/src/headingGroup/HeadingGroup.tsx +48 -48
- package/src/headingGroup/styles.module.css +3 -3
- package/src/i18n.ts +24 -25
- package/src/iconBadge/IconBadge.stories.tsx +46 -0
- package/src/iconBadge/IconBadge.tsx +35 -35
- package/src/iconBadge/getAppearance.ts +53 -53
- package/src/iconBadge/styles.module.css +19 -19
- package/src/iconsSprite/Icon.stories.tsx +73 -0
- package/src/iconsSprite/Icon.tsx +17 -17
- package/src/iconsSprite/IconsSprite.tsx +5 -5
- package/src/index.ts +117 -107
- package/src/infoButton/InfoButton.stories.tsx +52 -0
- package/src/infoButton/InfoButton.tsx +45 -45
- package/src/infoButton/styles.module.css +43 -43
- package/src/link/Link.stories.tsx +49 -0
- package/src/link/Link.tsx +10 -10
- package/src/markdown/Markdown.stories.tsx +48 -0
- package/src/markdown/Markdown.tsx +42 -42
- package/src/overlay/Overlay.stories.tsx +38 -0
- package/src/overlay/Overlay.tsx +18 -18
- package/src/overlay/styles.module.css +15 -15
- package/src/pagination/Pagination.stories.tsx +91 -0
- package/src/pagination/Pagination.tsx +267 -267
- package/src/pagination/styles.module.css +28 -28
- package/src/paragraph/Paragraph.stories.tsx +45 -0
- package/src/paragraph/Paragraph.tsx +24 -24
- package/src/paragraph/styles.module.css +6 -6
- package/src/pillBadge/PillBadge.examples.tsx +107 -107
- package/src/pillBadge/PillBadge.stories.tsx +257 -0
- package/src/pillBadge/PillBadge.tsx +60 -51
- package/src/pillBadge/styles.module.css +214 -214
- package/src/readOnlyTextInput/ReadOnlyTextInput.stories.tsx +49 -0
- package/src/readOnlyTextInput/ReadOnlyTextInput.tsx +24 -24
- package/src/readOnlyTextInput/styles.module.css +19 -19
- package/src/scoreBadge/ScoreBadge.stories.tsx +45 -0
- package/src/scoreBadge/ScoreBadge.tsx +135 -133
- package/src/search/Search.stories.tsx +65 -0
- package/src/search/Search.tsx +82 -82
- package/src/search/styles.module.css +40 -39
- package/src/siteLogo/ExampleLogo.stories.tsx +40 -0
- package/src/siteLogo/SiteLogo.stories.tsx +28 -0
- package/src/siteLogo/SiteLogo.tsx +24 -24
- package/src/sortForm/SortForm.stories.tsx +111 -0
- package/src/sortForm/SortForm.tsx +121 -0
- package/src/sortForm/styles.module.css +40 -0
- package/src/switch/Switch.stories.tsx +68 -0
- package/src/switch/Switch.tsx +152 -86
- package/src/switch/styles.module.css +54 -7
- package/src/toolTip/ToolTip.stories.tsx +131 -0
- package/src/toolTip/ToolTip.tsx +55 -55
- package/src/toolTip/styles.module.css +49 -49
- package/src/topNavigation/TopNavigation.stories.tsx +71 -0
- package/src/topNavigation/TopNavigation.tsx +67 -67
- package/src/topNavigation/styles.module.css +54 -54
- package/tsconfig.json +122 -121
package/package.json
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
"author": "developer.overheid.nl",
|
|
4
4
|
"description": "The components for the API- and OSS registers",
|
|
5
5
|
"license": "EUPL-1.2",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/developer-overheid-nl/don-register-site"
|
|
9
|
+
},
|
|
6
10
|
"private": false,
|
|
7
11
|
"type": "module",
|
|
8
|
-
"version": "1.
|
|
12
|
+
"version": "1.6.1",
|
|
9
13
|
"keywords": [],
|
|
10
14
|
"publishConfig": {
|
|
11
15
|
"access": "public"
|
|
@@ -29,19 +33,17 @@
|
|
|
29
33
|
"@rijkshuisstijl-community/design-tokens": "11.0.0",
|
|
30
34
|
"@types/parse-link-header": "^2.0.3",
|
|
31
35
|
"clsx": "2.1.1",
|
|
32
|
-
"i18next": "
|
|
36
|
+
"i18next": "26.4.2",
|
|
33
37
|
"parse-link-header": "^2.0.0",
|
|
34
|
-
"react-i18next": "
|
|
38
|
+
"react-i18next": "17.0.14",
|
|
35
39
|
"react-markdown": "10.1.0",
|
|
36
40
|
"remark-behead": "^3.1.0",
|
|
37
|
-
"@developer-overheid-nl/don-register-locales": "1.2.
|
|
41
|
+
"@developer-overheid-nl/don-register-locales": "1.2.3"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"rimraf": "^6.1.2",
|
|
44
|
+
"rimraf": "6.1.3",
|
|
42
45
|
"typescript": "5.9.3",
|
|
43
|
-
"vite": "
|
|
44
|
-
"vite-plugin-dts": "^4.5.4"
|
|
46
|
+
"vite": "8.3.0"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
49
|
"@types/react": ">=19.2 <19.3",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="Introduction" />
|
|
4
|
+
|
|
5
|
+
# Register Site Components
|
|
6
|
+
|
|
7
|
+
Dit is de Storybook van `@developer-overheid-nl/don-register-components`: de gedeelde
|
|
8
|
+
React-componenten voor de registersites van developer.overheid.nl (het API-register en
|
|
9
|
+
het OSS-register).
|
|
10
|
+
|
|
11
|
+
De componenten zijn gebouwd op de [Rijkshuisstijl Community](https://www.rijkshuisstijl-community.nl/)
|
|
12
|
+
(RHC) design-system-componenten, CSS en design tokens, aangevuld met eigen componenten en
|
|
13
|
+
teksten (via `@developer-overheid-nl/don-register-locales`).
|
|
14
|
+
|
|
15
|
+
## Componenten in de zijbalk
|
|
16
|
+
|
|
17
|
+
Elke component in de zijbalk heeft een label dat aangeeft hoe de component zich verhoudt
|
|
18
|
+
tot de onderliggende RHC-component:
|
|
19
|
+
|
|
20
|
+
| Label | Icon | Betekenis |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| **Re-export** | 🚛 | Rechtstreeks doorgegeven vanuit RHC, zonder eigen aanpassingen. |
|
|
23
|
+
| **Remixed** | ♻️ | Een RHC-component die hier is aangevuld of anders is samengesteld. |
|
|
24
|
+
| **Custom** | ✨ | Een component die volledig eigen is aan deze registry, niet afkomstig uit RHC. |
|
|
25
|
+
| **Deprecated** | | Verouderd; wordt in een latere versie verwijderd. Gebruik niet in nieuwe code. |
|
|
26
|
+
|
|
27
|
+
## Meer informatie
|
|
28
|
+
|
|
29
|
+
- [Broncode van deze package](https://github.com/developer-overheid-nl/don-register-site/tree/main/packages/components)
|
|
30
|
+
- [CHANGELOG](https://github.com/developer-overheid-nl/don-register-site/blob/main/packages/components/CHANGELOG.md)
|
|
31
|
+
- [NPM package](https://www.npmjs.com/package/@developer-overheid-nl/don-register-components)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import Alert from "./Alert";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Een Alert toont een bericht op de pagina.
|
|
6
|
+
*
|
|
7
|
+
* ## Wijzigingen tov RHC:
|
|
8
|
+
* - Space around aangepast
|
|
9
|
+
*/
|
|
10
|
+
const meta = {
|
|
11
|
+
title: "Components/Alert",
|
|
12
|
+
component: Alert,
|
|
13
|
+
tags: ["autodocs", "remixed"],
|
|
14
|
+
args: {
|
|
15
|
+
children: "Dit is een melding.",
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
type: {
|
|
19
|
+
control: "select",
|
|
20
|
+
options: ["info", "ok", "warning", "error"],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
} satisfies Meta<typeof Alert>;
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
export const InfoAlert: Story = {
|
|
29
|
+
name: "Info",
|
|
30
|
+
args: {
|
|
31
|
+
type: "info",
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const OkAlert: Story = {
|
|
36
|
+
name: "Ok",
|
|
37
|
+
args: {
|
|
38
|
+
type: "ok",
|
|
39
|
+
children: "De actie is succesvol uitgevoerd.",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const WarningAlert: Story = {
|
|
44
|
+
name: "Warning",
|
|
45
|
+
args: {
|
|
46
|
+
type: "warning",
|
|
47
|
+
children: "Let op: controleer de ingevoerde gegevens.",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const ErrorAlert: Story = {
|
|
52
|
+
name: "Error",
|
|
53
|
+
args: {
|
|
54
|
+
type: "error",
|
|
55
|
+
children: "Er is een fout opgetreden.",
|
|
56
|
+
},
|
|
57
|
+
};
|
package/src/alert/Alert.tsx
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Alert as RHCAlert,
|
|
3
|
-
type AlertProps as RHCAlertProps,
|
|
4
|
-
} from "@rijkshuisstijl-community/components-react";
|
|
5
|
-
import clsx from "clsx";
|
|
6
|
-
import type { PropsWithChildren } from "react";
|
|
7
|
-
import styles from "./styles.module.css";
|
|
8
|
-
|
|
9
|
-
export interface AlertProps extends RHCAlertProps {
|
|
10
|
-
className?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const Alert = (props: PropsWithChildren<AlertProps>) => {
|
|
14
|
-
const { className } = props;
|
|
15
|
-
|
|
16
|
-
return <RHCAlert className={clsx(className, styles.alert)} {...props} />;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default Alert;
|
|
1
|
+
import {
|
|
2
|
+
Alert as RHCAlert,
|
|
3
|
+
type AlertProps as RHCAlertProps,
|
|
4
|
+
} from "@rijkshuisstijl-community/components-react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import type { PropsWithChildren } from "react";
|
|
7
|
+
import styles from "./styles.module.css";
|
|
8
|
+
|
|
9
|
+
export interface AlertProps extends RHCAlertProps {
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Alert = (props: PropsWithChildren<AlertProps>) => {
|
|
14
|
+
const { className } = props;
|
|
15
|
+
|
|
16
|
+
return <RHCAlert className={clsx(className, styles.alert)} {...props} />;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Alert;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.alert {
|
|
2
|
-
--utrecht-space-around: 1;
|
|
3
|
-
}
|
|
1
|
+
.alert {
|
|
2
|
+
--utrecht-space-around: 1;
|
|
3
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import AlignBox from "./AlignBox";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AlignBox is een hulpcomponent om kindelementen ten opzichte van elkaar uit
|
|
6
|
+
* te lijnen (bijv. links, gecentreerd, gespreid) met flexbox.
|
|
7
|
+
*/
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Components/AlignBox",
|
|
10
|
+
component: AlignBox,
|
|
11
|
+
tags: ["autodocs", "custom"],
|
|
12
|
+
argTypes: {
|
|
13
|
+
align: {
|
|
14
|
+
control: "select",
|
|
15
|
+
options: [
|
|
16
|
+
"left",
|
|
17
|
+
"center",
|
|
18
|
+
"right",
|
|
19
|
+
"top",
|
|
20
|
+
"bottom",
|
|
21
|
+
"middle",
|
|
22
|
+
"top-left",
|
|
23
|
+
"top-right",
|
|
24
|
+
"bottom-left",
|
|
25
|
+
"bottom-right",
|
|
26
|
+
"stretch",
|
|
27
|
+
"space-between",
|
|
28
|
+
"space-around",
|
|
29
|
+
"space-evenly",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
gap: {
|
|
33
|
+
control: "select",
|
|
34
|
+
options: ["none", "small", "medium", "large"],
|
|
35
|
+
},
|
|
36
|
+
direction: {
|
|
37
|
+
control: "select",
|
|
38
|
+
options: ["row", "column"],
|
|
39
|
+
},
|
|
40
|
+
display: {
|
|
41
|
+
control: "select",
|
|
42
|
+
options: ["block", "inline"],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
args: {
|
|
46
|
+
align: "center",
|
|
47
|
+
gap: "medium",
|
|
48
|
+
direction: "row",
|
|
49
|
+
wrap: false,
|
|
50
|
+
display: "block",
|
|
51
|
+
},
|
|
52
|
+
render: (args) => (
|
|
53
|
+
<AlignBox {...args} style={{ border: "1px dashed #ccc", minHeight: 120 }}>
|
|
54
|
+
<div style={{ background: "#e0e0e0", padding: "8px 16px" }}>Een</div>
|
|
55
|
+
<div style={{ background: "#e0e0e0", padding: "8px 16px" }}>Twee</div>
|
|
56
|
+
<div style={{ background: "#e0e0e0", padding: "8px 16px" }}>Drie</div>
|
|
57
|
+
</AlignBox>
|
|
58
|
+
),
|
|
59
|
+
} satisfies Meta<typeof AlignBox>;
|
|
60
|
+
|
|
61
|
+
export default meta;
|
|
62
|
+
type Story = StoryObj<typeof meta>;
|
|
63
|
+
|
|
64
|
+
export const Default: Story = {};
|
|
65
|
+
|
|
66
|
+
export const SpaceBetween: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
align: "space-between",
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const Column: Story = {
|
|
73
|
+
args: {
|
|
74
|
+
direction: "column",
|
|
75
|
+
align: "stretch",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const Wrap: Story = {
|
|
80
|
+
args: {
|
|
81
|
+
wrap: true,
|
|
82
|
+
gap: "small",
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import type React from "react";
|
|
3
|
-
import type { ReactNode } from "react";
|
|
4
|
-
import styles from "./styles.module.css";
|
|
5
|
-
|
|
6
|
-
type Align =
|
|
7
|
-
| "left"
|
|
8
|
-
| "center"
|
|
9
|
-
| "right"
|
|
10
|
-
| "top"
|
|
11
|
-
| "bottom"
|
|
12
|
-
| "middle"
|
|
13
|
-
| "top-left"
|
|
14
|
-
| "top-right"
|
|
15
|
-
| "bottom-left"
|
|
16
|
-
| "bottom-right"
|
|
17
|
-
| "stretch"
|
|
18
|
-
| "space-between"
|
|
19
|
-
| "space-around"
|
|
20
|
-
| "space-evenly";
|
|
21
|
-
|
|
22
|
-
type Gap = "none" | "small" | "medium" | "large";
|
|
23
|
-
|
|
24
|
-
export interface AlignBoxProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
25
|
-
align?: Align;
|
|
26
|
-
gap?: Gap;
|
|
27
|
-
direction?: "row" | "column";
|
|
28
|
-
wrap?: boolean;
|
|
29
|
-
display?: "block" | "inline";
|
|
30
|
-
children: ReactNode;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const getAlignmentClass = (align: Align): string => {
|
|
34
|
-
switch (align) {
|
|
35
|
-
case "left":
|
|
36
|
-
return styles.left;
|
|
37
|
-
case "center":
|
|
38
|
-
return styles.center;
|
|
39
|
-
case "right":
|
|
40
|
-
return styles.right;
|
|
41
|
-
case "top":
|
|
42
|
-
return styles.top;
|
|
43
|
-
case "bottom":
|
|
44
|
-
return styles.bottom;
|
|
45
|
-
case "middle":
|
|
46
|
-
return styles.middle;
|
|
47
|
-
case "top-left":
|
|
48
|
-
return styles.topLeft;
|
|
49
|
-
case "top-right":
|
|
50
|
-
return styles.topRight;
|
|
51
|
-
case "bottom-left":
|
|
52
|
-
return styles.bottomLeft;
|
|
53
|
-
case "bottom-right":
|
|
54
|
-
return styles.bottomRight;
|
|
55
|
-
case "stretch":
|
|
56
|
-
return styles.stretch;
|
|
57
|
-
case "space-between":
|
|
58
|
-
return styles.spaceBetween;
|
|
59
|
-
case "space-around":
|
|
60
|
-
return styles.spaceAround;
|
|
61
|
-
case "space-evenly":
|
|
62
|
-
return styles.spaceEvenly;
|
|
63
|
-
default:
|
|
64
|
-
return styles.center;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const getGapClass = (gap: Gap): string => {
|
|
69
|
-
switch (gap) {
|
|
70
|
-
case "none":
|
|
71
|
-
return styles.gapNone;
|
|
72
|
-
case "small":
|
|
73
|
-
return styles.gapSmall;
|
|
74
|
-
case "medium":
|
|
75
|
-
return styles.gapMedium;
|
|
76
|
-
case "large":
|
|
77
|
-
return styles.gapLarge;
|
|
78
|
-
default:
|
|
79
|
-
return styles.gapMedium;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const AlignBox: React.FC<AlignBoxProps> = ({
|
|
84
|
-
align = "center",
|
|
85
|
-
gap = "none",
|
|
86
|
-
direction = "row",
|
|
87
|
-
wrap = false,
|
|
88
|
-
display = "block",
|
|
89
|
-
className,
|
|
90
|
-
children,
|
|
91
|
-
...restProps
|
|
92
|
-
}) => {
|
|
93
|
-
const alignmentClass = getAlignmentClass(align);
|
|
94
|
-
const gapClass = getGapClass(gap);
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<div
|
|
98
|
-
className={clsx(
|
|
99
|
-
styles.alignBox,
|
|
100
|
-
styles[direction],
|
|
101
|
-
wrap && styles.wrap,
|
|
102
|
-
styles[display],
|
|
103
|
-
alignmentClass,
|
|
104
|
-
gapClass,
|
|
105
|
-
className ?? "",
|
|
106
|
-
)}
|
|
107
|
-
{...restProps}
|
|
108
|
-
>
|
|
109
|
-
{children}
|
|
110
|
-
</div>
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export default AlignBox;
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import styles from "./styles.module.css";
|
|
5
|
+
|
|
6
|
+
type Align =
|
|
7
|
+
| "left"
|
|
8
|
+
| "center"
|
|
9
|
+
| "right"
|
|
10
|
+
| "top"
|
|
11
|
+
| "bottom"
|
|
12
|
+
| "middle"
|
|
13
|
+
| "top-left"
|
|
14
|
+
| "top-right"
|
|
15
|
+
| "bottom-left"
|
|
16
|
+
| "bottom-right"
|
|
17
|
+
| "stretch"
|
|
18
|
+
| "space-between"
|
|
19
|
+
| "space-around"
|
|
20
|
+
| "space-evenly";
|
|
21
|
+
|
|
22
|
+
type Gap = "none" | "small" | "medium" | "large";
|
|
23
|
+
|
|
24
|
+
export interface AlignBoxProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
25
|
+
align?: Align;
|
|
26
|
+
gap?: Gap;
|
|
27
|
+
direction?: "row" | "column";
|
|
28
|
+
wrap?: boolean;
|
|
29
|
+
display?: "block" | "inline";
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getAlignmentClass = (align: Align): string => {
|
|
34
|
+
switch (align) {
|
|
35
|
+
case "left":
|
|
36
|
+
return styles.left;
|
|
37
|
+
case "center":
|
|
38
|
+
return styles.center;
|
|
39
|
+
case "right":
|
|
40
|
+
return styles.right;
|
|
41
|
+
case "top":
|
|
42
|
+
return styles.top;
|
|
43
|
+
case "bottom":
|
|
44
|
+
return styles.bottom;
|
|
45
|
+
case "middle":
|
|
46
|
+
return styles.middle;
|
|
47
|
+
case "top-left":
|
|
48
|
+
return styles.topLeft;
|
|
49
|
+
case "top-right":
|
|
50
|
+
return styles.topRight;
|
|
51
|
+
case "bottom-left":
|
|
52
|
+
return styles.bottomLeft;
|
|
53
|
+
case "bottom-right":
|
|
54
|
+
return styles.bottomRight;
|
|
55
|
+
case "stretch":
|
|
56
|
+
return styles.stretch;
|
|
57
|
+
case "space-between":
|
|
58
|
+
return styles.spaceBetween;
|
|
59
|
+
case "space-around":
|
|
60
|
+
return styles.spaceAround;
|
|
61
|
+
case "space-evenly":
|
|
62
|
+
return styles.spaceEvenly;
|
|
63
|
+
default:
|
|
64
|
+
return styles.center;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const getGapClass = (gap: Gap): string => {
|
|
69
|
+
switch (gap) {
|
|
70
|
+
case "none":
|
|
71
|
+
return styles.gapNone;
|
|
72
|
+
case "small":
|
|
73
|
+
return styles.gapSmall;
|
|
74
|
+
case "medium":
|
|
75
|
+
return styles.gapMedium;
|
|
76
|
+
case "large":
|
|
77
|
+
return styles.gapLarge;
|
|
78
|
+
default:
|
|
79
|
+
return styles.gapMedium;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const AlignBox: React.FC<AlignBoxProps> = ({
|
|
84
|
+
align = "center",
|
|
85
|
+
gap = "none",
|
|
86
|
+
direction = "row",
|
|
87
|
+
wrap = false,
|
|
88
|
+
display = "block",
|
|
89
|
+
className,
|
|
90
|
+
children,
|
|
91
|
+
...restProps
|
|
92
|
+
}) => {
|
|
93
|
+
const alignmentClass = getAlignmentClass(align);
|
|
94
|
+
const gapClass = getGapClass(gap);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
className={clsx(
|
|
99
|
+
styles.alignBox,
|
|
100
|
+
styles[direction],
|
|
101
|
+
wrap && styles.wrap,
|
|
102
|
+
styles[display],
|
|
103
|
+
alignmentClass,
|
|
104
|
+
gapClass,
|
|
105
|
+
className ?? "",
|
|
106
|
+
)}
|
|
107
|
+
{...restProps}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default AlignBox;
|