@grantbii/design-system 1.0.46 → 1.0.48
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/core/atoms/RadioButton.js +1 -1
- package/core/atoms/Textarea.d.ts +4 -0
- package/core/atoms/Textarea.js +31 -0
- package/core/atoms/index.d.ts +1 -0
- package/core/atoms/index.js +1 -0
- package/core/molecules/RadioButtons.js +1 -1
- package/core/organisms/YesNoOptions.d.ts +9 -0
- package/core/organisms/YesNoOptions.js +10 -0
- package/core/organisms/index.d.ts +1 -0
- package/core/organisms/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -1
- package/stories/atoms/Textarea.stories.d.ts +7 -0
- package/stories/atoms/Textarea.stories.js +16 -0
- package/stories/molecules/RadioButtons.stories.js +15 -16
- package/stories/organisms/YesNoOptions.stories.d.ts +7 -0
- package/stories/organisms/YesNoOptions.stories.js +21 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import styled from "styled-components";
|
|
14
14
|
const RadioButton = (_a) => {
|
|
15
15
|
var { label, id } = _a, radioButtonProps = __rest(_a, ["label", "id"]);
|
|
16
|
-
return (_jsxs(BaseRadioButton, { children: [_jsx("input", Object.assign({}, radioButtonProps, { id: id
|
|
16
|
+
return (_jsxs(BaseRadioButton, { children: [_jsx("input", Object.assign({}, radioButtonProps, { id: `${id}-radio-button`, type: "radio" })), _jsx("label", { htmlFor: `${id}-radio-button`, children: label })] }));
|
|
17
17
|
};
|
|
18
18
|
export default RadioButton;
|
|
19
19
|
const BaseRadioButton = styled.div `
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const Textarea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, {
|
|
2
|
+
$heightPixels?: number;
|
|
3
|
+
}>> & string;
|
|
4
|
+
export default Textarea;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { Colors } from "../foundations";
|
|
3
|
+
const Textarea = styled.textarea `
|
|
4
|
+
height: ${({ $heightPixels = 100 }) => $heightPixels}px;
|
|
5
|
+
padding: 12px 16px;
|
|
6
|
+
border-radius: 6px;
|
|
7
|
+
|
|
8
|
+
&:disabled {
|
|
9
|
+
background-color: ${Colors.neutral.grey4};
|
|
10
|
+
border: 1px solid ${Colors.neutral.grey3};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&:valid {
|
|
14
|
+
border: 1px solid ${Colors.neutral.grey3};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:invalid {
|
|
18
|
+
border: 1px solid ${Colors.accent.red1};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:focus&:valid {
|
|
22
|
+
border: 1px solid ${Colors.accent.blue1};
|
|
23
|
+
outline: 1px solid ${Colors.accent.blue1};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:focus&:invalid {
|
|
27
|
+
border: 1px solid ${Colors.accent.red1};
|
|
28
|
+
outline: 1px solid ${Colors.accent.red1};
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
export default Textarea;
|
package/core/atoms/index.d.ts
CHANGED
package/core/atoms/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { RadioButton } from "../atoms";
|
|
|
16
16
|
const RadioButtons = ({ name, options }) => {
|
|
17
17
|
return (_jsx(RadioGroup, { children: options.map((_a) => {
|
|
18
18
|
var { value } = _a, props = __rest(_a, ["value"]);
|
|
19
|
-
return (_createElement(RadioButton, Object.assign({}, props, { key: `${value}
|
|
19
|
+
return (_createElement(RadioButton, Object.assign({}, props, { key: `${name}-${value}`, id: `${name}-${value}`, value: value, name: name })));
|
|
20
20
|
}) }));
|
|
21
21
|
};
|
|
22
22
|
export default RadioButtons;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DetailedHTMLProps, InputHTMLAttributes } from "react";
|
|
2
|
+
type YesNoOptionsProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
yesProps: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
5
|
+
noProps: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
|
+
unsureProps?: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
7
|
+
};
|
|
8
|
+
declare const YesNoOptions: ({ name, yesProps, noProps, unsureProps, }: YesNoOptionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default YesNoOptions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { RadioButton } from "../atoms";
|
|
4
|
+
import { LogicOption } from "@grantbii/ui-base/enums";
|
|
5
|
+
const YesNoOptions = ({ name, yesProps, noProps, unsureProps, }) => (_jsxs(RadioGroup, { children: [_jsx(RadioButton, Object.assign({}, yesProps, { id: `${name}-yes`, label: LogicOption.YES, value: LogicOption.YES, name: name })), _jsx(RadioButton, Object.assign({}, noProps, { id: `${name}-no`, label: LogicOption.NO, value: LogicOption.NO, name: name })), unsureProps ? (_jsx(RadioButton, Object.assign({}, unsureProps, { id: `${name}-unsure`, label: LogicOption.UNSURE, value: LogicOption.UNSURE, name: name }))) : (_jsx(_Fragment, {}))] }));
|
|
6
|
+
export default YesNoOptions;
|
|
7
|
+
const RadioGroup = styled.div `
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: 12px;
|
|
10
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as YesNoOptions } from "./YesNoOptions";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as YesNoOptions } from "./YesNoOptions";
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grantbii/design-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
4
4
|
"description": "Grantbii's Design System",
|
|
5
5
|
"homepage": "https://design.grantbii.com",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"build-storybook": "storybook build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@grantbii/ui-base": "1.0.13",
|
|
21
22
|
"@phosphor-icons/react": "^2.1.10",
|
|
22
23
|
"country-flag-icons": "^1.5.19",
|
|
23
24
|
"next": "^15.3.5",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Textarea } from "@/.";
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
+
declare const meta: Meta<typeof Textarea>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const BasicExample: Story;
|
|
7
|
+
export declare const WithValidation: Story;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Textarea } from "@/.";
|
|
2
|
+
const meta = {
|
|
3
|
+
title: "Atoms/Textarea",
|
|
4
|
+
component: Textarea,
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: "centered",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const BasicExample = {
|
|
12
|
+
args: { placeholder: "Type here" },
|
|
13
|
+
};
|
|
14
|
+
export const WithValidation = {
|
|
15
|
+
args: { placeholder: "Must be at least 10 characters long", minLength: 10 },
|
|
16
|
+
};
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RadioButtons } from "@/.";
|
|
3
|
+
import { Location } from "@grantbii/ui-base/enums";
|
|
3
4
|
import { useState } from "react";
|
|
4
|
-
const SINGAPORE = "Singapore";
|
|
5
|
-
const HONG_KONG = "Hong Kong";
|
|
6
5
|
const RadioButtonsExample = ({ controlled }) => {
|
|
7
6
|
const [location, setLocation] = useState("");
|
|
8
7
|
const controlledProps = {
|
|
9
8
|
options: [
|
|
10
9
|
{
|
|
11
|
-
label: SINGAPORE,
|
|
12
|
-
value: SINGAPORE,
|
|
13
|
-
checked: location === SINGAPORE,
|
|
14
|
-
onClick: () => setLocation(SINGAPORE),
|
|
10
|
+
label: Location.SINGAPORE,
|
|
11
|
+
value: Location.SINGAPORE,
|
|
12
|
+
checked: location === Location.SINGAPORE,
|
|
13
|
+
onClick: () => setLocation(Location.SINGAPORE),
|
|
15
14
|
},
|
|
16
15
|
{
|
|
17
|
-
label: HONG_KONG,
|
|
18
|
-
value: HONG_KONG,
|
|
19
|
-
checked: location === HONG_KONG,
|
|
20
|
-
onClick: () => setLocation(HONG_KONG),
|
|
16
|
+
label: Location.HONG_KONG,
|
|
17
|
+
value: Location.HONG_KONG,
|
|
18
|
+
checked: location === Location.HONG_KONG,
|
|
19
|
+
onClick: () => setLocation(Location.HONG_KONG),
|
|
21
20
|
},
|
|
22
21
|
],
|
|
23
22
|
};
|
|
@@ -27,14 +26,14 @@ const uncontrolledProps = {
|
|
|
27
26
|
name: "location",
|
|
28
27
|
options: [
|
|
29
28
|
{
|
|
30
|
-
label: SINGAPORE,
|
|
31
|
-
value: SINGAPORE,
|
|
32
|
-
onChange: () => alert(`Selected ${SINGAPORE}!`),
|
|
29
|
+
label: Location.SINGAPORE,
|
|
30
|
+
value: Location.SINGAPORE,
|
|
31
|
+
onChange: () => alert(`Selected ${Location.SINGAPORE}!`),
|
|
33
32
|
},
|
|
34
33
|
{
|
|
35
|
-
label: HONG_KONG,
|
|
36
|
-
value: HONG_KONG,
|
|
37
|
-
onChange: () => alert(`Selected ${HONG_KONG}!`),
|
|
34
|
+
label: Location.HONG_KONG,
|
|
35
|
+
value: Location.HONG_KONG,
|
|
36
|
+
onChange: () => alert(`Selected ${Location.HONG_KONG}!`),
|
|
38
37
|
},
|
|
39
38
|
],
|
|
40
39
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { YesNoOptions } from "@/.";
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
+
declare const meta: Meta<typeof YesNoOptions>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const YesOrNo: Story;
|
|
7
|
+
export declare const YesOrNoOrUnsure: Story;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { YesNoOptions } from "@/.";
|
|
2
|
+
const meta = {
|
|
3
|
+
title: "Organisms/Yes-No Options",
|
|
4
|
+
component: YesNoOptions,
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: "centered",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
const baseArgs = {
|
|
12
|
+
name: "question",
|
|
13
|
+
yesProps: {},
|
|
14
|
+
noProps: {},
|
|
15
|
+
};
|
|
16
|
+
export const YesOrNo = {
|
|
17
|
+
args: baseArgs,
|
|
18
|
+
};
|
|
19
|
+
export const YesOrNoOrUnsure = {
|
|
20
|
+
args: Object.assign(Object.assign({}, baseArgs), { unsureProps: {} }),
|
|
21
|
+
};
|