@grantbii/design-system 1.22.0 → 1.23.1
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/molecules/Badge.d.ts +15 -8
- package/core/molecules/Badge.js +53 -15
- package/core/molecules/Badge.js.map +1 -1
- package/core/molecules/Button.d.ts +12 -12
- package/core/molecules/Button.js +4 -4
- package/core/molecules/Button.js.map +1 -1
- package/core/molecules/index.d.ts +1 -1
- package/core/molecules/index.js +1 -1
- package/core/molecules/index.js.map +1 -1
- package/core/organisms/FileDrop.js +1 -1
- package/core/organisms/FileDrop.js.map +1 -1
- package/core/shared.js +2 -2
- package/core/shared.js.map +1 -1
- package/core/templates/GrantMatch/ActiveQueryFiles.js +1 -1
- package/core/templates/GrantMatch/ActiveQueryFiles.js.map +1 -1
- package/package.json +1 -1
- package/stories/molecules/Badge.stories.d.ts +13 -3
- package/stories/molecules/Badge.stories.js +89 -8
- package/stories/molecules/Badge.stories.js.map +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import type { ComponentType, MouseEventHandler, ReactNode } from "react";
|
|
2
|
-
import { SystemIcon } from "../atoms";
|
|
3
|
-
|
|
2
|
+
import { Color, SystemIcon } from "../atoms";
|
|
3
|
+
type BadgeVariant = "default" | "neutral" | "blue" | "green" | "yellow" | "red";
|
|
4
|
+
type CustomBadgeProps = {
|
|
4
5
|
label: ReactNode;
|
|
5
6
|
Icon?: ComponentType<SystemIcon.IconProps>;
|
|
6
|
-
iconSize?: string | number;
|
|
7
|
-
iconWeight?: SystemIcon.IconWeight;
|
|
8
7
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
9
|
-
|
|
8
|
+
onClickX?: MouseEventHandler<HTMLButtonElement>;
|
|
10
9
|
labelWidthPixels?: number;
|
|
11
|
-
backgroundColor?: string;
|
|
12
|
-
color?: string;
|
|
13
10
|
};
|
|
14
|
-
|
|
11
|
+
type BadgeProps = {
|
|
12
|
+
variant?: BadgeVariant;
|
|
13
|
+
} & CustomBadgeProps;
|
|
14
|
+
declare const Badge: ({ variant, ...restOfProps }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
export default Badge;
|
|
16
|
+
type VariantStyleProps = {
|
|
17
|
+
color: Color.DesignColor;
|
|
18
|
+
defaultBackgroundColor: Color.DesignColor;
|
|
19
|
+
hoverBackgroundColor?: Color.DesignColor;
|
|
20
|
+
};
|
|
21
|
+
type RawBadgeProps = CustomBadgeProps & VariantStyleProps;
|
|
22
|
+
export declare const RawBadge: ({ label, Icon, onClick, onClickX, labelWidthPixels, defaultBackgroundColor, hoverBackgroundColor, color, }: RawBadgeProps) => import("react/jsx-runtime").JSX.Element;
|
package/core/molecules/Badge.js
CHANGED
|
@@ -1,30 +1,68 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from "styled-components";
|
|
3
|
-
import { Color, SystemIcon, Responsive, Typography } from "../atoms";
|
|
3
|
+
import { Color, SystemIcon, Responsive, Typography, Spacing } from "../atoms";
|
|
4
4
|
import { applyTypography } from "../integrations";
|
|
5
|
-
const Badge = ({
|
|
5
|
+
const Badge = ({ variant = "default", ...restOfProps }) => {
|
|
6
|
+
const variantProps = VARIANT_PROPS_MAP[variant];
|
|
7
|
+
return _jsx(RawBadge, { ...variantProps, ...restOfProps });
|
|
8
|
+
};
|
|
6
9
|
export default Badge;
|
|
10
|
+
const VARIANT_PROPS_MAP = {
|
|
11
|
+
default: {
|
|
12
|
+
color: Color.typography.blackHigh,
|
|
13
|
+
defaultBackgroundColor: Color.accent.blue3,
|
|
14
|
+
hoverBackgroundColor: Color.accent.blue4,
|
|
15
|
+
},
|
|
16
|
+
neutral: {
|
|
17
|
+
color: Color.typography.blackHigh,
|
|
18
|
+
defaultBackgroundColor: Color.neutral.grey4,
|
|
19
|
+
hoverBackgroundColor: Color.neutral.grey3,
|
|
20
|
+
},
|
|
21
|
+
blue: {
|
|
22
|
+
color: Color.accent.blue1,
|
|
23
|
+
defaultBackgroundColor: Color.accent.blue3,
|
|
24
|
+
hoverBackgroundColor: Color.accent.blue4,
|
|
25
|
+
},
|
|
26
|
+
green: {
|
|
27
|
+
color: Color.accent.green1,
|
|
28
|
+
defaultBackgroundColor: Color.accent.green3,
|
|
29
|
+
hoverBackgroundColor: Color.accent.green4,
|
|
30
|
+
},
|
|
31
|
+
yellow: {
|
|
32
|
+
color: Color.accent.yellow1,
|
|
33
|
+
defaultBackgroundColor: Color.accent.yellow3,
|
|
34
|
+
hoverBackgroundColor: Color.accent.yellow4,
|
|
35
|
+
},
|
|
36
|
+
red: {
|
|
37
|
+
color: Color.accent.red1,
|
|
38
|
+
defaultBackgroundColor: Color.accent.red3,
|
|
39
|
+
hoverBackgroundColor: Color.accent.red4,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const RawBadge = ({ label, Icon, onClick, onClickX, labelWidthPixels, defaultBackgroundColor, hoverBackgroundColor = defaultBackgroundColor, color, }) => (_jsxs(BaseBadge, { onClick: onClick, "$isClickable": !!onClick, "$defaultBackgroundColor": defaultBackgroundColor, "$hoverBackgroundColor": hoverBackgroundColor, "$color": color, children: [_jsxs(BadgeContent, { hasX: !!onClickX, "$widthPixels": labelWidthPixels, children: [Icon ? (_jsx(IconContainer, { children: _jsx(Icon, { color: color, size: 12 }) })) : (_jsx(_Fragment, {})), _jsx(BadgeLabel, { children: label })] }), onClickX ? _jsx(XButton, { onClick: onClickX }) : _jsx(_Fragment, {})] }));
|
|
7
43
|
const BaseBadge = styled.div `
|
|
8
44
|
display: flex;
|
|
9
45
|
align-items: center;
|
|
10
46
|
justify-content: space-between;
|
|
11
47
|
gap: 10px;
|
|
12
48
|
|
|
13
|
-
|
|
14
|
-
|
|
49
|
+
height: 26px;
|
|
50
|
+
padding: 5px ${Spacing.px12};
|
|
51
|
+
border-radius: 100px;
|
|
15
52
|
|
|
16
|
-
|
|
17
|
-
|
|
53
|
+
font-size: 12px;
|
|
54
|
+
font-weight: ${Typography.weight.medium};
|
|
18
55
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
56
|
+
color: ${(props) => props.$color};
|
|
57
|
+
background-color: ${(props) => props.$defaultBackgroundColor};
|
|
22
58
|
|
|
23
|
-
|
|
24
|
-
min-height: 30px;
|
|
25
|
-
}
|
|
59
|
+
cursor: ${(props) => (props.$isClickable ? "pointer" : "auto")};
|
|
26
60
|
|
|
27
|
-
|
|
61
|
+
&:hover {
|
|
62
|
+
background-color: ${(props) => props.$isClickable
|
|
63
|
+
? props.$hoverBackgroundColor
|
|
64
|
+
: props.$defaultBackgroundColor};
|
|
65
|
+
}
|
|
28
66
|
`;
|
|
29
67
|
const BadgeContent = styled.div `
|
|
30
68
|
display: flex;
|
|
@@ -32,7 +70,7 @@ const BadgeContent = styled.div `
|
|
|
32
70
|
gap: 10px;
|
|
33
71
|
|
|
34
72
|
width: ${({ $widthPixels }) => ($widthPixels ? `${$widthPixels}px` : "auto")};
|
|
35
|
-
max-width: ${({ $closeable }) =>
|
|
73
|
+
max-width: ${({ hasX: $closeable }) => $closeable ? "calc(100% - 20px)" : "auto"};
|
|
36
74
|
`;
|
|
37
75
|
const IconContainer = styled.div `
|
|
38
76
|
display: flex;
|
|
@@ -49,7 +87,7 @@ const BadgeLabel = styled.div `
|
|
|
49
87
|
|
|
50
88
|
${applyTypography(Typography.bodySecondaryMedium)}
|
|
51
89
|
`;
|
|
52
|
-
const
|
|
90
|
+
const XButton = ({ onClick }) => (_jsx(BaseCloseButton, { type: "button", onClick: onClick, children: _jsx(SystemIcon.XIcon, { color: Color.typography.blackMedium, size: 12 }) }));
|
|
53
91
|
const BaseCloseButton = styled.button `
|
|
54
92
|
display: flex;
|
|
55
93
|
flex-direction: column;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../core/molecules/Badge.tsx"],"names":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e,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,OAAO,YAC7C,KAAC,UAAU,CAAC,KAAK,IAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,GAAI,GACnD,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 { Color, SystemIcon, Responsive, Typography, Spacing } from \"../atoms\";\nimport { applyTypography } from \"../integrations\";\n\ntype BadgeVariant = \"default\" | \"neutral\" | \"blue\" | \"green\" | \"yellow\" | \"red\";\n\ntype CustomBadgeProps = {\n label: ReactNode;\n Icon?: ComponentType<SystemIcon.IconProps>;\n onClick?: MouseEventHandler<HTMLDivElement>;\n onClickX?: MouseEventHandler<HTMLButtonElement>;\n labelWidthPixels?: number;\n};\n\ntype BadgeProps = {\n variant?: BadgeVariant;\n} & CustomBadgeProps;\n\nconst Badge = ({ variant = \"default\", ...restOfProps }: BadgeProps) => {\n const variantProps = VARIANT_PROPS_MAP[variant];\n return <RawBadge {...variantProps} {...restOfProps} />;\n};\n\nexport default Badge;\n\ntype VariantStyleProps = {\n color: Color.DesignColor;\n defaultBackgroundColor: Color.DesignColor;\n hoverBackgroundColor?: Color.DesignColor;\n};\n\nconst VARIANT_PROPS_MAP: { [variant in BadgeVariant]: VariantStyleProps } = {\n default: {\n color: Color.typography.blackHigh,\n defaultBackgroundColor: Color.accent.blue3,\n hoverBackgroundColor: Color.accent.blue4,\n },\n neutral: {\n color: Color.typography.blackHigh,\n defaultBackgroundColor: Color.neutral.grey4,\n hoverBackgroundColor: Color.neutral.grey3,\n },\n blue: {\n color: Color.accent.blue1,\n defaultBackgroundColor: Color.accent.blue3,\n hoverBackgroundColor: Color.accent.blue4,\n },\n green: {\n color: Color.accent.green1,\n defaultBackgroundColor: Color.accent.green3,\n hoverBackgroundColor: Color.accent.green4,\n },\n yellow: {\n color: Color.accent.yellow1,\n defaultBackgroundColor: Color.accent.yellow3,\n hoverBackgroundColor: Color.accent.yellow4,\n },\n red: {\n color: Color.accent.red1,\n defaultBackgroundColor: Color.accent.red3,\n hoverBackgroundColor: Color.accent.red4,\n },\n};\n\ntype RawBadgeProps = CustomBadgeProps & VariantStyleProps;\n\nexport const RawBadge = ({\n label,\n Icon,\n onClick,\n onClickX,\n labelWidthPixels,\n defaultBackgroundColor,\n hoverBackgroundColor = defaultBackgroundColor,\n color,\n}: RawBadgeProps) => (\n <BaseBadge\n onClick={onClick}\n $isClickable={!!onClick}\n $defaultBackgroundColor={defaultBackgroundColor}\n $hoverBackgroundColor={hoverBackgroundColor}\n $color={color}\n >\n <BadgeContent hasX={!!onClickX} $widthPixels={labelWidthPixels}>\n {Icon ? (\n <IconContainer>\n <Icon color={color} size={12} />\n </IconContainer>\n ) : (\n <></>\n )}\n\n <BadgeLabel>{label}</BadgeLabel>\n </BadgeContent>\n\n {onClickX ? <XButton onClick={onClickX} /> : <></>}\n </BaseBadge>\n);\n\nconst BaseBadge = styled.div<{\n $isClickable: boolean;\n $defaultBackgroundColor: Color.DesignColor;\n $hoverBackgroundColor: Color.DesignColor;\n $color: Color.DesignColor;\n}>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n\n height: 26px;\n padding: 5px ${Spacing.px12};\n border-radius: 100px;\n\n font-size: 12px;\n font-weight: ${Typography.weight.medium};\n\n color: ${(props) => props.$color};\n background-color: ${(props) => props.$defaultBackgroundColor};\n\n cursor: ${(props) => (props.$isClickable ? \"pointer\" : \"auto\")};\n\n &:hover {\n background-color: ${(props) =>\n props.$isClickable\n ? props.$hoverBackgroundColor\n : props.$defaultBackgroundColor};\n }\n`;\n\nconst BadgeContent = styled.div<{\n hasX: 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: ${({ hasX: $closeable }) =>\n $closeable ? \"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 ${applyTypography(Typography.bodySecondaryMedium)}\n`;\n\ntype XButtonProps = {\n onClick: MouseEventHandler<HTMLButtonElement>;\n};\n\nconst XButton = ({ onClick }: XButtonProps) => (\n <BaseCloseButton type=\"button\" onClick={onClick}>\n <SystemIcon.XIcon color={Color.typography.blackMedium} size={12} />\n </BaseCloseButton>\n);\n\nconst BaseCloseButton = styled.button`\n display: flex;\n flex-direction: column;\n\n min-width: 12px;\n`;\n"]}
|
|
@@ -2,6 +2,16 @@ import type { ButtonHTMLAttributes, HTMLAttributeAnchorTarget, MouseEventHandler
|
|
|
2
2
|
import { Color, SystemIcon } from "../atoms";
|
|
3
3
|
type ButtonVariant = "primary" | "secondary" | "tertiary" | "outline" | "ghost" | "text" | "danger";
|
|
4
4
|
type ButtonSize = "small" | "medium" | "large";
|
|
5
|
+
type CustomButtonProps = {
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
Icon?: SystemIcon.Icon;
|
|
8
|
+
iconRight?: boolean;
|
|
9
|
+
onClick?: MouseEventHandler<HTMLElement>;
|
|
10
|
+
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
target?: HTMLAttributeAnchorTarget;
|
|
13
|
+
href?: string;
|
|
14
|
+
};
|
|
5
15
|
type ButtonProps = {
|
|
6
16
|
variant?: ButtonVariant;
|
|
7
17
|
size?: ButtonSize;
|
|
@@ -19,20 +29,10 @@ type VariantStyleProps = {
|
|
|
19
29
|
textDecoration?: string;
|
|
20
30
|
};
|
|
21
31
|
type SizeStyleProps = {
|
|
22
|
-
actionIconSize: string;
|
|
23
32
|
height: string;
|
|
24
33
|
padding: string;
|
|
25
34
|
fontSize: string;
|
|
26
|
-
|
|
27
|
-
type CustomButtonProps = {
|
|
28
|
-
label?: ReactNode;
|
|
29
|
-
Icon?: SystemIcon.Icon;
|
|
30
|
-
iconRight?: boolean;
|
|
31
|
-
onClick?: MouseEventHandler<HTMLElement>;
|
|
32
|
-
type?: ButtonHTMLAttributes<HTMLButtonElement>["type"];
|
|
33
|
-
disabled?: boolean;
|
|
34
|
-
target?: HTMLAttributeAnchorTarget;
|
|
35
|
-
href?: string;
|
|
35
|
+
actionIconSize?: string;
|
|
36
36
|
};
|
|
37
37
|
type RawButtonProps = CustomButtonProps & VariantStyleProps & SizeStyleProps;
|
|
38
|
-
export declare const RawButton: ({ Icon, iconRight, label, href, target, disabled, type,
|
|
38
|
+
export declare const RawButton: ({ Icon, iconRight, label, href, target, disabled, type, height, padding, fontSize, actionIconSize, textDecoration, defaultColor, hoverColor, disabledColor, defaultBackgroundColor, hoverBackgroundColor, disabledBackgroundColor, borderColor, ...restOfProps }: RawButtonProps) => import("react/jsx-runtime").JSX.Element;
|
package/core/molecules/Button.js
CHANGED
|
@@ -62,25 +62,25 @@ const VARIANT_PROPS_MAP = {
|
|
|
62
62
|
};
|
|
63
63
|
const SIZE_PROPS_MAP = {
|
|
64
64
|
small: {
|
|
65
|
-
actionIconSize: "40px",
|
|
66
65
|
height: "40px",
|
|
67
66
|
padding: "10px", // not following spacing scale
|
|
68
67
|
fontSize: "14px",
|
|
68
|
+
actionIconSize: "40px",
|
|
69
69
|
},
|
|
70
70
|
medium: {
|
|
71
|
-
actionIconSize: "44px",
|
|
72
71
|
height: "46px",
|
|
73
72
|
padding: "12px", // not following spacing scale
|
|
74
73
|
fontSize: "16px",
|
|
74
|
+
actionIconSize: "44px",
|
|
75
75
|
},
|
|
76
76
|
large: {
|
|
77
|
-
actionIconSize: "48px",
|
|
78
77
|
height: "52px",
|
|
79
78
|
padding: "14px", // not following spacing scale
|
|
80
79
|
fontSize: "18px",
|
|
80
|
+
actionIconSize: "48px",
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
|
-
export const RawButton = ({ Icon, iconRight = false, label, href, target, disabled, type,
|
|
83
|
+
export const RawButton = ({ Icon, iconRight = false, label, href, target, disabled, type, height, padding, fontSize, actionIconSize = height, textDecoration = "none", defaultColor, hoverColor = defaultColor, disabledColor = defaultColor, defaultBackgroundColor, hoverBackgroundColor = defaultBackgroundColor, disabledBackgroundColor = defaultBackgroundColor, borderColor, ...restOfProps }) => {
|
|
84
84
|
const isActionIcon = !!Icon && !label;
|
|
85
85
|
const styleProps = {
|
|
86
86
|
$isActionIcon: isActionIcon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../core/molecules/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAkBlE,MAAM,MAAM,GAAG,CAAC,EACd,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,QAAQ,EACf,GAAG,WAAW,EACF,EAAE,EAAE;IAChB,MAAM,YAAY,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEvC,OAAO,KAAC,SAAS,OAAK,YAAY,KAAM,SAAS,KAAM,WAAW,GAAI,CAAC;AACzE,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC;AAatB,MAAM,iBAAiB,GAAsD;IAC3E,OAAO,EAAE;QACP,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS;QAC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C9C,WAAW;CACd,CAAC","sourcesContent":["import Link from \"next/link\";\nimport type {\n ButtonHTMLAttributes,\n HTMLAttributeAnchorTarget,\n MouseEventHandler,\n ReactNode,\n} from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { Color, Spacing, SystemIcon, Typography } from \"../atoms\";\n\ntype ButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"tertiary\"\n | \"outline\"\n | \"ghost\"\n | \"text\"\n | \"danger\";\n\ntype ButtonSize = \"small\" | \"medium\" | \"large\";\n\ntype ButtonProps = {\n variant?: ButtonVariant;\n size?: ButtonSize;\n} & CustomButtonProps;\n\nconst Button = ({\n variant = \"primary\",\n size = \"medium\",\n ...restOfProps\n}: ButtonProps) => {\n const variantProps = VARIANT_PROPS_MAP[variant];\n const sizeProps = SIZE_PROPS_MAP[size];\n\n return <RawButton {...variantProps} {...sizeProps} {...restOfProps} />;\n};\n\nexport default Button;\n\ntype VariantStyleProps = {\n defaultColor: Color.DesignColor;\n hoverColor?: Color.DesignColor;\n disabledColor?: Color.DesignColor;\n defaultBackgroundColor: Color.DesignColor;\n hoverBackgroundColor?: Color.DesignColor;\n disabledBackgroundColor?: Color.DesignColor;\n borderColor?: Color.DesignColor;\n textDecoration?: string;\n};\n\nconst VARIANT_PROPS_MAP: { [variant in ButtonVariant]: VariantStyleProps } = {\n primary: {\n defaultColor: Color.typography.whiteHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.brand.grantbiiBlue,\n hoverBackgroundColor: Color.accent.blue2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n secondary: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.brand.grantbiiYellow,\n hoverBackgroundColor: Color.accent.yellow2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n tertiary: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.neutral.grey3,\n hoverBackgroundColor: Color.accent.blue3,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n outline: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: \"transparent\",\n hoverBackgroundColor: Color.accent.blue3,\n borderColor: Color.neutral.grey2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n ghost: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: \"transparent\",\n hoverBackgroundColor: Color.accent.blue3,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n text: {\n defaultColor: Color.typography.blackHigh,\n hoverColor: Color.typography.blackMedium,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: \"transparent\",\n textDecoration: \"underline\",\n },\n danger: {\n defaultColor: Color.typography.whiteHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.accent.red1,\n hoverBackgroundColor: Color.accent.red2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n};\n\ntype SizeStyleProps = {\n actionIconSize: string;\n height: string;\n padding: string;\n fontSize: string;\n};\n\nconst SIZE_PROPS_MAP: { [size in ButtonSize]: SizeStyleProps } = {\n small: {\n actionIconSize: \"40px\",\n height: \"40px\",\n padding: \"10px\", // not following spacing scale\n fontSize: \"14px\",\n },\n medium: {\n actionIconSize: \"44px\",\n height: \"46px\",\n padding: \"12px\", // not following spacing scale\n fontSize: \"16px\",\n },\n large: {\n actionIconSize: \"48px\",\n height: \"52px\",\n padding: \"14px\", // not following spacing scale\n fontSize: \"18px\",\n },\n};\n\ntype CustomButtonProps = {\n label?: ReactNode;\n Icon?: SystemIcon.Icon;\n iconRight?: boolean;\n onClick?: MouseEventHandler<HTMLElement>;\n type?: ButtonHTMLAttributes<HTMLButtonElement>[\"type\"];\n disabled?: boolean;\n target?: HTMLAttributeAnchorTarget;\n href?: string;\n};\n\ntype RawButtonProps = CustomButtonProps & VariantStyleProps & SizeStyleProps;\n\nexport const RawButton = ({\n Icon,\n iconRight = false,\n label,\n href,\n target,\n disabled,\n type,\n actionIconSize,\n height,\n padding,\n fontSize,\n textDecoration = \"none\",\n defaultColor,\n hoverColor = defaultColor,\n disabledColor = defaultColor,\n defaultBackgroundColor,\n hoverBackgroundColor = defaultBackgroundColor,\n disabledBackgroundColor = defaultBackgroundColor,\n borderColor,\n ...restOfProps\n}: RawButtonProps) => {\n const isActionIcon = !!Icon && !label;\n\n const styleProps: ButtonStyleProps = {\n $isActionIcon: isActionIcon,\n $actionIconSize: actionIconSize,\n $height: height,\n $fontSize: fontSize,\n $padding: padding,\n $textDecoration: textDecoration,\n $defaultColor: defaultColor,\n $hoverColor: hoverColor,\n $disabledColor: disabledColor,\n $defaultBackgroundColor: defaultBackgroundColor,\n $hoverBackgroundColor: hoverBackgroundColor,\n $disabledBackgroundColor: disabledBackgroundColor,\n $borderColor: borderColor,\n };\n\n const content = (\n <>\n {Icon && !iconRight && <Icon size={20} />}\n {label}\n {Icon && iconRight && <Icon size={20} />}\n </>\n );\n\n const isLink = !!href && !disabled;\n\n return isLink ? (\n <BaseLink {...restOfProps} {...styleProps} href={href} target={target}>\n {content}\n </BaseLink>\n ) : (\n <BaseButton\n {...restOfProps}\n {...styleProps}\n disabled={disabled}\n type={type}\n >\n {content}\n </BaseButton>\n );\n};\n\ntype ButtonStyleProps = {\n $isActionIcon: boolean;\n $actionIconSize: string;\n $height: string;\n $padding: string;\n $fontSize: string;\n $textDecoration: string;\n $defaultColor: Color.DesignColor;\n $hoverColor: Color.DesignColor;\n $disabledColor: Color.DesignColor;\n $defaultBackgroundColor: Color.DesignColor;\n $hoverBackgroundColor: Color.DesignColor;\n $disabledBackgroundColor: Color.DesignColor;\n $borderColor?: Color.DesignColor;\n};\n\nconst ButtonStyle = css<ButtonStyleProps>`\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n gap: ${Spacing.px8};\n\n box-sizing: border-box;\n width: ${(props) => (props.$isActionIcon ? props.$actionIconSize : \"auto\")};\n height: ${(props) =>\n props.$isActionIcon ? props.$actionIconSize : props.$height};\n padding: ${(props) =>\n props.$isActionIcon ? props.$padding : `${props.$padding} ${Spacing.px16}`};\n\n font-weight: ${Typography.weight.medium};\n font-size: ${(props) => props.$fontSize};\n white-space: nowrap;\n\n color: ${(props) => props.$defaultColor};\n background-color: ${(props) => props.$defaultBackgroundColor};\n\n border: ${(props) =>\n props.$borderColor ? `1px solid ${props.$borderColor}` : \"none\"};\n border-radius: ${Spacing.px8};\n\n text-decoration: ${(props) => props.$textDecoration};\n\n &:hover {\n color: ${(props) => props.$hoverColor};\n background-color: ${(props) => props.$hoverBackgroundColor};\n }\n\n &:disabled {\n color: ${(props) => props.$disabledColor};\n background-color: ${(props) => props.$disabledBackgroundColor};\n }\n`;\n\nconst BaseLink = styled(Link)<ButtonStyleProps>`\n ${ButtonStyle}\n`;\n\nconst BaseButton = styled.button<ButtonStyleProps>`\n ${ButtonStyle}\n`;\n"]}
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../core/molecules/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA6BlE,MAAM,MAAM,GAAG,CAAC,EACd,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,QAAQ,EACf,GAAG,WAAW,EACF,EAAE,EAAE;IAChB,MAAM,YAAY,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEvC,OAAO,KAAC,SAAS,OAAK,YAAY,KAAM,SAAS,KAAM,WAAW,GAAI,CAAC;AACzE,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC;AAatB,MAAM,iBAAiB,GAAsD;IAC3E,OAAO,EAAE;QACP,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CAAC;AAEF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAkB;IAC9C,WAAW;CACd,CAAC","sourcesContent":["import Link from \"next/link\";\nimport type {\n ButtonHTMLAttributes,\n HTMLAttributeAnchorTarget,\n MouseEventHandler,\n ReactNode,\n} from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { Color, Spacing, SystemIcon, Typography } from \"../atoms\";\n\ntype ButtonVariant =\n | \"primary\"\n | \"secondary\"\n | \"tertiary\"\n | \"outline\"\n | \"ghost\"\n | \"text\"\n | \"danger\";\n\ntype ButtonSize = \"small\" | \"medium\" | \"large\";\n\ntype CustomButtonProps = {\n label?: ReactNode;\n Icon?: SystemIcon.Icon;\n iconRight?: boolean;\n onClick?: MouseEventHandler<HTMLElement>;\n type?: ButtonHTMLAttributes<HTMLButtonElement>[\"type\"];\n disabled?: boolean;\n target?: HTMLAttributeAnchorTarget;\n href?: string;\n};\n\ntype ButtonProps = {\n variant?: ButtonVariant;\n size?: ButtonSize;\n} & CustomButtonProps;\n\nconst Button = ({\n variant = \"primary\",\n size = \"medium\",\n ...restOfProps\n}: ButtonProps) => {\n const variantProps = VARIANT_PROPS_MAP[variant];\n const sizeProps = SIZE_PROPS_MAP[size];\n\n return <RawButton {...variantProps} {...sizeProps} {...restOfProps} />;\n};\n\nexport default Button;\n\ntype VariantStyleProps = {\n defaultColor: Color.DesignColor;\n hoverColor?: Color.DesignColor;\n disabledColor?: Color.DesignColor;\n defaultBackgroundColor: Color.DesignColor;\n hoverBackgroundColor?: Color.DesignColor;\n disabledBackgroundColor?: Color.DesignColor;\n borderColor?: Color.DesignColor;\n textDecoration?: string;\n};\n\nconst VARIANT_PROPS_MAP: { [variant in ButtonVariant]: VariantStyleProps } = {\n primary: {\n defaultColor: Color.typography.whiteHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.brand.grantbiiBlue,\n hoverBackgroundColor: Color.accent.blue2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n secondary: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.brand.grantbiiYellow,\n hoverBackgroundColor: Color.accent.yellow2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n tertiary: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.neutral.grey3,\n hoverBackgroundColor: Color.accent.blue3,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n outline: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: \"transparent\",\n hoverBackgroundColor: Color.accent.blue3,\n borderColor: Color.neutral.grey2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n ghost: {\n defaultColor: Color.typography.blackHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: \"transparent\",\n hoverBackgroundColor: Color.accent.blue3,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n text: {\n defaultColor: Color.typography.blackHigh,\n hoverColor: Color.typography.blackMedium,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: \"transparent\",\n textDecoration: \"underline\",\n },\n danger: {\n defaultColor: Color.typography.whiteHigh,\n disabledColor: Color.typography.blackLow,\n defaultBackgroundColor: Color.accent.red1,\n hoverBackgroundColor: Color.accent.red2,\n disabledBackgroundColor: Color.neutral.grey3,\n },\n};\n\ntype SizeStyleProps = {\n height: string;\n padding: string;\n fontSize: string;\n actionIconSize?: string;\n};\n\nconst SIZE_PROPS_MAP: { [size in ButtonSize]: SizeStyleProps } = {\n small: {\n height: \"40px\",\n padding: \"10px\", // not following spacing scale\n fontSize: \"14px\",\n actionIconSize: \"40px\",\n },\n medium: {\n height: \"46px\",\n padding: \"12px\", // not following spacing scale\n fontSize: \"16px\",\n actionIconSize: \"44px\",\n },\n large: {\n height: \"52px\",\n padding: \"14px\", // not following spacing scale\n fontSize: \"18px\",\n actionIconSize: \"48px\",\n },\n};\n\ntype RawButtonProps = CustomButtonProps & VariantStyleProps & SizeStyleProps;\n\nexport const RawButton = ({\n Icon,\n iconRight = false,\n label,\n href,\n target,\n disabled,\n type,\n height,\n padding,\n fontSize,\n actionIconSize = height,\n textDecoration = \"none\",\n defaultColor,\n hoverColor = defaultColor,\n disabledColor = defaultColor,\n defaultBackgroundColor,\n hoverBackgroundColor = defaultBackgroundColor,\n disabledBackgroundColor = defaultBackgroundColor,\n borderColor,\n ...restOfProps\n}: RawButtonProps) => {\n const isActionIcon = !!Icon && !label;\n\n const styleProps: ButtonStyleProps = {\n $isActionIcon: isActionIcon,\n $actionIconSize: actionIconSize,\n $height: height,\n $fontSize: fontSize,\n $padding: padding,\n $textDecoration: textDecoration,\n $defaultColor: defaultColor,\n $hoverColor: hoverColor,\n $disabledColor: disabledColor,\n $defaultBackgroundColor: defaultBackgroundColor,\n $hoverBackgroundColor: hoverBackgroundColor,\n $disabledBackgroundColor: disabledBackgroundColor,\n $borderColor: borderColor,\n };\n\n const content = (\n <>\n {Icon && !iconRight && <Icon size={20} />}\n {label}\n {Icon && iconRight && <Icon size={20} />}\n </>\n );\n\n const isLink = !!href && !disabled;\n\n return isLink ? (\n <BaseLink {...restOfProps} {...styleProps} href={href} target={target}>\n {content}\n </BaseLink>\n ) : (\n <BaseButton\n {...restOfProps}\n {...styleProps}\n disabled={disabled}\n type={type}\n >\n {content}\n </BaseButton>\n );\n};\n\ntype ButtonStyleProps = {\n $isActionIcon: boolean;\n $actionIconSize: string;\n $height: string;\n $padding: string;\n $fontSize: string;\n $textDecoration: string;\n $defaultColor: Color.DesignColor;\n $hoverColor: Color.DesignColor;\n $disabledColor: Color.DesignColor;\n $defaultBackgroundColor: Color.DesignColor;\n $hoverBackgroundColor: Color.DesignColor;\n $disabledBackgroundColor: Color.DesignColor;\n $borderColor?: Color.DesignColor;\n};\n\nconst ButtonStyle = css<ButtonStyleProps>`\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n gap: ${Spacing.px8};\n\n box-sizing: border-box;\n width: ${(props) => (props.$isActionIcon ? props.$actionIconSize : \"auto\")};\n height: ${(props) =>\n props.$isActionIcon ? props.$actionIconSize : props.$height};\n padding: ${(props) =>\n props.$isActionIcon ? props.$padding : `${props.$padding} ${Spacing.px16}`};\n\n font-weight: ${Typography.weight.medium};\n font-size: ${(props) => props.$fontSize};\n white-space: nowrap;\n\n color: ${(props) => props.$defaultColor};\n background-color: ${(props) => props.$defaultBackgroundColor};\n\n border: ${(props) =>\n props.$borderColor ? `1px solid ${props.$borderColor}` : \"none\"};\n border-radius: ${Spacing.px8};\n\n text-decoration: ${(props) => props.$textDecoration};\n\n &:hover {\n color: ${(props) => props.$hoverColor};\n background-color: ${(props) => props.$hoverBackgroundColor};\n }\n\n &:disabled {\n color: ${(props) => props.$disabledColor};\n background-color: ${(props) => props.$disabledBackgroundColor};\n }\n`;\n\nconst BaseLink = styled(Link)<ButtonStyleProps>`\n ${ButtonStyle}\n`;\n\nconst BaseButton = styled.button<ButtonStyleProps>`\n ${ButtonStyle}\n`;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as Badge,
|
|
1
|
+
export { default as Badge, RawBadge } from "./Badge";
|
|
2
2
|
export { default as Button, RawButton } from "./Button";
|
|
3
3
|
export { default as Checkbox } from "./Checkbox";
|
|
4
4
|
export { default as Input } from "./Input";
|
package/core/molecules/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/molecules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/molecules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { default as Badge, RawBadge } from \"./Badge\";\nexport { default as Button, RawButton } from \"./Button\";\nexport { default as Checkbox } from \"./Checkbox\";\nexport { default as Input } from \"./Input\";\nexport { default as Overlay } from \"./Overlay\";\nexport { default as PageLoader } from \"./PageLoader\";\nexport { default as RadioButton } from \"./RadioButton\";\nexport { default as Textarea } from \"./Textarea\";\n"]}
|
|
@@ -68,7 +68,7 @@ const DropzoneSubtitle = styled.p `
|
|
|
68
68
|
const ErrorMessage = styled.p `
|
|
69
69
|
color: ${Color.accent.red1};
|
|
70
70
|
`;
|
|
71
|
-
const UploadedFiles = ({ uploadedFiles, removeFile }) => (_jsx(BaseUploadedFiles, { children: uploadedFiles.map(({ name: fileName, type: fileType }) => (_jsx(Badge, { label: getFileNameWithoutExtension(fileName),
|
|
71
|
+
const UploadedFiles = ({ uploadedFiles, removeFile }) => (_jsx(BaseUploadedFiles, { children: uploadedFiles.map(({ name: fileName, type: fileType }) => (_jsx(Badge, { label: getFileNameWithoutExtension(fileName), onClickX: () => removeFile(fileName), Icon: FILE_TYPE_ICON_MAP[fileType] ?? SystemIcon.FileIcon, variant: "neutral" }, fileName))) }));
|
|
72
72
|
const BaseUploadedFiles = styled.div `
|
|
73
73
|
display: flex;
|
|
74
74
|
flex-direction: column;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDrop.js","sourceRoot":"","sources":["../../../core/organisms/FileDrop.tsx"],"names":[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gB,EACR,EAAE;IACV,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAClC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAC7C,CAAC;IAEF,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAU,EAAE,CACpE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AAEjD,MAAM,2BAA2B,GAAG,CAAC,QAAgB,EAAU,EAAE,CAC/D,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { useDropzone } from \"react-dropzone\";\nimport styled from \"styled-components\";\nimport { Color, Spacing, SystemIcon, Typography } from \"../atoms\";\nimport { applyTypography } from \"../integrations\";\nimport { FILE_TYPE_ICON_MAP } from \"../shared\";\nimport { Badge } from \"../molecules\";\n\nconst DEFAULT_MAX_FILE_SIZE_MB = 5;\nconst DEFAULT_MAX_FILES = 5;\n\ntype FileDropzoneProps = {\n uploadedFiles: File[];\n uploadFiles: (acceptedFiles: File[]) => void;\n removeFile: (fileName: string) => void;\n errorMessage?: string;\n maxFiles?: number;\n maxSizeMB?: number;\n};\n\nconst FileDrop = ({\n uploadedFiles,\n uploadFiles,\n removeFile,\n errorMessage,\n maxFiles = DEFAULT_MAX_FILES,\n maxSizeMB = DEFAULT_MAX_FILE_SIZE_MB,\n}: FileDropzoneProps) => {\n const reachedMaxUploads = uploadedFiles.length >= maxFiles;\n\n const { getInputProps, getRootProps } = useDropzone({\n onDrop: uploadFiles,\n accept: {\n \"application/pdf\": [\".pdf\"],\n \"image/jpeg\": [\".jpeg\", \".jpg\"],\n \"image/png\": [\".png\"],\n },\n disabled: reachedMaxUploads,\n noClick: reachedMaxUploads,\n noDrag: reachedMaxUploads,\n multiple: true,\n });\n\n return (\n <BaseFileDrop>\n <Dropzone\n {...getRootProps()}\n $reachedMaxUploads={reachedMaxUploads}\n $hasError={!!errorMessage}\n >\n <input {...getInputProps()} type=\"file\" />\n <DropzoneContent maxFiles={maxFiles} maxSizeMB={maxSizeMB} />\n </Dropzone>\n\n {errorMessage ? <ErrorMessage>{errorMessage}</ErrorMessage> : <></>}\n\n <UploadedFiles uploadedFiles={uploadedFiles} removeFile={removeFile} />\n </BaseFileDrop>\n );\n};\n\nexport default FileDrop;\n\nconst BaseFileDrop = styled.div`\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 6px;\n`;\n\nconst Dropzone = styled.div<{\n $reachedMaxUploads: boolean;\n $hasError: boolean;\n}>`\n padding: 40px;\n border-radius: 8px;\n border: 1px solid\n ${({ $hasError }) => ($hasError ? Color.accent.red1 : Color.neutral.grey3)};\n\n &:hover {\n cursor: ${({ $reachedMaxUploads }) =>\n $reachedMaxUploads ? \"not-allowed\" : \"pointer\"};\n }\n`;\n\ntype DropzoneContentProps = {\n maxFiles: number;\n maxSizeMB: number;\n};\n\nconst DropzoneContent = ({ maxFiles, maxSizeMB }: DropzoneContentProps) => (\n <BaseDropzoneContent>\n <SystemIcon.FileDashedIcon\n weight=\"thin\"\n size={48}\n color={Color.neutral.grey1}\n />\n <AllDropzoneText>\n <DropzoneText>\n {`Drop up to ${maxFiles} files here (up to ${maxSizeMB}MB each)`}\n </DropzoneText>\n\n <DropzoneSubtitle $isHighlighted>\n or click to browse with your file explorer\n </DropzoneSubtitle>\n\n <DropzoneSubtitle>Accepted file formats: pdf, png, jpg</DropzoneSubtitle>\n </AllDropzoneText>\n </BaseDropzoneContent>\n);\n\nconst BaseDropzoneContent = styled.div`\n display: flex;\n flex-direction: column;\n gap: 24px;\n align-items: center;\n`;\n\nconst AllDropzoneText = styled.div`\n display: flex;\n flex-direction: column;\n gap: 4px;\n`;\n\nconst DropzoneText = styled.p`\n text-align: center;\n\n ${applyTypography(Typography.bodyPrimaryMedium)}\n`;\n\nconst DropzoneSubtitle = styled.p<{ $isHighlighted?: boolean }>`\n text-align: center;\n\n color: ${({ $isHighlighted = false }) =>\n $isHighlighted ? Color.accent.yellow1 : Color.typography.blackLow};\n\n ${applyTypography(Typography.bodySecondaryRegular)}\n`;\n\nconst ErrorMessage = styled.p`\n color: ${Color.accent.red1};\n`;\n\ntype UploadedFilesProps = {\n uploadedFiles: File[];\n removeFile: (fileName: string) => void;\n};\n\nconst UploadedFiles = ({ uploadedFiles, removeFile }: UploadedFilesProps) => (\n <BaseUploadedFiles>\n {uploadedFiles.map(({ name: fileName, type: fileType }) => (\n <Badge\n key={fileName}\n label={getFileNameWithoutExtension(fileName)}\n onClickClose={() => removeFile(fileName)}\n Icon={FILE_TYPE_ICON_MAP[fileType] ?? SystemIcon.FileIcon}\n />\n ))}\n </BaseUploadedFiles>\n);\n\nconst BaseUploadedFiles = styled.div`\n display: flex;\n flex-direction: column;\n gap: ${Spacing.px4};\n`;\n\nexport const useFileDrop = (\n initialFiles: File[] = [],\n maxFiles: number = DEFAULT_MAX_FILES,\n maxSizeMB: number = DEFAULT_MAX_FILE_SIZE_MB,\n) => {\n const [files, setFiles] = useState<File[]>(() => initialFiles);\n const [errorMessage, setErrorMessage] = useState<string | undefined>();\n\n const uploadFiles = (acceptedFiles: File[]) => {\n if (files.length + acceptedFiles.length > maxFiles) {\n setErrorMessage(() => `Maximum upload limit is ${maxFiles} files`);\n } else if (anyFileTooLarge(acceptedFiles, maxSizeMB)) {\n setErrorMessage(() => `Maximum file size is ${maxSizeMB}MB`);\n } else {\n setErrorMessage(() => undefined);\n setFiles((previousFiles) =>\n combineFilesWithoutDuplicates(previousFiles, acceptedFiles),\n );\n }\n };\n\n const removeFile = (fileName: string) => {\n setErrorMessage(() => undefined);\n setFiles((previousFiles) => filterFilesByName(previousFiles, fileName));\n };\n\n return {\n files,\n uploadFiles,\n removeFile,\n errorMessage,\n };\n};\n\nconst anyFileTooLarge = (files: File[], maxSizeMB: number): boolean =>\n files.some((file) => file.size > convertMegabytesToBytes(maxSizeMB));\n\nconst convertMegabytesToBytes = (megabytes: number): number =>\n megabytes * 1024 * 1024;\n\nconst combineFilesWithoutDuplicates = (\n oldFiles: File[],\n newFiles: File[],\n): File[] => {\n const newFileNames = new Set(newFiles.map((file) => file.name));\n const keptOldFiles = oldFiles.filter(\n (oldFile) => !newFileNames.has(oldFile.name),\n );\n\n return [...keptOldFiles, ...newFiles];\n};\n\nconst filterFilesByName = (files: File[], fileName: string): File[] =>\n files.filter((file) => file.name !== fileName);\n\nconst getFileNameWithoutExtension = (fileName: string): string =>\n fileName.substring(0, fileName.lastIndexOf(\".\"));\n"]}
|
|
1
|
+
{"version":3,"file":"FileDrop.js","sourceRoot":"","sources":["../../../core/organisms/FileDrop.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAW5B,MAAM,QAAQ,GAAG,CAAC,EAChB,aAAa,EACb,WAAW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E,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AAEjD,MAAM,2BAA2B,GAAG,CAAC,QAAgB,EAAU,EAAE,CAC/D,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { useDropzone } from \"react-dropzone\";\nimport styled from \"styled-components\";\nimport { Color, Spacing, SystemIcon, Typography } from \"../atoms\";\nimport { applyTypography } from \"../integrations\";\nimport { FILE_TYPE_ICON_MAP } from \"../shared\";\nimport { Badge } from \"../molecules\";\n\nconst DEFAULT_MAX_FILE_SIZE_MB = 5;\nconst DEFAULT_MAX_FILES = 5;\n\ntype FileDropzoneProps = {\n uploadedFiles: File[];\n uploadFiles: (acceptedFiles: File[]) => void;\n removeFile: (fileName: string) => void;\n errorMessage?: string;\n maxFiles?: number;\n maxSizeMB?: number;\n};\n\nconst FileDrop = ({\n uploadedFiles,\n uploadFiles,\n removeFile,\n errorMessage,\n maxFiles = DEFAULT_MAX_FILES,\n maxSizeMB = DEFAULT_MAX_FILE_SIZE_MB,\n}: FileDropzoneProps) => {\n const reachedMaxUploads = uploadedFiles.length >= maxFiles;\n\n const { getInputProps, getRootProps } = useDropzone({\n onDrop: uploadFiles,\n accept: {\n \"application/pdf\": [\".pdf\"],\n \"image/jpeg\": [\".jpeg\", \".jpg\"],\n \"image/png\": [\".png\"],\n },\n disabled: reachedMaxUploads,\n noClick: reachedMaxUploads,\n noDrag: reachedMaxUploads,\n multiple: true,\n });\n\n return (\n <BaseFileDrop>\n <Dropzone\n {...getRootProps()}\n $reachedMaxUploads={reachedMaxUploads}\n $hasError={!!errorMessage}\n >\n <input {...getInputProps()} type=\"file\" />\n <DropzoneContent maxFiles={maxFiles} maxSizeMB={maxSizeMB} />\n </Dropzone>\n\n {errorMessage ? <ErrorMessage>{errorMessage}</ErrorMessage> : <></>}\n\n <UploadedFiles uploadedFiles={uploadedFiles} removeFile={removeFile} />\n </BaseFileDrop>\n );\n};\n\nexport default FileDrop;\n\nconst BaseFileDrop = styled.div`\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 6px;\n`;\n\nconst Dropzone = styled.div<{\n $reachedMaxUploads: boolean;\n $hasError: boolean;\n}>`\n padding: 40px;\n border-radius: 8px;\n border: 1px solid\n ${({ $hasError }) => ($hasError ? Color.accent.red1 : Color.neutral.grey3)};\n\n &:hover {\n cursor: ${({ $reachedMaxUploads }) =>\n $reachedMaxUploads ? \"not-allowed\" : \"pointer\"};\n }\n`;\n\ntype DropzoneContentProps = {\n maxFiles: number;\n maxSizeMB: number;\n};\n\nconst DropzoneContent = ({ maxFiles, maxSizeMB }: DropzoneContentProps) => (\n <BaseDropzoneContent>\n <SystemIcon.FileDashedIcon\n weight=\"thin\"\n size={48}\n color={Color.neutral.grey1}\n />\n <AllDropzoneText>\n <DropzoneText>\n {`Drop up to ${maxFiles} files here (up to ${maxSizeMB}MB each)`}\n </DropzoneText>\n\n <DropzoneSubtitle $isHighlighted>\n or click to browse with your file explorer\n </DropzoneSubtitle>\n\n <DropzoneSubtitle>Accepted file formats: pdf, png, jpg</DropzoneSubtitle>\n </AllDropzoneText>\n </BaseDropzoneContent>\n);\n\nconst BaseDropzoneContent = styled.div`\n display: flex;\n flex-direction: column;\n gap: 24px;\n align-items: center;\n`;\n\nconst AllDropzoneText = styled.div`\n display: flex;\n flex-direction: column;\n gap: 4px;\n`;\n\nconst DropzoneText = styled.p`\n text-align: center;\n\n ${applyTypography(Typography.bodyPrimaryMedium)}\n`;\n\nconst DropzoneSubtitle = styled.p<{ $isHighlighted?: boolean }>`\n text-align: center;\n\n color: ${({ $isHighlighted = false }) =>\n $isHighlighted ? Color.accent.yellow1 : Color.typography.blackLow};\n\n ${applyTypography(Typography.bodySecondaryRegular)}\n`;\n\nconst ErrorMessage = styled.p`\n color: ${Color.accent.red1};\n`;\n\ntype UploadedFilesProps = {\n uploadedFiles: File[];\n removeFile: (fileName: string) => void;\n};\n\nconst UploadedFiles = ({ uploadedFiles, removeFile }: UploadedFilesProps) => (\n <BaseUploadedFiles>\n {uploadedFiles.map(({ name: fileName, type: fileType }) => (\n <Badge\n key={fileName}\n label={getFileNameWithoutExtension(fileName)}\n onClickX={() => removeFile(fileName)}\n Icon={FILE_TYPE_ICON_MAP[fileType] ?? SystemIcon.FileIcon}\n variant=\"neutral\"\n />\n ))}\n </BaseUploadedFiles>\n);\n\nconst BaseUploadedFiles = styled.div`\n display: flex;\n flex-direction: column;\n gap: ${Spacing.px4};\n`;\n\nexport const useFileDrop = (\n initialFiles: File[] = [],\n maxFiles: number = DEFAULT_MAX_FILES,\n maxSizeMB: number = DEFAULT_MAX_FILE_SIZE_MB,\n) => {\n const [files, setFiles] = useState<File[]>(() => initialFiles);\n const [errorMessage, setErrorMessage] = useState<string | undefined>();\n\n const uploadFiles = (acceptedFiles: File[]) => {\n if (files.length + acceptedFiles.length > maxFiles) {\n setErrorMessage(() => `Maximum upload limit is ${maxFiles} files`);\n } else if (anyFileTooLarge(acceptedFiles, maxSizeMB)) {\n setErrorMessage(() => `Maximum file size is ${maxSizeMB}MB`);\n } else {\n setErrorMessage(() => undefined);\n setFiles((previousFiles) =>\n combineFilesWithoutDuplicates(previousFiles, acceptedFiles),\n );\n }\n };\n\n const removeFile = (fileName: string) => {\n setErrorMessage(() => undefined);\n setFiles((previousFiles) => filterFilesByName(previousFiles, fileName));\n };\n\n return {\n files,\n uploadFiles,\n removeFile,\n errorMessage,\n };\n};\n\nconst anyFileTooLarge = (files: File[], maxSizeMB: number): boolean =>\n files.some((file) => file.size > convertMegabytesToBytes(maxSizeMB));\n\nconst convertMegabytesToBytes = (megabytes: number): number =>\n megabytes * 1024 * 1024;\n\nconst combineFilesWithoutDuplicates = (\n oldFiles: File[],\n newFiles: File[],\n): File[] => {\n const newFileNames = new Set(newFiles.map((file) => file.name));\n const keptOldFiles = oldFiles.filter(\n (oldFile) => !newFileNames.has(oldFile.name),\n );\n\n return [...keptOldFiles, ...newFiles];\n};\n\nconst filterFilesByName = (files: File[], fileName: string): File[] =>\n files.filter((file) => file.name !== fileName);\n\nconst getFileNameWithoutExtension = (fileName: string): string =>\n fileName.substring(0, fileName.lastIndexOf(\".\"));\n"]}
|
package/core/shared.js
CHANGED
|
@@ -54,7 +54,7 @@ export const InputValidation = css `
|
|
|
54
54
|
`;
|
|
55
55
|
export const FILE_TYPE_ICON_MAP = {
|
|
56
56
|
"application/pdf": SystemIcon.FilePdfIcon,
|
|
57
|
-
"image/png": SystemIcon.
|
|
58
|
-
"image/jpeg": SystemIcon.
|
|
57
|
+
"image/png": SystemIcon.ImageIcon,
|
|
58
|
+
"image/jpeg": SystemIcon.ImageIcon,
|
|
59
59
|
};
|
|
60
60
|
//# sourceMappingURL=shared.js.map
|
package/core/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../core/shared.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAItC,CAAC;AAMF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAsB;;wBAEhC,KAAK,CAAC,OAAO,CAAC,KAAK;wBACnB,KAAK,CAAC,OAAO,CAAC,KAAK;;;;;wBAKnB,KAAK,CAAC,OAAO,CAAC,KAAK;wBACnB,KAAK,CAAC,OAAO,CAAC,KAAK;;;;;wBAKnB,KAAK,CAAC,OAAO,CAAC,KAAK;wBACnB,KAAK,CAAC,MAAM,CAAC,KAAK;yBACjB,KAAK,CAAC,MAAM,CAAC,KAAK;;;;wBAInB,KAAK,CAAC,OAAO,CAAC,KAAK;wBACnB,KAAK,CAAC,MAAM,CAAC,IAAI;;;;;wBAKjB,K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,IAAI;;;;;wBAKjB,KAAK,CAAC,OAAO,CAAC,KAAK;wBACnB,KAAK,CAAC,MAAM,CAAC,IAAI;yBAChB,KAAK,CAAC,MAAM,CAAC,IAAI;;;IAGtC,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE,EAAE,CAC1B,SAAS;IACP,CAAC,CAAC,GAAG,CAAA;;gCAEqB,KAAK,CAAC,OAAO,CAAC,KAAK;gCACnB,KAAK,CAAC,MAAM,CAAC,IAAI;;;;;gCAKjB,KAAK,CAAC,OAAO,CAAC,KAAK;gCACnB,KAAK,CAAC,MAAM,CAAC,IAAI;iCAChB,KAAK,CAAC,MAAM,CAAC,IAAI;;SAEzC;IACH,CAAC,CAAC,GAAG,CAAA,EAAE;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA4C;IACzE,iBAAiB,EAAE,UAAU,CAAC,WAAW;IACzC,WAAW,EAAE,UAAU,CAAC,SAAS;IACjC,YAAY,EAAE,UAAU,CAAC,SAAS;CACnC,CAAC","sourcesContent":["import styled, { css } from \"styled-components\";\nimport { Color, SystemIcon } from \"./atoms\";\n\nexport const LabelledInput = styled.div`\n display: flex;\n align-items: center;\n gap: 8px;\n`;\n\nexport type InputValidationProps = {\n $hasError?: boolean;\n};\n\nexport const InputValidation = css<InputValidationProps>`\n &:disabled {\n background-color: ${Color.neutral.grey4};\n border: 1px solid ${Color.neutral.grey3};\n outline: none;\n }\n\n &:valid {\n background-color: ${Color.neutral.white};\n border: 1px solid ${Color.neutral.grey3};\n outline: none;\n }\n\n &:valid&:focus {\n background-color: ${Color.neutral.white};\n border: 1px solid ${Color.accent.blue1};\n outline: 1px solid ${Color.accent.blue1};\n }\n\n &:invalid {\n background-color: ${Color.neutral.white};\n border: 1px solid ${Color.accent.red1};\n outline: none;\n }\n\n &:invalid&:focus {\n background-color: ${Color.neutral.white};\n border: 1px solid ${Color.accent.red1};\n outline: 1px solid ${Color.accent.red1};\n }\n\n ${({ $hasError = false }) =>\n $hasError\n ? css`\n &:valid {\n background-color: ${Color.neutral.white};\n border: 1px solid ${Color.accent.red1};\n outline: none;\n }\n\n &:valid&:focus {\n background-color: ${Color.neutral.white};\n border: 1px solid ${Color.accent.red1};\n outline: 1px solid ${Color.accent.red1};\n }\n `\n : css``}\n`;\n\nexport const FILE_TYPE_ICON_MAP: { [mimeType: string]: SystemIcon.Icon } = {\n \"application/pdf\": SystemIcon.FilePdfIcon,\n \"image/png\": SystemIcon.ImageIcon,\n \"image/jpeg\": SystemIcon.ImageIcon,\n};\n"]}
|
|
@@ -20,7 +20,7 @@ const FileBadges = () => {
|
|
|
20
20
|
};
|
|
21
21
|
updateActiveQuery(newQuery);
|
|
22
22
|
};
|
|
23
|
-
return (_jsx(BaseFileBadges, { children: activeQuery.files.map((file) => (_jsx(Badge, { label: file.name.substring(0, file.name.lastIndexOf(".")), Icon: FILE_TYPE_ICON_MAP[file.type] ?? SystemIcon.FileIcon,
|
|
23
|
+
return (_jsx(BaseFileBadges, { children: activeQuery.files.map((file) => (_jsx(Badge, { label: file.name.substring(0, file.name.lastIndexOf(".")), Icon: FILE_TYPE_ICON_MAP[file.type] ?? SystemIcon.FileIcon, onClickX: () => removeActiveQueryFile(file.name), labelWidthPixels: 160, variant: "neutral" }, file.name))) }));
|
|
24
24
|
};
|
|
25
25
|
const BaseFileBadges = styled.div `
|
|
26
26
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActiveQueryFiles.js","sourceRoot":"","sources":["../../../../core/templates/GrantMatch/ActiveQueryFiles.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,C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ClB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;CAiBhC,CAAC;AAEF,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAElE,OAAO,CACL,KAAC,MAAM,IACL,KAAK,EAAC,OAAO,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,EACvE,OAAO,EAAC,MAAM,GACd,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import styled from \"styled-components\";\nimport { SystemIcon } from \"../../atoms\";\nimport { Badge, Button } from \"../../molecules\";\nimport { FILE_TYPE_ICON_MAP } from \"../../shared\";\nimport { useGrantMatchContext } from \"./context\";\n\nconst ActiveQueryFiles = () => (\n <BaseActiveFiles>\n <FileBadges />\n <ResetFilesButton />\n </BaseActiveFiles>\n);\n\nexport default ActiveQueryFiles;\n\nconst BaseActiveFiles = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n`;\n\nconst FileBadges = () => {\n const { activeQuery, updateActiveQuery } = useGrantMatchContext();\n\n const removeActiveQueryFile = (fileName: string) => {\n const newQuery = {\n files: activeQuery.files.filter((file) => file.name !== fileName),\n text: activeQuery.text,\n };\n\n updateActiveQuery(newQuery);\n };\n\n return (\n <BaseFileBadges>\n {activeQuery.files.map((file) => (\n <Badge\n key={file.name}\n label={file.name.substring(0, file.name.lastIndexOf(\".\"))}\n Icon={FILE_TYPE_ICON_MAP[file.type] ?? SystemIcon.FileIcon}\n onClickX={() => removeActiveQueryFile(file.name)}\n labelWidthPixels={160}\n variant=\"neutral\"\n />\n ))}\n </BaseFileBadges>\n );\n};\n\nconst BaseFileBadges = styled.div`\n display: flex;\n align-items: center;\n gap: 8px;\n\n width: 100%;\n\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 /* TODO: fade effect on overflow-x */\n`;\n\nconst ResetFilesButton = () => {\n const { activeQuery, updateActiveQuery } = useGrantMatchContext();\n\n return (\n <Button\n label=\"Reset\"\n onClick={() => updateActiveQuery({ files: [], text: activeQuery.text })}\n variant=\"text\"\n />\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -3,9 +3,19 @@ import type { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
|
3
3
|
declare const meta: Meta<typeof Badge>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
6
|
+
export declare const DefaultTextOnly: Story;
|
|
7
|
+
export declare const WithIcon: Story;
|
|
8
|
+
export declare const ClickableX: Story;
|
|
9
9
|
export declare const LongText: Story;
|
|
10
10
|
export declare const AlmostEverything: Story;
|
|
11
11
|
export declare const Clickable: Story;
|
|
12
|
+
export declare const Neutral: Story;
|
|
13
|
+
export declare const ClickableNeutral: Story;
|
|
14
|
+
export declare const Blue: Story;
|
|
15
|
+
export declare const ClickableBlue: Story;
|
|
16
|
+
export declare const Green: Story;
|
|
17
|
+
export declare const ClickableGreen: Story;
|
|
18
|
+
export declare const Yellow: Story;
|
|
19
|
+
export declare const ClickableYellow: Story;
|
|
20
|
+
export declare const Red: Story;
|
|
21
|
+
export declare const ClickableRed: Story;
|
|
@@ -5,24 +5,25 @@ const meta = {
|
|
|
5
5
|
tags: ["autodocs"],
|
|
6
6
|
};
|
|
7
7
|
export default meta;
|
|
8
|
+
const Icon = SystemIcon.FilePdfIcon;
|
|
8
9
|
const defaultText = "Badge";
|
|
9
|
-
const longText = "
|
|
10
|
+
const longText = "super_long_file_name.pdf";
|
|
10
11
|
const onClickClose = () => alert("You have closed the badge.");
|
|
11
|
-
export const
|
|
12
|
+
export const DefaultTextOnly = {
|
|
12
13
|
args: {
|
|
13
14
|
label: defaultText,
|
|
14
15
|
},
|
|
15
16
|
};
|
|
16
|
-
export const
|
|
17
|
+
export const WithIcon = {
|
|
17
18
|
args: {
|
|
18
|
-
Icon
|
|
19
|
+
Icon,
|
|
19
20
|
label: defaultText,
|
|
20
21
|
},
|
|
21
22
|
};
|
|
22
|
-
export const
|
|
23
|
+
export const ClickableX = {
|
|
23
24
|
args: {
|
|
24
25
|
label: defaultText,
|
|
25
|
-
onClickClose,
|
|
26
|
+
onClickX: onClickClose,
|
|
26
27
|
},
|
|
27
28
|
};
|
|
28
29
|
export const LongText = {
|
|
@@ -33,10 +34,10 @@ export const LongText = {
|
|
|
33
34
|
};
|
|
34
35
|
export const AlmostEverything = {
|
|
35
36
|
args: {
|
|
36
|
-
Icon: SystemIcon.SmileyXEyesIcon,
|
|
37
37
|
label: longText,
|
|
38
|
+
Icon,
|
|
38
39
|
labelWidthPixels: 160,
|
|
39
|
-
onClickClose,
|
|
40
|
+
onClickX: onClickClose,
|
|
40
41
|
},
|
|
41
42
|
};
|
|
42
43
|
export const Clickable = {
|
|
@@ -45,4 +46,84 @@ export const Clickable = {
|
|
|
45
46
|
onClick: () => alert("Clicked on badge"),
|
|
46
47
|
},
|
|
47
48
|
};
|
|
49
|
+
export const Neutral = {
|
|
50
|
+
args: {
|
|
51
|
+
label: longText,
|
|
52
|
+
Icon,
|
|
53
|
+
labelWidthPixels: 160,
|
|
54
|
+
onClickX: onClickClose,
|
|
55
|
+
variant: "neutral",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
export const ClickableNeutral = {
|
|
59
|
+
args: {
|
|
60
|
+
label: "Click Me",
|
|
61
|
+
onClick: () => alert("Clicked on badge"),
|
|
62
|
+
variant: "neutral",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export const Blue = {
|
|
66
|
+
args: {
|
|
67
|
+
label: longText,
|
|
68
|
+
Icon,
|
|
69
|
+
labelWidthPixels: 160,
|
|
70
|
+
onClickX: onClickClose,
|
|
71
|
+
variant: "blue",
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
export const ClickableBlue = {
|
|
75
|
+
args: {
|
|
76
|
+
label: "Click Me",
|
|
77
|
+
onClick: () => alert("Clicked on badge"),
|
|
78
|
+
variant: "blue",
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
export const Green = {
|
|
82
|
+
args: {
|
|
83
|
+
label: longText,
|
|
84
|
+
Icon: SystemIcon.FilePngIcon,
|
|
85
|
+
labelWidthPixels: 160,
|
|
86
|
+
onClickX: onClickClose,
|
|
87
|
+
variant: "green",
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
export const ClickableGreen = {
|
|
91
|
+
args: {
|
|
92
|
+
label: "Click Me",
|
|
93
|
+
onClick: () => alert("Clicked on badge"),
|
|
94
|
+
variant: "green",
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
export const Yellow = {
|
|
98
|
+
args: {
|
|
99
|
+
label: longText,
|
|
100
|
+
Icon,
|
|
101
|
+
labelWidthPixels: 160,
|
|
102
|
+
onClickX: onClickClose,
|
|
103
|
+
variant: "yellow",
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
export const ClickableYellow = {
|
|
107
|
+
args: {
|
|
108
|
+
label: "Click Me",
|
|
109
|
+
onClick: () => alert("Clicked on badge"),
|
|
110
|
+
variant: "yellow",
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
export const Red = {
|
|
114
|
+
args: {
|
|
115
|
+
label: longText,
|
|
116
|
+
Icon,
|
|
117
|
+
labelWidthPixels: 160,
|
|
118
|
+
onClickX: onClickClose,
|
|
119
|
+
variant: "red",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
export const ClickableRed = {
|
|
123
|
+
args: {
|
|
124
|
+
label: "Click Me",
|
|
125
|
+
onClick: () => alert("Clicked on badge"),
|
|
126
|
+
variant: "red",
|
|
127
|
+
},
|
|
128
|
+
};
|
|
48
129
|
//# sourceMappingURL=Badge.stories.js.map
|