@sproutsocial/seeds-react-progress 0.2.7 → 0.2.9
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +13 -0
- package/dist/esm/index.js +74 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +76 -8
- package/dist/index.js.map +1 -1
- package/dist/progress.css +29 -0
- package/package.json +4 -4
- package/postcss.config.js +6 -0
- package/src/Progress.stories.tsx +15 -0
- package/src/Progress.tsx +10 -28
- package/src/ProgressHybrid.tsx +48 -0
- package/src/ProgressTailwind.tsx +67 -0
- package/src/__tests__/Progress.test.tsx +24 -0
- package/src/__tests__/displayName.test.tsx +11 -0
- package/src/css.d.ts +1 -0
- package/src/progress.css +29 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
yarn run v1.22.22
|
|
2
|
-
$ tsup --dts
|
|
2
|
+
$ tsup --dts && cp src/progress.css dist/progress.css
|
|
3
3
|
[34mCLI[39m Building entry: src/index.ts
|
|
4
4
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
5
|
[34mCLI[39m tsup v8.5.0
|
|
@@ -8,14 +8,14 @@ $ tsup --dts
|
|
|
8
8
|
[34mCLI[39m Cleaning output folder
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
12
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
-
[32mESM[39m [1mdist/esm/index.js [22m[
|
|
15
|
-
[32mESM[39m [1mdist/esm/index.js.map [22m[
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m5.25 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m7.81 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 46ms
|
|
14
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m3.23 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m7.65 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 46ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.
|
|
21
|
-
Done in
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 5377ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.42 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.42 KB[39m
|
|
21
|
+
Done in 6.46s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-progress
|
|
2
2
|
|
|
3
|
+
## 0.2.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0e113bc: Migrate progress, token, select, spot-illustration, and collapsible to the Button hybrid Tailwind pattern. Each component now ships a CSS-class implementation routed alongside the styled-components path. Component CSS is wrapped in `@layer components` so Tailwind utility classes win the cascade and can override component styles via `className`. `Collapsible.Panel` now forwards `className` onto the panel root so utility overrides reach the styled element.
|
|
8
|
+
|
|
9
|
+
## 0.2.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [a13a571]
|
|
14
|
+
- @sproutsocial/seeds-react-theme@4.1.1
|
|
15
|
+
|
|
3
16
|
## 0.2.7
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// src/Progress.tsx
|
|
2
2
|
import "react";
|
|
3
3
|
|
|
4
|
+
// src/ProgressHybrid.tsx
|
|
5
|
+
import "react";
|
|
6
|
+
|
|
4
7
|
// src/styles.ts
|
|
5
8
|
import styled from "styled-components";
|
|
6
9
|
import * as Progress from "@radix-ui/react-progress";
|
|
@@ -25,29 +28,50 @@ var StyledIndicator = styled(Progress.Indicator)`
|
|
|
25
28
|
transition: transform 150ms ease;
|
|
26
29
|
`;
|
|
27
30
|
|
|
28
|
-
// src/
|
|
31
|
+
// src/ProgressTailwind.tsx
|
|
32
|
+
import "react";
|
|
33
|
+
import * as RadixProgress from "@radix-ui/react-progress";
|
|
29
34
|
import { jsx } from "react/jsx-runtime";
|
|
30
|
-
|
|
35
|
+
function cn(...inputs) {
|
|
36
|
+
const classes = [];
|
|
37
|
+
for (const input of inputs) {
|
|
38
|
+
if (!input) continue;
|
|
39
|
+
if (typeof input === "string") {
|
|
40
|
+
classes.push(input);
|
|
41
|
+
} else if (typeof input === "object") {
|
|
42
|
+
for (const [key, value] of Object.entries(input)) {
|
|
43
|
+
if (value) {
|
|
44
|
+
classes.push(key);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return classes.join(" ");
|
|
50
|
+
}
|
|
51
|
+
var ProgressTailwind = ({
|
|
31
52
|
value,
|
|
32
53
|
max = 100,
|
|
33
54
|
getValueLabel,
|
|
34
55
|
trackStyle,
|
|
35
56
|
indicatorStyle,
|
|
57
|
+
className,
|
|
36
58
|
...rest
|
|
37
59
|
}) => {
|
|
38
60
|
const percentage = max > 0 ? Math.min(value / max * 100, 100) : 0;
|
|
39
61
|
return /* @__PURE__ */ jsx(
|
|
40
|
-
|
|
62
|
+
RadixProgress.Root,
|
|
41
63
|
{
|
|
42
64
|
value,
|
|
43
65
|
max,
|
|
44
66
|
getValueLabel,
|
|
67
|
+
className: cn("Progress", "seeds-progress", className),
|
|
45
68
|
"data-qa-progress": "",
|
|
46
69
|
style: trackStyle,
|
|
47
70
|
...rest,
|
|
48
71
|
children: /* @__PURE__ */ jsx(
|
|
49
|
-
|
|
72
|
+
RadixProgress.Indicator,
|
|
50
73
|
{
|
|
74
|
+
className: "seeds-progress-indicator",
|
|
51
75
|
style: {
|
|
52
76
|
transform: `translateX(-${100 - percentage}%)`,
|
|
53
77
|
...indicatorStyle
|
|
@@ -57,14 +81,58 @@ var Progress2 = ({
|
|
|
57
81
|
}
|
|
58
82
|
);
|
|
59
83
|
};
|
|
84
|
+
ProgressTailwind.displayName = "ProgressTailwind";
|
|
85
|
+
|
|
86
|
+
// src/ProgressHybrid.tsx
|
|
87
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
88
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
89
|
+
var Progress2 = (props) => {
|
|
90
|
+
const {
|
|
91
|
+
value,
|
|
92
|
+
max = 100,
|
|
93
|
+
getValueLabel,
|
|
94
|
+
trackStyle,
|
|
95
|
+
indicatorStyle,
|
|
96
|
+
...rest
|
|
97
|
+
} = props;
|
|
98
|
+
if (hasStyledProps(rest)) {
|
|
99
|
+
const percentage = max > 0 ? Math.min(value / max * 100, 100) : 0;
|
|
100
|
+
return /* @__PURE__ */ jsx2(
|
|
101
|
+
StyledRoot,
|
|
102
|
+
{
|
|
103
|
+
value,
|
|
104
|
+
max,
|
|
105
|
+
getValueLabel,
|
|
106
|
+
"data-qa-progress": "",
|
|
107
|
+
style: trackStyle,
|
|
108
|
+
...rest,
|
|
109
|
+
children: /* @__PURE__ */ jsx2(
|
|
110
|
+
StyledIndicator,
|
|
111
|
+
{
|
|
112
|
+
style: {
|
|
113
|
+
transform: `translateX(-${100 - percentage}%)`,
|
|
114
|
+
...indicatorStyle
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return /* @__PURE__ */ jsx2(ProgressTailwind, { ...props });
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// src/Progress.tsx
|
|
125
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
126
|
+
var Progress3 = (props) => /* @__PURE__ */ jsx3(Progress2, { ...props });
|
|
127
|
+
Progress3.displayName = "Progress";
|
|
60
128
|
|
|
61
129
|
// src/ProgressTypes.ts
|
|
62
130
|
import "react";
|
|
63
131
|
|
|
64
132
|
// src/index.ts
|
|
65
|
-
var index_default =
|
|
133
|
+
var index_default = Progress3;
|
|
66
134
|
export {
|
|
67
|
-
|
|
135
|
+
Progress3 as Progress,
|
|
68
136
|
index_default as default
|
|
69
137
|
};
|
|
70
138
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Progress.tsx","../../src/styles.ts","../../src/ProgressTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { StyledRoot, StyledIndicator } from \"./styles\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\nexport const Progress = ({\n value,\n
|
|
1
|
+
{"version":3,"sources":["../../src/Progress.tsx","../../src/ProgressHybrid.tsx","../../src/styles.ts","../../src/ProgressTailwind.tsx","../../src/ProgressTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Progress as ProgressHybrid } from \"./ProgressHybrid\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\n/**\n * Progress component. Automatically routes between the Tailwind implementation\n * (preferred) and the styled-components implementation (for consumers using\n * system props or styled() extension).\n */\nconst Progress = (props: TypeProgressProps) => <ProgressHybrid {...props} />;\n\nProgress.displayName = \"Progress\";\n\nexport { Progress };\n","/**\n * Hybrid Progress Component\n * Automatically chooses between Tailwind and styled-components based on props.\n * Consumers passing styled-system props (e.g. `mb`, `width`, `bg`) get the\n * styled-components implementation; everyone else gets the Tailwind path.\n */\n\nimport * as React from \"react\";\nimport { StyledRoot, StyledIndicator } from \"./styles\";\nimport { ProgressTailwind } from \"./ProgressTailwind\";\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\nexport const Progress = (props: TypeProgressProps) => {\n const {\n value,\n max = 100,\n getValueLabel,\n trackStyle,\n indicatorStyle,\n ...rest\n } = props;\n\n if (hasStyledProps(rest)) {\n const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0;\n\n return (\n <StyledRoot\n value={value}\n max={max}\n getValueLabel={getValueLabel}\n data-qa-progress=\"\"\n style={trackStyle}\n {...rest}\n >\n <StyledIndicator\n style={{\n transform: `translateX(-${100 - percentage}%)`,\n ...indicatorStyle,\n }}\n />\n </StyledRoot>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return <ProgressTailwind {...props} />;\n};\n","import styled from \"styled-components\";\nimport * as Progress from \"@radix-ui/react-progress\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\n\nexport const StyledRoot = styled(Progress.Root).attrs({\n className: \"Progress\",\n})`\n position: relative;\n overflow: hidden;\n width: 100%;\n height: 8px;\n border-radius: ${(p) => p.theme.radii.outer};\n background-color: ${(p) => p.theme.colors.container.border.base};\n\n ${COMMON}\n`;\n\nexport const StyledIndicator = styled(Progress.Indicator)`\n height: 100%;\n width: 100%;\n border-radius: ${(p) => p.theme.radii.outer};\n background-color: ${(p) => p.theme.colors.icon.base};\n transition: transform 150ms ease;\n`;\n","/**\n * Tailwind CSS implementation of Progress component\n * Uses Seeds progress CSS classes from progress.css\n */\n\nimport * as React from \"react\";\nimport * as RadixProgress from \"@radix-ui/react-progress\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\n// Utility for merging class names properly\nfunction cn(\n ...inputs: (string | undefined | null | false | Record<string, boolean>)[]\n): string {\n const classes: string[] = [];\n\n for (const input of inputs) {\n if (!input) continue;\n\n if (typeof input === \"string\") {\n classes.push(input);\n } else if (typeof input === \"object\") {\n for (const [key, value] of Object.entries(input)) {\n if (value) {\n classes.push(key);\n }\n }\n }\n }\n\n return classes.join(\" \");\n}\n\nexport const ProgressTailwind = ({\n value,\n max = 100,\n getValueLabel,\n trackStyle,\n indicatorStyle,\n className,\n ...rest\n}: TypeProgressProps) => {\n const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0;\n\n return (\n <RadixProgress.Root\n value={value}\n max={max}\n getValueLabel={getValueLabel}\n // Keep the literal \"Progress\" class so existing selectors (e.g. `.Progress`,\n // `.Progress > div`) continue to resolve. seeds-progress carries the styling.\n className={cn(\"Progress\", \"seeds-progress\", className)}\n data-qa-progress=\"\"\n style={trackStyle}\n {...(rest as any)}\n >\n <RadixProgress.Indicator\n className=\"seeds-progress-indicator\"\n style={{\n transform: `translateX(-${100 - percentage}%)`,\n ...indicatorStyle,\n }}\n />\n </RadixProgress.Root>\n );\n};\n\nProgressTailwind.displayName = \"ProgressTailwind\";\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\ntype TypeAriaLabel =\n | { \"aria-label\": string; \"aria-labelledby\"?: string }\n | { \"aria-label\"?: string; \"aria-labelledby\": string };\n\nexport type TypeProgressProps = TypeStyledComponentsCommonProps &\n TypeSystemCommonProps &\n Omit<React.ComponentPropsWithoutRef<\"div\">, \"color\" | \"style\"> &\n TypeAriaLabel & {\n /** The current progress value */\n value: number;\n /** The maximum progress value. Defaults to 100 */\n max?: number;\n /** A function to get the accessible label text representing the current value. Defaults to \"{value}%\" */\n getValueLabel?: (value: number, max: number) => string;\n /** Custom CSS for the track (background) element, e.g. backgroundColor */\n trackStyle?: React.CSSProperties;\n /** Custom CSS for the indicator (fill) element, e.g. a gradient background */\n indicatorStyle?: React.CSSProperties;\n };\n","import { Progress } from \"./Progress\";\n\nexport default Progress;\nexport { Progress };\nexport * from \"./ProgressTypes\";\n"],"mappings":";AAAA,OAAuB;;;ACOvB,OAAuB;;;ACPvB,OAAO,YAAY;AACnB,YAAY,cAAc;AAC1B,SAAS,cAAc;AAEhB,IAAM,aAAa,OAAgB,aAAI,EAAE,MAAM;AAAA,EACpD,WAAW;AACb,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKkB,CAAC,MAAM,EAAE,MAAM,MAAM,KAAK;AAAA,sBACvB,CAAC,MAAM,EAAE,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA;AAAA,IAE7D,MAAM;AAAA;AAGH,IAAM,kBAAkB,OAAgB,kBAAS;AAAA;AAAA;AAAA,mBAGrC,CAAC,MAAM,EAAE,MAAM,MAAM,KAAK;AAAA,sBACvB,CAAC,MAAM,EAAE,MAAM,OAAO,KAAK,IAAI;AAAA;AAAA;;;AChBrD,OAAuB;AACvB,YAAY,mBAAmB;AAiDzB;AA7CN,SAAS,MACJ,QACK;AACR,QAAM,UAAoB,CAAC;AAE3B,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,MAAO;AAEZ,QAAI,OAAO,UAAU,UAAU;AAC7B,cAAQ,KAAK,KAAK;AAAA,IACpB,WAAW,OAAO,UAAU,UAAU;AACpC,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,YAAI,OAAO;AACT,kBAAQ,KAAK,GAAG;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,KAAK,GAAG;AACzB;AAEO,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyB;AACvB,QAAM,aAAa,MAAM,IAAI,KAAK,IAAK,QAAQ,MAAO,KAAK,GAAG,IAAI;AAElE,SACE;AAAA,IAAe;AAAA,IAAd;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MAGA,WAAW,GAAG,YAAY,kBAAkB,SAAS;AAAA,MACrD,oBAAiB;AAAA,MACjB,OAAO;AAAA,MACN,GAAI;AAAA,MAEL;AAAA,QAAe;AAAA,QAAd;AAAA,UACC,WAAU;AAAA,UACV,OAAO;AAAA,YACL,WAAW,eAAe,MAAM,UAAU;AAAA,YAC1C,GAAG;AAAA,UACL;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEA,iBAAiB,cAAc;;;AFxD/B,SAAS,sBAAsB;AAyBvB,gBAAAA,YAAA;AAtBD,IAAMC,YAAW,CAAC,UAA6B;AACpD,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,MAAI,eAAe,IAAI,GAAG;AACxB,UAAM,aAAa,MAAM,IAAI,KAAK,IAAK,QAAQ,MAAO,KAAK,GAAG,IAAI;AAElE,WACE,gBAAAD;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,oBAAiB;AAAA,QACjB,OAAO;AAAA,QACN,GAAG;AAAA,QAEJ,0BAAAA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,WAAW,eAAe,MAAM,UAAU;AAAA,cAC1C,GAAG;AAAA,YACL;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AAGA,SAAO,gBAAAA,KAAC,oBAAkB,GAAG,OAAO;AACtC;;;ADtC+C,gBAAAE,YAAA;AAA/C,IAAMC,YAAW,CAAC,UAA6B,gBAAAD,KAACC,WAAA,EAAgB,GAAG,OAAO;AAE1EA,UAAS,cAAc;;;AIXvB,OAAuB;;;ACEvB,IAAO,gBAAQC;","names":["jsx","Progress","jsx","Progress","Progress"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -22,6 +22,14 @@ type TypeProgressProps = TypeStyledComponentsCommonProps & TypeSystemCommonProps
|
|
|
22
22
|
indicatorStyle?: React.CSSProperties;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Progress component. Automatically routes between the Tailwind implementation
|
|
27
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
28
|
+
* system props or styled() extension).
|
|
29
|
+
*/
|
|
30
|
+
declare const Progress: {
|
|
31
|
+
(props: TypeProgressProps): react_jsx_runtime.JSX.Element;
|
|
32
|
+
displayName: string;
|
|
33
|
+
};
|
|
26
34
|
|
|
27
35
|
export { Progress, type TypeProgressProps, Progress as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,14 @@ type TypeProgressProps = TypeStyledComponentsCommonProps & TypeSystemCommonProps
|
|
|
22
22
|
indicatorStyle?: React.CSSProperties;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Progress component. Automatically routes between the Tailwind implementation
|
|
27
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
28
|
+
* system props or styled() extension).
|
|
29
|
+
*/
|
|
30
|
+
declare const Progress: {
|
|
31
|
+
(props: TypeProgressProps): react_jsx_runtime.JSX.Element;
|
|
32
|
+
displayName: string;
|
|
33
|
+
};
|
|
26
34
|
|
|
27
35
|
export { Progress, type TypeProgressProps, Progress as default };
|
package/dist/index.js
CHANGED
|
@@ -30,13 +30,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
Progress: () =>
|
|
33
|
+
Progress: () => Progress3,
|
|
34
34
|
default: () => index_default
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/Progress.tsx
|
|
39
|
-
var
|
|
39
|
+
var React3 = require("react");
|
|
40
|
+
|
|
41
|
+
// src/ProgressHybrid.tsx
|
|
42
|
+
var React2 = require("react");
|
|
40
43
|
|
|
41
44
|
// src/styles.ts
|
|
42
45
|
var import_styled_components = __toESM(require("styled-components"));
|
|
@@ -62,29 +65,50 @@ var StyledIndicator = (0, import_styled_components.default)(Progress.Indicator)`
|
|
|
62
65
|
transition: transform 150ms ease;
|
|
63
66
|
`;
|
|
64
67
|
|
|
65
|
-
// src/
|
|
68
|
+
// src/ProgressTailwind.tsx
|
|
69
|
+
var React = require("react");
|
|
70
|
+
var RadixProgress = __toESM(require("@radix-ui/react-progress"));
|
|
66
71
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
67
|
-
|
|
72
|
+
function cn(...inputs) {
|
|
73
|
+
const classes = [];
|
|
74
|
+
for (const input of inputs) {
|
|
75
|
+
if (!input) continue;
|
|
76
|
+
if (typeof input === "string") {
|
|
77
|
+
classes.push(input);
|
|
78
|
+
} else if (typeof input === "object") {
|
|
79
|
+
for (const [key, value] of Object.entries(input)) {
|
|
80
|
+
if (value) {
|
|
81
|
+
classes.push(key);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return classes.join(" ");
|
|
87
|
+
}
|
|
88
|
+
var ProgressTailwind = ({
|
|
68
89
|
value,
|
|
69
90
|
max = 100,
|
|
70
91
|
getValueLabel,
|
|
71
92
|
trackStyle,
|
|
72
93
|
indicatorStyle,
|
|
94
|
+
className,
|
|
73
95
|
...rest
|
|
74
96
|
}) => {
|
|
75
97
|
const percentage = max > 0 ? Math.min(value / max * 100, 100) : 0;
|
|
76
98
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
|
-
|
|
99
|
+
RadixProgress.Root,
|
|
78
100
|
{
|
|
79
101
|
value,
|
|
80
102
|
max,
|
|
81
103
|
getValueLabel,
|
|
104
|
+
className: cn("Progress", "seeds-progress", className),
|
|
82
105
|
"data-qa-progress": "",
|
|
83
106
|
style: trackStyle,
|
|
84
107
|
...rest,
|
|
85
108
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
-
|
|
109
|
+
RadixProgress.Indicator,
|
|
87
110
|
{
|
|
111
|
+
className: "seeds-progress-indicator",
|
|
88
112
|
style: {
|
|
89
113
|
transform: `translateX(-${100 - percentage}%)`,
|
|
90
114
|
...indicatorStyle
|
|
@@ -94,12 +118,56 @@ var Progress2 = ({
|
|
|
94
118
|
}
|
|
95
119
|
);
|
|
96
120
|
};
|
|
121
|
+
ProgressTailwind.displayName = "ProgressTailwind";
|
|
122
|
+
|
|
123
|
+
// src/ProgressHybrid.tsx
|
|
124
|
+
var import_seeds_react_system_props2 = require("@sproutsocial/seeds-react-system-props");
|
|
125
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
126
|
+
var Progress2 = (props) => {
|
|
127
|
+
const {
|
|
128
|
+
value,
|
|
129
|
+
max = 100,
|
|
130
|
+
getValueLabel,
|
|
131
|
+
trackStyle,
|
|
132
|
+
indicatorStyle,
|
|
133
|
+
...rest
|
|
134
|
+
} = props;
|
|
135
|
+
if ((0, import_seeds_react_system_props2.hasStyledProps)(rest)) {
|
|
136
|
+
const percentage = max > 0 ? Math.min(value / max * 100, 100) : 0;
|
|
137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
138
|
+
StyledRoot,
|
|
139
|
+
{
|
|
140
|
+
value,
|
|
141
|
+
max,
|
|
142
|
+
getValueLabel,
|
|
143
|
+
"data-qa-progress": "",
|
|
144
|
+
style: trackStyle,
|
|
145
|
+
...rest,
|
|
146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
147
|
+
StyledIndicator,
|
|
148
|
+
{
|
|
149
|
+
style: {
|
|
150
|
+
transform: `translateX(-${100 - percentage}%)`,
|
|
151
|
+
...indicatorStyle
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ProgressTailwind, { ...props });
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// src/Progress.tsx
|
|
162
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
163
|
+
var Progress3 = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Progress2, { ...props });
|
|
164
|
+
Progress3.displayName = "Progress";
|
|
97
165
|
|
|
98
166
|
// src/ProgressTypes.ts
|
|
99
|
-
var
|
|
167
|
+
var React4 = require("react");
|
|
100
168
|
|
|
101
169
|
// src/index.ts
|
|
102
|
-
var index_default =
|
|
170
|
+
var index_default = Progress3;
|
|
103
171
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
172
|
0 && (module.exports = {
|
|
105
173
|
Progress
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/Progress.tsx","../src/styles.ts","../src/ProgressTypes.ts"],"sourcesContent":["import { Progress } from \"./Progress\";\n\nexport default Progress;\nexport { Progress };\nexport * from \"./ProgressTypes\";\n","import * as React from \"react\";\nimport { StyledRoot, StyledIndicator } from \"./styles\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\nexport const Progress = ({\n value,\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Progress.tsx","../src/ProgressHybrid.tsx","../src/styles.ts","../src/ProgressTailwind.tsx","../src/ProgressTypes.ts"],"sourcesContent":["import { Progress } from \"./Progress\";\n\nexport default Progress;\nexport { Progress };\nexport * from \"./ProgressTypes\";\n","import * as React from \"react\";\nimport { Progress as ProgressHybrid } from \"./ProgressHybrid\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\n/**\n * Progress component. Automatically routes between the Tailwind implementation\n * (preferred) and the styled-components implementation (for consumers using\n * system props or styled() extension).\n */\nconst Progress = (props: TypeProgressProps) => <ProgressHybrid {...props} />;\n\nProgress.displayName = \"Progress\";\n\nexport { Progress };\n","/**\n * Hybrid Progress Component\n * Automatically chooses between Tailwind and styled-components based on props.\n * Consumers passing styled-system props (e.g. `mb`, `width`, `bg`) get the\n * styled-components implementation; everyone else gets the Tailwind path.\n */\n\nimport * as React from \"react\";\nimport { StyledRoot, StyledIndicator } from \"./styles\";\nimport { ProgressTailwind } from \"./ProgressTailwind\";\nimport { hasStyledProps } from \"@sproutsocial/seeds-react-system-props\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\nexport const Progress = (props: TypeProgressProps) => {\n const {\n value,\n max = 100,\n getValueLabel,\n trackStyle,\n indicatorStyle,\n ...rest\n } = props;\n\n if (hasStyledProps(rest)) {\n const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0;\n\n return (\n <StyledRoot\n value={value}\n max={max}\n getValueLabel={getValueLabel}\n data-qa-progress=\"\"\n style={trackStyle}\n {...rest}\n >\n <StyledIndicator\n style={{\n transform: `translateX(-${100 - percentage}%)`,\n ...indicatorStyle,\n }}\n />\n </StyledRoot>\n );\n }\n\n // Use Tailwind version (preferred - better performance)\n return <ProgressTailwind {...props} />;\n};\n","import styled from \"styled-components\";\nimport * as Progress from \"@radix-ui/react-progress\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\n\nexport const StyledRoot = styled(Progress.Root).attrs({\n className: \"Progress\",\n})`\n position: relative;\n overflow: hidden;\n width: 100%;\n height: 8px;\n border-radius: ${(p) => p.theme.radii.outer};\n background-color: ${(p) => p.theme.colors.container.border.base};\n\n ${COMMON}\n`;\n\nexport const StyledIndicator = styled(Progress.Indicator)`\n height: 100%;\n width: 100%;\n border-radius: ${(p) => p.theme.radii.outer};\n background-color: ${(p) => p.theme.colors.icon.base};\n transition: transform 150ms ease;\n`;\n","/**\n * Tailwind CSS implementation of Progress component\n * Uses Seeds progress CSS classes from progress.css\n */\n\nimport * as React from \"react\";\nimport * as RadixProgress from \"@radix-ui/react-progress\";\nimport type { TypeProgressProps } from \"./ProgressTypes\";\n\n// Utility for merging class names properly\nfunction cn(\n ...inputs: (string | undefined | null | false | Record<string, boolean>)[]\n): string {\n const classes: string[] = [];\n\n for (const input of inputs) {\n if (!input) continue;\n\n if (typeof input === \"string\") {\n classes.push(input);\n } else if (typeof input === \"object\") {\n for (const [key, value] of Object.entries(input)) {\n if (value) {\n classes.push(key);\n }\n }\n }\n }\n\n return classes.join(\" \");\n}\n\nexport const ProgressTailwind = ({\n value,\n max = 100,\n getValueLabel,\n trackStyle,\n indicatorStyle,\n className,\n ...rest\n}: TypeProgressProps) => {\n const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0;\n\n return (\n <RadixProgress.Root\n value={value}\n max={max}\n getValueLabel={getValueLabel}\n // Keep the literal \"Progress\" class so existing selectors (e.g. `.Progress`,\n // `.Progress > div`) continue to resolve. seeds-progress carries the styling.\n className={cn(\"Progress\", \"seeds-progress\", className)}\n data-qa-progress=\"\"\n style={trackStyle}\n {...(rest as any)}\n >\n <RadixProgress.Indicator\n className=\"seeds-progress-indicator\"\n style={{\n transform: `translateX(-${100 - percentage}%)`,\n ...indicatorStyle,\n }}\n />\n </RadixProgress.Root>\n );\n};\n\nProgressTailwind.displayName = \"ProgressTailwind\";\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\ntype TypeAriaLabel =\n | { \"aria-label\": string; \"aria-labelledby\"?: string }\n | { \"aria-label\"?: string; \"aria-labelledby\": string };\n\nexport type TypeProgressProps = TypeStyledComponentsCommonProps &\n TypeSystemCommonProps &\n Omit<React.ComponentPropsWithoutRef<\"div\">, \"color\" | \"style\"> &\n TypeAriaLabel & {\n /** The current progress value */\n value: number;\n /** The maximum progress value. Defaults to 100 */\n max?: number;\n /** A function to get the accessible label text representing the current value. Defaults to \"{value}%\" */\n getValueLabel?: (value: number, max: number) => string;\n /** Custom CSS for the track (background) element, e.g. backgroundColor */\n trackStyle?: React.CSSProperties;\n /** Custom CSS for the indicator (fill) element, e.g. a gradient background */\n indicatorStyle?: React.CSSProperties;\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kBAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,IAAAC,SAAuB;;;ACOvB,IAAAC,SAAuB;;;ACPvB,+BAAmB;AACnB,eAA0B;AAC1B,sCAAuB;AAEhB,IAAM,iBAAa,yBAAAC,SAAgB,aAAI,EAAE,MAAM;AAAA,EACpD,WAAW;AACb,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKkB,CAAC,MAAM,EAAE,MAAM,MAAM,KAAK;AAAA,sBACvB,CAAC,MAAM,EAAE,MAAM,OAAO,UAAU,OAAO,IAAI;AAAA;AAAA,IAE7D,sCAAM;AAAA;AAGH,IAAM,sBAAkB,yBAAAA,SAAgB,kBAAS;AAAA;AAAA;AAAA,mBAGrC,CAAC,MAAM,EAAE,MAAM,MAAM,KAAK;AAAA,sBACvB,CAAC,MAAM,EAAE,MAAM,OAAO,KAAK,IAAI;AAAA;AAAA;;;AChBrD,YAAuB;AACvB,oBAA+B;AAiDzB;AA7CN,SAAS,MACJ,QACK;AACR,QAAM,UAAoB,CAAC;AAE3B,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,MAAO;AAEZ,QAAI,OAAO,UAAU,UAAU;AAC7B,cAAQ,KAAK,KAAK;AAAA,IACpB,WAAW,OAAO,UAAU,UAAU;AACpC,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,YAAI,OAAO;AACT,kBAAQ,KAAK,GAAG;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,KAAK,GAAG;AACzB;AAEO,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyB;AACvB,QAAM,aAAa,MAAM,IAAI,KAAK,IAAK,QAAQ,MAAO,KAAK,GAAG,IAAI;AAElE,SACE;AAAA,IAAe;AAAA,IAAd;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MAGA,WAAW,GAAG,YAAY,kBAAkB,SAAS;AAAA,MACrD,oBAAiB;AAAA,MACjB,OAAO;AAAA,MACN,GAAI;AAAA,MAEL;AAAA,QAAe;AAAA,QAAd;AAAA,UACC,WAAU;AAAA,UACV,OAAO;AAAA,YACL,WAAW,eAAe,MAAM,UAAU;AAAA,YAC1C,GAAG;AAAA,UACL;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEA,iBAAiB,cAAc;;;AFxD/B,IAAAC,mCAA+B;AAyBvB,IAAAC,sBAAA;AAtBD,IAAMC,YAAW,CAAC,UAA6B;AACpD,QAAM;AAAA,IACJ;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,UAAI,iDAAe,IAAI,GAAG;AACxB,UAAM,aAAa,MAAM,IAAI,KAAK,IAAK,QAAQ,MAAO,KAAK,GAAG,IAAI;AAElE,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,oBAAiB;AAAA,QACjB,OAAO;AAAA,QACN,GAAG;AAAA,QAEJ;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,WAAW,eAAe,MAAM,UAAU;AAAA,cAC1C,GAAG;AAAA,YACL;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,EAEJ;AAGA,SAAO,6CAAC,oBAAkB,GAAG,OAAO;AACtC;;;ADtC+C,IAAAC,sBAAA;AAA/C,IAAMC,YAAW,CAAC,UAA6B,6CAACA,WAAA,EAAgB,GAAG,OAAO;AAE1EA,UAAS,cAAc;;;AIXvB,IAAAC,SAAuB;;;ALEvB,IAAO,gBAAQC;","names":["Progress","React","React","styled","import_seeds_react_system_props","import_jsx_runtime","Progress","import_jsx_runtime","Progress","React","Progress"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds Progress component classes
|
|
3
|
+
* Use these instead of writing out individual Tailwind utility classes.
|
|
4
|
+
*
|
|
5
|
+
* Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
|
|
6
|
+
* CSS variable definitions and dark mode support.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* <div class="Progress seeds-progress"><div class="seeds-progress-indicator" /></div>
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer components {
|
|
13
|
+
.seeds-progress {
|
|
14
|
+
position: relative;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 8px;
|
|
18
|
+
border-radius: var(--radius-outer);
|
|
19
|
+
background-color: var(--color-container-border-base);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.seeds-progress-indicator {
|
|
23
|
+
height: 100%;
|
|
24
|
+
width: 100%;
|
|
25
|
+
border-radius: var(--radius-outer);
|
|
26
|
+
background-color: var(--color-icon-base);
|
|
27
|
+
transition: transform 150ms ease;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-progress",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Seeds React Progress",
|
|
5
5
|
"author": "Sprout Social, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "tsup --dts",
|
|
12
|
-
"build:debug": "tsup --dts --metafile",
|
|
11
|
+
"build": "tsup --dts && cp src/progress.css dist/progress.css",
|
|
12
|
+
"build:debug": "tsup --dts --metafile && cp src/progress.css dist/progress.css",
|
|
13
13
|
"dev": "tsup --watch --dts",
|
|
14
14
|
"clean": "rm -rf .turbo dist",
|
|
15
15
|
"clean:modules": "rm -rf node_modules",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@radix-ui/react-progress": "^1.1.2",
|
|
22
|
-
"@sproutsocial/seeds-react-theme": "^4.1.
|
|
22
|
+
"@sproutsocial/seeds-react-theme": "^4.1.1",
|
|
23
23
|
"@sproutsocial/seeds-react-system-props": "^3.1.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Empty PostCSS config — prevents tsup from picking up the root postcss.config.js
|
|
2
|
+
// (which runs Tailwind CSS and would fail without a tailwind.config.js in scope).
|
|
3
|
+
// progress.css uses plain CSS custom properties and needs no PostCSS processing.
|
|
4
|
+
export default {
|
|
5
|
+
plugins: {},
|
|
6
|
+
};
|
package/src/Progress.stories.tsx
CHANGED
|
@@ -96,3 +96,18 @@ export const CustomTrackAndIndicator: Story = {
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
CustomTrackAndIndicator.storyName = "Custom Track and Indicator";
|
|
99
|
+
|
|
100
|
+
export const TailwindClassOverride: Story = {
|
|
101
|
+
name: "🚀 Tailwind class override",
|
|
102
|
+
render: (args: TypeProgressProps) => (
|
|
103
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
|
|
104
|
+
<Progress {...args} />
|
|
105
|
+
<Progress {...args} className="mx-200 p-300 inline-flex" />
|
|
106
|
+
</div>
|
|
107
|
+
),
|
|
108
|
+
args: {
|
|
109
|
+
value: 50,
|
|
110
|
+
max: 100,
|
|
111
|
+
"aria-label": "Credits remaining",
|
|
112
|
+
},
|
|
113
|
+
};
|
package/src/Progress.tsx
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Progress as ProgressHybrid } from "./ProgressHybrid";
|
|
3
3
|
import type { TypeProgressProps } from "./ProgressTypes";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...rest
|
|
12
|
-
}: TypeProgressProps) => {
|
|
13
|
-
const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0;
|
|
5
|
+
/**
|
|
6
|
+
* Progress component. Automatically routes between the Tailwind implementation
|
|
7
|
+
* (preferred) and the styled-components implementation (for consumers using
|
|
8
|
+
* system props or styled() extension).
|
|
9
|
+
*/
|
|
10
|
+
const Progress = (props: TypeProgressProps) => <ProgressHybrid {...props} />;
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
max={max}
|
|
19
|
-
getValueLabel={getValueLabel}
|
|
20
|
-
data-qa-progress=""
|
|
21
|
-
style={trackStyle}
|
|
22
|
-
{...rest}
|
|
23
|
-
>
|
|
24
|
-
<StyledIndicator
|
|
25
|
-
style={{
|
|
26
|
-
transform: `translateX(-${100 - percentage}%)`,
|
|
27
|
-
...indicatorStyle,
|
|
28
|
-
}}
|
|
29
|
-
/>
|
|
30
|
-
</StyledRoot>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
12
|
+
Progress.displayName = "Progress";
|
|
13
|
+
|
|
14
|
+
export { Progress };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hybrid Progress Component
|
|
3
|
+
* Automatically chooses between Tailwind and styled-components based on props.
|
|
4
|
+
* Consumers passing styled-system props (e.g. `mb`, `width`, `bg`) get the
|
|
5
|
+
* styled-components implementation; everyone else gets the Tailwind path.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { StyledRoot, StyledIndicator } from "./styles";
|
|
10
|
+
import { ProgressTailwind } from "./ProgressTailwind";
|
|
11
|
+
import { hasStyledProps } from "@sproutsocial/seeds-react-system-props";
|
|
12
|
+
import type { TypeProgressProps } from "./ProgressTypes";
|
|
13
|
+
|
|
14
|
+
export const Progress = (props: TypeProgressProps) => {
|
|
15
|
+
const {
|
|
16
|
+
value,
|
|
17
|
+
max = 100,
|
|
18
|
+
getValueLabel,
|
|
19
|
+
trackStyle,
|
|
20
|
+
indicatorStyle,
|
|
21
|
+
...rest
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
if (hasStyledProps(rest)) {
|
|
25
|
+
const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<StyledRoot
|
|
29
|
+
value={value}
|
|
30
|
+
max={max}
|
|
31
|
+
getValueLabel={getValueLabel}
|
|
32
|
+
data-qa-progress=""
|
|
33
|
+
style={trackStyle}
|
|
34
|
+
{...rest}
|
|
35
|
+
>
|
|
36
|
+
<StyledIndicator
|
|
37
|
+
style={{
|
|
38
|
+
transform: `translateX(-${100 - percentage}%)`,
|
|
39
|
+
...indicatorStyle,
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
</StyledRoot>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Use Tailwind version (preferred - better performance)
|
|
47
|
+
return <ProgressTailwind {...props} />;
|
|
48
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tailwind CSS implementation of Progress component
|
|
3
|
+
* Uses Seeds progress CSS classes from progress.css
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import * as RadixProgress from "@radix-ui/react-progress";
|
|
8
|
+
import type { TypeProgressProps } from "./ProgressTypes";
|
|
9
|
+
|
|
10
|
+
// Utility for merging class names properly
|
|
11
|
+
function cn(
|
|
12
|
+
...inputs: (string | undefined | null | false | Record<string, boolean>)[]
|
|
13
|
+
): string {
|
|
14
|
+
const classes: string[] = [];
|
|
15
|
+
|
|
16
|
+
for (const input of inputs) {
|
|
17
|
+
if (!input) continue;
|
|
18
|
+
|
|
19
|
+
if (typeof input === "string") {
|
|
20
|
+
classes.push(input);
|
|
21
|
+
} else if (typeof input === "object") {
|
|
22
|
+
for (const [key, value] of Object.entries(input)) {
|
|
23
|
+
if (value) {
|
|
24
|
+
classes.push(key);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return classes.join(" ");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const ProgressTailwind = ({
|
|
34
|
+
value,
|
|
35
|
+
max = 100,
|
|
36
|
+
getValueLabel,
|
|
37
|
+
trackStyle,
|
|
38
|
+
indicatorStyle,
|
|
39
|
+
className,
|
|
40
|
+
...rest
|
|
41
|
+
}: TypeProgressProps) => {
|
|
42
|
+
const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<RadixProgress.Root
|
|
46
|
+
value={value}
|
|
47
|
+
max={max}
|
|
48
|
+
getValueLabel={getValueLabel}
|
|
49
|
+
// Keep the literal "Progress" class so existing selectors (e.g. `.Progress`,
|
|
50
|
+
// `.Progress > div`) continue to resolve. seeds-progress carries the styling.
|
|
51
|
+
className={cn("Progress", "seeds-progress", className)}
|
|
52
|
+
data-qa-progress=""
|
|
53
|
+
style={trackStyle}
|
|
54
|
+
{...(rest as any)}
|
|
55
|
+
>
|
|
56
|
+
<RadixProgress.Indicator
|
|
57
|
+
className="seeds-progress-indicator"
|
|
58
|
+
style={{
|
|
59
|
+
transform: `translateX(-${100 - percentage}%)`,
|
|
60
|
+
...indicatorStyle,
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</RadixProgress.Root>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
ProgressTailwind.displayName = "ProgressTailwind";
|
|
@@ -118,6 +118,30 @@ describe("Progress", () => {
|
|
|
118
118
|
).toBeTruthy();
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
+
it("should render the Tailwind (CSS-class) implementation by default", () => {
|
|
122
|
+
const { container } = render(
|
|
123
|
+
<Progress value={50} aria-label="Credits remaining" />
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// The default (no styled-system props) path renders the CSS-class
|
|
127
|
+
// implementation, which carries the seeds-progress class.
|
|
128
|
+
expect(container.querySelector(".seeds-progress")).toBeInTheDocument();
|
|
129
|
+
expect(
|
|
130
|
+
container.querySelector(".seeds-progress > .seeds-progress-indicator")
|
|
131
|
+
).toBeInTheDocument();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("should render the styled-components implementation when styled-system props are passed", () => {
|
|
135
|
+
const { container } = render(
|
|
136
|
+
<Progress value={50} aria-label="Credits remaining" mb={400} />
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// styled-system props route to the styled-components path, which does not
|
|
140
|
+
// emit the seeds-progress class.
|
|
141
|
+
expect(container.querySelector(".seeds-progress")).not.toBeInTheDocument();
|
|
142
|
+
expect(container.querySelector(".Progress")).toBeInTheDocument();
|
|
143
|
+
});
|
|
144
|
+
|
|
121
145
|
it("should apply trackStyle to the track", () => {
|
|
122
146
|
const { container } = render(
|
|
123
147
|
<Progress
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Progress } from "../";
|
|
2
|
+
|
|
3
|
+
// Regression guard for DS-4394: racine's `generate:props-docs` runs react-docgen
|
|
4
|
+
// over each package's entry component and keys the output on `displayName`. A bare
|
|
5
|
+
// cross-file re-export resolves to no local definition, so the entry must be a real
|
|
6
|
+
// local component with an explicit `displayName`.
|
|
7
|
+
describe("Progress entry component", () => {
|
|
8
|
+
it("exposes an explicit displayName for react-docgen", () => {
|
|
9
|
+
expect((Progress as { displayName?: string }).displayName).toBe("Progress");
|
|
10
|
+
});
|
|
11
|
+
});
|
package/src/css.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.css";
|
package/src/progress.css
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeds Progress component classes
|
|
3
|
+
* Use these instead of writing out individual Tailwind utility classes.
|
|
4
|
+
*
|
|
5
|
+
* Requires @sproutsocial/seeds-react-theme/dist/theme-all.css imported for
|
|
6
|
+
* CSS variable definitions and dark mode support.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* <div class="Progress seeds-progress"><div class="seeds-progress-indicator" /></div>
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer components {
|
|
13
|
+
.seeds-progress {
|
|
14
|
+
position: relative;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 8px;
|
|
18
|
+
border-radius: var(--radius-outer);
|
|
19
|
+
background-color: var(--color-container-border-base);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.seeds-progress-indicator {
|
|
23
|
+
height: 100%;
|
|
24
|
+
width: 100%;
|
|
25
|
+
border-radius: var(--radius-outer);
|
|
26
|
+
background-color: var(--color-icon-base);
|
|
27
|
+
transition: transform 150ms ease;
|
|
28
|
+
}
|
|
29
|
+
}
|