@sproutsocial/seeds-react-progress 0.1.0 → 0.2.1
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 +10 -10
- package/CHANGELOG.md +34 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Progress.stories.tsx +15 -0
- package/src/Progress.tsx +2 -0
- package/src/ProgressTypes.ts +3 -1
- package/src/__tests__/Progress.test.tsx +13 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -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[32m3.
|
|
12
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m3.
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
-
[32mESM[39m [1mdist/esm/index.js [22m[32m1.
|
|
15
|
-
[32mESM[39m [1mdist/esm/index.js.map [22m[32m3.
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m3.31 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m3.70 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 15ms
|
|
14
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m1.50 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m3.60 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 15ms
|
|
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 4762ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.25 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.25 KB[39m
|
|
21
|
+
Done in 5.65s.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @sproutsocial/seeds-react-progress
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [1f9a473]
|
|
8
|
+
- @sproutsocial/seeds-react-theme@3.6.1
|
|
9
|
+
|
|
10
|
+
## 0.2.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- b3744f2: Add trackStyle prop to Progress component
|
|
15
|
+
|
|
16
|
+
This change adds a dedicated `trackStyle` prop for styling the track (background bar) of the Progress component, enabling cleaner separation of track and indicator styling.
|
|
17
|
+
|
|
18
|
+
**Key Changes:**
|
|
19
|
+
|
|
20
|
+
- Add `trackStyle` prop for styling the track (background bar)
|
|
21
|
+
- Remove generic `style` prop to eliminate API ambiguity
|
|
22
|
+
- Simplify implementation by removing complex prop merging logic
|
|
23
|
+
- Update tests, documentation, and Storybook stories
|
|
24
|
+
|
|
25
|
+
**Migration:**
|
|
26
|
+
This is technically a breaking change (removes `style` prop), but has zero impact on existing consumers - only 2 files in web-app-core use Progress, and neither uses the `style` prop.
|
|
27
|
+
|
|
28
|
+
**Benefits:**
|
|
29
|
+
|
|
30
|
+
- Clear, semantic API with dedicated props for track vs indicator styling
|
|
31
|
+
- Simpler implementation (no runtime merging overhead)
|
|
32
|
+
- Better TypeScript type safety
|
|
33
|
+
- Self-documenting code
|
|
34
|
+
|
|
35
|
+
Resolves GROWTH-1932
|
|
36
|
+
|
|
3
37
|
## 0.1.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var Progress2 = ({
|
|
|
31
31
|
value,
|
|
32
32
|
max = 100,
|
|
33
33
|
getValueLabel,
|
|
34
|
+
trackStyle,
|
|
34
35
|
indicatorStyle,
|
|
35
36
|
...rest
|
|
36
37
|
}) => {
|
|
@@ -42,6 +43,7 @@ var Progress2 = ({
|
|
|
42
43
|
max,
|
|
43
44
|
getValueLabel,
|
|
44
45
|
"data-qa-progress": "",
|
|
46
|
+
style: trackStyle,
|
|
45
47
|
...rest,
|
|
46
48
|
children: /* @__PURE__ */ jsx(
|
|
47
49
|
StyledIndicator,
|
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 max = 100,\n getValueLabel,\n indicatorStyle,\n ...rest\n}: TypeProgressProps) => {\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 {...rest}\n >\n <StyledIndicator\n style={{\n transform: `translateX(-${100 - percentage}%)`,\n ...indicatorStyle,\n }}\n />\n </StyledRoot>\n );\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","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\"> &\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 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;;;ACAvB,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;;;
|
|
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 max = 100,\n getValueLabel,\n trackStyle,\n indicatorStyle,\n ...rest\n}: TypeProgressProps) => {\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","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","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;;;ACAvB,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;;;ADE/C;AAnBC,IAAMA,YAAW,CAAC;AAAA,EACvB;AAAA,EACA,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyB;AACvB,QAAM,aAAa,MAAM,IAAI,KAAK,IAAK,QAAQ,MAAO,KAAK,GAAG,IAAI;AAElE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAiB;AAAA,MACjB,OAAO;AAAA,MACN,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,WAAW,eAAe,MAAM,UAAU;AAAA,YAC1C,GAAG;AAAA,UACL;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;;;AE/BA,OAAuB;;;ACEvB,IAAO,gBAAQC;","names":["Progress","Progress"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -9,17 +9,19 @@ type TypeAriaLabel = {
|
|
|
9
9
|
"aria-label"?: string;
|
|
10
10
|
"aria-labelledby": string;
|
|
11
11
|
};
|
|
12
|
-
type TypeProgressProps = TypeStyledComponentsCommonProps & TypeSystemCommonProps & Omit<React.ComponentPropsWithoutRef<"div">, "color"> & TypeAriaLabel & {
|
|
12
|
+
type TypeProgressProps = TypeStyledComponentsCommonProps & TypeSystemCommonProps & Omit<React.ComponentPropsWithoutRef<"div">, "color" | "style"> & TypeAriaLabel & {
|
|
13
13
|
/** The current progress value */
|
|
14
14
|
value: number;
|
|
15
15
|
/** The maximum progress value. Defaults to 100 */
|
|
16
16
|
max?: number;
|
|
17
17
|
/** A function to get the accessible label text representing the current value. Defaults to "{value}%" */
|
|
18
18
|
getValueLabel?: (value: number, max: number) => string;
|
|
19
|
+
/** Custom CSS for the track (background) element, e.g. backgroundColor */
|
|
20
|
+
trackStyle?: React.CSSProperties;
|
|
19
21
|
/** Custom CSS for the indicator (fill) element, e.g. a gradient background */
|
|
20
22
|
indicatorStyle?: React.CSSProperties;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
declare const Progress: ({ value, max, getValueLabel, indicatorStyle, ...rest }: TypeProgressProps) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
declare const Progress: ({ value, max, getValueLabel, trackStyle, indicatorStyle, ...rest }: TypeProgressProps) => react_jsx_runtime.JSX.Element;
|
|
24
26
|
|
|
25
27
|
export { Progress, type TypeProgressProps, Progress as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,17 +9,19 @@ type TypeAriaLabel = {
|
|
|
9
9
|
"aria-label"?: string;
|
|
10
10
|
"aria-labelledby": string;
|
|
11
11
|
};
|
|
12
|
-
type TypeProgressProps = TypeStyledComponentsCommonProps & TypeSystemCommonProps & Omit<React.ComponentPropsWithoutRef<"div">, "color"> & TypeAriaLabel & {
|
|
12
|
+
type TypeProgressProps = TypeStyledComponentsCommonProps & TypeSystemCommonProps & Omit<React.ComponentPropsWithoutRef<"div">, "color" | "style"> & TypeAriaLabel & {
|
|
13
13
|
/** The current progress value */
|
|
14
14
|
value: number;
|
|
15
15
|
/** The maximum progress value. Defaults to 100 */
|
|
16
16
|
max?: number;
|
|
17
17
|
/** A function to get the accessible label text representing the current value. Defaults to "{value}%" */
|
|
18
18
|
getValueLabel?: (value: number, max: number) => string;
|
|
19
|
+
/** Custom CSS for the track (background) element, e.g. backgroundColor */
|
|
20
|
+
trackStyle?: React.CSSProperties;
|
|
19
21
|
/** Custom CSS for the indicator (fill) element, e.g. a gradient background */
|
|
20
22
|
indicatorStyle?: React.CSSProperties;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
declare const Progress: ({ value, max, getValueLabel, indicatorStyle, ...rest }: TypeProgressProps) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
declare const Progress: ({ value, max, getValueLabel, trackStyle, indicatorStyle, ...rest }: TypeProgressProps) => react_jsx_runtime.JSX.Element;
|
|
24
26
|
|
|
25
27
|
export { Progress, type TypeProgressProps, Progress as default };
|
package/dist/index.js
CHANGED
|
@@ -68,6 +68,7 @@ var Progress2 = ({
|
|
|
68
68
|
value,
|
|
69
69
|
max = 100,
|
|
70
70
|
getValueLabel,
|
|
71
|
+
trackStyle,
|
|
71
72
|
indicatorStyle,
|
|
72
73
|
...rest
|
|
73
74
|
}) => {
|
|
@@ -79,6 +80,7 @@ var Progress2 = ({
|
|
|
79
80
|
max,
|
|
80
81
|
getValueLabel,
|
|
81
82
|
"data-qa-progress": "",
|
|
83
|
+
style: trackStyle,
|
|
82
84
|
...rest,
|
|
83
85
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
86
|
StyledIndicator,
|
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 max = 100,\n getValueLabel,\n indicatorStyle,\n ...rest\n}: TypeProgressProps) => {\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 {...rest}\n >\n <StyledIndicator\n style={{\n transform: `translateX(-${100 - percentage}%)`,\n ...indicatorStyle,\n }}\n />\n </StyledRoot>\n );\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","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\"> &\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 indicator (fill) element, e.g. a gradient background */\n indicatorStyle?: React.CSSProperties;\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kBAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,YAAuB;;;ACAvB,+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;;;
|
|
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 max = 100,\n getValueLabel,\n trackStyle,\n indicatorStyle,\n ...rest\n}: TypeProgressProps) => {\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","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","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,YAAuB;;;ACAvB,+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;;;ADE/C;AAnBC,IAAMC,YAAW,CAAC;AAAA,EACvB;AAAA,EACA,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAyB;AACvB,QAAM,aAAa,MAAM,IAAI,KAAK,IAAK,QAAQ,MAAO,KAAK,GAAG,IAAI;AAElE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAiB;AAAA,MACjB,OAAO;AAAA,MACN,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,WAAW,eAAe,MAAM,UAAU;AAAA,YAC1C,GAAG;AAAA,UACL;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;;;AE/BA,IAAAC,SAAuB;;;AHEvB,IAAO,gBAAQC;","names":["Progress","styled","Progress","React","Progress"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/seeds-react-progress",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Seeds React Progress",
|
|
5
5
|
"author": "Sprout Social, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@radix-ui/react-progress": "^1.1.2",
|
|
22
|
-
"@sproutsocial/seeds-react-theme": "^3.6.
|
|
22
|
+
"@sproutsocial/seeds-react-theme": "^3.6.1",
|
|
23
23
|
"@sproutsocial/seeds-react-system-props": "^3.0.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
package/src/Progress.stories.tsx
CHANGED
|
@@ -81,3 +81,18 @@ export const CustomGradient: Story = {
|
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
|
+
|
|
85
|
+
export const CustomTrackAndIndicator: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
value: 67,
|
|
88
|
+
"aria-label": "Progress",
|
|
89
|
+
trackStyle: {
|
|
90
|
+
backgroundColor: "#F59E0B",
|
|
91
|
+
},
|
|
92
|
+
indicatorStyle: {
|
|
93
|
+
backgroundColor: "#059669",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
CustomTrackAndIndicator.storyName = "Custom Track and Indicator";
|
package/src/Progress.tsx
CHANGED
|
@@ -6,6 +6,7 @@ export const Progress = ({
|
|
|
6
6
|
value,
|
|
7
7
|
max = 100,
|
|
8
8
|
getValueLabel,
|
|
9
|
+
trackStyle,
|
|
9
10
|
indicatorStyle,
|
|
10
11
|
...rest
|
|
11
12
|
}: TypeProgressProps) => {
|
|
@@ -17,6 +18,7 @@ export const Progress = ({
|
|
|
17
18
|
max={max}
|
|
18
19
|
getValueLabel={getValueLabel}
|
|
19
20
|
data-qa-progress=""
|
|
21
|
+
style={trackStyle}
|
|
20
22
|
{...rest}
|
|
21
23
|
>
|
|
22
24
|
<StyledIndicator
|
package/src/ProgressTypes.ts
CHANGED
|
@@ -10,7 +10,7 @@ type TypeAriaLabel =
|
|
|
10
10
|
|
|
11
11
|
export type TypeProgressProps = TypeStyledComponentsCommonProps &
|
|
12
12
|
TypeSystemCommonProps &
|
|
13
|
-
Omit<React.ComponentPropsWithoutRef<"div">, "color"> &
|
|
13
|
+
Omit<React.ComponentPropsWithoutRef<"div">, "color" | "style"> &
|
|
14
14
|
TypeAriaLabel & {
|
|
15
15
|
/** The current progress value */
|
|
16
16
|
value: number;
|
|
@@ -18,6 +18,8 @@ export type TypeProgressProps = TypeStyledComponentsCommonProps &
|
|
|
18
18
|
max?: number;
|
|
19
19
|
/** A function to get the accessible label text representing the current value. Defaults to "{value}%" */
|
|
20
20
|
getValueLabel?: (value: number, max: number) => string;
|
|
21
|
+
/** Custom CSS for the track (background) element, e.g. backgroundColor */
|
|
22
|
+
trackStyle?: React.CSSProperties;
|
|
21
23
|
/** Custom CSS for the indicator (fill) element, e.g. a gradient background */
|
|
22
24
|
indicatorStyle?: React.CSSProperties;
|
|
23
25
|
};
|
|
@@ -117,4 +117,17 @@ describe("Progress", () => {
|
|
|
117
117
|
screen.getByRole("progressbar").closest("[data-qa-progress]")
|
|
118
118
|
).toBeTruthy();
|
|
119
119
|
});
|
|
120
|
+
|
|
121
|
+
it("should apply trackStyle to the track", () => {
|
|
122
|
+
const { container } = render(
|
|
123
|
+
<Progress
|
|
124
|
+
value={50}
|
|
125
|
+
aria-label="Credits remaining"
|
|
126
|
+
trackStyle={{ backgroundColor: "red" }}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const track = container.querySelector(".Progress");
|
|
131
|
+
expect(track).toHaveStyle("background-color: red");
|
|
132
|
+
});
|
|
120
133
|
});
|