@grantbii/design-system 1.0.43 → 1.0.45
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/Button.d.ts +3 -2
- package/core/atoms/Button.js +2 -6
- package/core/atoms/LinkButton.d.ts +1 -0
- package/core/atoms/LinkButton.js +2 -6
- package/core/atoms/shared.d.ts +3 -2
- package/core/atoms/shared.js +5 -3
- package/core/molecules/RadioButtons.d.ts +1 -1
- package/package.json +1 -1
- package/stories/atoms/Button.stories.d.ts +1 -0
- package/stories/atoms/Button.stories.js +4 -1
- package/stories/atoms/LinkButton.stories.d.ts +1 -0
- package/stories/atoms/LinkButton.stories.js +4 -1
- package/stories/molecules/RadioButtons.stories.d.ts +7 -4
- package/stories/molecules/RadioButtons.stories.js +45 -31
- package/tsconfig.tsbuildinfo +1 -1
package/core/atoms/Button.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { ComponentType, MouseEventHandler } from "react";
|
|
|
2
2
|
import { Icons } from "../foundations";
|
|
3
3
|
type ButtonProps = {
|
|
4
4
|
text: string;
|
|
5
|
-
disabled?: boolean;
|
|
6
5
|
onClick: MouseEventHandler<HTMLButtonElement>;
|
|
6
|
+
disabled?: boolean;
|
|
7
7
|
type?: "button" | "submit" | "reset";
|
|
8
8
|
LeftIcon?: ComponentType<Icons.IconProps>;
|
|
9
9
|
RightIcon?: ComponentType<Icons.IconProps>;
|
|
10
|
+
underline?: boolean;
|
|
10
11
|
backgroundColor?: string;
|
|
11
12
|
color?: string;
|
|
12
13
|
};
|
|
13
|
-
declare const Button: ({ text, onClick, disabled, LeftIcon, RightIcon, backgroundColor, color, type, }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare const Button: ({ text, onClick, disabled, LeftIcon, RightIcon, underline, backgroundColor, color, type, }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export default Button;
|
package/core/atoms/Button.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const Button = ({ text, onClick, disabled, LeftIcon, RightIcon, backgroundColor, color, type = "button", }) => (_jsx("button", { type: type, onClick: onClick, disabled: disabled, children: _jsxs(BaseButton, { "$backgroundColor": backgroundColor, "$color": color, children: [LeftIcon ? _jsx(LeftIcon, { color: color, size: 20 }) : _jsx(_Fragment, {}), _jsx("p", { children: text }), RightIcon ? _jsx(RightIcon, { color: color, size: 20 }) : _jsx(_Fragment, {})] }) }));
|
|
2
|
+
import { BaseButton } from "./shared";
|
|
3
|
+
const Button = ({ text, onClick, disabled, LeftIcon, RightIcon, underline, backgroundColor, color, type = "button", }) => (_jsx("button", { type: type, onClick: onClick, disabled: disabled, children: _jsxs(BaseButton, { "$underline": underline, "$backgroundColor": backgroundColor, "$color": color, children: [LeftIcon ? _jsx(LeftIcon, { color: color, size: 20 }) : _jsx(_Fragment, {}), _jsx("p", { children: text }), RightIcon ? _jsx(RightIcon, { color: color, size: 20 }) : _jsx(_Fragment, {})] }) }));
|
|
5
4
|
export default Button;
|
|
6
|
-
const BaseButton = styled.div `
|
|
7
|
-
${ButtonStyle}
|
|
8
|
-
`;
|
package/core/atoms/LinkButton.js
CHANGED
|
@@ -11,14 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import Link from "next/link";
|
|
14
|
-
import
|
|
15
|
-
import { ButtonStyle } from "./shared";
|
|
14
|
+
import { BaseButton } from "./shared";
|
|
16
15
|
const LinkButton = (_a) => {
|
|
17
16
|
var { href, target, disabled } = _a, contentProps = __rest(_a, ["href", "target", "disabled"]);
|
|
18
17
|
return disabled ? (_jsx(Content, Object.assign({}, contentProps))) : (_jsx(Link, { href: href, target: target, children: _jsx(Content, Object.assign({}, contentProps)) }));
|
|
19
18
|
};
|
|
20
19
|
export default LinkButton;
|
|
21
|
-
const Content = ({ text, LeftIcon, RightIcon, backgroundColor, color, }) => (_jsxs(
|
|
22
|
-
const BaseLinkButton = styled.div `
|
|
23
|
-
${ButtonStyle}
|
|
24
|
-
`;
|
|
20
|
+
const Content = ({ text, LeftIcon, RightIcon, underline, backgroundColor, color, }) => (_jsxs(BaseButton, { "$underline": underline, "$backgroundColor": backgroundColor, "$color": color, children: [LeftIcon ? _jsx(LeftIcon, { color: color, size: 20 }) : _jsx(_Fragment, {}), _jsx("p", { children: text }), RightIcon ? _jsx(RightIcon, { color: color, size: 20 }) : _jsx(_Fragment, {})] }));
|
package/core/atoms/shared.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const BaseButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
2
|
+
$underline?: boolean;
|
|
2
3
|
$backgroundColor?: string;
|
|
3
4
|
$color?: string;
|
|
4
|
-
}
|
|
5
|
+
}>> & string;
|
package/core/atoms/shared.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import styled from "styled-components";
|
|
2
2
|
import { Colors } from "../foundations";
|
|
3
|
-
export const
|
|
3
|
+
export const BaseButton = styled.div `
|
|
4
4
|
display: flex;
|
|
5
5
|
justify-content: center;
|
|
6
6
|
align-items: center;
|
|
@@ -12,6 +12,8 @@ export const ButtonStyle = css `
|
|
|
12
12
|
font-weight: 500;
|
|
13
13
|
font-size: 14px;
|
|
14
14
|
|
|
15
|
+
text-decoration: ${({ $underline = false }) => $underline ? "underline" : "none"};
|
|
16
|
+
|
|
15
17
|
color: ${({ $color = Colors.typography.whiteHigh }) => $color};
|
|
16
|
-
background-color: ${({ $backgroundColor = Colors.main.grantbiiBlue }) => $backgroundColor};
|
|
18
|
+
background-color: ${({ $underline = false, $backgroundColor = Colors.main.grantbiiBlue, }) => ($underline ? "transparent" : $backgroundColor)};
|
|
17
19
|
`;
|
|
@@ -2,7 +2,7 @@ import { DetailedHTMLProps, InputHTMLAttributes } from "react";
|
|
|
2
2
|
import { Option } from "../foundations";
|
|
3
3
|
export type RadioOption = Option & DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
4
4
|
type RadioButtonProps = {
|
|
5
|
-
name
|
|
5
|
+
name?: string;
|
|
6
6
|
options: RadioOption[];
|
|
7
7
|
};
|
|
8
8
|
declare const RadioButtons: ({ name, options }: RadioButtonProps) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Icons } from "@/.";
|
|
1
|
+
import { Button, Colors, Icons } from "@/.";
|
|
2
2
|
const meta = {
|
|
3
3
|
title: "Atoms/Button",
|
|
4
4
|
component: Button,
|
|
@@ -24,3 +24,6 @@ export const RightIcon = {
|
|
|
24
24
|
export const BothIcons = {
|
|
25
25
|
args: Object.assign(Object.assign({}, baseArgs), { LeftIcon: Icons.SmileyXEyesIcon, RightIcon: Icons.SmileyMeltingIcon }),
|
|
26
26
|
};
|
|
27
|
+
export const Underline = {
|
|
28
|
+
args: Object.assign(Object.assign({}, baseArgs), { underline: true, color: Colors.typography.blackMedium }),
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Icons, LinkButton } from "@/.";
|
|
1
|
+
import { Colors, Icons, LinkButton } from "@/.";
|
|
2
2
|
const meta = {
|
|
3
3
|
title: "Atoms/LinkButton",
|
|
4
4
|
component: LinkButton,
|
|
@@ -25,3 +25,6 @@ export const RightIcon = {
|
|
|
25
25
|
export const BothIcons = {
|
|
26
26
|
args: Object.assign(Object.assign({}, baseArgs), { LeftIcon: Icons.SmileyXEyesIcon, RightIcon: Icons.SmileyMeltingIcon }),
|
|
27
27
|
};
|
|
28
|
+
export const Underline = {
|
|
29
|
+
args: Object.assign(Object.assign({}, baseArgs), { underline: true, color: Colors.typography.blackMedium }),
|
|
30
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { RadioButtons } from "@/core/molecules";
|
|
2
1
|
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
-
|
|
2
|
+
type ExampleProps = {
|
|
3
|
+
controlled: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const RadioButtonsExample: ({ controlled }: ExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const meta: Meta<typeof RadioButtonsExample>;
|
|
4
7
|
export default meta;
|
|
5
8
|
type Story = StoryObj<typeof meta>;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
9
|
+
export declare const Uncontrolled: Story;
|
|
10
|
+
export declare const Controlled: Story;
|
|
@@ -1,45 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RadioButtons } from "@/.";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
const SINGAPORE = "Singapore";
|
|
5
|
+
const HONG_KONG = "Hong Kong";
|
|
6
|
+
const RadioButtonsExample = ({ controlled }) => {
|
|
7
|
+
const [location, setLocation] = useState("");
|
|
8
|
+
const controlledProps = {
|
|
9
|
+
options: [
|
|
10
|
+
{
|
|
11
|
+
label: SINGAPORE,
|
|
12
|
+
value: SINGAPORE,
|
|
13
|
+
checked: location === SINGAPORE,
|
|
14
|
+
onClick: () => setLocation(SINGAPORE),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: HONG_KONG,
|
|
18
|
+
value: HONG_KONG,
|
|
19
|
+
checked: location === HONG_KONG,
|
|
20
|
+
onClick: () => setLocation(HONG_KONG),
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
return (_jsx(RadioButtons, Object.assign({}, (controlled ? controlledProps : uncontrolledProps))));
|
|
25
|
+
};
|
|
26
|
+
const uncontrolledProps = {
|
|
27
|
+
name: "location",
|
|
28
|
+
options: [
|
|
29
|
+
{
|
|
30
|
+
label: SINGAPORE,
|
|
31
|
+
value: SINGAPORE,
|
|
32
|
+
onChange: () => alert(`Selected ${SINGAPORE}!`),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: HONG_KONG,
|
|
36
|
+
value: HONG_KONG,
|
|
37
|
+
onChange: () => alert(`Selected ${HONG_KONG}!`),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
2
41
|
const meta = {
|
|
3
42
|
title: "Molecules/Radio Buttons",
|
|
4
|
-
component:
|
|
43
|
+
component: RadioButtonsExample,
|
|
5
44
|
tags: ["autodocs"],
|
|
6
45
|
parameters: {
|
|
7
46
|
layout: "centered",
|
|
8
47
|
},
|
|
9
48
|
};
|
|
10
49
|
export default meta;
|
|
11
|
-
export const
|
|
50
|
+
export const Uncontrolled = {
|
|
12
51
|
args: {
|
|
13
|
-
|
|
14
|
-
options: [
|
|
15
|
-
{
|
|
16
|
-
label: "Singapore",
|
|
17
|
-
value: "Singapore",
|
|
18
|
-
onChange: () => alert("Selected Singapore!"),
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
label: "Hong Kong",
|
|
22
|
-
value: "Hong Kong",
|
|
23
|
-
onChange: () => alert("Selected Hong Kong!"),
|
|
24
|
-
},
|
|
25
|
-
],
|
|
52
|
+
controlled: false,
|
|
26
53
|
},
|
|
27
54
|
};
|
|
28
|
-
export const
|
|
55
|
+
export const Controlled = {
|
|
29
56
|
args: {
|
|
30
|
-
|
|
31
|
-
options: [
|
|
32
|
-
{
|
|
33
|
-
label: "Singapore",
|
|
34
|
-
value: "Singapore",
|
|
35
|
-
onChange: () => alert("Selected Singapore!"),
|
|
36
|
-
defaultChecked: true,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
label: "Hong Kong",
|
|
40
|
-
value: "Hong Kong",
|
|
41
|
-
onChange: () => alert("Selected Hong Kong!"),
|
|
42
|
-
},
|
|
43
|
-
],
|
|
57
|
+
controlled: true,
|
|
44
58
|
},
|
|
45
59
|
};
|