@instructure/ui-view 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.
Files changed (97) hide show
  1. package/CHANGELOG.md +42 -307
  2. package/es/ContextView/{index.js → v1/index.js} +2 -2
  3. package/es/ContextView/v2/index.js +125 -0
  4. package/es/ContextView/v2/props.js +26 -0
  5. package/es/ContextView/v2/styles.js +256 -0
  6. package/es/View/{index.js → v1/index.js} +1 -1
  7. package/es/View/v2/index.js +167 -0
  8. package/es/View/v2/props.js +29 -0
  9. package/es/View/v2/styles.js +420 -0
  10. package/es/{index.js → exports/a.js} +2 -2
  11. package/{src/index.ts → es/exports/b.js} +2 -6
  12. package/lib/ContextView/{index.js → v1/index.js} +4 -4
  13. package/lib/ContextView/v2/index.js +130 -0
  14. package/lib/ContextView/v2/props.js +31 -0
  15. package/lib/ContextView/v2/styles.js +262 -0
  16. package/lib/View/{index.js → v1/index.js} +1 -1
  17. package/lib/View/v2/index.js +175 -0
  18. package/lib/View/v2/props.js +34 -0
  19. package/lib/View/v2/styles.js +426 -0
  20. package/lib/{index.js → exports/a.js} +4 -4
  21. package/lib/exports/b.js +19 -0
  22. package/package.json +41 -19
  23. package/src/ContextView/{index.tsx → v1/index.tsx} +2 -2
  24. package/src/ContextView/v2/README.md +53 -0
  25. package/src/ContextView/v2/index.tsx +144 -0
  26. package/src/ContextView/v2/props.ts +98 -0
  27. package/src/ContextView/v2/styles.ts +332 -0
  28. package/src/View/{index.tsx → v1/index.tsx} +1 -1
  29. package/src/View/v2/README.md +803 -0
  30. package/src/View/v2/index.tsx +240 -0
  31. package/src/View/v2/props.ts +278 -0
  32. package/src/View/v2/styles.ts +503 -0
  33. package/src/exports/a.ts +29 -0
  34. package/src/exports/b.ts +29 -0
  35. package/tsconfig.build.tsbuildinfo +1 -1
  36. package/types/ContextView/v1/index.d.ts.map +1 -0
  37. package/types/ContextView/v1/props.d.ts.map +1 -0
  38. package/types/ContextView/v1/styles.d.ts.map +1 -0
  39. package/types/ContextView/v1/theme.d.ts.map +1 -0
  40. package/types/ContextView/v2/index.d.ts +50 -0
  41. package/types/ContextView/v2/index.d.ts.map +1 -0
  42. package/types/ContextView/v2/props.d.ts +36 -0
  43. package/types/ContextView/v2/props.d.ts.map +1 -0
  44. package/types/ContextView/v2/styles.d.ts +14 -0
  45. package/types/ContextView/v2/styles.d.ts.map +1 -0
  46. package/types/View/v1/index.d.ts.map +1 -0
  47. package/types/View/v1/props.d.ts.map +1 -0
  48. package/types/View/v1/styles.d.ts.map +1 -0
  49. package/types/View/v1/theme.d.ts.map +1 -0
  50. package/types/View/v2/index.d.ts +36 -0
  51. package/types/View/v2/index.d.ts.map +1 -0
  52. package/types/View/v2/props.d.ts +157 -0
  53. package/types/View/v2/props.d.ts.map +1 -0
  54. package/types/View/v2/styles.d.ts +11 -0
  55. package/types/View/v2/styles.d.ts.map +1 -0
  56. package/types/exports/a.d.ts +5 -0
  57. package/types/exports/a.d.ts.map +1 -0
  58. package/types/exports/b.d.ts +5 -0
  59. package/types/exports/b.d.ts.map +1 -0
  60. package/types/ContextView/index.d.ts.map +0 -1
  61. package/types/ContextView/props.d.ts.map +0 -1
  62. package/types/ContextView/styles.d.ts.map +0 -1
  63. package/types/ContextView/theme.d.ts.map +0 -1
  64. package/types/View/index.d.ts.map +0 -1
  65. package/types/View/props.d.ts.map +0 -1
  66. package/types/View/styles.d.ts.map +0 -1
  67. package/types/View/theme.d.ts.map +0 -1
  68. package/types/index.d.ts +0 -5
  69. package/types/index.d.ts.map +0 -1
  70. /package/es/ContextView/{props.js → v1/props.js} +0 -0
  71. /package/es/ContextView/{styles.js → v1/styles.js} +0 -0
  72. /package/es/ContextView/{theme.js → v1/theme.js} +0 -0
  73. /package/es/View/{props.js → v1/props.js} +0 -0
  74. /package/es/View/{styles.js → v1/styles.js} +0 -0
  75. /package/es/View/{theme.js → v1/theme.js} +0 -0
  76. /package/lib/ContextView/{props.js → v1/props.js} +0 -0
  77. /package/lib/ContextView/{styles.js → v1/styles.js} +0 -0
  78. /package/lib/ContextView/{theme.js → v1/theme.js} +0 -0
  79. /package/lib/View/{props.js → v1/props.js} +0 -0
  80. /package/lib/View/{styles.js → v1/styles.js} +0 -0
  81. /package/lib/View/{theme.js → v1/theme.js} +0 -0
  82. /package/src/ContextView/{README.md → v1/README.md} +0 -0
  83. /package/src/ContextView/{props.ts → v1/props.ts} +0 -0
  84. /package/src/ContextView/{styles.ts → v1/styles.ts} +0 -0
  85. /package/src/ContextView/{theme.ts → v1/theme.ts} +0 -0
  86. /package/src/View/{README.md → v1/README.md} +0 -0
  87. /package/src/View/{props.ts → v1/props.ts} +0 -0
  88. /package/src/View/{styles.ts → v1/styles.ts} +0 -0
  89. /package/src/View/{theme.ts → v1/theme.ts} +0 -0
  90. /package/types/ContextView/{index.d.ts → v1/index.d.ts} +0 -0
  91. /package/types/ContextView/{props.d.ts → v1/props.d.ts} +0 -0
  92. /package/types/ContextView/{styles.d.ts → v1/styles.d.ts} +0 -0
  93. /package/types/ContextView/{theme.d.ts → v1/theme.d.ts} +0 -0
  94. /package/types/View/{index.d.ts → v1/index.d.ts} +0 -0
  95. /package/types/View/{props.d.ts → v1/props.d.ts} +0 -0
  96. /package/types/View/{styles.d.ts → v1/styles.d.ts} +0 -0
  97. /package/types/View/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,144 @@
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 { Component } from 'react'
26
+
27
+ import { withStyle } from '@instructure/emotion'
28
+ import { omitProps } from '@instructure/ui-react-utils'
29
+
30
+ import { View } from '../../View/v2'
31
+
32
+ import generateStyle from './styles'
33
+ import { allowedProps } from './props'
34
+ import type { ContextViewProps } from './props'
35
+
36
+ /**
37
+ ---
38
+ category: components
39
+ ---
40
+ **/
41
+
42
+ @withStyle(generateStyle)
43
+ class ContextView extends Component<ContextViewProps> {
44
+ static readonly componentId = 'ContextView'
45
+ static allowedProps = allowedProps
46
+ static defaultProps = {
47
+ as: 'span',
48
+ elementRef: () => {},
49
+ debug: false,
50
+ width: 'auto',
51
+ height: 'auto',
52
+ children: null,
53
+ textAlign: 'start',
54
+ background: 'default',
55
+ shadow: 'above',
56
+ placement: 'center end'
57
+ }
58
+
59
+ componentDidMount() {
60
+ this.props.makeStyles?.()
61
+ }
62
+
63
+ componentDidUpdate() {
64
+ this.props.makeStyles?.()
65
+ }
66
+
67
+ ref: Element | null = null
68
+
69
+ handleRef = (el: Element | null) => {
70
+ const { elementRef } = this.props
71
+
72
+ this.ref = el
73
+
74
+ if (typeof elementRef === 'function') {
75
+ elementRef(el)
76
+ }
77
+ }
78
+
79
+ render() {
80
+ const {
81
+ as,
82
+ background,
83
+ children,
84
+ debug,
85
+ height,
86
+ width,
87
+ maxHeight,
88
+ maxWidth,
89
+ minHeight,
90
+ minWidth,
91
+ margin,
92
+ padding,
93
+ shadow,
94
+ stacking,
95
+ style,
96
+ textAlign,
97
+ styles,
98
+ borderColor
99
+ } = this.props
100
+
101
+ return (
102
+ <View
103
+ {...omitProps(this.props, ContextView.allowedProps)}
104
+ css={styles?.contextView}
105
+ style={style}
106
+ borderWidth="none"
107
+ display="inline-block"
108
+ as={as}
109
+ withVisualDebug={debug}
110
+ elementRef={this.handleRef}
111
+ margin={margin}
112
+ stacking={stacking}
113
+ >
114
+ <View
115
+ css={styles?.contextView__content}
116
+ display="block"
117
+ borderRadius={styles?.borderRadius}
118
+ borderWidth="small"
119
+ borderColor={
120
+ borderColor ||
121
+ (background === 'default' ? 'primary' : 'transparent')
122
+ }
123
+ background={background === 'default' ? 'primary' : 'primary-inverse'}
124
+ withVisualDebug={debug}
125
+ height={height}
126
+ width={width}
127
+ maxHeight={maxHeight}
128
+ maxWidth={maxWidth}
129
+ minHeight={minHeight}
130
+ minWidth={minWidth}
131
+ padding={padding}
132
+ shadow={shadow}
133
+ textAlign={textAlign}
134
+ >
135
+ <span css={styles?.contextView__arrow} />
136
+ {children}
137
+ </View>
138
+ </View>
139
+ )
140
+ }
141
+ }
142
+
143
+ export default ContextView
144
+ export { ContextView }
@@ -0,0 +1,98 @@
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 React from 'react'
26
+ import type {
27
+ AsElementType,
28
+ ContextViewTheme,
29
+ OtherHTMLAttributes
30
+ } from '@instructure/shared-types'
31
+ import type { PlacementPropValues } from '@instructure/ui-position'
32
+ import type {
33
+ Shadow,
34
+ Spacing,
35
+ Stacking,
36
+ WithStyleProps,
37
+ ComponentStyle
38
+ } from '@instructure/emotion'
39
+
40
+ type ContextViewOwnProps = {
41
+ as?: AsElementType
42
+ elementRef?: (element: Element | null) => void
43
+ height?: string | number
44
+ width?: string | number
45
+ maxHeight?: string | number
46
+ maxWidth?: string | number
47
+ minHeight?: string | number
48
+ minWidth?: string | number
49
+ children?: React.ReactNode
50
+ textAlign?: 'start' | 'center' | 'end'
51
+ background?: 'default' | 'inverse'
52
+ debug?: boolean
53
+ margin?: Spacing
54
+ padding?: Spacing
55
+ shadow?: Shadow
56
+ stacking?: Stacking
57
+ placement?: PlacementPropValues
58
+ borderColor?: string
59
+ }
60
+
61
+ type PropKeys = keyof ContextViewOwnProps
62
+
63
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
64
+
65
+ type ContextViewProps = ContextViewOwnProps &
66
+ WithStyleProps<ContextViewTheme, ContextViewStyle> &
67
+ OtherHTMLAttributes<ContextViewOwnProps>
68
+
69
+ type ContextViewStyle = ComponentStyle<
70
+ 'contextView' | 'contextView__content' | 'contextView__arrow'
71
+ > & {
72
+ arrowSize: string | 0
73
+ arrowBorderWidth: string | 0
74
+ borderRadius: string
75
+ }
76
+ const allowedProps: AllowedPropKeys = [
77
+ 'as',
78
+ 'elementRef',
79
+ 'margin',
80
+ 'padding',
81
+ 'height',
82
+ 'width',
83
+ 'maxHeight',
84
+ 'maxWidth',
85
+ 'minHeight',
86
+ 'minWidth',
87
+ 'children',
88
+ 'textAlign',
89
+ 'shadow',
90
+ 'stacking',
91
+ 'background',
92
+ 'placement',
93
+ 'debug',
94
+ 'borderColor'
95
+ ]
96
+
97
+ export type { ContextViewProps, ContextViewStyle }
98
+ export { allowedProps }
@@ -0,0 +1,332 @@
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 { mirrorPlacement } from '@instructure/ui-position'
26
+
27
+ import type { NewComponentTypes } from '@instructure/ui-themes'
28
+ import type { PlacementPropValues } from '@instructure/ui-position'
29
+ import type { ContextViewProps, ContextViewStyle } from './props'
30
+
31
+ type PlacementArray = PlacementPropValues[]
32
+
33
+ const endPlacements: PlacementArray = [
34
+ 'end center',
35
+ 'end top',
36
+ 'end bottom',
37
+ 'end stretch',
38
+ 'center end',
39
+ 'end'
40
+ ]
41
+ const startPlacements: PlacementArray = [
42
+ 'start center',
43
+ 'start top',
44
+ 'start bottom',
45
+ 'start stretch',
46
+ 'center start',
47
+ 'start'
48
+ ]
49
+ const bottomPlacements: PlacementArray = [
50
+ 'bottom',
51
+ 'bottom end',
52
+ 'bottom start',
53
+ 'bottom stretch',
54
+ 'bottom center'
55
+ ]
56
+ const topPlacements: PlacementArray = [
57
+ 'top',
58
+ 'top start',
59
+ 'top end',
60
+ 'top stretch',
61
+ 'top center'
62
+ ]
63
+
64
+ const getPlacementStyle = (
65
+ placement: PlacementPropValues,
66
+ theme: NewComponentTypes['ContextView']
67
+ ) => {
68
+ if (endPlacements.includes(placement)) {
69
+ return { paddingInlineStart: theme?.arrowSize, paddingInlineEnd: '0' }
70
+ }
71
+ if (startPlacements.includes(placement)) {
72
+ return { paddingInlineEnd: theme?.arrowSize, paddingInlineStart: '0' }
73
+ }
74
+ if (bottomPlacements.includes(placement)) {
75
+ return { paddingTop: theme?.arrowSize }
76
+ }
77
+ if (topPlacements.includes(placement)) {
78
+ return { paddingBottom: theme?.arrowSize }
79
+ }
80
+
81
+ return { position: 'absolute', left: '-999em' }
82
+ }
83
+
84
+ const getArrowCorrections = (
85
+ placement: PlacementPropValues,
86
+ theme: NewComponentTypes['ContextView']
87
+ ) => {
88
+ const center: PlacementArray = [
89
+ 'top',
90
+ 'bottom',
91
+ 'top center',
92
+ 'bottom center',
93
+ 'top stretch',
94
+ 'bottom stretch'
95
+ ]
96
+ const start: PlacementArray = ['top start', 'bottom start']
97
+ const end: PlacementArray = ['top end', 'bottom end']
98
+ const top: PlacementArray = ['start top', 'end top']
99
+ const bottom: PlacementArray = ['start bottom', 'end bottom']
100
+
101
+ if (center.includes(placement)) {
102
+ return {
103
+ insetInlineStart: '50%'
104
+ }
105
+ }
106
+ if (start.includes(placement)) {
107
+ return {
108
+ insetInlineStart: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
109
+ insetInlineEnd: 'auto'
110
+ }
111
+ }
112
+ if (end.includes(placement)) {
113
+ return {
114
+ insetInlineStart: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
115
+ insetInlineEnd: 'auto'
116
+ }
117
+ }
118
+ if (top.includes(placement)) {
119
+ return {
120
+ top: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
121
+ }
122
+ }
123
+ if (bottom.includes(placement)) {
124
+ return {
125
+ top: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
126
+ }
127
+ }
128
+
129
+ return {}
130
+ }
131
+
132
+ const getArrowPlacementVariant = (
133
+ placement: PlacementPropValues,
134
+ background: ContextViewProps['background'],
135
+ theme: NewComponentTypes['ContextView'],
136
+ props: ContextViewProps
137
+ ) => {
138
+ const transformedPlacement = mirrorPlacement(placement, ' ')
139
+ const isInversed = background === 'inverse'
140
+ const { borderColor } = props
141
+
142
+ if (endPlacements.includes(transformedPlacement)) {
143
+ return {
144
+ main: {
145
+ top: '50%',
146
+ insetInlineStart: '100%',
147
+ insetInlineEnd: 'auto',
148
+ marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
149
+ borderInlineEndWidth: '0',
150
+ borderInlineEndColor: 'transparent',
151
+ borderInlineStartColor:
152
+ borderColor ||
153
+ (isInversed
154
+ ? theme?.arrowBorderColorInverse
155
+ : theme?.arrowBorderColor),
156
+ borderTopColor: 'transparent',
157
+ borderBottomColor: 'transparent',
158
+ borderInlineStartWidth: theme?.arrowSize
159
+ },
160
+
161
+ __after: {
162
+ insetInlineEnd: theme?.arrowBorderWidth,
163
+ insetInlineStart: 'auto',
164
+ marginTop: `calc(-1 * ${theme?.arrowSize})`,
165
+ borderInlineEndWidth: '0',
166
+ borderInlineEndColor: 'transparent',
167
+ borderTopColor: 'transparent',
168
+ borderBottomColor: 'transparent',
169
+ borderInlineStartWidth: theme?.arrowSize,
170
+ borderInlineStartColor: isInversed
171
+ ? theme?.arrowBackgroundColorInverse
172
+ : theme?.arrowBackgroundColor
173
+ }
174
+ }
175
+ }
176
+
177
+ if (startPlacements.includes(transformedPlacement)) {
178
+ return {
179
+ main: {
180
+ top: '50%',
181
+ insetInlineEnd: '100%',
182
+ insetInlineStart: 'auto',
183
+ marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
184
+ borderInlineStartWidth: '0',
185
+ borderInlineStartColor: 'transparent',
186
+ borderInlineEndColor:
187
+ borderColor ||
188
+ (isInversed
189
+ ? theme?.arrowBorderColorInverse
190
+ : theme?.arrowBorderColor),
191
+ borderTopColor: 'transparent',
192
+ borderBottomColor: 'transparent',
193
+ borderInlineEndWidth: theme?.arrowSize
194
+ },
195
+ __after: {
196
+ insetInlineStart: theme?.arrowBorderWidth,
197
+ insetInlineEnd: 'auto',
198
+ marginTop: `calc(-1 * ${theme?.arrowSize})`,
199
+ borderInlineStartWidth: '0',
200
+ borderInlineStartColor: 'transparent',
201
+ borderTopColor: 'transparent',
202
+ borderBottomColor: 'transparent',
203
+ borderInlineEndWidth: theme?.arrowSize,
204
+ borderInlineEndColor: isInversed
205
+ ? theme?.arrowBackgroundColorInverse
206
+ : theme?.arrowBackgroundColor
207
+ }
208
+ }
209
+ }
210
+
211
+ if (bottomPlacements.includes(transformedPlacement)) {
212
+ return {
213
+ main: {
214
+ top: '100%',
215
+ marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
216
+ marginInlineEnd: '0',
217
+ borderBottomWidth: '0',
218
+ borderBottomColor: 'transparent',
219
+ borderInlineStartColor: 'transparent',
220
+ borderInlineEndColor: 'transparent'
221
+ },
222
+ __after: {
223
+ bottom: theme?.arrowBorderWidth,
224
+ marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
225
+ marginInlineEnd: '0',
226
+ borderBottomWidth: '0',
227
+ borderBottomColor: 'transparent',
228
+ borderInlineStartColor: 'transparent',
229
+ borderInlineEndColor: 'transparent',
230
+ borderTopColor: isInversed
231
+ ? theme?.arrowBackgroundColorInverse
232
+ : theme?.arrowBackgroundColor
233
+ }
234
+ }
235
+ }
236
+
237
+ return {
238
+ main: {
239
+ bottom: '100%',
240
+ marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
241
+ marginInlineEnd: '0',
242
+ borderTopWidth: '0',
243
+ borderTopColor: 'transparent',
244
+ borderInlineStartColor: 'transparent',
245
+ borderInlineEndColor: 'transparent'
246
+ },
247
+ __after: {
248
+ top: theme?.arrowBorderWidth,
249
+ marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
250
+ marginInlineEnd: '0',
251
+ borderTopWidth: '0',
252
+ borderTopColor: 'transparent',
253
+ borderInlineStartColor: 'transparent',
254
+ borderInlineEndColor: 'transparent',
255
+ borderBottomColor: isInversed
256
+ ? theme?.arrowBackgroundColorInverse
257
+ : theme?.arrowBackgroundColor
258
+ }
259
+ }
260
+ }
261
+
262
+ /**
263
+ * ---
264
+ * private: true
265
+ * ---
266
+ * Generates the style object from the theme and provided additional information
267
+ * @param {Object} componentTheme The theme variable object.
268
+ * @param {Object} props the props of the component, the style is applied to
269
+ * @return {Object} The final style object, which will be used in the component
270
+ */
271
+ const generateStyle = (
272
+ componentTheme: NewComponentTypes['ContextView'],
273
+ props: ContextViewProps
274
+ ): ContextViewStyle => {
275
+ const { placement, background, borderColor } = props
276
+
277
+ const arrowBaseStyles = {
278
+ content: '""',
279
+ height: '0',
280
+ width: '0',
281
+ position: 'absolute',
282
+ display: 'block',
283
+ boxSizing: 'border-box',
284
+ pointerEvents: 'none',
285
+ borderStyle: 'solid'
286
+ }
287
+
288
+ const arrowBackGroundVariants = {
289
+ default: componentTheme?.arrowBorderColor,
290
+ inverse: componentTheme?.arrowBorderColorInverse
291
+ }
292
+
293
+ const arrowPlacementVariant = getArrowPlacementVariant(
294
+ placement!,
295
+ background,
296
+ componentTheme,
297
+ props
298
+ )
299
+
300
+ return {
301
+ borderRadius: componentTheme?.borderRadius,
302
+ contextView: {
303
+ label: 'contextView',
304
+ boxSizing: 'border-box',
305
+ minHeight: `calc(${componentTheme?.arrowSize} * 2)`,
306
+ ...getPlacementStyle(placement!, componentTheme)
307
+ },
308
+ contextView__content: {
309
+ label: 'contextView__content',
310
+ position: 'relative'
311
+ },
312
+ contextView__arrow: {
313
+ label: 'contextView__arrow',
314
+ ...arrowBaseStyles,
315
+ display: 'block',
316
+ borderWidth: `calc(${componentTheme?.arrowSize} + ${componentTheme?.arrowBorderWidth})`,
317
+ borderColor: borderColor || arrowBackGroundVariants[background!],
318
+ ...arrowPlacementVariant.main,
319
+ ...getArrowCorrections(placement!, componentTheme),
320
+ '&::after': {
321
+ borderWidth: componentTheme?.arrowSize,
322
+ borderColor: arrowBackGroundVariants[background!],
323
+ ...arrowPlacementVariant.__after,
324
+ ...arrowBaseStyles
325
+ }
326
+ },
327
+ arrowSize: componentTheme.arrowSize,
328
+ arrowBorderWidth: componentTheme.arrowBorderWidth
329
+ }
330
+ }
331
+
332
+ export default generateStyle
@@ -33,7 +33,7 @@ import {
33
33
  pickProps,
34
34
  passthroughProps
35
35
  } from '@instructure/ui-react-utils'
36
- import { withStyle } from '@instructure/emotion'
36
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
37
37
 
38
38
  import generateStyle from './styles'
39
39
  import generateComponentTheme from './theme'