@grantbii/design-system 1.0.26 → 1.0.28
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 +11 -0
- package/core/molecules/Badge.js +28 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/stories/molecules/Badge.stories.d.ts +11 -0
- package/stories/molecules/Badge.stories.js +46 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JSX, MouseEventHandler } from "react";
|
|
2
|
+
type BadgeProps = {
|
|
3
|
+
text: string;
|
|
4
|
+
icon?: JSX.Element;
|
|
5
|
+
onClickClose?: MouseEventHandler<HTMLButtonElement>;
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
textWidthPixels?: number;
|
|
9
|
+
};
|
|
10
|
+
declare const Badge: ({ icon, text, onClickClose, backgroundColor, color, textWidthPixels, }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default Badge;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { Colors, Icons } from "../../index";
|
|
4
|
+
const Badge = ({ icon, text, onClickClose, backgroundColor, color, textWidthPixels, }) => (_jsxs(BaseBadge, { "$backgroundColor": backgroundColor, "$color": color, children: [icon ? icon : _jsx(_Fragment, {}), _jsx(BadgeText, { "$widthPixels": textWidthPixels, children: text }), onClickClose ? (_jsx(Button, { type: "button", onClick: onClickClose, children: _jsx(Icons.XIcon, { size: 12 }) })) : (_jsx(_Fragment, {}))] }));
|
|
5
|
+
export default Badge;
|
|
6
|
+
const BaseBadge = styled.div `
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 10px;
|
|
10
|
+
|
|
11
|
+
padding: 5px 16px;
|
|
12
|
+
border-radius: 130px;
|
|
13
|
+
|
|
14
|
+
color: ${({ $color = Colors.typography.blackHigh }) => $color};
|
|
15
|
+
background-color: ${({ $backgroundColor = Colors.neutral.grey3 }) => $backgroundColor};
|
|
16
|
+
`;
|
|
17
|
+
const BadgeText = styled.p `
|
|
18
|
+
width: ${({ $widthPixels }) => ($widthPixels ? `${$widthPixels}px` : "auto")};
|
|
19
|
+
overflow-x: hidden;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
text-overflow: ellipsis;
|
|
22
|
+
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
`;
|
|
26
|
+
const Button = styled.button `
|
|
27
|
+
display: flex;
|
|
28
|
+
`;
|
package/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { default as BrandLogo } from "./core/atoms/BrandLogo";
|
|
|
4
4
|
export * as Colors from "./core/atoms/colors";
|
|
5
5
|
export { default as GlobalStyle } from "./core/global/GlobalStyle";
|
|
6
6
|
export { default as StyledComponentsRegistry } from "./core/integrations/StyledComponentsRegistry";
|
|
7
|
+
export { default as Badge } from "./core/molecules/Badge";
|
package/index.js
CHANGED
|
@@ -4,3 +4,4 @@ export { default as BrandLogo } from "./core/atoms/BrandLogo";
|
|
|
4
4
|
export * as Colors from "./core/atoms/colors";
|
|
5
5
|
export { default as GlobalStyle } from "./core/global/GlobalStyle";
|
|
6
6
|
export { default as StyledComponentsRegistry } from "./core/integrations/StyledComponentsRegistry";
|
|
7
|
+
export { default as Badge } from "./core/molecules/Badge";
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Badge } from "@/.";
|
|
2
|
+
import type { StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
+
import { Meta } from "@storybook/nextjs-vite";
|
|
4
|
+
declare const meta: Meta<typeof Badge>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<typeof meta>;
|
|
7
|
+
export declare const Default: Story;
|
|
8
|
+
export declare const Icon: Story;
|
|
9
|
+
export declare const Close: Story;
|
|
10
|
+
export declare const Long: Story;
|
|
11
|
+
export declare const Everything: Story;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Badge, Icons } from "@/.";
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "Design System/Atoms/Badge",
|
|
5
|
+
component: Badge,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
const DEFAULT_TEXT = "Badge";
|
|
13
|
+
const LONG_TEXT = "the quick brown fox jumps over the lazy dog";
|
|
14
|
+
const ICON = _jsx(Icons.SmileyXEyesIcon, { size: 20 });
|
|
15
|
+
const ON_CLICK_CLOSE = () => alert("You have closed the badge!");
|
|
16
|
+
export const Default = {
|
|
17
|
+
args: {
|
|
18
|
+
text: DEFAULT_TEXT,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export const Icon = {
|
|
22
|
+
args: {
|
|
23
|
+
icon: ICON,
|
|
24
|
+
text: DEFAULT_TEXT,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const Close = {
|
|
28
|
+
args: {
|
|
29
|
+
text: DEFAULT_TEXT,
|
|
30
|
+
onClickClose: ON_CLICK_CLOSE,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const Long = {
|
|
34
|
+
args: {
|
|
35
|
+
text: LONG_TEXT,
|
|
36
|
+
textWidthPixels: 160,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const Everything = {
|
|
40
|
+
args: {
|
|
41
|
+
icon: ICON,
|
|
42
|
+
text: LONG_TEXT,
|
|
43
|
+
textWidthPixels: 160,
|
|
44
|
+
onClickClose: ON_CLICK_CLOSE,
|
|
45
|
+
},
|
|
46
|
+
};
|