@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.
@@ -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;
@@ -1,8 +1,4 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import styled from "styled-components";
3
- import { ButtonStyle } from "./shared";
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
- `;
@@ -7,6 +7,7 @@ type LinkButtonProps = {
7
7
  target?: HTMLAttributeAnchorTarget;
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
  };
@@ -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 styled from "styled-components";
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(BaseLinkButton, { "$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, {})] }));
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, {})] }));
@@ -1,4 +1,5 @@
1
- export declare const ButtonStyle: import("styled-components").RuleSet<{
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;
@@ -1,6 +1,6 @@
1
- import { css } from "styled-components";
1
+ import styled from "styled-components";
2
2
  import { Colors } from "../foundations";
3
- export const ButtonStyle = css `
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: string;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@grantbii/design-system",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "Grantbii's Design System",
5
5
  "homepage": "https://design.grantbii.com",
6
6
  "repository": {
@@ -7,3 +7,4 @@ export declare const TextOnly: Story;
7
7
  export declare const LeftIcon: Story;
8
8
  export declare const RightIcon: Story;
9
9
  export declare const BothIcons: Story;
10
+ export declare const Underline: Story;
@@ -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
+ };
@@ -7,3 +7,4 @@ export declare const TextOnly: Story;
7
7
  export declare const LeftIcon: Story;
8
8
  export declare const RightIcon: Story;
9
9
  export declare const BothIcons: Story;
10
+ export declare const Underline: Story;
@@ -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
- declare const meta: Meta<typeof RadioButtons>;
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 NoneSelectedByDefault: Story;
7
- export declare const OneSelectedByDefault: Story;
9
+ export declare const Uncontrolled: Story;
10
+ export declare const Controlled: Story;
@@ -1,45 +1,59 @@
1
- import { RadioButtons } from "@/core/molecules";
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: RadioButtons,
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 NoneSelectedByDefault = {
50
+ export const Uncontrolled = {
12
51
  args: {
13
- name: "location ",
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 OneSelectedByDefault = {
55
+ export const Controlled = {
29
56
  args: {
30
- name: "location ",
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
  };