@instructure/ui-buttons 9.5.2-snapshot-1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -2
- package/es/BaseButton/theme.js +64 -95
- package/lib/BaseButton/theme.js +63 -95
- package/package.json +20 -20
- package/src/BaseButton/theme.ts +81 -145
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/BaseButton/theme.d.ts.map +1 -1
package/src/BaseButton/theme.ts
CHANGED
|
@@ -22,109 +22,19 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import {
|
|
26
|
-
import type { Theme, ThemeSpecificStyle } from '@instructure/ui-themes'
|
|
25
|
+
import type { Theme } from '@instructure/ui-themes'
|
|
27
26
|
import { BaseButtonTheme } from '@instructure/shared-types'
|
|
27
|
+
import { alpha } from '@instructure/ui-color-utils'
|
|
28
28
|
|
|
29
29
|
const activeShadow = 'inset 0 0 0.1875rem 0.0625rem'
|
|
30
30
|
|
|
31
|
-
type Variants =
|
|
32
|
-
| 'primary'
|
|
33
|
-
| 'secondary'
|
|
34
|
-
| 'success'
|
|
35
|
-
| 'danger'
|
|
36
|
-
| 'primaryInverse'
|
|
37
|
-
|
|
38
|
-
type VariantValues =
|
|
39
|
-
| 'Color'
|
|
40
|
-
| 'BorderColor'
|
|
41
|
-
| 'Background'
|
|
42
|
-
| 'HoverBackground'
|
|
43
|
-
| 'ActiveBackground'
|
|
44
|
-
| 'ActiveBoxShadow'
|
|
45
|
-
| 'GhostColor'
|
|
46
|
-
| 'GhostBorderColor'
|
|
47
|
-
| 'GhostBackground'
|
|
48
|
-
| 'GhostHoverBackground'
|
|
49
|
-
| 'GhostActiveBackground'
|
|
50
|
-
| 'GhostActiveBoxShadow'
|
|
51
|
-
|
|
52
|
-
type VariantMap<Variant extends Variants> = Record<
|
|
53
|
-
`${Variant}${VariantValues}`,
|
|
54
|
-
string
|
|
55
|
-
>
|
|
56
|
-
|
|
57
|
-
const generateButtonThemeVars = <Variant extends Variants>({
|
|
58
|
-
style,
|
|
59
|
-
textColor,
|
|
60
|
-
ghostTextColor,
|
|
61
|
-
backgroundColor,
|
|
62
|
-
borderColor,
|
|
63
|
-
ghostBorderColor = borderColor
|
|
64
|
-
}: {
|
|
65
|
-
style: Variant
|
|
66
|
-
textColor: string
|
|
67
|
-
ghostTextColor: string
|
|
68
|
-
backgroundColor: string
|
|
69
|
-
borderColor: string
|
|
70
|
-
ghostBorderColor?: string
|
|
71
|
-
}) =>
|
|
72
|
-
({
|
|
73
|
-
[`${style}Color`]: textColor,
|
|
74
|
-
[`${style}BorderColor`]: darken(borderColor, 10),
|
|
75
|
-
[`${style}Background`]: backgroundColor,
|
|
76
|
-
[`${style}HoverBackground`]: darken(backgroundColor, 10),
|
|
77
|
-
[`${style}ActiveBackground`]: darken(backgroundColor, 10),
|
|
78
|
-
[`${style}ActiveBoxShadow`]: `${activeShadow} ${darken(borderColor, 20)}`,
|
|
79
|
-
|
|
80
|
-
[`${style}GhostColor`]: ghostTextColor,
|
|
81
|
-
[`${style}GhostBorderColor`]: ghostBorderColor,
|
|
82
|
-
[`${style}GhostBackground`]: 'transparent',
|
|
83
|
-
[`${style}GhostHoverBackground`]: alpha(ghostTextColor, 10),
|
|
84
|
-
[`${style}GhostActiveBackground`]: 'transparent',
|
|
85
|
-
[`${style}GhostActiveBoxShadow`]: `${activeShadow} ${alpha(
|
|
86
|
-
ghostBorderColor,
|
|
87
|
-
28
|
|
88
|
-
)}`
|
|
89
|
-
} as VariantMap<Variant>)
|
|
90
|
-
|
|
91
31
|
/**
|
|
92
32
|
* Generates the theme object for the component from the theme and provided additional information
|
|
93
33
|
* @param {Object} theme The actual theme object.
|
|
94
34
|
* @return {Object} The final theme object with the overrides and component variables
|
|
95
35
|
*/
|
|
96
36
|
const generateComponentTheme = (theme: Theme): BaseButtonTheme => {
|
|
97
|
-
const { borders, colors, forms, spacing, typography
|
|
98
|
-
|
|
99
|
-
const themeSpecificStyle: ThemeSpecificStyle<BaseButtonTheme> = {
|
|
100
|
-
canvas: {
|
|
101
|
-
...generateButtonThemeVars({
|
|
102
|
-
style: 'primary',
|
|
103
|
-
backgroundColor: theme['ic-brand-button--primary-bgd']!,
|
|
104
|
-
borderColor: theme['ic-brand-button--primary-bgd']!,
|
|
105
|
-
textColor: theme['ic-brand-button--primary-text']!,
|
|
106
|
-
ghostTextColor: theme['ic-brand-button--primary-bgd']!
|
|
107
|
-
}),
|
|
108
|
-
primaryGhostHoverBackground: alpha(
|
|
109
|
-
theme['ic-brand-button--primary-bgd']!,
|
|
110
|
-
10
|
|
111
|
-
)
|
|
112
|
-
},
|
|
113
|
-
'canvas-high-contrast': {
|
|
114
|
-
secondaryBorderColor: colors?.borderMedium,
|
|
115
|
-
primaryInverseBorderColor: colors?.borderMedium
|
|
116
|
-
},
|
|
117
|
-
instructure: {
|
|
118
|
-
borderRadius: '999em',
|
|
119
|
-
smallPaddingTop: '0.5rem',
|
|
120
|
-
smallPaddingBottom: '0.4375rem',
|
|
121
|
-
mediumPaddingTop: '0.75rem',
|
|
122
|
-
mediumPaddingBottom: '0.75rem',
|
|
123
|
-
largePaddingTop: '1rem',
|
|
124
|
-
largePaddingBottom: '1rem',
|
|
125
|
-
largeFontSize: '1.125rem'
|
|
126
|
-
}
|
|
127
|
-
}
|
|
37
|
+
const { borders, colors, forms, spacing, typography } = theme
|
|
128
38
|
|
|
129
39
|
const componentVariables: BaseButtonTheme = {
|
|
130
40
|
transform: 'none',
|
|
@@ -163,63 +73,89 @@ const generateComponentTheme = (theme: Theme): BaseButtonTheme => {
|
|
|
163
73
|
iconTextGap: spacing.xSmall,
|
|
164
74
|
iconTextGapCondensed: spacing.xxSmall,
|
|
165
75
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
76
|
+
primaryColor: colors?.contrasts?.white1010,
|
|
77
|
+
primaryBorderColor: colors?.contrasts?.blue5782,
|
|
78
|
+
primaryBackground: colors?.contrasts?.blue4570,
|
|
79
|
+
primaryHoverBackground: colors?.contrasts?.blue5782,
|
|
80
|
+
primaryActiveBackground: colors?.contrasts?.blue5782,
|
|
81
|
+
primaryActiveBoxShadow: `${activeShadow} ${colors?.contrasts?.white1010}`,
|
|
82
|
+
primaryGhostColor: colors?.contrasts?.blue4570,
|
|
83
|
+
primaryGhostBorderColor: colors?.contrasts?.blue4570,
|
|
84
|
+
primaryGhostBackground: 'transparent',
|
|
85
|
+
primaryGhostHoverBackground: alpha(colors?.contrasts?.blue4570, 10),
|
|
86
|
+
primaryGhostActiveBackground: 'transparent',
|
|
87
|
+
primaryGhostActiveBoxShadow: `${activeShadow} ${alpha(
|
|
88
|
+
colors?.contrasts?.blue1212,
|
|
89
|
+
28
|
|
90
|
+
)}`,
|
|
91
|
+
|
|
92
|
+
secondaryColor: colors?.contrasts?.grey125125,
|
|
93
|
+
secondaryBorderColor: colors?.contrasts?.grey1214,
|
|
94
|
+
secondaryBackground: colors?.contrasts?.grey1111,
|
|
95
|
+
secondaryHoverBackground: colors?.contrasts?.grey1214,
|
|
96
|
+
secondaryActiveBackground: colors?.contrasts?.grey1214,
|
|
97
|
+
secondaryActiveBoxShadow: `${activeShadow} ${colors?.contrasts?.white1010}`,
|
|
98
|
+
secondaryGhostColor: colors?.contrasts?.grey125125,
|
|
99
|
+
secondaryGhostBorderColor: colors?.contrasts?.grey125125,
|
|
100
|
+
secondaryGhostBackground: 'transparent',
|
|
101
|
+
secondaryGhostHoverBackground: alpha(colors?.contrasts?.grey125125, 10),
|
|
102
|
+
secondaryGhostActiveBackground: 'transparent',
|
|
103
|
+
secondaryGhostActiveBoxShadow: `${activeShadow} ${alpha(
|
|
104
|
+
colors?.contrasts?.grey125125,
|
|
105
|
+
28
|
|
106
|
+
)}`,
|
|
107
|
+
|
|
108
|
+
successColor: colors?.contrasts?.white1010,
|
|
109
|
+
successBorderColor: colors?.contrasts?.green5782,
|
|
110
|
+
successBackground: colors?.contrasts?.green4570,
|
|
111
|
+
successHoverBackground: colors?.contrasts?.green5782,
|
|
112
|
+
successActiveBackground: colors?.contrasts?.green5782,
|
|
113
|
+
successActiveBoxShadow: `${activeShadow} ${colors?.contrasts?.white1010}`,
|
|
114
|
+
successGhostColor: colors?.contrasts?.green4570,
|
|
115
|
+
successGhostBorderColor: colors?.contrasts?.green4570,
|
|
116
|
+
successGhostBackground: 'transparent',
|
|
117
|
+
successGhostHoverBackground: alpha(colors?.contrasts?.green4570, 10),
|
|
118
|
+
successGhostActiveBackground: 'transparent',
|
|
119
|
+
successGhostActiveBoxShadow: `${activeShadow} ${alpha(
|
|
120
|
+
colors?.contrasts?.green4570,
|
|
121
|
+
28
|
|
122
|
+
)}`,
|
|
123
|
+
|
|
124
|
+
dangerColor: colors?.contrasts?.white1010,
|
|
125
|
+
dangerBorderColor: colors?.contrasts?.red5782,
|
|
126
|
+
dangerBackground: colors?.contrasts?.red4570,
|
|
127
|
+
dangerHoverBackground: colors?.contrasts?.red5782,
|
|
128
|
+
dangerActiveBackground: colors?.contrasts?.red5782,
|
|
129
|
+
dangerActiveBoxShadow: `${activeShadow} ${colors?.contrasts?.white1010}`,
|
|
130
|
+
dangerGhostColor: colors?.contrasts?.red4570,
|
|
131
|
+
dangerGhostBorderColor: colors?.contrasts?.red4570,
|
|
132
|
+
dangerGhostBackground: 'transparent',
|
|
133
|
+
dangerGhostHoverBackground: alpha(colors?.contrasts?.red4570, 10),
|
|
134
|
+
dangerGhostActiveBackground: 'transparent',
|
|
135
|
+
dangerGhostActiveBoxShadow: `${activeShadow} ${alpha(
|
|
136
|
+
colors?.contrasts?.red4570,
|
|
137
|
+
28
|
|
214
138
|
)}`,
|
|
215
139
|
|
|
216
|
-
|
|
217
|
-
|
|
140
|
+
primaryInverseColor: colors?.contrasts?.grey125125,
|
|
141
|
+
primaryInverseBorderColor: colors?.contrasts?.grey1214,
|
|
142
|
+
primaryInverseBackground: colors?.contrasts?.white1010,
|
|
143
|
+
primaryInverseHoverBackground: colors?.contrasts?.grey1111,
|
|
144
|
+
primaryInverseActiveBackground: colors?.contrasts?.white1010,
|
|
145
|
+
primaryInverseActiveBoxShadow: `${activeShadow} ${colors?.contrasts?.white1010}`,
|
|
146
|
+
primaryInverseGhostColor: colors?.contrasts?.white1010,
|
|
147
|
+
primaryInverseGhostBorderColor: colors?.contrasts?.white1010,
|
|
148
|
+
primaryInverseGhostBackground: 'transparent',
|
|
149
|
+
primaryInverseGhostHoverBackground: alpha(colors?.contrasts?.white1010, 10),
|
|
150
|
+
primaryInverseGhostActiveBackground: 'transparent',
|
|
151
|
+
primaryInverseGhostActiveBoxShadow: `${activeShadow} ${alpha(
|
|
152
|
+
colors?.contrasts?.white1010,
|
|
153
|
+
28
|
|
154
|
+
)}`
|
|
218
155
|
}
|
|
219
156
|
|
|
220
157
|
return {
|
|
221
|
-
...componentVariables
|
|
222
|
-
...themeSpecificStyle[themeName]
|
|
158
|
+
...componentVariables
|
|
223
159
|
}
|
|
224
160
|
}
|
|
225
161
|
|