@react5/ui 1.0.26 → 1.0.28
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/LICENSE +21 -21
- package/README.md +2 -2
- package/package.json +38 -38
- package/packages/app/README.md +50 -50
- package/packages/app/eslint.config.js +28 -28
- package/packages/app/index.html +13 -13
- package/packages/app/jest.config.js +12 -12
- package/packages/app/package.json +36 -36
- package/packages/app/src/App.css +5 -5
- package/packages/app/src/App.tsx +35 -35
- package/packages/app/src/i18n/config.ts +21 -21
- package/packages/app/src/i18n/en/translation.json +4 -4
- package/packages/app/src/i18n/fr/translation.json +4 -4
- package/packages/app/src/i18n/index.ts +3 -3
- package/packages/app/src/main.tsx +16 -16
- package/packages/app/src/styles/1-reset.scss +72 -72
- package/packages/app/src/styles/2-colors.scss +11 -11
- package/packages/app/src/vite-env.d.ts +1 -1
- package/packages/app/tsconfig.app.json +26 -26
- package/packages/app/tsconfig.json +7 -7
- package/packages/app/tsconfig.node.json +24 -24
- package/packages/app/vite.config.ts +7 -7
- package/packages/lib/.babelrc +9 -9
- package/packages/lib/.storybook/main.js +50 -50
- package/packages/lib/.storybook/preview.js +13 -13
- package/packages/lib/declaration.d.ts +9 -9
- package/packages/lib/dist/esm/index.esm.css +0 -2
- package/packages/lib/dist/esm/index.esm.js +1 -1
- package/packages/lib/dist/esm/index.esm.js.map +1 -1
- package/packages/lib/dist/esm/index.esm.scss +1401 -1403
- package/packages/lib/dist/index.css +0 -2
- package/packages/lib/dist/index.js +1 -1
- package/packages/lib/dist/index.js.map +1 -1
- package/packages/lib/dist/index.scss +1401 -1403
- package/packages/lib/jest.config.js +19 -19
- package/packages/lib/package.json +100 -102
- package/packages/lib/plop/component/index.js +43 -43
- package/packages/lib/plop/index.js +3 -3
- package/packages/lib/plop/templates/component/component.hbs +19 -19
- package/packages/lib/plop/templates/component/index.hbs +1 -1
- package/packages/lib/plop/templates/component/stories.hbs +17 -17
- package/packages/lib/plop/templates/component/style.hbs +1 -1
- package/packages/lib/plop/templates/component/test.hbs +11 -11
- package/packages/lib/plopfile.js +1 -1
- package/packages/lib/rollup.config.mjs +64 -64
- package/packages/lib/src/components/Accordion/Accordion.scss +67 -67
- package/packages/lib/src/components/Accordion/Accordion.tsx +36 -36
- package/packages/lib/src/components/Button/Button.scss +60 -62
- package/packages/lib/src/components/Button/Button.stories.tsx +26 -26
- package/packages/lib/src/components/Button/Button.tsx +40 -40
- package/packages/lib/src/components/Button/index.tsx +1 -1
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.scss +3 -3
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.stories.tsx +17 -17
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.test.tsx +11 -11
- package/packages/lib/src/components/ButtonsGroup/ButtonsGroup.tsx +17 -17
- package/packages/lib/src/components/ButtonsGroup/index.tsx +1 -1
- package/packages/lib/src/components/CheckBox/CheckBox.scss +63 -63
- package/packages/lib/src/components/CheckBox/CheckBox.stories.tsx +22 -22
- package/packages/lib/src/components/CheckBox/CheckBox.tsx +42 -42
- package/packages/lib/src/components/CheckBox/index.tsx +1 -1
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.scss +6 -6
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.stories.tsx +17 -17
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.test.tsx +11 -11
- package/packages/lib/src/components/DialogPrompt/DialogPrompt.tsx +41 -41
- package/packages/lib/src/components/DialogPrompt/index.tsx +1 -1
- package/packages/lib/src/components/Divider/Divider.scss +22 -22
- package/packages/lib/src/components/Divider/Divider.tsx +20 -20
- package/packages/lib/src/components/DropDown/DropDown.scss +70 -70
- package/packages/lib/src/components/DropDown/DropDown.stories.tsx +45 -45
- package/packages/lib/src/components/DropDown/DropDown.tsx +61 -61
- package/packages/lib/src/components/DropDown/index.tsx +1 -1
- package/packages/lib/src/components/Form/Form.scss +3 -3
- package/packages/lib/src/components/Form/Form.stories.tsx +20 -20
- package/packages/lib/src/components/Form/Form.tsx +25 -25
- package/packages/lib/src/components/FormButtons/FormButtons.scss +5 -5
- package/packages/lib/src/components/FormButtons/FormButtons.tsx +18 -18
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.scss +6 -6
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.stories.tsx +17 -17
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.test.tsx +11 -11
- package/packages/lib/src/components/HeaderButtons/HeaderButtons.tsx +28 -28
- package/packages/lib/src/components/HeaderButtons/index.tsx +1 -1
- package/packages/lib/src/components/IconButton/IconButton.scss +64 -64
- package/packages/lib/src/components/IconButton/IconButton.tsx +44 -44
- package/packages/lib/src/components/MenuItem/MenuItem.scss +13 -13
- package/packages/lib/src/components/MenuItem/MenuItem.tsx +36 -36
- package/packages/lib/src/components/Modal/Modal.scss +71 -71
- package/packages/lib/src/components/Modal/Modal.tsx +60 -60
- package/packages/lib/src/components/Navbar/Navbar.scss +52 -52
- package/packages/lib/src/components/Navbar/Navbar.stories.tsx +25 -25
- package/packages/lib/src/components/Navbar/Navbar.tsx +38 -38
- package/packages/lib/src/components/NavbarLink/NavbarLink.scss +15 -15
- package/packages/lib/src/components/NavbarLink/NavbarLink.tsx +34 -34
- package/packages/lib/src/components/NavbarMenu/NavbarMenu.scss +156 -156
- package/packages/lib/src/components/NavbarMenu/NavbarMenu.stories.tsx +24 -24
- package/packages/lib/src/components/NavbarMenu/NavbarMenu.tsx +72 -72
- package/packages/lib/src/components/Panel/Panel.scss +29 -29
- package/packages/lib/src/components/Panel/Panel.stories.tsx +32 -32
- package/packages/lib/src/components/Panel/Panel.test.tsx +11 -11
- package/packages/lib/src/components/Panel/Panel.tsx +29 -29
- package/packages/lib/src/components/Panel/index.tsx +1 -1
- package/packages/lib/src/components/Paper/Paper.scss +5 -5
- package/packages/lib/src/components/Paper/Paper.stories.tsx +18 -18
- package/packages/lib/src/components/Paper/Paper.tsx +18 -18
- package/packages/lib/src/components/Paper/index.tsx +1 -1
- package/packages/lib/src/components/RangeSlider/RangeSlider.scss +83 -83
- package/packages/lib/src/components/RangeSlider/RangeSlider.stories.tsx +24 -24
- package/packages/lib/src/components/RangeSlider/RangeSlider.tsx +150 -150
- package/packages/lib/src/components/ResponsiveBar/ResponsiveBar.scss +72 -72
- package/packages/lib/src/components/ResponsiveBar/ResponsiveBar.tsx +38 -38
- package/packages/lib/src/components/ScrollView/ScrollView.scss +20 -20
- package/packages/lib/src/components/ScrollView/ScrollView.stories.tsx +17 -17
- package/packages/lib/src/components/ScrollView/ScrollView.test.tsx +11 -11
- package/packages/lib/src/components/ScrollView/ScrollView.tsx +19 -19
- package/packages/lib/src/components/ScrollView/index.tsx +1 -1
- package/packages/lib/src/components/Section/Section.scss +17 -17
- package/packages/lib/src/components/Section/Section.tsx +26 -26
- package/packages/lib/src/components/SelectField/SelectField.scss +42 -42
- package/packages/lib/src/components/SelectField/SelectField.stories.tsx +14 -14
- package/packages/lib/src/components/SelectField/SelectField.tsx +54 -54
- package/packages/lib/src/components/SelectField/index.tsx +1 -1
- package/packages/lib/src/components/Spacer/Spacer.scss +2 -2
- package/packages/lib/src/components/Spacer/Spacer.tsx +6 -6
- package/packages/lib/src/components/StackPanel/StackPanel.scss +8 -8
- package/packages/lib/src/components/StackPanel/StackPanel.stories.tsx +17 -17
- package/packages/lib/src/components/StackPanel/StackPanel.test.tsx +11 -11
- package/packages/lib/src/components/StackPanel/StackPanel.tsx +31 -31
- package/packages/lib/src/components/StackPanel/index.tsx +1 -1
- package/packages/lib/src/components/Submenu/Submenu.scss +55 -55
- package/packages/lib/src/components/Submenu/Submenu.stories.tsx +45 -45
- package/packages/lib/src/components/Submenu/Submenu.tsx +59 -59
- package/packages/lib/src/components/Submenu/index.tsx +1 -1
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.scss +75 -75
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.stories.tsx +17 -17
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.test.tsx +11 -11
- package/packages/lib/src/components/SuccessCongratulation/SuccessCongratulation.tsx +63 -63
- package/packages/lib/src/components/SuccessCongratulation/index.tsx +1 -1
- package/packages/lib/src/components/TextArea/TextArea.scss +41 -41
- package/packages/lib/src/components/TextArea/TextArea.stories.tsx +14 -14
- package/packages/lib/src/components/TextArea/TextArea.tsx +50 -50
- package/packages/lib/src/components/TextArea/index.tsx +1 -1
- package/packages/lib/src/components/TextField/TextField.scss +56 -56
- package/packages/lib/src/components/TextField/TextField.stories.tsx +14 -14
- package/packages/lib/src/components/TextField/TextField.tsx +89 -89
- package/packages/lib/src/components/TextField/index.tsx +1 -1
- package/packages/lib/src/components/TitleEdit/TitleEdit.scss +17 -17
- package/packages/lib/src/components/TitleEdit/TitleEdit.tsx +69 -69
- package/packages/lib/src/components/Toast/Toast.scss +32 -32
- package/packages/lib/src/components/Toast/Toast.tsx +29 -29
- package/packages/lib/src/components/ToggleButton/ToggleButton.scss +47 -47
- package/packages/lib/src/components/ToggleButton/ToggleButton.stories.tsx +22 -22
- package/packages/lib/src/components/ToggleButton/ToggleButton.tsx +41 -41
- package/packages/lib/src/components/ToggleButton/index.tsx +1 -1
- package/packages/lib/src/components/Toolbar/Toolbar.scss +16 -16
- package/packages/lib/src/components/Toolbar/Toolbar.stories.tsx +17 -17
- package/packages/lib/src/components/Toolbar/Toolbar.test.tsx +11 -11
- package/packages/lib/src/components/Toolbar/Toolbar.tsx +20 -20
- package/packages/lib/src/components/Toolbar/index.tsx +1 -1
- package/packages/lib/src/components/Typography/Typography.scss +51 -51
- package/packages/lib/src/components/Typography/Typography.stories.tsx +18 -18
- package/packages/lib/src/components/Typography/Typography.tsx +19 -19
- package/packages/lib/src/components/index.tsx +34 -34
- package/packages/lib/src/hooks/index.tsx +3 -3
- package/packages/lib/src/hooks/use-click-outside.tsx +19 -19
- package/packages/lib/src/hooks/use-form.tsx +107 -107
- package/packages/lib/src/hooks/use-keys-enteresc.tsx +25 -25
- package/packages/lib/src/hooks/use-set-startup-focus.tsx +8 -8
- package/packages/lib/src/i18n/config.ts +8 -8
- package/packages/lib/src/i18n/en/translation.json +11 -11
- package/packages/lib/src/i18n/fr/translation.json +11 -11
- package/packages/lib/src/i18n/index.ts +11 -11
- package/packages/lib/src/index.tsx +7 -7
- package/packages/lib/src/stories/Intrduction.mdx +171 -171
- package/packages/lib/src/stories/assets/github.svg +3 -3
- package/packages/lib/src/styles/1-color-vars.scss +51 -51
- package/packages/lib/src/styles/2-font-variables.scss +2 -2
- package/packages/lib/src/styles/variables.scss +1 -1
- package/packages/lib/src/test/i18n.ts +17 -17
- package/packages/lib/src/utils/bem.ts +4 -4
- package/packages/lib/src/utils/formatError.ts +5 -5
- package/packages/lib/src/utils/index.ts +1 -1
- package/packages/lib/src/utils/interfaces.ts +5 -5
- package/packages/lib/tsconfig.json +26 -25
- package/packages/lib/vite.config.js +18 -18
- package/packages/ui-test/package-lock.json +97 -97
- package/packages/ui-test/package.json +19 -19
- package/packages/ui-test/playwright.config.ts +80 -80
- package/packages/ui-test/tests/example.spec.ts +18 -18
- package/packages/ui-test/tests-examples/demo-todo-app.spec.ts +437 -437
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
.r5ui-accordion {
|
|
2
|
-
width: 100%;
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
border: 0 solid $primary_border_color;
|
|
6
|
-
border-top-width: 1px;
|
|
7
|
-
border-bottom-width: 1px;
|
|
8
|
-
margin: 0;
|
|
9
|
-
+ .accordion {
|
|
10
|
-
border-top: none;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&__toggle-header {
|
|
14
|
-
color: $page_text_color;
|
|
15
|
-
background: $page_bg_color;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
display: flex;
|
|
18
|
-
align-items: center;
|
|
19
|
-
justify-content: space-between;
|
|
20
|
-
padding: 1rem;
|
|
21
|
-
flex: 1;
|
|
22
|
-
text-align: left;
|
|
23
|
-
outline: none;
|
|
24
|
-
display: flex;
|
|
25
|
-
border: none;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&__title {
|
|
29
|
-
font-size: 1.3rem;
|
|
30
|
-
font-weight: 500;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&__indicator {
|
|
34
|
-
margin-left: 0.6em;
|
|
35
|
-
border: solid $secondary_border_color;
|
|
36
|
-
border-width: 0 2px 2px 0;
|
|
37
|
-
display: inline-block;
|
|
38
|
-
padding: 3px;
|
|
39
|
-
transform: rotate(45deg);
|
|
40
|
-
transition: transform 0.3s ease;
|
|
41
|
-
align-self: last;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&__indicator--open {
|
|
45
|
-
transform: rotate(-135deg);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&__content {
|
|
49
|
-
display: none;
|
|
50
|
-
padding: 0 0 1em 0;
|
|
51
|
-
overflow: hidden;
|
|
52
|
-
transition: max-height 0.3s ease, opacity 0.3s ease;
|
|
53
|
-
max-height: 0;
|
|
54
|
-
opacity: 0;
|
|
55
|
-
|
|
56
|
-
&--open {
|
|
57
|
-
display: block;
|
|
58
|
-
max-height: initial; // Adjust max height as needed
|
|
59
|
-
opacity: 1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&--open {
|
|
64
|
-
.accordion__content {
|
|
65
|
-
display: block;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
.r5ui-accordion {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
border: 0 solid $primary_border_color;
|
|
6
|
+
border-top-width: 1px;
|
|
7
|
+
border-bottom-width: 1px;
|
|
8
|
+
margin: 0;
|
|
9
|
+
+ .accordion {
|
|
10
|
+
border-top: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__toggle-header {
|
|
14
|
+
color: $page_text_color;
|
|
15
|
+
background: $page_bg_color;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
padding: 1rem;
|
|
21
|
+
flex: 1;
|
|
22
|
+
text-align: left;
|
|
23
|
+
outline: none;
|
|
24
|
+
display: flex;
|
|
25
|
+
border: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&__title {
|
|
29
|
+
font-size: 1.3rem;
|
|
30
|
+
font-weight: 500;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__indicator {
|
|
34
|
+
margin-left: 0.6em;
|
|
35
|
+
border: solid $secondary_border_color;
|
|
36
|
+
border-width: 0 2px 2px 0;
|
|
37
|
+
display: inline-block;
|
|
38
|
+
padding: 3px;
|
|
39
|
+
transform: rotate(45deg);
|
|
40
|
+
transition: transform 0.3s ease;
|
|
41
|
+
align-self: last;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&__indicator--open {
|
|
45
|
+
transform: rotate(-135deg);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&__content {
|
|
49
|
+
display: none;
|
|
50
|
+
padding: 0 0 1em 0;
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
transition: max-height 0.3s ease, opacity 0.3s ease;
|
|
53
|
+
max-height: 0;
|
|
54
|
+
opacity: 0;
|
|
55
|
+
|
|
56
|
+
&--open {
|
|
57
|
+
display: block;
|
|
58
|
+
max-height: initial; // Adjust max height as needed
|
|
59
|
+
opacity: 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&--open {
|
|
64
|
+
.accordion__content {
|
|
65
|
+
display: block;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
68
|
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import React, { useState, ReactNode, useEffect, MouseEvent } from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import { bem } from '../../utils/bem';
|
|
4
|
-
import './Accordion.scss';
|
|
5
|
-
|
|
6
|
-
const b = bem('accordion');
|
|
7
|
-
|
|
8
|
-
interface AccordionProps {
|
|
9
|
-
title: string;
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
className?: string;
|
|
12
|
-
isOpen?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const Accordion: React.FC<AccordionProps> = ({ title, children, className, isOpen = false }) => {
|
|
16
|
-
const [isAccOpen, setIsOpen] = useState(isOpen);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
isOpen && setIsOpen(isOpen);
|
|
19
|
-
}, [isOpen])
|
|
20
|
-
|
|
21
|
-
const toggleAccordion = (e: MouseEvent<HTMLButtonElement>) => {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
setIsOpen((prev) => !prev);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div className={clsx(b(), className, { [b('open')]: isAccOpen })}>
|
|
28
|
-
<button className={b('toggle-header')} onClick={toggleAccordion}>
|
|
29
|
-
<h3 className={b('title')}>{title}</h3>
|
|
30
|
-
<span className={clsx(b("indicator"), isAccOpen && b("indicator", "open"))}></span>
|
|
31
|
-
</button>
|
|
32
|
-
<div className={clsx(b('content'), isAccOpen && b('content', 'open'))}>
|
|
33
|
-
{children}
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
1
|
+
import React, { useState, ReactNode, useEffect, MouseEvent } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { bem } from '../../utils/bem';
|
|
4
|
+
import './Accordion.scss';
|
|
5
|
+
|
|
6
|
+
const b = bem('accordion');
|
|
7
|
+
|
|
8
|
+
interface AccordionProps {
|
|
9
|
+
title: string;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
isOpen?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const Accordion: React.FC<AccordionProps> = ({ title, children, className, isOpen = false }) => {
|
|
16
|
+
const [isAccOpen, setIsOpen] = useState(isOpen);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
isOpen && setIsOpen(isOpen);
|
|
19
|
+
}, [isOpen])
|
|
20
|
+
|
|
21
|
+
const toggleAccordion = (e: MouseEvent<HTMLButtonElement>) => {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
setIsOpen((prev) => !prev);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className={clsx(b(), className, { [b('open')]: isAccOpen })}>
|
|
28
|
+
<button className={b('toggle-header')} onClick={toggleAccordion}>
|
|
29
|
+
<h3 className={b('title')}>{title}</h3>
|
|
30
|
+
<span className={clsx(b("indicator"), isAccOpen && b("indicator", "open"))}></span>
|
|
31
|
+
</button>
|
|
32
|
+
<div className={clsx(b('content'), isAccOpen && b('content', 'open'))}>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
37
|
};
|
|
@@ -1,63 +1,61 @@
|
|
|
1
|
-
//@import "../../styles/colors.scss";
|
|
2
|
-
.r5ui-button {
|
|
3
|
-
display: inline-block;
|
|
4
|
-
margin: .5em;
|
|
5
|
-
padding: .5em 1em;
|
|
6
|
-
border: $border_size solid $primary_border_color;
|
|
7
|
-
background-color: $primary_bg_color;
|
|
8
|
-
border-radius: $border_radius;
|
|
9
|
-
color: $primary_text_color;
|
|
10
|
-
font-weight: bold;
|
|
11
|
-
text-decoration: none;
|
|
12
|
-
text-align: center;
|
|
13
|
-
transition: color 0.3s ease;
|
|
14
|
-
cursor: pointer;
|
|
15
|
-
&:disabled {
|
|
16
|
-
background-color: $disabled_bg_color;
|
|
17
|
-
color: $disabled_text_color;
|
|
18
|
-
border-color: $disabled_border_color;
|
|
19
|
-
cursor: not-allowed;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&:not(:disabled):hover {
|
|
23
|
-
color: $primary_text_color_highlight;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&__primary {
|
|
27
|
-
background-color: $primary_bg_color;
|
|
28
|
-
color: $primary_text_color;
|
|
29
|
-
border-color: $primary_border_color;
|
|
30
|
-
}
|
|
31
|
-
&__secondary {
|
|
32
|
-
background-color: $secondary_bg_color;
|
|
33
|
-
color: $secondary_text_color;
|
|
34
|
-
border-color: $secondary_border_color;
|
|
35
|
-
}
|
|
36
|
-
&__disabled {
|
|
37
|
-
background-color: $disabled_bg_color;
|
|
38
|
-
color: $disabled_text_color;
|
|
39
|
-
border-color: $disabled_border_color;
|
|
40
|
-
cursor: not-allowed;
|
|
41
|
-
}
|
|
42
|
-
&__link {
|
|
43
|
-
background: none;
|
|
44
|
-
border: none;
|
|
45
|
-
padding: 0;
|
|
46
|
-
color: $link_color;
|
|
47
|
-
font: inherit;
|
|
48
|
-
cursor: pointer;
|
|
49
|
-
//text-decoration: underline;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
//@import "../../styles/colors.scss";
|
|
2
|
+
.r5ui-button {
|
|
3
|
+
display: inline-block;
|
|
4
|
+
margin: .5em;
|
|
5
|
+
padding: .5em 1em;
|
|
6
|
+
border: $border_size solid $primary_border_color;
|
|
7
|
+
background-color: $primary_bg_color;
|
|
8
|
+
border-radius: $border_radius;
|
|
9
|
+
color: $primary_text_color;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
text-decoration: none;
|
|
12
|
+
text-align: center;
|
|
13
|
+
transition: color 0.3s ease;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
&:disabled {
|
|
16
|
+
background-color: $disabled_bg_color;
|
|
17
|
+
color: $disabled_text_color;
|
|
18
|
+
border-color: $disabled_border_color;
|
|
19
|
+
cursor: not-allowed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&:not(:disabled):hover {
|
|
23
|
+
color: $primary_text_color_highlight;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__primary {
|
|
27
|
+
background-color: $primary_bg_color;
|
|
28
|
+
color: $primary_text_color;
|
|
29
|
+
border-color: $primary_border_color;
|
|
30
|
+
}
|
|
31
|
+
&__secondary {
|
|
32
|
+
background-color: $secondary_bg_color;
|
|
33
|
+
color: $secondary_text_color;
|
|
34
|
+
border-color: $secondary_border_color;
|
|
35
|
+
}
|
|
36
|
+
&__disabled {
|
|
37
|
+
background-color: $disabled_bg_color;
|
|
38
|
+
color: $disabled_text_color;
|
|
39
|
+
border-color: $disabled_border_color;
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
}
|
|
42
|
+
&__link {
|
|
43
|
+
background: none;
|
|
44
|
+
border: none;
|
|
45
|
+
padding: 0;
|
|
46
|
+
color: $link_color;
|
|
47
|
+
font: inherit;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
//text-decoration: underline;
|
|
50
|
+
color: $link_color_highlight;
|
|
51
|
+
text-decoration: underline;
|
|
52
|
+
}
|
|
53
|
+
&__disabled {
|
|
54
|
+
color: $disabled_text_color;
|
|
55
|
+
cursor: not-allowed;
|
|
56
|
+
&:hover {
|
|
57
|
+
color: $disabled_text_color;
|
|
58
|
+
text-decoration: none;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
63
61
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import Colors from '../../stories/assets/github.svg';
|
|
3
|
-
import { Button } from './Button';
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Button> = {
|
|
6
|
-
title: 'Example/Button',
|
|
7
|
-
component: Button,
|
|
8
|
-
argTypes: {
|
|
9
|
-
backgroundColor: { control: 'color' },
|
|
10
|
-
},
|
|
11
|
-
} as Meta;
|
|
12
|
-
export default meta;
|
|
13
|
-
|
|
14
|
-
type Story = StoryObj<typeof Button>;
|
|
15
|
-
|
|
16
|
-
export const TextButton: Story = {
|
|
17
|
-
render: () => <Button>Test</Button>,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const IconButton: Story = {
|
|
21
|
-
render: () => (
|
|
22
|
-
<Button>
|
|
23
|
-
<Colors />
|
|
24
|
-
</Button>
|
|
25
|
-
),
|
|
26
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Colors from '../../stories/assets/github.svg';
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
6
|
+
title: 'Example/Button',
|
|
7
|
+
component: Button,
|
|
8
|
+
argTypes: {
|
|
9
|
+
backgroundColor: { control: 'color' },
|
|
10
|
+
},
|
|
11
|
+
} as Meta;
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof Button>;
|
|
15
|
+
|
|
16
|
+
export const TextButton: Story = {
|
|
17
|
+
render: () => <Button>Test</Button>,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const IconButton: Story = {
|
|
21
|
+
render: () => (
|
|
22
|
+
<Button>
|
|
23
|
+
<Colors />
|
|
24
|
+
</Button>
|
|
25
|
+
),
|
|
26
|
+
};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { FormEvent, ReactNode, FC, MouseEvent } from 'react';
|
|
2
|
-
import { Link } from 'react-router';
|
|
3
|
-
import './Button.scss';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
import { bem } from '../../utils/bem';
|
|
6
|
-
|
|
7
|
-
interface ButtonProps {
|
|
8
|
-
to?: string;
|
|
9
|
-
onClick?: (e?: FormEvent<HTMLButtonElement>) => void;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
className?: string;
|
|
12
|
-
variant?: 'primary' | 'secondary' | 'link';
|
|
13
|
-
type?: 'submit' | 'reset' | 'button';
|
|
14
|
-
children: ReactNode;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const b = bem('button');
|
|
18
|
-
export const Button: FC<ButtonProps> = ({ className, variant = "primary", type = "button", to, onClick, disabled, children }) => {
|
|
19
|
-
const c = clsx(b(), b(variant), b(type), disabled && b('disabled'), className);
|
|
20
|
-
const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
21
|
-
if(onClick) {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
onClick(e);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if(to) {
|
|
27
|
-
return (
|
|
28
|
-
<Link className={c} to={disabled ? '#' : to} aria-disabled={disabled}>
|
|
29
|
-
{children}
|
|
30
|
-
</Link>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
return (
|
|
34
|
-
<button className={c} onClick={handleClick} disabled={disabled} type={type}>
|
|
35
|
-
{children}
|
|
36
|
-
</button>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default Button;
|
|
1
|
+
import { FormEvent, ReactNode, FC, MouseEvent } from 'react';
|
|
2
|
+
import { Link } from 'react-router';
|
|
3
|
+
import './Button.scss';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { bem } from '../../utils/bem';
|
|
6
|
+
|
|
7
|
+
interface ButtonProps {
|
|
8
|
+
to?: string;
|
|
9
|
+
onClick?: (e?: FormEvent<HTMLButtonElement>) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
variant?: 'primary' | 'secondary' | 'link';
|
|
13
|
+
type?: 'submit' | 'reset' | 'button';
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const b = bem('button');
|
|
18
|
+
export const Button: FC<ButtonProps> = ({ className, variant = "primary", type = "button", to, onClick, disabled, children }) => {
|
|
19
|
+
const c = clsx(b(), b(variant), b(type), disabled && b('disabled'), className);
|
|
20
|
+
const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
21
|
+
if(onClick) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
onClick(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if(to) {
|
|
27
|
+
return (
|
|
28
|
+
<Link className={c} to={disabled ? '#' : to} aria-disabled={disabled}>
|
|
29
|
+
{children}
|
|
30
|
+
</Link>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return (
|
|
34
|
+
<button className={c} onClick={handleClick} disabled={disabled} type={type}>
|
|
35
|
+
{children}
|
|
36
|
+
</button>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Button";
|
|
1
|
+
export * from "./Button";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.r5ui-buttons-group {
|
|
2
|
-
display: flex;
|
|
3
|
-
gap: 0.5em;
|
|
1
|
+
.r5ui-buttons-group {
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: 0.5em;
|
|
4
4
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { ButtonsGroup } from './ButtonsGroup';
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof ButtonsGroup> = {
|
|
5
|
-
title: 'Example/ButtonsGroup',
|
|
6
|
-
component: ButtonsGroup,
|
|
7
|
-
argTypes: {
|
|
8
|
-
backgroundColor: { control: 'color' },
|
|
9
|
-
},
|
|
10
|
-
} as Meta;
|
|
11
|
-
export default meta;
|
|
12
|
-
|
|
13
|
-
type Story = StoryObj<typeof ButtonsGroup>;
|
|
14
|
-
|
|
15
|
-
export const TextButtonsGroup: Story = {
|
|
16
|
-
render: () => <ButtonsGroup>Test</ButtonsGroup>,
|
|
17
|
-
};
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { ButtonsGroup } from './ButtonsGroup';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ButtonsGroup> = {
|
|
5
|
+
title: 'Example/ButtonsGroup',
|
|
6
|
+
component: ButtonsGroup,
|
|
7
|
+
argTypes: {
|
|
8
|
+
backgroundColor: { control: 'color' },
|
|
9
|
+
},
|
|
10
|
+
} as Meta;
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof ButtonsGroup>;
|
|
14
|
+
|
|
15
|
+
export const TextButtonsGroup: Story = {
|
|
16
|
+
render: () => <ButtonsGroup>Test</ButtonsGroup>,
|
|
17
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { ButtonsGroup } from './ButtonsGroup';
|
|
5
|
-
|
|
6
|
-
describe('ButtonsGroup Component', () => {
|
|
7
|
-
test('renders the button with the correct label', () => {
|
|
8
|
-
render(<ButtonsGroup>test</ButtonsGroup>);
|
|
9
|
-
const div = screen.getByRole('ButtonsGroup', { name: /click me/i });
|
|
10
|
-
expect(div).toBeInTheDocument();
|
|
11
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { ButtonsGroup } from './ButtonsGroup';
|
|
5
|
+
|
|
6
|
+
describe('ButtonsGroup Component', () => {
|
|
7
|
+
test('renders the button with the correct label', () => {
|
|
8
|
+
render(<ButtonsGroup>test</ButtonsGroup>);
|
|
9
|
+
const div = screen.getByRole('ButtonsGroup', { name: /click me/i });
|
|
10
|
+
expect(div).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
12
|
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import './ButtonsGroup.scss'
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { bem } from '../../utils/bem';
|
|
5
|
-
|
|
6
|
-
interface ButtonsGroupProps {
|
|
7
|
-
className?: string;
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
const b = bem("buttons-group");
|
|
11
|
-
export const ButtonsGroup = ({children, className}: ButtonsGroupProps) => {
|
|
12
|
-
return (
|
|
13
|
-
<div className={clsx(b(), className)}>
|
|
14
|
-
{children}
|
|
15
|
-
</div>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import './ButtonsGroup.scss'
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { bem } from '../../utils/bem';
|
|
5
|
+
|
|
6
|
+
interface ButtonsGroupProps {
|
|
7
|
+
className?: string;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
const b = bem("buttons-group");
|
|
11
|
+
export const ButtonsGroup = ({children, className}: ButtonsGroupProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className={clsx(b(), className)}>
|
|
14
|
+
{children}
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
18
|
export default ButtonsGroup
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./ButtonsGroup";
|
|
1
|
+
export * from "./ButtonsGroup";
|