@instructure/ui-heading 11.6.0 → 11.6.1-snapshot-129
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 +42 -304
- package/es/Heading/{index.js → v1/index.js} +2 -2
- package/es/Heading/v2/index.js +266 -0
- package/es/Heading/v2/props.js +26 -0
- package/es/Heading/v2/styles.js +273 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -3
- package/lib/Heading/{index.js → v1/index.js} +4 -4
- package/lib/Heading/v2/index.js +271 -0
- package/lib/Heading/v2/props.js +31 -0
- package/lib/Heading/v2/styles.js +279 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +39 -17
- package/src/Heading/{index.tsx → v1/index.tsx} +2 -2
- package/src/Heading/v2/README.md +158 -0
- package/src/Heading/v2/index.tsx +291 -0
- package/src/Heading/v2/props.ts +133 -0
- package/src/Heading/v2/styles.ts +273 -0
- package/src/exports/a.ts +26 -0
- package/src/exports/b.ts +26 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Heading/v1/index.d.ts.map +1 -0
- package/types/Heading/v1/props.d.ts.map +1 -0
- package/types/Heading/v1/styles.d.ts.map +1 -0
- package/types/Heading/v1/theme.d.ts.map +1 -0
- package/types/Heading/v2/index.d.ts +40 -0
- package/types/Heading/v2/index.d.ts.map +1 -0
- package/types/Heading/v2/props.d.ts +62 -0
- package/types/Heading/v2/props.d.ts.map +1 -0
- package/types/Heading/v2/styles.d.ts +14 -0
- package/types/Heading/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Heading/index.d.ts.map +0 -1
- package/types/Heading/props.d.ts.map +0 -1
- package/types/Heading/styles.d.ts.map +0 -1
- package/types/Heading/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/Heading/{props.js → v1/props.js} +0 -0
- /package/es/Heading/{styles.js → v1/styles.js} +0 -0
- /package/es/Heading/{theme.js → v1/theme.js} +0 -0
- /package/lib/Heading/{props.js → v1/props.js} +0 -0
- /package/lib/Heading/{styles.js → v1/styles.js} +0 -0
- /package/lib/Heading/{theme.js → v1/theme.js} +0 -0
- /package/src/Heading/{README.md → v1/README.md} +0 -0
- /package/src/Heading/{props.ts → v1/props.ts} +0 -0
- /package/src/Heading/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Heading/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Heading/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/Heading/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Heading/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Heading/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,273 @@
|
|
|
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
|
+
import type { NewComponentTypes } from '@instructure/ui-themes'
|
|
26
|
+
import type { HeadingProps, HeadingStyle } from './props'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ---
|
|
30
|
+
* private: true
|
|
31
|
+
* ---
|
|
32
|
+
* Generates the style object from the theme and provided additional information
|
|
33
|
+
* @param {Object} componentTheme The theme variable object.
|
|
34
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
35
|
+
* @return {Object} The final style object, which will be used in the component
|
|
36
|
+
*/
|
|
37
|
+
const generateStyle = (
|
|
38
|
+
componentTheme: NewComponentTypes['Heading'],
|
|
39
|
+
props: HeadingProps
|
|
40
|
+
): HeadingStyle => {
|
|
41
|
+
const { level, color, border, variant, aiVariant } = props
|
|
42
|
+
|
|
43
|
+
const variants: Record<NonNullable<HeadingProps['variant']>, object> = {
|
|
44
|
+
titlePageDesktop: {
|
|
45
|
+
fontStyle: 'normal',
|
|
46
|
+
...componentTheme.titlePageDesktop
|
|
47
|
+
},
|
|
48
|
+
titlePageMobile: {
|
|
49
|
+
fontStyle: 'normal',
|
|
50
|
+
...componentTheme.titlePageMobile
|
|
51
|
+
},
|
|
52
|
+
titleSection: {
|
|
53
|
+
fontStyle: 'normal',
|
|
54
|
+
...componentTheme.titleSection
|
|
55
|
+
},
|
|
56
|
+
titleCardSection: {
|
|
57
|
+
fontStyle: 'normal',
|
|
58
|
+
...componentTheme.titleCardSection
|
|
59
|
+
},
|
|
60
|
+
titleModule: {
|
|
61
|
+
fontStyle: 'normal',
|
|
62
|
+
...componentTheme.titleModule
|
|
63
|
+
},
|
|
64
|
+
titleCardLarge: {
|
|
65
|
+
fontStyle: 'normal',
|
|
66
|
+
...componentTheme.titleCardLarge
|
|
67
|
+
},
|
|
68
|
+
titleCardRegular: {
|
|
69
|
+
fontStyle: 'normal',
|
|
70
|
+
...componentTheme.titleCardRegular
|
|
71
|
+
},
|
|
72
|
+
titleCardMini: {
|
|
73
|
+
fontStyle: 'normal',
|
|
74
|
+
...componentTheme.titleCardMini
|
|
75
|
+
},
|
|
76
|
+
label: {
|
|
77
|
+
fontStyle: 'normal',
|
|
78
|
+
...componentTheme.label
|
|
79
|
+
},
|
|
80
|
+
labelInline: {
|
|
81
|
+
fontStyle: 'normal',
|
|
82
|
+
...componentTheme.labelInline
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const levelStyles = {
|
|
87
|
+
h1: {
|
|
88
|
+
fontFamily: componentTheme.h1FontFamily,
|
|
89
|
+
fontSize: componentTheme.h1FontSize,
|
|
90
|
+
fontWeight: componentTheme.h1FontWeight
|
|
91
|
+
},
|
|
92
|
+
h2: {
|
|
93
|
+
fontFamily: componentTheme.h2FontFamily,
|
|
94
|
+
fontSize: componentTheme.h2FontSize,
|
|
95
|
+
fontWeight: componentTheme.h2FontWeight
|
|
96
|
+
},
|
|
97
|
+
h3: {
|
|
98
|
+
fontFamily: componentTheme.h3FontFamily,
|
|
99
|
+
fontSize: componentTheme.h3FontSize,
|
|
100
|
+
fontWeight: componentTheme.h3FontWeight
|
|
101
|
+
},
|
|
102
|
+
h4: {
|
|
103
|
+
fontFamily: componentTheme.h4FontFamily,
|
|
104
|
+
fontSize: componentTheme.h4FontSize,
|
|
105
|
+
fontWeight: componentTheme.h4FontWeight
|
|
106
|
+
},
|
|
107
|
+
h5: {
|
|
108
|
+
fontFamily: componentTheme.h5FontFamily,
|
|
109
|
+
fontSize: componentTheme.h5FontSize,
|
|
110
|
+
fontWeight: componentTheme.h5FontWeight
|
|
111
|
+
},
|
|
112
|
+
h6: {
|
|
113
|
+
fontFamily: componentTheme.h6FontFamily,
|
|
114
|
+
fontSize: componentTheme.h6FontSize,
|
|
115
|
+
fontWeight: componentTheme.h6FontWeight
|
|
116
|
+
},
|
|
117
|
+
reset: {
|
|
118
|
+
margin: 0,
|
|
119
|
+
fontSize: 'inherit',
|
|
120
|
+
fontWeight: 'inherit',
|
|
121
|
+
lineHeight: 'inherit'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const colorStyles = {
|
|
126
|
+
inherit: { color: 'inherit' },
|
|
127
|
+
primary: { color: componentTheme.baseColor },
|
|
128
|
+
secondary: { color: componentTheme.mutedColor },
|
|
129
|
+
'primary-inverse': { color: componentTheme.inverseColor },
|
|
130
|
+
'secondary-inverse': { color: componentTheme.inverseColor },
|
|
131
|
+
'primary-on': { color: componentTheme.baseOnColor },
|
|
132
|
+
'secondary-on': { color: componentTheme.mutedOnColor },
|
|
133
|
+
ai: {
|
|
134
|
+
background: `
|
|
135
|
+
linear-gradient(to bottom, ${componentTheme.aiTextTopGradientColor} 0%, ${componentTheme.aiTextBottomGradientColor} 100%) text`,
|
|
136
|
+
border: 'solid transparent',
|
|
137
|
+
WebkitTextFillColor: 'transparent',
|
|
138
|
+
'@media print': {
|
|
139
|
+
background: 'transparent',
|
|
140
|
+
WebkitTextFillColor: 'unset'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const borderStyles = {
|
|
146
|
+
top: {
|
|
147
|
+
paddingTop: componentTheme.borderPadding,
|
|
148
|
+
borderTop: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`
|
|
149
|
+
},
|
|
150
|
+
bottom: {
|
|
151
|
+
paddingBottom: componentTheme.borderPadding,
|
|
152
|
+
borderBottom: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`
|
|
153
|
+
},
|
|
154
|
+
none: {}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const inputStyles = {
|
|
158
|
+
outline: 0,
|
|
159
|
+
appearance: 'none',
|
|
160
|
+
boxSizing: 'border-box',
|
|
161
|
+
background: 'none',
|
|
162
|
+
border: 'none',
|
|
163
|
+
borderRadius: 0,
|
|
164
|
+
padding: 0,
|
|
165
|
+
margin: '-0.375rem 0 0 0',
|
|
166
|
+
color: 'inherit',
|
|
167
|
+
height: 'auto',
|
|
168
|
+
width: '100%',
|
|
169
|
+
lineHeight: 'inherit',
|
|
170
|
+
textAlign: 'start',
|
|
171
|
+
boxShadow: 'none',
|
|
172
|
+
display: 'block',
|
|
173
|
+
'&:focus': { outline: 'none' }
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const iconGapVariants: Record<
|
|
177
|
+
NonNullable<HeadingProps['variant']>,
|
|
178
|
+
string
|
|
179
|
+
> = {
|
|
180
|
+
titlePageDesktop: componentTheme.gapIconLg,
|
|
181
|
+
titlePageMobile: componentTheme.gapIconLg,
|
|
182
|
+
titleSection: componentTheme.gapIconLg,
|
|
183
|
+
titleCardSection: componentTheme.gapIconLg,
|
|
184
|
+
titleModule: componentTheme.gapIconMd,
|
|
185
|
+
titleCardLarge: componentTheme.gapIconMd,
|
|
186
|
+
titleCardRegular: componentTheme.gapIconMd,
|
|
187
|
+
titleCardMini: componentTheme.gapIconSm,
|
|
188
|
+
label: componentTheme.gapIconSm,
|
|
189
|
+
labelInline: componentTheme.gapIconSm
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const iconGapLevels: Record<
|
|
193
|
+
Exclude<HeadingProps['level'], 'reset' | undefined>,
|
|
194
|
+
string
|
|
195
|
+
> = {
|
|
196
|
+
h1: componentTheme.gapIconLg,
|
|
197
|
+
h2: componentTheme.gapIconLg,
|
|
198
|
+
h3: componentTheme.gapIconMd,
|
|
199
|
+
h4: componentTheme.gapIconMd,
|
|
200
|
+
h5: componentTheme.gapIconSm,
|
|
201
|
+
h6: componentTheme.gapIconSm
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const getIconGap = () => {
|
|
205
|
+
if (variant) return { gap: iconGapVariants[variant] }
|
|
206
|
+
if (level && level !== 'reset') return { gap: iconGapLevels[level] }
|
|
207
|
+
if (
|
|
208
|
+
props.as &&
|
|
209
|
+
typeof props.as === 'string' &&
|
|
210
|
+
['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(props.as)
|
|
211
|
+
) {
|
|
212
|
+
return {
|
|
213
|
+
gap: iconGapLevels[
|
|
214
|
+
props.as as Exclude<HeadingProps['level'], 'reset' | undefined>
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return { gap: componentTheme.gapIconLg }
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
heading: {
|
|
223
|
+
label: 'heading',
|
|
224
|
+
lineHeight: componentTheme.lineHeight,
|
|
225
|
+
margin: 0,
|
|
226
|
+
// NOTE: the input styles exist to accommodate the InPlaceEdit component
|
|
227
|
+
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
|
|
228
|
+
'&:is(input)[type]': inputStyles,
|
|
229
|
+
'&:-webkit-any(input)[type]': inputStyles,
|
|
230
|
+
|
|
231
|
+
...(variant ? variants[variant] : levelStyles[level!]),
|
|
232
|
+
...colorStyles[color!],
|
|
233
|
+
...borderStyles[border!]
|
|
234
|
+
},
|
|
235
|
+
igniteAI: {
|
|
236
|
+
label: 'heading__ignite-ai',
|
|
237
|
+
background: `
|
|
238
|
+
linear-gradient(to bottom, ${componentTheme.aiTextTopGradientColor} 0%, ${componentTheme.aiTextBottomGradientColor} 100%) text`,
|
|
239
|
+
border: 'solid transparent',
|
|
240
|
+
WebkitTextFillColor: 'transparent',
|
|
241
|
+
'@media print': {
|
|
242
|
+
background: 'transparent',
|
|
243
|
+
WebkitTextFillColor: 'unset'
|
|
244
|
+
},
|
|
245
|
+
...(aiVariant !== 'stacked' && { paddingRight: '.25rem' })
|
|
246
|
+
},
|
|
247
|
+
igniteAIStacked: {
|
|
248
|
+
label: 'heading__ignite-ai-stacked',
|
|
249
|
+
fontSize: '1rem',
|
|
250
|
+
lineHeight: '1.25rem',
|
|
251
|
+
display: 'flex',
|
|
252
|
+
alignItems: 'center',
|
|
253
|
+
gap: componentTheme.gapIconSm
|
|
254
|
+
},
|
|
255
|
+
igniteAIHorizontal: {
|
|
256
|
+
label: 'heading__ignite-ai-horizontal',
|
|
257
|
+
display: 'flex',
|
|
258
|
+
alignItems: 'center',
|
|
259
|
+
...getIconGap()
|
|
260
|
+
},
|
|
261
|
+
withIcon: {
|
|
262
|
+
label: 'heading__with-icon',
|
|
263
|
+
display: 'flex',
|
|
264
|
+
alignItems: 'center',
|
|
265
|
+
...(aiVariant === 'stacked' && {
|
|
266
|
+
flexDirection: 'column',
|
|
267
|
+
alignItems: 'flex-start'
|
|
268
|
+
}),
|
|
269
|
+
...getIconGap()
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
export default generateStyle
|
package/src/exports/a.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export { Heading } from '../Heading/v1'
|
|
26
|
+
export type { HeadingProps } from '../Heading/v1/props'
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export { Heading } from '../Heading/v2'
|
|
26
|
+
export type { HeadingProps } from '../Heading/v2/props'
|