@sproutsocial/racine 11.1.1 → 11.1.2-badge-update.2
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/CHANGELOG.md +6 -0
- package/__flow__/Badge/constants.js +48 -0
- package/__flow__/Badge/index.js +58 -32
- package/__flow__/Badge/index.stories.js +29 -42
- package/__flow__/Badge/index.test.js +34 -32
- package/__flow__/Badge/styles.js +22 -42
- package/__flow__/themes/dark/theme.js +1 -0
- package/__flow__/themes/light/literal-colors.js +2 -0
- package/__flow__/themes/light/theme.js +1 -0
- package/__flow__/types/theme.colors.flow.js +27 -0
- package/bin/buildNpm.js +58 -0
- package/commonjs/Avatar/index.js +7 -4
- package/commonjs/Badge/constants.js +43 -0
- package/commonjs/Badge/index.js +42 -38
- package/commonjs/Badge/styles.js +16 -32
- package/commonjs/Banner/index.js +3 -1
- package/commonjs/Banner/styles.js +1 -1
- package/commonjs/Box/styles.js +1 -1
- package/commonjs/Breadcrumb/index.js +5 -2
- package/commonjs/Button/index.js +3 -1
- package/commonjs/Card/index.js +3 -1
- package/commonjs/Card/styles.js +3 -3
- package/commonjs/CharacterCounter/index.js +3 -1
- package/commonjs/CharacterCounter/styles.js +1 -1
- package/commonjs/ChartLegend/index.js +3 -1
- package/commonjs/ChartLegend/styles.js +3 -3
- package/commonjs/Checkbox/index.js +3 -1
- package/commonjs/Checkbox/styles.js +1 -1
- package/commonjs/Collapsible/index.js +5 -2
- package/commonjs/DatePicker/DateRangePicker.js +3 -1
- package/commonjs/DatePicker/SingleDatePicker.js +3 -1
- package/commonjs/DatePicker/StatefulDateRangePicker.js +3 -1
- package/commonjs/DatePicker/StatefulSingleDatePicker.js +3 -1
- package/commonjs/DatePicker/common.js +1 -1
- package/commonjs/DatePicker/styles.js +2 -6
- package/commonjs/Drawer/SlideTransition.js +3 -1
- package/commonjs/Drawer/index.js +9 -4
- package/commonjs/Drawer/styles.js +2 -2
- package/commonjs/EmptyState/index.js +3 -1
- package/commonjs/Fieldset/index.js +7 -3
- package/commonjs/FormField/index.js +3 -1
- package/commonjs/Icon/index.js +5 -2
- package/commonjs/Icon/styles.js +1 -1
- package/commonjs/Image/index.js +3 -1
- package/commonjs/Image/styles.js +1 -1
- package/commonjs/Indicator/index.js +3 -1
- package/commonjs/Input/index.js +3 -1
- package/commonjs/Input/styles.js +2 -2
- package/commonjs/KeyboardKey/index.js +3 -1
- package/commonjs/Label/index.js +4 -2
- package/commonjs/Link/index.js +3 -1
- package/commonjs/Link/styles.js +1 -1
- package/commonjs/Listbox/index.js +7 -4
- package/commonjs/Loader/index.js +3 -1
- package/commonjs/Loader/styles.js +2 -2
- package/commonjs/LoaderButton/index.js +3 -1
- package/commonjs/Menu/constants.js +1 -1
- package/commonjs/Menu/descendants.js +10 -7
- package/commonjs/Menu/hooks.js +1 -1
- package/commonjs/Menu/index.js +22 -16
- package/commonjs/Menu/styles.js +2 -2
- package/commonjs/Message/index.js +3 -1
- package/commonjs/Message/styles.js +1 -1
- package/commonjs/Modal/index.js +7 -3
- package/commonjs/Modal/styles.js +4 -6
- package/commonjs/Numeral/constants.js +1 -1
- package/commonjs/Numeral/index.js +3 -1
- package/commonjs/Numeral/styles.js +3 -3
- package/commonjs/OverflowList/styles.js +1 -1
- package/commonjs/Popout/index.js +7 -3
- package/commonjs/Popout/styles.js +1 -1
- package/commonjs/Radio/index.js +3 -1
- package/commonjs/Radio/styles.js +4 -4
- package/commonjs/SegmentedControl/index.js +5 -2
- package/commonjs/Select/index.js +3 -1
- package/commonjs/Stack/index.js +3 -1
- package/commonjs/Switch/index.js +3 -1
- package/commonjs/Switch/styles.js +1 -1
- package/commonjs/Table/index.js +10 -5
- package/commonjs/TableCell/index.js +3 -1
- package/commonjs/TableHeaderCell/index.js +3 -1
- package/commonjs/TableRowAccordion/index.js +3 -1
- package/commonjs/Tabs/index.js +5 -2
- package/commonjs/Tabs/styles.js +4 -4
- package/commonjs/Text/index.js +3 -1
- package/commonjs/Text/styles.js +1 -1
- package/commonjs/Textarea/index.js +3 -1
- package/commonjs/Toast/index.js +15 -15
- package/commonjs/Toast/styles.js +4 -7
- package/commonjs/ToggleHint/index.js +3 -1
- package/commonjs/Token/index.js +3 -1
- package/commonjs/Token/styles.js +1 -1
- package/commonjs/TokenInput/index.js +3 -1
- package/commonjs/Tooltip/index.js +5 -2
- package/commonjs/Tooltip/styles.js +1 -1
- package/commonjs/VisuallyHidden/index.js +1 -1
- package/commonjs/index.js +1 -1
- package/commonjs/themes/dark/decorative-palettes.js +1 -1
- package/commonjs/themes/dark/theme.js +1 -1
- package/commonjs/themes/light/decorative-palettes.js +1 -1
- package/commonjs/themes/light/literal-colors.js +4 -2
- package/commonjs/themes/light/theme.js +1 -1
- package/commonjs/types/theme.colors.flow.js +2 -0
- package/commonjs/utils/hooks.js +3 -2
- package/commonjs/utils/mixins.js +1 -1
- package/commonjs/utils/system-props.js +1 -1
- package/dist/themes/dark/dark.scss +9 -7
- package/dist/themes/light/light.scss +99 -97
- package/lib/Avatar/index.js +7 -4
- package/lib/Badge/constants.js +38 -0
- package/lib/Badge/index.js +39 -38
- package/lib/Badge/styles.js +13 -28
- package/lib/Banner/index.js +3 -1
- package/lib/Banner/styles.js +1 -1
- package/lib/Box/styles.js +1 -1
- package/lib/Breadcrumb/index.js +5 -2
- package/lib/Button/index.js +3 -1
- package/lib/Card/index.js +3 -1
- package/lib/Card/styles.js +2 -2
- package/lib/CharacterCounter/index.js +3 -1
- package/lib/CharacterCounter/styles.js +1 -1
- package/lib/ChartLegend/index.js +3 -1
- package/lib/ChartLegend/styles.js +3 -3
- package/lib/Checkbox/index.js +3 -1
- package/lib/Collapsible/index.js +5 -2
- package/lib/DatePicker/DateRangePicker.js +3 -1
- package/lib/DatePicker/SingleDatePicker.js +3 -1
- package/lib/DatePicker/StatefulDateRangePicker.js +3 -1
- package/lib/DatePicker/StatefulSingleDatePicker.js +3 -1
- package/lib/DatePicker/styles.js +2 -6
- package/lib/Drawer/SlideTransition.js +3 -1
- package/lib/Drawer/index.js +9 -4
- package/lib/Drawer/styles.js +2 -2
- package/lib/EmptyState/index.js +3 -1
- package/lib/Fieldset/index.js +7 -3
- package/lib/FormField/index.js +3 -1
- package/lib/Icon/index.js +5 -2
- package/lib/Icon/styles.js +1 -1
- package/lib/Image/index.js +3 -1
- package/lib/Image/styles.js +1 -1
- package/lib/Indicator/index.js +3 -1
- package/lib/Input/index.js +3 -1
- package/lib/Input/styles.js +2 -2
- package/lib/KeyboardKey/index.js +3 -1
- package/lib/Label/index.js +4 -2
- package/lib/Link/index.js +3 -1
- package/lib/Link/styles.js +1 -1
- package/lib/Listbox/index.js +6 -3
- package/lib/Loader/index.js +3 -1
- package/lib/Loader/styles.js +2 -2
- package/lib/LoaderButton/index.js +3 -1
- package/lib/Menu/descendants.js +5 -2
- package/lib/Menu/index.js +20 -16
- package/lib/Menu/styles.js +2 -2
- package/lib/Message/index.js +3 -1
- package/lib/Modal/index.js +7 -3
- package/lib/Modal/styles.js +3 -5
- package/lib/Numeral/index.js +3 -1
- package/lib/Numeral/styles.js +2 -2
- package/lib/OverflowList/styles.js +1 -1
- package/lib/Popout/index.js +7 -3
- package/lib/Popout/styles.js +1 -1
- package/lib/Radio/index.js +3 -1
- package/lib/Radio/styles.js +4 -4
- package/lib/SegmentedControl/index.js +5 -2
- package/lib/Select/index.js +3 -1
- package/lib/Stack/index.js +3 -1
- package/lib/Switch/index.js +3 -1
- package/lib/Switch/styles.js +1 -1
- package/lib/Table/index.js +9 -4
- package/lib/TableCell/index.js +3 -1
- package/lib/TableHeaderCell/index.js +3 -1
- package/lib/TableRowAccordion/index.js +3 -1
- package/lib/Tabs/index.js +5 -2
- package/lib/Tabs/styles.js +3 -3
- package/lib/Text/index.js +3 -1
- package/lib/Text/styles.js +1 -1
- package/lib/Textarea/index.js +3 -1
- package/lib/Toast/index.js +14 -14
- package/lib/Toast/styles.js +3 -7
- package/lib/ToggleHint/index.js +3 -1
- package/lib/Token/index.js +3 -1
- package/lib/Token/styles.js +1 -1
- package/lib/TokenInput/index.js +3 -1
- package/lib/Tooltip/index.js +5 -2
- package/lib/Tooltip/styles.js +1 -1
- package/lib/VisuallyHidden/index.js +1 -1
- package/lib/themes/light/literal-colors.js +4 -2
- package/lib/types/theme.colors.flow.js +2 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//@flow
|
|
2
|
+
|
|
3
|
+
const defaultPurple = {
|
|
4
|
+
color: "colors.text.body",
|
|
5
|
+
background: "colors.container.background.decorative.purple",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const suggestion = {
|
|
9
|
+
color: "colors.text.body",
|
|
10
|
+
background: "colors.container.background.decorative.blue",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const passive = {
|
|
14
|
+
color: "colors.text.body",
|
|
15
|
+
background: "colors.container.background.decorative.neutral",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const primary = {
|
|
19
|
+
color: "colors.text.body",
|
|
20
|
+
background: "colors.container.background.decorative.blue",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const secondary = {
|
|
24
|
+
color: "colors.text.body",
|
|
25
|
+
background: "colors.container.background.decorative.yellow",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const common = {
|
|
29
|
+
color: "colors.text.inverse",
|
|
30
|
+
background: "colors.aqua.600",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const approval = {
|
|
34
|
+
color: "colors.text.body",
|
|
35
|
+
background: "colors.container.background.decorative.orange",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//Deprecated former "types"
|
|
39
|
+
|
|
40
|
+
export const legacyBadgeColors = {
|
|
41
|
+
primary,
|
|
42
|
+
secondary,
|
|
43
|
+
passive,
|
|
44
|
+
common,
|
|
45
|
+
approval,
|
|
46
|
+
default: defaultPurple,
|
|
47
|
+
suggestion,
|
|
48
|
+
};
|
package/__flow__/Badge/index.js
CHANGED
|
@@ -1,43 +1,69 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import Icon from "../Icon";
|
|
3
4
|
import Container from "./styles";
|
|
5
|
+
import Box from "../Box";
|
|
4
6
|
|
|
5
7
|
type TypeProps = {
|
|
8
|
+
children?: React.Node,
|
|
9
|
+
/** DEPRECATED: Use children instead of text */
|
|
6
10
|
text: React.Node,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
| "
|
|
10
|
-
| "
|
|
11
|
-
| "
|
|
12
|
-
| "
|
|
13
|
-
| "
|
|
14
|
-
| "
|
|
15
|
-
|
|
11
|
+
size?: "small" | "large" | "default",
|
|
12
|
+
badgeColor?:
|
|
13
|
+
| "green"
|
|
14
|
+
| "blue"
|
|
15
|
+
| "purple"
|
|
16
|
+
| "yellow"
|
|
17
|
+
| "orange"
|
|
18
|
+
| "red"
|
|
19
|
+
| "neutral",
|
|
20
|
+
iconName?: string,
|
|
21
|
+
/** DEPRECATED: Possibly only used for testing. Refrain from using at all if possible. (optional) */
|
|
16
22
|
tip?: React.Node,
|
|
23
|
+
/** DEPRECATED: The legacy method of choosing a theme. Use badgeColor instead. (optional) */
|
|
24
|
+
type?: string,
|
|
17
25
|
};
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
data-tip={tip}
|
|
33
|
-
data-qa-badge={text || ""}
|
|
34
|
-
data-qa-badge-type={type}
|
|
35
|
-
data-qa-badge-tip={tip || ""}
|
|
36
|
-
// $FlowIssue - upgrade v0.112.0
|
|
37
|
-
{...rest}
|
|
38
|
-
>
|
|
39
|
-
{text}
|
|
40
|
-
</Container>
|
|
27
|
+
const Badge = ({
|
|
28
|
+
children,
|
|
29
|
+
text,
|
|
30
|
+
iconName,
|
|
31
|
+
type,
|
|
32
|
+
tip,
|
|
33
|
+
size = "small",
|
|
34
|
+
badgeColor = "blue",
|
|
35
|
+
...rest
|
|
36
|
+
}: TypeProps) => {
|
|
37
|
+
if (children && text) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"can't use both `children` and `text` props. Text is deprecated, consider using children."
|
|
41
40
|
);
|
|
42
41
|
}
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Container
|
|
45
|
+
{...rest}
|
|
46
|
+
// size previously included default, which currently maps to small. Once consumers have updated this can be simplified.
|
|
47
|
+
size={size === "default" ? "large" : size}
|
|
48
|
+
badgeColor={badgeColor}
|
|
49
|
+
data-tip={tip}
|
|
50
|
+
data-qa-badge={text || ""}
|
|
51
|
+
data-qa-badge-type={type}
|
|
52
|
+
data-qa-badge-tip={tip || ""}
|
|
53
|
+
type={type && type}
|
|
54
|
+
>
|
|
55
|
+
<Box display="flex" alignItems="center" JustifyContent="center">
|
|
56
|
+
{iconName ? (
|
|
57
|
+
<Icon
|
|
58
|
+
mr={200}
|
|
59
|
+
name={iconName}
|
|
60
|
+
size={size === "small" ? "mini" : "default"}
|
|
61
|
+
/>
|
|
62
|
+
) : null}
|
|
63
|
+
{children || text}
|
|
64
|
+
</Box>
|
|
65
|
+
</Container>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default Badge;
|
|
@@ -1,53 +1,40 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { text } from "@storybook/addon-knobs";
|
|
3
2
|
import Badge from "./index";
|
|
3
|
+
import Box from "../Box";
|
|
4
|
+
import Numeral from "../Numeral";
|
|
5
|
+
import Text from "../Text";
|
|
6
|
+
import Stack from "../Stack";
|
|
4
7
|
|
|
5
8
|
export default {
|
|
6
9
|
title: "Badge",
|
|
7
10
|
};
|
|
8
11
|
|
|
9
12
|
export const permutations = () => (
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
size={text("size", "small")}
|
|
36
|
-
/>
|
|
37
|
-
<Badge
|
|
38
|
-
text={text("text", "Test")}
|
|
39
|
-
type="suggestion"
|
|
40
|
-
size={text("size", "small")}
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
<Badge text={text("text", "Test")} type="default" />
|
|
44
|
-
<Badge text={text("text", "Test")} />
|
|
45
|
-
<Badge text={text("text", "Test")} type="secondary" />
|
|
46
|
-
<Badge text={text("text", "Test")} type="passive" />
|
|
47
|
-
<Badge text={text("text", "Test")} type="common" />
|
|
48
|
-
<Badge text={text("text", "Test")} type="approval" />
|
|
49
|
-
<Badge text={text("text", "Test")} type="suggestion" />
|
|
50
|
-
</>
|
|
13
|
+
<Stack space={450}>
|
|
14
|
+
<Box display="flex" alignItems="center">
|
|
15
|
+
<Badge badgeColor="green">Badge</Badge>
|
|
16
|
+
<Badge>Badge</Badge>
|
|
17
|
+
<Badge badgeColor="purple">Badge</Badge>
|
|
18
|
+
<Badge badgeColor="yellow">Badge</Badge>
|
|
19
|
+
<Badge badgeColor="orange">Badge</Badge>
|
|
20
|
+
<Badge badgeColor="red">Badge</Badge>
|
|
21
|
+
<Badge badgeColor="neutral" iconName="atom">
|
|
22
|
+
Badge
|
|
23
|
+
</Badge>
|
|
24
|
+
<Badge bg="chartreuse" color="crimson">
|
|
25
|
+
Radical overrides!
|
|
26
|
+
</Badge>
|
|
27
|
+
</Box>
|
|
28
|
+
<Box display="flex" alignItems="center">
|
|
29
|
+
<Badge size="large" type="secondary" iconName="sparkles">
|
|
30
|
+
Supports legacy types
|
|
31
|
+
</Badge>
|
|
32
|
+
<Badge size="large">
|
|
33
|
+
<Numeral fontWeight="bold" number={1569241} />
|
|
34
|
+
<Text ml={200}>and children!</Text>
|
|
35
|
+
</Badge>
|
|
36
|
+
</Box>
|
|
37
|
+
</Stack>
|
|
51
38
|
);
|
|
52
39
|
|
|
53
40
|
permutations.story = {
|
|
@@ -3,48 +3,50 @@ import Badge from "./";
|
|
|
3
3
|
import { render } from "../utils/react-testing-library";
|
|
4
4
|
import "jest-styled-components";
|
|
5
5
|
|
|
6
|
-
describe("
|
|
7
|
-
it("should render with default props", () => {
|
|
8
|
-
const { getByText
|
|
6
|
+
describe("Badge...", () => {
|
|
7
|
+
it("...should render with default props", () => {
|
|
8
|
+
const { getByText } = render(<Badge>Test</Badge>);
|
|
9
9
|
expect(getByText("Test")).toBeTruthy();
|
|
10
|
-
expect(
|
|
10
|
+
expect(getByText("Test").closest("span")).toHaveStyleRule(
|
|
11
|
+
"padding",
|
|
12
|
+
"0px 4px"
|
|
13
|
+
);
|
|
14
|
+
expect(getByText("Test").closest("span")).toHaveStyleRule(
|
|
15
|
+
"background",
|
|
16
|
+
"#dcf2ff"
|
|
17
|
+
);
|
|
11
18
|
});
|
|
12
19
|
|
|
13
|
-
it("should render with correct size styling", () => {
|
|
14
|
-
const { getByText } = render(<Badge
|
|
15
|
-
expect(getByText("Test")).toHaveStyleRule("padding", "
|
|
20
|
+
it("...should render with correct size styling", () => {
|
|
21
|
+
const { getByText } = render(<Badge size="large">Test</Badge>);
|
|
22
|
+
expect(getByText("Test").closest("span")).toHaveStyleRule("padding", "8px");
|
|
16
23
|
});
|
|
17
24
|
|
|
18
|
-
it("should render with
|
|
19
|
-
const { getByText
|
|
20
|
-
<Badge text="Test" type="secondary" />
|
|
21
|
-
);
|
|
25
|
+
it("...should render with legacy type", () => {
|
|
26
|
+
const { getByText } = render(<Badge type="secondary">Test</Badge>);
|
|
22
27
|
expect(getByText("Test")).toBeTruthy();
|
|
23
|
-
expect(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
expect(getByText("Test").closest("span")).toHaveStyleRule(
|
|
29
|
+
"color",
|
|
30
|
+
"#364141"
|
|
31
|
+
);
|
|
32
|
+
expect(getByText("Test").closest("span")).toHaveStyleRule(
|
|
33
|
+
"background",
|
|
34
|
+
"#fdefcd"
|
|
29
35
|
);
|
|
30
|
-
expect(getByText("Test")).toBeTruthy();
|
|
31
|
-
expect(getByDataQaLabel({ "badge-type": "passive" })).toBeTruthy();
|
|
32
36
|
});
|
|
33
37
|
|
|
34
|
-
it("should render with
|
|
35
|
-
const { getByText
|
|
36
|
-
<Badge text="Test" type="common" />
|
|
37
|
-
);
|
|
38
|
+
it("...should render with a badge color", () => {
|
|
39
|
+
const { getByText } = render(<Badge badgeColor="purple">Test</Badge>);
|
|
38
40
|
expect(getByText("Test")).toBeTruthy();
|
|
39
|
-
expect(
|
|
41
|
+
expect(getByText("Test").closest("span")).toHaveStyleRule(
|
|
42
|
+
"background",
|
|
43
|
+
"#eaeaf9"
|
|
44
|
+
);
|
|
40
45
|
});
|
|
41
46
|
|
|
42
|
-
it("should render with
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
);
|
|
46
|
-
expect(getByText("Test")).toBeTruthy();
|
|
47
|
-
expect(getByDataQaLabel({ "badge-type": "approval" })).toBeTruthy();
|
|
47
|
+
it("...should render with an icon", () => {
|
|
48
|
+
const { container } = render(<Badge iconName="sparkles">Test</Badge>);
|
|
49
|
+
expect(container.querySelector("svg")).toBeTruthy();
|
|
48
50
|
});
|
|
49
51
|
it("should render with suggestion type", () => {
|
|
50
52
|
const { getByText, getByDataQaLabel } = render(
|
|
@@ -54,9 +56,9 @@ describe("Racine Badge", () => {
|
|
|
54
56
|
expect(getByDataQaLabel({ "badge-type": "suggestion" })).toBeTruthy();
|
|
55
57
|
});
|
|
56
58
|
|
|
57
|
-
it("should render with tooltip class", () => {
|
|
59
|
+
it("...should render with tooltip class", () => {
|
|
58
60
|
const { getByText, getByDataQaLabel } = render(
|
|
59
|
-
<Badge
|
|
61
|
+
<Badge tip="test tip">Test</Badge>
|
|
60
62
|
);
|
|
61
63
|
expect(getByText("Test")).toBeTruthy();
|
|
62
64
|
expect(getByDataQaLabel({ "badge-tip": "test tip" })).toBeTruthy();
|
package/__flow__/Badge/styles.js
CHANGED
|
@@ -1,51 +1,31 @@
|
|
|
1
1
|
//@flow
|
|
2
|
-
import styled, {
|
|
2
|
+
import styled, { type StyledComponent } from "styled-components";
|
|
3
3
|
import { COMMON } from "../utils/system-props";
|
|
4
|
-
import { themeGet } from "@styled-system/theme-get";
|
|
5
|
-
|
|
6
4
|
import type { TypeTheme } from "../types/theme.flow";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
primary: "colors.neutral.0",
|
|
10
|
-
secondary: "colors.neutral.800",
|
|
11
|
-
passive: "colors.neutral.800",
|
|
12
|
-
common: "colors.neutral.0",
|
|
13
|
-
approval: "colors.neutral.800",
|
|
14
|
-
default: "colors.neutral.0",
|
|
15
|
-
suggestion: "colors.neutral.900",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const backgroundColors = {
|
|
19
|
-
primary: "colors.blue.700",
|
|
20
|
-
secondary: "colors.yellow.500",
|
|
21
|
-
passive: "colors.neutral.200",
|
|
22
|
-
common: "colors.aqua.600",
|
|
23
|
-
approval: "colors.orange.300",
|
|
24
|
-
default: "colors.purple.700",
|
|
25
|
-
suggestion: "colors.blue.300",
|
|
26
|
-
};
|
|
5
|
+
import { themeGet } from "@styled-system/theme-get";
|
|
6
|
+
import { legacyBadgeColors } from "./constants";
|
|
27
7
|
|
|
28
8
|
// eslint-disable-next-line prettier/prettier
|
|
29
|
-
const Container: StyledComponent<{type:
|
|
9
|
+
const Container: StyledComponent<{type: ?string, badgeColor: string, size: string, ...}, TypeTheme, *> = styled.span`
|
|
10
|
+
font-family: ${(p) => p.theme.fontFamily};
|
|
11
|
+
${(p) =>
|
|
12
|
+
p.size === "small" ? p.theme.typography[100] : p.theme.typography[200]};
|
|
13
|
+
border-radius: 9999px;
|
|
14
|
+
line-height: 16px;
|
|
30
15
|
display: inline-block;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
?
|
|
38
|
-
:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
${
|
|
44
|
-
color: ${themeGet(colors[props.type])(props)};
|
|
45
|
-
background: ${themeGet(backgroundColors[props.type])(props)};
|
|
46
|
-
`}
|
|
47
|
-
|
|
48
|
-
${COMMON}
|
|
16
|
+
color: ${(p) =>
|
|
17
|
+
p.type
|
|
18
|
+
? themeGet(legacyBadgeColors[p.type].color)
|
|
19
|
+
: p.theme.colors.text.body};
|
|
20
|
+
background: ${(p) =>
|
|
21
|
+
p.type
|
|
22
|
+
? themeGet(legacyBadgeColors[p.type].background)
|
|
23
|
+
: p.theme.colors.container.background.decorative[p.badgeColor]};
|
|
24
|
+
padding: ${(p) =>
|
|
25
|
+
p.size === "small"
|
|
26
|
+
? `${p.theme.space[0]} ${p.theme.space[200]}`
|
|
27
|
+
: `${p.theme.space[300]}`};
|
|
28
|
+
${COMMON};
|
|
49
29
|
`;
|
|
50
30
|
|
|
51
31
|
export default Container;
|
|
@@ -15,6 +15,7 @@ const literalColors = {
|
|
|
15
15
|
"800": COLORS.COLOR_NEUTRAL_800,
|
|
16
16
|
"900": COLORS.COLOR_NEUTRAL_900,
|
|
17
17
|
"1000": COLORS.COLOR_NEUTRAL_1000,
|
|
18
|
+
"1100": COLORS.COLOR_NEUTRAL_1100,
|
|
18
19
|
},
|
|
19
20
|
green: {
|
|
20
21
|
"0": COLORS.COLOR_GREEN_0,
|
|
@@ -42,6 +43,7 @@ const literalColors = {
|
|
|
42
43
|
"800": COLORS.COLOR_RED_800,
|
|
43
44
|
"900": COLORS.COLOR_RED_900,
|
|
44
45
|
"1000": COLORS.COLOR_RED_1000,
|
|
46
|
+
"1100": COLORS.COLOR_RED_1100,
|
|
45
47
|
},
|
|
46
48
|
blue: {
|
|
47
49
|
"0": COLORS.COLOR_BLUE_0,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
|
|
3
3
|
import literalColors from "../themes/light/literal-colors";
|
|
4
|
+
import { datavizPalette } from "../themes/light/dataviz-palette";
|
|
4
5
|
|
|
5
6
|
type TypeAppColors = {|
|
|
6
7
|
app: {
|
|
@@ -170,6 +171,7 @@ type TypeIconColors = {|
|
|
|
170
171
|
danger: string,
|
|
171
172
|
info: string,
|
|
172
173
|
opportunity: string,
|
|
174
|
+
applied: string,
|
|
173
175
|
positive_sentiment: string,
|
|
174
176
|
negative_sentiment: string,
|
|
175
177
|
neutral_sentiment: string,
|
|
@@ -204,6 +206,28 @@ type TypeListItemColors = {|
|
|
|
204
206
|
},
|
|
205
207
|
|};
|
|
206
208
|
|
|
209
|
+
type TypeOverlayColors = {|
|
|
210
|
+
overlay: {
|
|
211
|
+
background: {
|
|
212
|
+
base: string,
|
|
213
|
+
},
|
|
214
|
+
text: {
|
|
215
|
+
base: string,
|
|
216
|
+
},
|
|
217
|
+
icon: {
|
|
218
|
+
base: string,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
|};
|
|
222
|
+
|
|
223
|
+
type TypeElevationColors = {|
|
|
224
|
+
elevation: {
|
|
225
|
+
base: string,
|
|
226
|
+
},
|
|
227
|
+
|};
|
|
228
|
+
|
|
229
|
+
type TypeDatavizColors = typeof datavizPalette;
|
|
230
|
+
|
|
207
231
|
type TypeNetworkColors = {|
|
|
208
232
|
network: {
|
|
209
233
|
twitter: string,
|
|
@@ -245,6 +269,9 @@ export type TypeColors = {
|
|
|
245
269
|
...TypeIconColors,
|
|
246
270
|
...TypeFormColors,
|
|
247
271
|
...TypeListItemColors,
|
|
272
|
+
...TypeOverlayColors,
|
|
273
|
+
...TypeElevationColors,
|
|
274
|
+
...TypeDatavizColors,
|
|
248
275
|
...TypeNetworkColors,
|
|
249
276
|
...TypeLiteralColors,
|
|
250
277
|
};
|
package/bin/buildNpm.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file handles the generation of an .npmrc with Jfrog credentials during the CI process.
|
|
3
|
+
* It replicates the local configuration requirements of a developer running `yarn` on their machine
|
|
4
|
+
* If run locally please do not commit your auth credentials
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const https = require("https");
|
|
8
|
+
const { exit } = require("process");
|
|
9
|
+
|
|
10
|
+
const { ARTIFACTORY_KEY, CI } = process.env;
|
|
11
|
+
|
|
12
|
+
// Check if we're in CI context, otherwise skip the process
|
|
13
|
+
if (!CI) {
|
|
14
|
+
exit();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const options = {
|
|
18
|
+
hostname: "sproutsocial.jfrog.io",
|
|
19
|
+
path: "/artifactory/api/npm/auth",
|
|
20
|
+
method: "GET",
|
|
21
|
+
headers: {
|
|
22
|
+
"X-JFrog-Art-Api": ARTIFACTORY_KEY,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const req = https.request(options, (res) => {
|
|
27
|
+
console.log(`statusCode: ${res.statusCode}`);
|
|
28
|
+
|
|
29
|
+
// Call our auth endpoint with environment credentials
|
|
30
|
+
res.on("data", (data) => {
|
|
31
|
+
// Writes out an .npmrc file with the response
|
|
32
|
+
fs.writeFile(".npmrc", data, (err) => {
|
|
33
|
+
if (err) console.log(err);
|
|
34
|
+
else {
|
|
35
|
+
console.log(".npmrc generated successfully!");
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Once the file is created we append the registry info
|
|
40
|
+
fs.appendFile(
|
|
41
|
+
".npmrc",
|
|
42
|
+
"registry=https://sproutsocial.jfrog.io/artifactory/api/npm/npm_virtual",
|
|
43
|
+
function (err) {
|
|
44
|
+
if (err) throw err;
|
|
45
|
+
console.log("Registry Config Added!");
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Finally, we set permissions for the file so that netlify recognizes it
|
|
50
|
+
fs.chmodSync(".npmrc", "0600");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
req.on("error", (error) => {
|
|
55
|
+
console.error(error);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
req.end();
|
package/commonjs/Avatar/index.js
CHANGED
|
@@ -15,6 +15,9 @@ var _Image = _interopRequireDefault(require("../Image"));
|
|
|
15
15
|
|
|
16
16
|
var _Text = _interopRequireDefault(require("../Text"));
|
|
17
17
|
|
|
18
|
+
var _excluded = ["fontSize"],
|
|
19
|
+
_excluded2 = ["appearance", "name", "src", "variant", "type", "size", "bg", "color"];
|
|
20
|
+
|
|
18
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
22
|
|
|
20
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -27,12 +30,12 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
27
30
|
|
|
28
31
|
var AvatarText = (0, _styledComponents.default)(function (_ref) {
|
|
29
32
|
var fontSize = _ref.fontSize,
|
|
30
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
33
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
34
|
|
|
32
35
|
return /*#__PURE__*/React.createElement(_Text.default, rest);
|
|
33
36
|
}).withConfig({
|
|
34
37
|
displayName: "Avatar__AvatarText",
|
|
35
|
-
componentId: "yx873f-0"
|
|
38
|
+
componentId: "sc-yx873f-0"
|
|
36
39
|
})(["font-size:", "px;color:", "px;"], function (props) {
|
|
37
40
|
return props.fontSize;
|
|
38
41
|
}, function (props) {
|
|
@@ -40,7 +43,7 @@ var AvatarText = (0, _styledComponents.default)(function (_ref) {
|
|
|
40
43
|
});
|
|
41
44
|
var Container = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
42
45
|
displayName: "Avatar__Container",
|
|
43
|
-
componentId: "yx873f-1"
|
|
46
|
+
componentId: "sc-yx873f-1"
|
|
44
47
|
})(["", ""], function (_ref2) {
|
|
45
48
|
var theme = _ref2.theme,
|
|
46
49
|
type = _ref2.type,
|
|
@@ -75,7 +78,7 @@ var Avatar = function Avatar(_ref3) {
|
|
|
75
78
|
size = _ref3$size === void 0 ? "40px" : _ref3$size,
|
|
76
79
|
bg = _ref3.bg,
|
|
77
80
|
color = _ref3.color,
|
|
78
|
-
rest = _objectWithoutPropertiesLoose(_ref3,
|
|
81
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded2);
|
|
79
82
|
|
|
80
83
|
var _useState = (0, React.useState)(false),
|
|
81
84
|
imageFailedLoading = _useState[0],
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.legacyBadgeColors = void 0;
|
|
5
|
+
var defaultPurple = {
|
|
6
|
+
color: "colors.text.body",
|
|
7
|
+
background: "colors.container.background.decorative.purple"
|
|
8
|
+
};
|
|
9
|
+
var suggestion = {
|
|
10
|
+
color: "colors.text.body",
|
|
11
|
+
background: "colors.container.background.decorative.blue"
|
|
12
|
+
};
|
|
13
|
+
var passive = {
|
|
14
|
+
color: "colors.text.body",
|
|
15
|
+
background: "colors.container.background.decorative.neutral"
|
|
16
|
+
};
|
|
17
|
+
var primary = {
|
|
18
|
+
color: "colors.text.body",
|
|
19
|
+
background: "colors.container.background.decorative.blue"
|
|
20
|
+
};
|
|
21
|
+
var secondary = {
|
|
22
|
+
color: "colors.text.body",
|
|
23
|
+
background: "colors.container.background.decorative.yellow"
|
|
24
|
+
};
|
|
25
|
+
var common = {
|
|
26
|
+
color: "colors.text.inverse",
|
|
27
|
+
background: "colors.aqua.600"
|
|
28
|
+
};
|
|
29
|
+
var approval = {
|
|
30
|
+
color: "colors.text.body",
|
|
31
|
+
background: "colors.container.background.decorative.orange"
|
|
32
|
+
}; //Deprecated former "types"
|
|
33
|
+
|
|
34
|
+
var legacyBadgeColors = {
|
|
35
|
+
primary: primary,
|
|
36
|
+
secondary: secondary,
|
|
37
|
+
passive: passive,
|
|
38
|
+
common: common,
|
|
39
|
+
approval: approval,
|
|
40
|
+
default: defaultPurple,
|
|
41
|
+
suggestion: suggestion
|
|
42
|
+
};
|
|
43
|
+
exports.legacyBadgeColors = legacyBadgeColors;
|