@grantbii/design-system 1.0.27 → 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.
@@ -5,6 +5,7 @@ type BadgeProps = {
5
5
  onClickClose?: MouseEventHandler<HTMLButtonElement>;
6
6
  backgroundColor?: string;
7
7
  color?: string;
8
+ textWidthPixels?: number;
8
9
  };
9
- declare const Badge: ({ icon, text, onClickClose, backgroundColor, color, }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const Badge: ({ icon, text, onClickClose, backgroundColor, color, textWidthPixels, }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
10
11
  export default Badge;
@@ -1,7 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import { Colors, Icons } from "../../index";
4
- const Badge = ({ icon, text, onClickClose, backgroundColor = Colors.neutral.grey3, color = Colors.typography.blackHigh, }) => (_jsxs(BaseBadge, { "$backgroundColor": backgroundColor, "$color": color, children: [icon ? icon : _jsx(_Fragment, {}), text ? _jsx(BadgeText, { children: text }) : _jsx(_Fragment, {}), onClickClose ? (_jsx(Button, { type: "button", onClick: onClickClose, children: _jsx(Icons.XIcon, { size: 20 }) })) : (_jsx(_Fragment, {}))] }));
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
5
  export default Badge;
6
6
  const BaseBadge = styled.div `
7
7
  display: flex;
@@ -11,10 +11,15 @@ const BaseBadge = styled.div `
11
11
  padding: 5px 16px;
12
12
  border-radius: 130px;
13
13
 
14
- background-color: ${({ $backgroundColor }) => $backgroundColor};
15
- color: ${({ $color }) => $color};
14
+ color: ${({ $color = Colors.typography.blackHigh }) => $color};
15
+ background-color: ${({ $backgroundColor = Colors.neutral.grey3 }) => $backgroundColor};
16
16
  `;
17
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
+
18
23
  font-weight: 500;
19
24
  font-size: 14px;
20
25
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grantbii/design-system",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "Grantbii's Design System",
5
5
  "homepage": "https://design.grantbii.com",
6
6
  "repository": {
@@ -7,4 +7,5 @@ type Story = StoryObj<typeof meta>;
7
7
  export declare const Default: Story;
8
8
  export declare const Icon: Story;
9
9
  export declare const Close: Story;
10
+ export declare const Long: Story;
10
11
  export declare const Everything: Story;
@@ -9,27 +9,38 @@ const meta = {
9
9
  },
10
10
  };
11
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!");
12
16
  export const Default = {
13
17
  args: {
14
- text: "Badge",
18
+ text: DEFAULT_TEXT,
15
19
  },
16
20
  };
17
21
  export const Icon = {
18
22
  args: {
19
- icon: _jsx(Icons.SmileyXEyesIcon, { size: 20 }),
20
- text: "Badge",
23
+ icon: ICON,
24
+ text: DEFAULT_TEXT,
21
25
  },
22
26
  };
23
27
  export const Close = {
24
28
  args: {
25
- text: "Badge",
26
- onClickClose: () => alert("closed badge"),
29
+ text: DEFAULT_TEXT,
30
+ onClickClose: ON_CLICK_CLOSE,
31
+ },
32
+ };
33
+ export const Long = {
34
+ args: {
35
+ text: LONG_TEXT,
36
+ textWidthPixels: 160,
27
37
  },
28
38
  };
29
39
  export const Everything = {
30
40
  args: {
31
- icon: _jsx(Icons.SmileyXEyesIcon, { size: 20 }),
32
- text: "Badge",
33
- onClickClose: () => alert("You have closed the badge!"),
41
+ icon: ICON,
42
+ text: LONG_TEXT,
43
+ textWidthPixels: 160,
44
+ onClickClose: ON_CLICK_CLOSE,
34
45
  },
35
46
  };