@sproutsocial/seeds-react-badge 1.0.5 → 2.0.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.
@@ -1,94 +0,0 @@
1
- import React from "react";
2
- import { render, screen } from "@sproutsocial/seeds-react-testing-library";
3
- import Badge from "../Badge";
4
-
5
- describe("Badge...", () => {
6
- it("...should render with default props", () => {
7
- render(<Badge>Test</Badge>);
8
- expect(screen.getByText("Test")).toBeInTheDocument();
9
- expect(screen.getByText("Test").closest("span")).toHaveStyleRule(
10
- "padding",
11
- "0px 4px"
12
- );
13
- expect(screen.getByText("Test").closest("span")).toHaveStyleRule(
14
- "background",
15
- "#deebfe"
16
- );
17
- });
18
-
19
- it("...should render with correct size styling", () => {
20
- render(<Badge size="large">Test</Badge>);
21
- expect(screen.getByText("Test").closest("span")).toHaveStyleRule(
22
- "padding",
23
- "8px"
24
- );
25
- });
26
-
27
- it("...should render with legacy type", () => {
28
- render(<Badge type="secondary">Test</Badge>);
29
- expect(screen.getByText("Test")).toBeInTheDocument();
30
- expect(screen.getByText("Test").closest("span")).toHaveStyleRule(
31
- "color",
32
- "#364141"
33
- );
34
- expect(screen.getByText("Test").closest("span")).toHaveStyleRule(
35
- "background",
36
- "#fdefcd"
37
- );
38
- });
39
-
40
- it("...should render with a badge color", () => {
41
- render(<Badge badgeColor="purple">Test</Badge>);
42
- expect(screen.getByText("Test")).toBeInTheDocument();
43
- expect(screen.getByText("Test").closest("span")).toHaveStyleRule(
44
- "background",
45
- "#eaeaf9"
46
- );
47
- });
48
-
49
- it("...should render with an icon", () => {
50
- const { container } = render(
51
- <Badge iconName="sparkle-outline">Test</Badge>
52
- );
53
- expect(container.querySelector("svg")).toBeTruthy();
54
- });
55
- it("...should fail with invalid iconName", () => {
56
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
- // @ts-expect-error
58
- render(<Badge iconName="someinvalidname123">Test</Badge>);
59
- });
60
- it("should render with suggestion type", () => {
61
- render(<Badge text="Test" type="suggestion" />);
62
- expect(screen.getByText("Test")).toBeInTheDocument();
63
- expect(
64
- screen.getByDataQaLabel({ "badge-type": "suggestion" })
65
- ).toBeTruthy();
66
- });
67
-
68
- it("...should render with tooltip class", () => {
69
- render(<Badge tip="test tip">Test</Badge>);
70
- expect(screen.getByText("Test")).toBeInTheDocument();
71
- expect(screen.getByDataQaLabel({ "badge-tip": "test tip" })).toBeTruthy();
72
- });
73
-
74
- it("...should allow overriding qa props", () => {
75
- render(
76
- <Badge
77
- data-qa-badge="text-override"
78
- data-qa-badge-type="type-override"
79
- data-qa-badge-tip="tip-override"
80
- type="suggestion"
81
- tip="tip"
82
- >
83
- Text
84
- </Badge>
85
- );
86
- expect(screen.getByDataQaLabel({ badge: "text-override" })).toBeTruthy();
87
- expect(
88
- screen.getByDataQaLabel({ "badge-type": "type-override" })
89
- ).toBeTruthy();
90
- expect(
91
- screen.getByDataQaLabel({ "badge-tip": "tip-override" })
92
- ).toBeTruthy();
93
- });
94
- });
@@ -1,28 +0,0 @@
1
- import * as React from "react";
2
- import { render } from "@sproutsocial/seeds-react-testing-library";
3
- import Badge from "../Badge";
4
-
5
- describe.skip("Badge/types", () => {
6
- it("should render valid props", () => {
7
- render(
8
- <>
9
- <Badge>Test</Badge>
10
- <Badge size="large">Test</Badge>
11
- <Badge type="secondary">Test</Badge>
12
- <Badge badgeColor="purple">Test</Badge>
13
- <Badge badgeColor="red">Test</Badge>
14
- <Badge badgeColor="magenta">Test</Badge>
15
- <Badge badgeColor="neutral">Test</Badge>
16
- <Badge badgeColor="aqua">Test</Badge>
17
- <Badge iconName="sparkle-outline">Test</Badge>;
18
- <Badge text="Test" type="suggestion" />
19
- <Badge tip="test tip">Test</Badge>
20
- <Badge data-qa-badge="123456">Test</Badge>
21
- {/* @ts-expect-error - test that invalid iconName is rejected */}
22
- <Badge iconName="someinvalidname123">Test</Badge>
23
- {/* @ts-expect-error - test that invalid badgeColor is rejected */}
24
- <Badge badgeColor="notARealColor">Test</Badge>
25
- </>
26
- );
27
- });
28
- });
package/src/constants.ts DELETED
@@ -1,64 +0,0 @@
1
- const defaultPurple = {
2
- color: "colors.text.body",
3
- background: "colors.container.background.decorative.purple",
4
- };
5
-
6
- const suggestion = {
7
- color: "colors.text.body",
8
- background: "colors.container.background.decorative.blue",
9
- };
10
-
11
- const passive = {
12
- color: "colors.text.body",
13
- background: "colors.container.background.decorative.neutral",
14
- };
15
-
16
- const primary = {
17
- color: "colors.text.body",
18
- background: "colors.container.background.decorative.blue",
19
- };
20
-
21
- const secondary = {
22
- color: "colors.text.body",
23
- background: "colors.container.background.decorative.yellow",
24
- };
25
-
26
- const common = {
27
- color: "colors.text.inverse",
28
- background: "colors.aqua.600",
29
- };
30
-
31
- const approval = {
32
- color: "colors.text.body",
33
- background: "colors.container.background.decorative.orange",
34
- };
35
-
36
- //Deprecated former "types"
37
-
38
- /**
39
- * @deprecated Use badgeColor instead
40
- */
41
-
42
- export const legacyBadgeColors = {
43
- primary,
44
- secondary,
45
- passive,
46
- common,
47
- approval,
48
- default: defaultPurple,
49
- suggestion,
50
- };
51
-
52
- export const badgeColors = {
53
- green: "green",
54
- blue: "blue",
55
- purple: "purple",
56
- yellow: "yellow",
57
- orange: "orange",
58
- red: "red",
59
- neutral: "neutral",
60
- magenta: "magenta",
61
- pink: "pink",
62
- aqua: "aqua",
63
- teal: "teal",
64
- } as const;
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- import Badge from "./Badge";
2
-
3
- export default Badge;
4
- export { Badge };
5
- export * from "./BadgeTypes";
6
- export * from "./constants";
package/src/styles.ts DELETED
@@ -1,36 +0,0 @@
1
- import styled from "styled-components";
2
-
3
- import { COMMON } from "@sproutsocial/seeds-react-system-props";
4
- import { legacyBadgeColors } from "./constants";
5
- // @ts-ignore: no types exist for this thang
6
- import { themeGet } from "@styled-system/theme-get";
7
-
8
- type TypeTypeKey = keyof typeof legacyBadgeColors;
9
-
10
- const Container = styled.span<{
11
- type?: TypeTypeKey;
12
- badgeColor: string;
13
- size: string;
14
- }>`
15
- font-family: ${(p) => p.theme.fontFamily};
16
- ${(p) =>
17
- p.size === "small" ? p.theme.typography[100] : p.theme.typography[200]};
18
- border-radius: 9999px;
19
- line-height: 16px;
20
- display: inline-block;
21
- color: ${(p) =>
22
- p.type
23
- ? themeGet(legacyBadgeColors[p.type].color)
24
- : p.theme.colors.text.body};
25
- background: ${(p) =>
26
- p.type
27
- ? themeGet(legacyBadgeColors[p.type].background)
28
- : p.theme.colors.container.background.decorative[p.badgeColor]};
29
- padding: ${(p) =>
30
- p.size === "small"
31
- ? `${p.theme.space[0]} ${p.theme.space[200]}`
32
- : `${p.theme.space[300]}`};
33
- ${COMMON};
34
- `;
35
-
36
- export default Container;
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "extends": "@sproutsocial/seeds-tsconfig/bundler/dom/library-monorepo",
3
- "compilerOptions": {
4
- "jsx": "react-jsx",
5
- "module": "esnext"
6
- },
7
- "include": ["src/**/*"],
8
- "exclude": [
9
- "node_modules",
10
- "dist",
11
- "coverage",
12
- "**/*.stories.tsx",
13
- "**/*.stories.ts"
14
- ]
15
- }
package/tsup.config.ts DELETED
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig((options) => ({
4
- entry: ["src/index.ts"],
5
- format: ["cjs", "esm"],
6
- clean: true,
7
- legacyOutput: true,
8
- dts: options.dts,
9
- external: ["react"],
10
- sourcemap: true,
11
- metafile: options.metafile,
12
- }));