@grantbii/design-system 1.5.0 → 1.7.0
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/Badge.js +12 -3
- package/core/atoms/Badge.js.map +1 -1
- package/core/atoms/Checkbox.d.ts +3 -2
- package/core/atoms/Checkbox.js +2 -1
- package/core/atoms/Checkbox.js.map +1 -1
- package/core/atoms/LinkButton.d.ts +3 -3
- package/core/atoms/LinkButton.js +3 -3
- package/core/atoms/LinkButton.js.map +1 -1
- package/core/molecules/Badges.js +11 -4
- package/core/molecules/Badges.js.map +1 -1
- package/package.json +1 -1
- package/stories/atoms/Checkbox.stories.js +6 -3
- package/stories/atoms/Checkbox.stories.js.map +1 -1
- package/stories/atoms/LinkButton.stories.js +1 -1
- package/stories/atoms/LinkButton.stories.js.map +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/core/atoms/Badge.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import { Colors, Icons, Responsive, Typography } from "../foundations";
|
|
4
|
-
const Badge = ({ label, Icon, iconSize = 20, iconWeight = "regular", onClickClose, labelWidthPixels, backgroundColor, color, }) => (_jsxs(BaseBadge, { "$backgroundColor": backgroundColor, "$color": color, children: [_jsxs(BadgeContent, { "$isCloseable": !!onClickClose, "$widthPixels": labelWidthPixels, children: [Icon ? (_jsx(IconContainer, { children: _jsx(Icon, { color: color, size: iconSize, weight: iconWeight }) })) : (_jsx(_Fragment, {})), _jsx(BadgeLabel, { children: label })] }), onClickClose ?
|
|
4
|
+
const Badge = ({ label, Icon, iconSize = 20, iconWeight = "regular", onClickClose, labelWidthPixels, backgroundColor, color, }) => (_jsxs(BaseBadge, { "$backgroundColor": backgroundColor, "$color": color, children: [_jsxs(BadgeContent, { "$isCloseable": !!onClickClose, "$widthPixels": labelWidthPixels, children: [Icon ? (_jsx(IconContainer, { children: _jsx(Icon, { color: color, size: iconSize, weight: iconWeight }) })) : (_jsx(_Fragment, {})), _jsx(BadgeLabel, { children: label })] }), onClickClose ? _jsx(CloseButton, { onClick: onClickClose }) : _jsx(_Fragment, {})] }));
|
|
5
5
|
export default Badge;
|
|
6
6
|
const BaseBadge = styled.div `
|
|
7
7
|
display: flex;
|
|
@@ -9,11 +9,19 @@ const BaseBadge = styled.div `
|
|
|
9
9
|
justify-content: space-between;
|
|
10
10
|
gap: 10px;
|
|
11
11
|
|
|
12
|
-
padding: 5px
|
|
12
|
+
padding: 5px 15px;
|
|
13
13
|
border-radius: 120px;
|
|
14
14
|
|
|
15
15
|
color: ${({ $color = Colors.typography.blackHigh }) => $color};
|
|
16
16
|
background-color: ${({ $backgroundColor = Colors.neutral.grey3 }) => $backgroundColor};
|
|
17
|
+
|
|
18
|
+
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
19
|
+
min-height: 27px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
23
|
+
min-height: 30px;
|
|
24
|
+
}
|
|
17
25
|
`;
|
|
18
26
|
const BadgeContent = styled.div `
|
|
19
27
|
display: flex;
|
|
@@ -46,7 +54,8 @@ const BadgeLabel = styled.div `
|
|
|
46
54
|
font-size: ${Typography.HELPER_FONT_SIZES.big};
|
|
47
55
|
}
|
|
48
56
|
`;
|
|
49
|
-
const
|
|
57
|
+
const CloseButton = ({ onClick }) => (_jsx(BaseCloseButton, { type: "button", onClick: onClick, children: _jsx(Icons.XIcon, { size: 12 }) }));
|
|
58
|
+
const BaseCloseButton = styled.button `
|
|
50
59
|
display: flex;
|
|
51
60
|
flex-direction: column;
|
|
52
61
|
|
package/core/atoms/Badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../core/atoms/Badge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AU,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;oBAOT,UAAU,CAAC,iBAAiB,CAAC,MAAM;iBACtC,UAAU,CAAC,iBAAiB,CAAC,KAAK;;;qBAG9B,UAAU,CAAC,iBAAiB,CAAC,MAAM;iBACvC,UAAU,CAAC,iBAAiB,CAAC,GAAG;;CAEhD,CAAC;AAMF,MAAM,WAAW,GAAG,CAAC,EAAE,OAAO,EAAoB,EAAE,EAAE,CAAC,CACrD,KAAC,eAAe,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,OAAO,YAC7C,KAAC,KAAK,CAAC,KAAK,IAAC,IAAI,EAAE,EAAE,GAAI,GACT,CACnB,CAAC;AAEF,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;CAKpC,CAAC","sourcesContent":["import type { ComponentType, MouseEventHandler, ReactNode } from \"react\";\nimport styled from \"styled-components\";\nimport { Colors, Icons, Responsive, Typography } from \"../foundations\";\n\nexport type BadgeProps = {\n label: ReactNode;\n Icon?: ComponentType<Icons.IconProps>;\n iconSize?: string | number;\n iconWeight?: Icons.IconWeight;\n onClickClose?: MouseEventHandler<HTMLButtonElement>;\n labelWidthPixels?: number;\n backgroundColor?: string;\n color?: string;\n};\n\nconst Badge = ({\n label,\n Icon,\n iconSize = 20,\n iconWeight = \"regular\",\n onClickClose,\n labelWidthPixels,\n backgroundColor,\n color,\n}: BadgeProps) => (\n <BaseBadge $backgroundColor={backgroundColor} $color={color}>\n <BadgeContent $isCloseable={!!onClickClose} $widthPixels={labelWidthPixels}>\n {Icon ? (\n <IconContainer>\n <Icon color={color} size={iconSize} weight={iconWeight} />\n </IconContainer>\n ) : (\n <></>\n )}\n\n <BadgeLabel>{label}</BadgeLabel>\n </BadgeContent>\n\n {onClickClose ? <CloseButton onClick={onClickClose} /> : <></>}\n </BaseBadge>\n);\n\nexport default Badge;\n\nconst BaseBadge = styled.div<{ $backgroundColor?: string; $color?: string }>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n\n padding: 5px 15px;\n border-radius: 120px;\n\n color: ${({ $color = Colors.typography.blackHigh }) => $color};\n background-color: ${({ $backgroundColor = Colors.neutral.grey3 }) =>\n $backgroundColor};\n\n @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n min-height: 27px;\n }\n\n @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n min-height: 30px;\n }\n`;\n\nconst BadgeContent = styled.div<{\n $isCloseable: boolean;\n $widthPixels?: number;\n}>`\n display: flex;\n align-items: center;\n gap: 10px;\n\n width: ${({ $widthPixels }) => ($widthPixels ? `${$widthPixels}px` : \"auto\")};\n max-width: ${({ $isCloseable }) =>\n $isCloseable ? \"calc(100% - 20px)\" : \"auto\"};\n`;\n\nconst IconContainer = styled.div<{ $iconSize?: string | number }>`\n display: flex;\n flex-direction: column;\n\n width: ${({ $iconSize = \"auto\" }) => $iconSize};\n min-width: ${({ $iconSize = \"auto\" }) => $iconSize};\n max-width: ${({ $iconSize = \"auto\" }) => $iconSize};\n`;\n\nconst BadgeLabel = styled.div`\n overflow-x: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\n font-weight: 500;\n\n @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n font-size: ${Typography.HELPER_FONT_SIZES.small};\n }\n\n @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n font-size: ${Typography.HELPER_FONT_SIZES.big};\n }\n`;\n\ntype CloseButtonProps = {\n onClick: MouseEventHandler<HTMLButtonElement>;\n};\n\nconst CloseButton = ({ onClick }: CloseButtonProps) => (\n <BaseCloseButton type=\"button\" onClick={onClick}>\n <Icons.XIcon size={12} />\n </BaseCloseButton>\n);\n\nconst BaseCloseButton = styled.button`\n display: flex;\n flex-direction: column;\n\n min-width: 12px;\n`;\n"]}
|
package/core/atoms/Checkbox.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { DetailedHTMLProps, InputHTMLAttributes } from "react";
|
|
1
|
+
import type { DetailedHTMLProps, InputHTMLAttributes, ReactNode } from "react";
|
|
2
2
|
type CheckboxProps = {
|
|
3
|
-
|
|
3
|
+
id: string;
|
|
4
|
+
label: ReactNode;
|
|
4
5
|
labelBefore?: boolean;
|
|
5
6
|
} & DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
7
|
declare const Checkbox: ({ id, label, labelBefore, ...checkboxProps }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
package/core/atoms/Checkbox.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { LabelledInput } from "./shared";
|
|
3
|
-
const Checkbox = ({ id, label, labelBefore = false, ...checkboxProps }) => (_jsxs(LabelledInput, { children: [labelBefore ? _jsx(
|
|
3
|
+
const Checkbox = ({ id, label, labelBefore = false, ...checkboxProps }) => (_jsxs(LabelledInput, { children: [label && labelBefore ? _jsx(CheckboxLabel, { id: id, label: label }) : _jsx(_Fragment, {}), _jsx("input", { ...checkboxProps, id: `${id}-checkbox`, type: "checkbox" }), label && !labelBefore ? _jsx(CheckboxLabel, { id: id, label: label }) : _jsx(_Fragment, {})] }));
|
|
4
4
|
export default Checkbox;
|
|
5
|
+
const CheckboxLabel = ({ id, label }) => (_jsx("label", { htmlFor: `${id}-checkbox`, children: label }));
|
|
5
6
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../core/atoms/Checkbox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../core/atoms/Checkbox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQzC,MAAM,QAAQ,GAAG,CAAC,EAChB,EAAE,EACF,KAAK,EACL,WAAW,GAAG,KAAK,EACnB,GAAG,aAAa,EACF,EAAE,EAAE,CAAC,CACnB,MAAC,aAAa,eACX,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,KAAC,aAAa,IAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC,CAAC,CAAC,mBAAK,EACvE,mBAAW,aAAa,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAC,UAAU,GAAG,EACjE,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAC,aAAa,IAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC,CAAC,CAAC,mBAAK,IAC1D,CACjB,CAAC;AAEF,eAAe,QAAQ,CAAC;AAOxB,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAsB,EAAE,EAAE,CAAC,CAC3D,gBAAO,OAAO,EAAE,GAAG,EAAE,WAAW,YAAG,KAAK,GAAS,CAClD,CAAC","sourcesContent":["import type { DetailedHTMLProps, InputHTMLAttributes, ReactNode } from \"react\";\nimport { LabelledInput } from \"./shared\";\n\ntype CheckboxProps = {\n id: string;\n label: ReactNode;\n labelBefore?: boolean;\n} & DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;\n\nconst Checkbox = ({\n id,\n label,\n labelBefore = false,\n ...checkboxProps\n}: CheckboxProps) => (\n <LabelledInput>\n {label && labelBefore ? <CheckboxLabel id={id} label={label} /> : <></>}\n <input {...checkboxProps} id={`${id}-checkbox`} type=\"checkbox\" />\n {label && !labelBefore ? <CheckboxLabel id={id} label={label} /> : <></>}\n </LabelledInput>\n);\n\nexport default Checkbox;\n\ntype CheckboxLabelProps = {\n id: string;\n label: ReactNode;\n};\n\nconst CheckboxLabel = ({ id, label }: CheckboxLabelProps) => (\n <label htmlFor={`${id}-checkbox`}>{label}</label>\n);\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AnchorHTMLAttributes, ComponentType, DetailedHTMLProps, HTMLAttributeAnchorTarget } from "react";
|
|
1
|
+
import type { AnchorHTMLAttributes, ComponentType, DetailedHTMLProps, HTMLAttributeAnchorTarget, ReactNode } from "react";
|
|
2
2
|
import { Icons } from "../foundations";
|
|
3
3
|
type LinkButtonProps = {
|
|
4
|
-
|
|
4
|
+
label: ReactNode;
|
|
5
5
|
href: string;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
target?: HTMLAttributeAnchorTarget;
|
|
@@ -15,5 +15,5 @@ type LinkButtonProps = {
|
|
|
15
15
|
/**
|
|
16
16
|
* A link that looks like a button
|
|
17
17
|
*/
|
|
18
|
-
declare const LinkButton: ({
|
|
18
|
+
declare const LinkButton: ({ label, LeftIcon, RightIcon, underline, backgroundColor, color, width, disabled, target, ...linkProps }: LinkButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
export default LinkButton;
|
package/core/atoms/LinkButton.js
CHANGED
|
@@ -5,9 +5,9 @@ import { BaseButton } from "./shared";
|
|
|
5
5
|
/**
|
|
6
6
|
* A link that looks like a button
|
|
7
7
|
*/
|
|
8
|
-
const LinkButton = ({
|
|
8
|
+
const LinkButton = ({ label, LeftIcon, RightIcon, underline, backgroundColor, color, width, disabled, target = "_blank", ...linkProps }) => {
|
|
9
9
|
const contentProps = {
|
|
10
|
-
|
|
10
|
+
label,
|
|
11
11
|
LeftIcon,
|
|
12
12
|
RightIcon,
|
|
13
13
|
underline,
|
|
@@ -18,5 +18,5 @@ const LinkButton = ({ text, LeftIcon, RightIcon, underline, backgroundColor, col
|
|
|
18
18
|
return disabled ? (_jsx(Content, { ...contentProps })) : (_jsx(Link, { ...linkProps, target: target, children: _jsx(Content, { ...contentProps }) }));
|
|
19
19
|
};
|
|
20
20
|
export default LinkButton;
|
|
21
|
-
const Content = ({
|
|
21
|
+
const Content = ({ label, LeftIcon, RightIcon, underline, backgroundColor, color, width, }) => (_jsxs(BaseButton, { "$underline": underline, "$backgroundColor": backgroundColor, "$color": color, "$width": width, children: [LeftIcon ? _jsx(LeftIcon, { color: color, size: 20 }) : _jsx(_Fragment, {}), label, RightIcon ? _jsx(RightIcon, { color: color, size: 20 }) : _jsx(_Fragment, {})] }));
|
|
22
22
|
//# sourceMappingURL=LinkButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton.js","sourceRoot":"","sources":["../../../core/atoms/LinkButton.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"LinkButton.js","sourceRoot":"","sources":["../../../core/atoms/LinkButton.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAkBtC;;GAEG;AACH,MAAM,UAAU,GAAG,CAAC,EAClB,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,eAAe,EACf,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,QAAQ,EACjB,GAAG,SAAS,EACI,EAAE,EAAE;IACpB,MAAM,YAAY,GAAG;QACnB,KAAK;QACL,QAAQ;QACR,SAAS;QACT,SAAS;QACT,eAAe;QACf,KAAK;QACL,KAAK;KACN,CAAC;IAEF,OAAO,QAAQ,CAAC,CAAC,CAAC,CAChB,KAAC,OAAO,OAAK,YAAY,GAAI,CAC9B,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,YACjC,KAAC,OAAO,OAAK,YAAY,GAAI,GACxB,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC;AAY1B,MAAM,OAAO,GAAG,CAAC,EACf,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,eAAe,EACf,KAAK,EACL,KAAK,GACQ,EAAE,EAAE,CAAC,CAClB,MAAC,UAAU,kBACG,SAAS,sBACH,eAAe,YACzB,KAAK,YACL,KAAK,aAEZ,QAAQ,CAAC,CAAC,CAAC,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,mBAAK,EACvD,KAAK,EACL,SAAS,CAAC,CAAC,CAAC,KAAC,SAAS,IAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,mBAAK,IAC/C,CACd,CAAC","sourcesContent":["import Link from \"next/link\";\nimport type {\n AnchorHTMLAttributes,\n ComponentType,\n DetailedHTMLProps,\n HTMLAttributeAnchorTarget,\n ReactNode,\n} from \"react\";\nimport { Icons } from \"../foundations\";\nimport { BaseButton } from \"./shared\";\n\ntype LinkButtonProps = {\n label: ReactNode;\n href: string;\n disabled?: boolean;\n target?: HTMLAttributeAnchorTarget;\n LeftIcon?: ComponentType<Icons.IconProps>;\n RightIcon?: ComponentType<Icons.IconProps>;\n underline?: boolean;\n backgroundColor?: string;\n color?: string;\n width?: string;\n} & DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n>;\n\n/**\n * A link that looks like a button\n */\nconst LinkButton = ({\n label,\n LeftIcon,\n RightIcon,\n underline,\n backgroundColor,\n color,\n width,\n disabled,\n target = \"_blank\",\n ...linkProps\n}: LinkButtonProps) => {\n const contentProps = {\n label,\n LeftIcon,\n RightIcon,\n underline,\n backgroundColor,\n color,\n width,\n };\n\n return disabled ? (\n <Content {...contentProps} />\n ) : (\n <Link {...linkProps} target={target}>\n <Content {...contentProps} />\n </Link>\n );\n};\n\nexport default LinkButton;\n\ntype ContentProps = {\n label: ReactNode;\n LeftIcon?: ComponentType<Icons.IconProps>;\n RightIcon?: ComponentType<Icons.IconProps>;\n underline?: boolean;\n backgroundColor?: string;\n color?: string;\n width?: string;\n};\n\nconst Content = ({\n label,\n LeftIcon,\n RightIcon,\n underline,\n backgroundColor,\n color,\n width,\n}: ContentProps) => (\n <BaseButton\n $underline={underline}\n $backgroundColor={backgroundColor}\n $color={color}\n $width={width}\n >\n {LeftIcon ? <LeftIcon color={color} size={20} /> : <></>}\n {label}\n {RightIcon ? <RightIcon color={color} size={20} /> : <></>}\n </BaseButton>\n);\n"]}
|
package/core/molecules/Badges.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import styled, { css } from "styled-components";
|
|
4
4
|
import { Badge } from "../atoms";
|
|
5
|
+
import { Responsive } from "../foundations";
|
|
5
6
|
const Badges = ({ allBadgeProps, scrollable, vertical }) => (_jsx(BaseBadges, { "$scrollable": scrollable, "$vertical": vertical, children: allBadgeProps.map((badgeProps, index) => (_createElement(Badge, { ...badgeProps, key: `badge-${index}` }))) }));
|
|
6
7
|
export default Badges;
|
|
7
8
|
const BaseBadges = styled.div `
|
|
@@ -16,22 +17,28 @@ const deriveCSS = (scrollable, vertical) => {
|
|
|
16
17
|
return ScrollableVerticalCSS;
|
|
17
18
|
}
|
|
18
19
|
else if (vertical) {
|
|
19
|
-
// vertical && unscrollable
|
|
20
20
|
return UnscrollableVerticalCSS;
|
|
21
21
|
}
|
|
22
22
|
else if (scrollable) {
|
|
23
|
-
// horizontal && scrollable
|
|
24
23
|
return ScrollableHorizontalCSS;
|
|
25
24
|
}
|
|
26
25
|
else {
|
|
27
|
-
// horizontal && unscrollable
|
|
28
26
|
return UnscrollableHorizontalCSS;
|
|
29
27
|
}
|
|
30
28
|
};
|
|
31
29
|
const ScrollableVerticalCSS = css `
|
|
32
30
|
overflow-y: auto;
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
/* show 3 badges max */
|
|
33
|
+
@media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
34
|
+
/* 3 * 27px (badge height) + 2 * 4px (gap) = 89 */
|
|
35
|
+
height: 89px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {
|
|
39
|
+
/* 3 * 30px (badge height) + 2 * 4px (gap) = 98 */
|
|
40
|
+
height: 98px;
|
|
41
|
+
}
|
|
35
42
|
`;
|
|
36
43
|
const UnscrollableVerticalCSS = css ``;
|
|
37
44
|
const ScrollableHorizontalCSS = css `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badges.js","sourceRoot":"","sources":["../../../core/molecules/Badges.tsx"],"names":[],"mappings":";;AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"Badges.js","sourceRoot":"","sources":["../../../core/molecules/Badges.tsx"],"names":[],"mappings":";;AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAgB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQ5C,MAAM,MAAM,GAAG,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAe,EAAE,EAAE,CAAC,CACvE,KAAC,UAAU,mBAAc,UAAU,eAAa,QAAQ,YACrD,aAAa,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,CACxC,eAAC,KAAK,OAAK,UAAU,EAAE,GAAG,EAAE,SAAS,KAAK,EAAE,GAAI,CACjD,CAAC,GACS,CACd,CAAC;AAEF,eAAe,MAAM,CAAC;AAEtB,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAgD;;oBAEzD,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;SACpE,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;;IAE3D,CAAC,EAAE,WAAW,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE,EAAE,CAC/C,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC;CACpC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,UAAmB,EAAE,QAAiB,EAAW,EAAE;IACpE,IAAI,QAAQ,IAAI,UAAU,EAAE,CAAC;QAC3B,OAAO,qBAAqB,CAAC;IAC/B,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,OAAO,uBAAuB,CAAC;IACjC,CAAC;SAAM,IAAI,UAAU,EAAE,CAAC;QACtB,OAAO,uBAAuB,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,OAAO,yBAAyB,CAAC;IACnC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;oBAIb,UAAU,CAAC,iBAAiB,CAAC,MAAM;;;;;qBAKlC,UAAU,CAAC,iBAAiB,CAAC,MAAM;;;;CAIvD,CAAC;AAEF,MAAM,uBAAuB,GAAG,GAAG,CAAA,EAAE,CAAC;AAEtC,MAAM,uBAAuB,GAAG,GAAG,CAAA;;;;;;;;;;CAUlC,CAAC;AAEF,MAAM,yBAAyB,GAAG,GAAG,CAAA;;;CAGpC,CAAC","sourcesContent":["import styled, { css, type RuleSet } from \"styled-components\";\nimport { Badge, type BadgeProps } from \"../atoms\";\nimport { Responsive } from \"../foundations\";\n\ntype BadgesProps = {\n allBadgeProps: BadgeProps[];\n scrollable?: boolean;\n vertical?: boolean;\n};\n\nconst Badges = ({ allBadgeProps, scrollable, vertical }: BadgesProps) => (\n <BaseBadges $scrollable={scrollable} $vertical={vertical}>\n {allBadgeProps.map((badgeProps, index) => (\n <Badge {...badgeProps} key={`badge-${index}`} />\n ))}\n </BaseBadges>\n);\n\nexport default Badges;\n\nconst BaseBadges = styled.div<{ $scrollable?: boolean; $vertical?: boolean }>`\n display: flex;\n flex-direction: ${({ $vertical = false }) => ($vertical ? \"column\" : \"row\")};\n gap: ${({ $vertical = false }) => ($vertical ? \"4px\" : \"8px\")};\n\n ${({ $scrollable = false, $vertical = false }) =>\n deriveCSS($scrollable, $vertical)}\n`;\n\nconst deriveCSS = (scrollable: boolean, vertical: boolean): RuleSet => {\n if (vertical && scrollable) {\n return ScrollableVerticalCSS;\n } else if (vertical) {\n return UnscrollableVerticalCSS;\n } else if (scrollable) {\n return ScrollableHorizontalCSS;\n } else {\n return UnscrollableHorizontalCSS;\n }\n};\n\nconst ScrollableVerticalCSS = css`\n overflow-y: auto;\n\n /* show 3 badges max */\n @media (width < ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n /* 3 * 27px (badge height) + 2 * 4px (gap) = 89 */\n height: 89px;\n }\n\n @media (width >= ${Responsive.WIDTH_BREAKPOINTS.laptop}) {\n /* 3 * 30px (badge height) + 2 * 4px (gap) = 98 */\n height: 98px;\n }\n`;\n\nconst UnscrollableVerticalCSS = css``;\n\nconst ScrollableHorizontalCSS = css`\n flex-wrap: nowrap;\n overflow-x: auto;\n\n /* hide scrollbar but still allow for scrolling */\n -ms-overflow-style: none;\n scrollbar-width: none;\n ::-webkit-scrollbar {\n display: none;\n }\n`;\n\nconst UnscrollableHorizontalCSS = css`\n flex-wrap: wrap;\n overflow-x: visible;\n`;\n"]}
|
package/package.json
CHANGED
|
@@ -8,16 +8,19 @@ const meta = {
|
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
10
|
export default meta;
|
|
11
|
-
const
|
|
11
|
+
const baseArgs = {
|
|
12
|
+
id: "best",
|
|
13
|
+
label: "Grantbii is the best",
|
|
14
|
+
};
|
|
12
15
|
export const LabelBefore = {
|
|
13
16
|
args: {
|
|
14
|
-
|
|
17
|
+
...baseArgs,
|
|
15
18
|
labelBefore: true,
|
|
16
19
|
},
|
|
17
20
|
};
|
|
18
21
|
export const LabelAfter = {
|
|
19
22
|
args: {
|
|
20
|
-
|
|
23
|
+
...baseArgs,
|
|
21
24
|
labelBefore: false,
|
|
22
25
|
},
|
|
23
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.stories.js","sourceRoot":"","sources":["../../../stories/atoms/Checkbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAG/B,MAAM,IAAI,GAA0B;IAClC,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,QAAQ;IACnB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;KACnB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,
|
|
1
|
+
{"version":3,"file":"Checkbox.stories.js","sourceRoot":"","sources":["../../../stories/atoms/Checkbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAG/B,MAAM,IAAI,GAA0B;IAClC,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,QAAQ;IACnB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;KACnB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,QAAQ,GAAG;IACf,EAAE,EAAE,MAAM;IACV,KAAK,EAAE,sBAAsB;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAU;IAChC,IAAI,EAAE;QACJ,GAAG,QAAQ;QACX,WAAW,EAAE,IAAI;KAClB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,IAAI,EAAE;QACJ,GAAG,QAAQ;QACX,WAAW,EAAE,KAAK;KACnB;CACF,CAAC","sourcesContent":["import { Checkbox } from \"@/.\";\nimport type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\n\nconst meta: Meta<typeof Checkbox> = {\n title: \"Atoms/Checkbox\",\n component: Checkbox,\n tags: [\"autodocs\"],\n parameters: {\n layout: \"centered\",\n },\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nconst baseArgs = {\n id: \"best\",\n label: \"Grantbii is the best\",\n};\n\nexport const LabelBefore: Story = {\n args: {\n ...baseArgs,\n labelBefore: true,\n },\n};\n\nexport const LabelAfter: Story = {\n args: {\n ...baseArgs,\n labelBefore: false,\n },\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkButton.stories.js","sourceRoot":"","sources":["../../../stories/atoms/LinkButton.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAGhD,MAAM,IAAI,GAA4B;IACpC,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;KACnB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,QAAQ,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"LinkButton.stories.js","sourceRoot":"","sources":["../../../stories/atoms/LinkButton.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAGhD,MAAM,IAAI,GAA4B;IACpC,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;KACnB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAU;IAC7B,IAAI,EAAE;QACJ,GAAG,QAAQ;QACX,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC;KACxC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAU;IAC7B,IAAI,EAAE;QACJ,GAAG,QAAQ;QACX,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,GAAG,QAAQ;QACX,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,GAAG,QAAQ;QACX,QAAQ,EAAE,KAAK,CAAC,eAAe;QAC/B,SAAS,EAAE,KAAK,CAAC,iBAAiB;KACnC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAU;IAC9B,IAAI,EAAE;QACJ,GAAG,QAAQ;QACX,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW;KACrC;CACF,CAAC","sourcesContent":["import { Colors, Icons, LinkButton } from \"@/.\";\nimport type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\n\nconst meta: Meta<typeof LinkButton> = {\n title: \"Atoms/Link Button\",\n component: LinkButton,\n tags: [\"autodocs\"],\n parameters: {\n layout: \"centered\",\n },\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nconst baseArgs = { label: \"Link\", href: \"https://grantbii.com\" };\n\nexport const TextOnly: Story = {\n args: {\n ...baseArgs,\n onClick: () => alert(\"clicked on link\"),\n },\n};\n\nexport const LeftIcon: Story = {\n args: {\n ...baseArgs,\n LeftIcon: Icons.PlusIcon,\n },\n};\n\nexport const RightIcon: Story = {\n args: {\n ...baseArgs,\n RightIcon: Icons.MinusIcon,\n },\n};\n\nexport const BothIcons: Story = {\n args: {\n ...baseArgs,\n LeftIcon: Icons.SmileyXEyesIcon,\n RightIcon: Icons.SmileyMeltingIcon,\n },\n};\n\nexport const Underline: Story = {\n args: {\n ...baseArgs,\n underline: true,\n color: Colors.typography.blackMedium,\n },\n};\n"]}
|