@instructure/ui-progress 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/es/ProgressBar/v1/index.js +90 -123
  3. package/es/ProgressBar/v1/props.js +15 -26
  4. package/es/ProgressBar/v1/styles.js +167 -209
  5. package/es/ProgressBar/v1/theme.js +55 -93
  6. package/es/ProgressBar/v2/index.js +90 -123
  7. package/es/ProgressBar/v2/props.js +15 -26
  8. package/es/ProgressBar/v2/styles.js +188 -235
  9. package/es/ProgressCircle/v1/index.js +128 -165
  10. package/es/ProgressCircle/v1/props.js +16 -26
  11. package/es/ProgressCircle/v1/styles.js +291 -348
  12. package/es/ProgressCircle/v1/theme.js +88 -128
  13. package/es/ProgressCircle/v2/index.js +128 -165
  14. package/es/ProgressCircle/v2/props.js +16 -26
  15. package/es/ProgressCircle/v2/styles.js +291 -348
  16. package/es/exports/a.js +1 -25
  17. package/es/exports/b.js +1 -25
  18. package/package.json +13 -19
  19. package/tsconfig.build.json +0 -1
  20. package/tsconfig.build.tsbuildinfo +1 -1
  21. package/lib/ProgressBar/v1/index.js +0 -137
  22. package/lib/ProgressBar/v1/props.js +0 -31
  23. package/lib/ProgressBar/v1/styles.js +0 -216
  24. package/lib/ProgressBar/v1/theme.js +0 -100
  25. package/lib/ProgressBar/v2/index.js +0 -136
  26. package/lib/ProgressBar/v2/props.js +0 -31
  27. package/lib/ProgressBar/v2/styles.js +0 -242
  28. package/lib/ProgressCircle/v1/index.js +0 -182
  29. package/lib/ProgressCircle/v1/props.js +0 -31
  30. package/lib/ProgressCircle/v1/styles.js +0 -357
  31. package/lib/ProgressCircle/v1/theme.js +0 -146
  32. package/lib/ProgressCircle/v2/index.js +0 -181
  33. package/lib/ProgressCircle/v2/props.js +0 -31
  34. package/lib/ProgressCircle/v2/styles.js +0 -357
  35. package/lib/exports/a.js +0 -19
  36. package/lib/exports/b.js +0 -19
  37. package/lib/package.json +0 -1
@@ -1,236 +1,189 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- /**
26
- * ---
27
- * private: true
28
- * ---
29
- * Generates the style object from the theme and provided additional information
30
- * @param {Object} componentTheme The theme variable object.
31
- * @param {Object} props the props of the component, the style is applied to
32
- * @param {Object} sharedTokens Shared token object that stores common values for the theme.
33
- * @return {Object} The final style object, which will be used in the component
34
- */
35
- const generateStyle = (componentTheme, props, _sharedTokens) => {
36
- const {
37
- valueNow = 0,
38
- valueMax = 100,
39
- size,
40
- color,
41
- meterColor,
42
- shouldAnimate
43
- } = props;
44
- const meterColorClassName = typeof meterColor === 'function' ? meterColor({
45
- valueNow,
46
- valueMax
47
- }) : meterColor;
48
- const currentValue = valueNow > valueMax ? valueMax : valueNow < 0 ? 0 : valueNow;
49
- const currentValuePercent = `${currentValue / valueMax * 100}%`;
50
- const sizeVariants = {
51
- 'x-small': {
52
- track: {
53
- height: componentTheme.xSmallHeight
54
- },
55
- value: {
56
- fontSize: componentTheme.xSmallValueFontSize
57
- }
58
- },
59
- small: {
60
- track: {
61
- height: componentTheme.smallHeight
62
- },
63
- // product design wants = 18px
64
- value: {
65
- fontSize: componentTheme.smallValueFontSize
66
- }
67
- },
68
- medium: {
69
- track: {
70
- height: componentTheme.mediumHeight
71
- },
72
- value: {
73
- fontSize: componentTheme.mediumValueFontSize
74
- }
75
- },
76
- large: {
77
- track: {
78
- height: componentTheme.largeHeight
79
- },
80
- value: {
81
- fontSize: componentTheme.largeValueFontSize
82
- }
83
- }
84
- };
85
- const colorVariants = {
86
- primary: {
87
- trackLayout: {
88
- background: componentTheme.trackColor,
89
- borderWidth: componentTheme.trackBottomBorderWidth,
90
- borderStyle: 'solid',
91
- borderColor: componentTheme.borderColor
92
- },
93
- trackBorder: {
94
- borderBottomColor: componentTheme.trackBottomBorderColor
95
- },
96
- value: {
97
- color: componentTheme.textColor
98
- },
99
- htmlProgress: {
100
- borderColor: componentTheme.borderColor
101
- }
102
- },
103
- 'primary-inverse': {
104
- trackLayout: {
105
- background: componentTheme.trackColorInverse,
106
- borderWidth: componentTheme.trackBottomBorderWidth,
107
- borderStyle: 'solid',
108
- borderColor: componentTheme.borderColorInverse
109
- },
110
- trackBorder: {
111
- borderBottomColor: componentTheme.trackBottomBorderColorInverse
112
- },
113
- value: {
114
- color: componentTheme.textColorInverse
115
- },
116
- htmlProgress: {
117
- borderColor: componentTheme.borderColorInverse
118
- }
119
- }
120
- };
121
- const trackBackgroundVariants = {
122
- primary: {
123
- brand: {
124
- background: componentTheme.meterColorBrand
125
- },
126
- info: {
127
- background: componentTheme.meterColorInfo
128
- },
129
- success: {
130
- background: componentTheme.meterColorSuccess
131
- },
132
- danger: {
133
- background: componentTheme.meterColorDanger
134
- },
135
- warning: {
136
- background: componentTheme.meterColorWarning
137
- },
138
- alert: {
139
- background: componentTheme.meterColorAlert
140
- }
141
- },
142
- 'primary-inverse': {
143
- brand: {
144
- background: componentTheme.meterColorBrandInverse
145
- },
146
- info: {
147
- background: componentTheme.meterColorInfoInverse
148
- },
149
- success: {
150
- background: componentTheme.meterColorSuccessInverse
151
- },
152
- danger: {
153
- background: componentTheme.meterColorDangerInverse
154
- },
155
- warning: {
156
- background: componentTheme.meterColorWarningInverse
157
- },
158
- alert: {
159
- background: componentTheme.meterColorAlertInverse
160
- }
161
- }
162
- };
163
- return {
164
- progressBar: {
165
- label: 'progressBar',
166
- display: 'flex',
167
- alignItems: 'center',
168
- fontFamily: componentTheme.fontFamily,
169
- fontWeight: componentTheme.fontWeight,
170
- lineHeight: componentTheme.lineHeight,
171
- fontSize: componentTheme.fontSize,
172
- borderRadius: componentTheme.borderRadius
173
- },
174
- trackLayout: {
175
- label: 'progressBar__trackLayout',
176
- position: 'relative',
177
- flex: 1,
178
- borderRadius: 'inherit',
179
- ...colorVariants[color].trackLayout
180
- },
181
- track: {
182
- label: 'progressBar__track',
183
- display: 'block',
184
- boxSizing: 'border-box',
185
- width: '100%',
186
- borderBottomWidth: componentTheme.trackBottomBorderWidth,
187
- borderBottomStyle: 'solid',
188
- background: 'transparent',
189
- // Inner border-radius must be smaller than outer to avoid geometric gaps with nested rounded borders
190
- // Formula: inner radius = outer radius - border width
191
- borderRadius: `calc(${componentTheme.borderRadius} - ${componentTheme.trackBottomBorderWidth})`,
192
- // Negative margin pulls track down so trackLayout's full border overlaps and hides track's bottom border.
193
- // When trackLayout border is visible (light/dark themes), it creates a clean full border appearance.
194
- // When trackLayout border is transparent (legacy Canvas), track's bottom border remains visible.
195
- marginBottom: `calc(-1 * ${componentTheme.trackBottomBorderWidth})`,
196
- ...sizeVariants[size].track,
197
- ...colorVariants[color].trackBorder
198
- },
199
- trackValue: {
200
- label: 'progressBar__trackValue',
201
- display: 'block',
202
- boxSizing: 'border-box',
203
- height: '100%',
204
- width: currentValuePercent,
205
- maxWidth: '100%',
206
- borderRadius: 'inherit',
207
- ...(shouldAnimate && {
208
- transition: 'all 0.5s'
209
- }),
210
- ...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
211
- },
212
- value: {
213
- label: 'progressBar__value',
214
- lineHeight: 1,
215
- boxSizing: 'border-box',
216
- paddingInlineStart: componentTheme.valuePadding,
217
- flex: '0 0 5.625rem',
218
- ...sizeVariants[size].value,
219
- ...colorVariants[color].value
220
- },
221
- htmlProgress: {
222
- label: 'progressBar__htmlProgress',
223
- display: 'block',
224
- position: 'absolute',
225
- top: '0',
226
- left: '0',
227
- width: '100%',
228
- height: '100%',
229
- boxSizing: 'border-box',
230
- zIndex: -1,
231
- opacity: 0,
232
- ...colorVariants[color].htmlProgress
233
- }
234
- };
1
+ const generateStyle = (componentTheme, props, _sharedTokens)=>{
2
+ const { valueNow = 0, valueMax = 100, size, color, meterColor, shouldAnimate } = props;
3
+ const meterColorClassName = typeof meterColor === 'function' ? meterColor({
4
+ valueNow,
5
+ valueMax
6
+ }) : meterColor;
7
+ const currentValue = valueNow > valueMax ? valueMax : valueNow < 0 ? 0 : valueNow;
8
+ const currentValuePercent = `${currentValue / valueMax * 100}%`;
9
+ const sizeVariants = {
10
+ 'x-small': {
11
+ track: {
12
+ height: componentTheme.xSmallHeight
13
+ },
14
+ value: {
15
+ fontSize: componentTheme.xSmallValueFontSize
16
+ }
17
+ },
18
+ small: {
19
+ track: {
20
+ height: componentTheme.smallHeight
21
+ },
22
+ value: {
23
+ fontSize: componentTheme.smallValueFontSize
24
+ }
25
+ },
26
+ medium: {
27
+ track: {
28
+ height: componentTheme.mediumHeight
29
+ },
30
+ value: {
31
+ fontSize: componentTheme.mediumValueFontSize
32
+ }
33
+ },
34
+ large: {
35
+ track: {
36
+ height: componentTheme.largeHeight
37
+ },
38
+ value: {
39
+ fontSize: componentTheme.largeValueFontSize
40
+ }
41
+ }
42
+ };
43
+ const colorVariants = {
44
+ primary: {
45
+ trackLayout: {
46
+ background: componentTheme.trackColor,
47
+ borderWidth: componentTheme.trackBottomBorderWidth,
48
+ borderStyle: 'solid',
49
+ borderColor: componentTheme.borderColor
50
+ },
51
+ trackBorder: {
52
+ borderBottomColor: componentTheme.trackBottomBorderColor
53
+ },
54
+ value: {
55
+ color: componentTheme.textColor
56
+ },
57
+ htmlProgress: {
58
+ borderColor: componentTheme.borderColor
59
+ }
60
+ },
61
+ 'primary-inverse': {
62
+ trackLayout: {
63
+ background: componentTheme.trackColorInverse,
64
+ borderWidth: componentTheme.trackBottomBorderWidth,
65
+ borderStyle: 'solid',
66
+ borderColor: componentTheme.borderColorInverse
67
+ },
68
+ trackBorder: {
69
+ borderBottomColor: componentTheme.trackBottomBorderColorInverse
70
+ },
71
+ value: {
72
+ color: componentTheme.textColorInverse
73
+ },
74
+ htmlProgress: {
75
+ borderColor: componentTheme.borderColorInverse
76
+ }
77
+ }
78
+ };
79
+ const trackBackgroundVariants = {
80
+ primary: {
81
+ brand: {
82
+ background: componentTheme.meterColorBrand
83
+ },
84
+ info: {
85
+ background: componentTheme.meterColorInfo
86
+ },
87
+ success: {
88
+ background: componentTheme.meterColorSuccess
89
+ },
90
+ danger: {
91
+ background: componentTheme.meterColorDanger
92
+ },
93
+ warning: {
94
+ background: componentTheme.meterColorWarning
95
+ },
96
+ alert: {
97
+ background: componentTheme.meterColorAlert
98
+ }
99
+ },
100
+ 'primary-inverse': {
101
+ brand: {
102
+ background: componentTheme.meterColorBrandInverse
103
+ },
104
+ info: {
105
+ background: componentTheme.meterColorInfoInverse
106
+ },
107
+ success: {
108
+ background: componentTheme.meterColorSuccessInverse
109
+ },
110
+ danger: {
111
+ background: componentTheme.meterColorDangerInverse
112
+ },
113
+ warning: {
114
+ background: componentTheme.meterColorWarningInverse
115
+ },
116
+ alert: {
117
+ background: componentTheme.meterColorAlertInverse
118
+ }
119
+ }
120
+ };
121
+ return {
122
+ progressBar: {
123
+ label: 'progressBar',
124
+ display: 'flex',
125
+ alignItems: 'center',
126
+ fontFamily: componentTheme.fontFamily,
127
+ fontWeight: componentTheme.fontWeight,
128
+ lineHeight: componentTheme.lineHeight,
129
+ fontSize: componentTheme.fontSize,
130
+ borderRadius: componentTheme.borderRadius
131
+ },
132
+ trackLayout: {
133
+ label: 'progressBar__trackLayout',
134
+ position: 'relative',
135
+ flex: 1,
136
+ borderRadius: 'inherit',
137
+ ...colorVariants[color].trackLayout
138
+ },
139
+ track: {
140
+ label: 'progressBar__track',
141
+ display: 'block',
142
+ boxSizing: 'border-box',
143
+ width: '100%',
144
+ borderBottomWidth: componentTheme.trackBottomBorderWidth,
145
+ borderBottomStyle: 'solid',
146
+ background: 'transparent',
147
+ borderRadius: `calc(${componentTheme.borderRadius} - ${componentTheme.trackBottomBorderWidth})`,
148
+ marginBottom: `calc(-1 * ${componentTheme.trackBottomBorderWidth})`,
149
+ ...sizeVariants[size].track,
150
+ ...colorVariants[color].trackBorder
151
+ },
152
+ trackValue: {
153
+ label: 'progressBar__trackValue',
154
+ display: 'block',
155
+ boxSizing: 'border-box',
156
+ height: '100%',
157
+ width: currentValuePercent,
158
+ maxWidth: '100%',
159
+ borderRadius: 'inherit',
160
+ ...shouldAnimate && {
161
+ transition: 'all 0.5s'
162
+ },
163
+ ...meterColorClassName && trackBackgroundVariants[color][meterColorClassName]
164
+ },
165
+ value: {
166
+ label: 'progressBar__value',
167
+ lineHeight: 1,
168
+ boxSizing: 'border-box',
169
+ paddingInlineStart: componentTheme.valuePadding,
170
+ flex: '0 0 5.625rem',
171
+ ...sizeVariants[size].value,
172
+ ...colorVariants[color].value
173
+ },
174
+ htmlProgress: {
175
+ label: 'progressBar__htmlProgress',
176
+ display: 'block',
177
+ position: 'absolute',
178
+ top: '0',
179
+ left: '0',
180
+ width: '100%',
181
+ height: '100%',
182
+ boxSizing: 'border-box',
183
+ zIndex: -1,
184
+ opacity: 0,
185
+ ...colorVariants[color].htmlProgress
186
+ }
187
+ };
235
188
  };
236
- export default generateStyle;
189
+ export default generateStyle;