@instructure/ui-view 10.5.1-snapshot-2 → 10.5.1-snapshot-4
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 +5 -2
- package/es/ContextView/index.js +3 -2
- package/es/ContextView/props.js +7 -2
- package/es/ContextView/styles.js +8 -6
- package/es/View/props.js +1 -1
- package/es/View/styles.js +3 -1
- package/lib/ContextView/index.js +3 -2
- package/lib/ContextView/props.js +7 -2
- package/lib/ContextView/styles.js +8 -6
- package/lib/View/props.js +1 -1
- package/lib/View/styles.js +3 -1
- package/package.json +14 -14
- package/src/ContextView/index.tsx +6 -2
- package/src/ContextView/props.ts +10 -2
- package/src/ContextView/styles.ts +17 -10
- package/src/View/props.ts +17 -23
- package/src/View/styles.ts +5 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ContextView/index.d.ts +2 -0
- package/types/ContextView/index.d.ts.map +1 -1
- package/types/ContextView/props.d.ts +1 -0
- package/types/ContextView/props.d.ts.map +1 -1
- package/types/ContextView/styles.d.ts.map +1 -1
- package/types/View/props.d.ts +5 -3
- package/types/View/props.d.ts.map +1 -1
- package/types/View/styles.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.5.1-snapshot-
|
|
6
|
+
## [10.5.1-snapshot-4](https://github.com/instructure/instructure-ui/compare/v10.5.0...v10.5.1-snapshot-4) (2024-11-14)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ui-view:** add borderColor prop to ContextView; make borderColor accept HEX code as a string in View ([a823d51](https://github.com/instructure/instructure-ui/commit/a823d51b16f237629e3342ed4195a41a09eefbac))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/ContextView/index.js
CHANGED
|
@@ -74,7 +74,8 @@ let ContextView = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
74
74
|
stacking = _this$props3.stacking,
|
|
75
75
|
style = _this$props3.style,
|
|
76
76
|
textAlign = _this$props3.textAlign,
|
|
77
|
-
styles = _this$props3.styles
|
|
77
|
+
styles = _this$props3.styles,
|
|
78
|
+
borderColor = _this$props3.borderColor;
|
|
78
79
|
return jsx(View, Object.assign({}, omitProps(this.props, ContextView.allowedProps), {
|
|
79
80
|
css: styles === null || styles === void 0 ? void 0 : styles.contextView,
|
|
80
81
|
style: style,
|
|
@@ -90,7 +91,7 @@ let ContextView = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
90
91
|
display: "block",
|
|
91
92
|
borderRadius: "medium",
|
|
92
93
|
borderWidth: "small",
|
|
93
|
-
borderColor: background === 'default' ? 'primary' : 'transparent',
|
|
94
|
+
borderColor: borderColor || (background === 'default' ? 'primary' : 'transparent'),
|
|
94
95
|
background: background === 'default' ? 'primary' : 'primary-inverse',
|
|
95
96
|
withVisualDebug: debug,
|
|
96
97
|
height: height,
|
package/es/ContextView/props.js
CHANGED
|
@@ -81,7 +81,12 @@ const propTypes = {
|
|
|
81
81
|
* Activate an outline around the component to make building your
|
|
82
82
|
* layout easier
|
|
83
83
|
*/
|
|
84
|
-
debug: PropTypes.bool
|
|
84
|
+
debug: PropTypes.bool,
|
|
85
|
+
/**
|
|
86
|
+
* Sets the color of the ContextView border.
|
|
87
|
+
* Accepts a color string value (e.g., "#FFFFFF", "red")
|
|
88
|
+
*/
|
|
89
|
+
borderColor: PropTypes.string
|
|
85
90
|
};
|
|
86
|
-
const allowedProps = ['as', 'elementRef', 'margin', 'padding', 'height', 'width', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'children', 'textAlign', 'shadow', 'stacking', 'background', 'placement', 'debug'];
|
|
91
|
+
const allowedProps = ['as', 'elementRef', 'margin', 'padding', 'height', 'width', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'children', 'textAlign', 'shadow', 'stacking', 'background', 'placement', 'debug', 'borderColor'];
|
|
87
92
|
export { propTypes, allowedProps };
|
package/es/ContextView/styles.js
CHANGED
|
@@ -90,9 +90,10 @@ const getArrowCorrections = (placement, theme) => {
|
|
|
90
90
|
}
|
|
91
91
|
return {};
|
|
92
92
|
};
|
|
93
|
-
const getArrowPlacementVariant = (placement, background, theme) => {
|
|
93
|
+
const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
94
94
|
const transformedPlacement = mirrorPlacement(placement, ' ');
|
|
95
95
|
const isInversed = background === 'inverse';
|
|
96
|
+
const borderColor = props.borderColor;
|
|
96
97
|
if (endPlacements.includes(transformedPlacement)) {
|
|
97
98
|
return {
|
|
98
99
|
main: {
|
|
@@ -102,7 +103,7 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
102
103
|
marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
|
|
103
104
|
borderInlineEndWidth: '0',
|
|
104
105
|
borderInlineEndColor: 'transparent',
|
|
105
|
-
borderInlineStartColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor,
|
|
106
|
+
borderInlineStartColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
|
|
106
107
|
borderTopColor: 'transparent',
|
|
107
108
|
borderBottomColor: 'transparent',
|
|
108
109
|
borderInlineStartWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
|
|
@@ -129,7 +130,7 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
129
130
|
marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
|
|
130
131
|
borderInlineStartWidth: '0',
|
|
131
132
|
borderInlineStartColor: 'transparent',
|
|
132
|
-
borderInlineEndColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor,
|
|
133
|
+
borderInlineEndColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
|
|
133
134
|
borderTopColor: 'transparent',
|
|
134
135
|
borderBottomColor: 'transparent',
|
|
135
136
|
borderInlineEndWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
|
|
@@ -205,7 +206,8 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
205
206
|
*/
|
|
206
207
|
const generateStyle = (componentTheme, props) => {
|
|
207
208
|
const placement = props.placement,
|
|
208
|
-
background = props.background
|
|
209
|
+
background = props.background,
|
|
210
|
+
borderColor = props.borderColor;
|
|
209
211
|
const arrowBaseStyles = {
|
|
210
212
|
content: '""',
|
|
211
213
|
height: '0',
|
|
@@ -220,7 +222,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
220
222
|
default: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColor,
|
|
221
223
|
inverse: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColorInverse
|
|
222
224
|
};
|
|
223
|
-
const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme);
|
|
225
|
+
const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
|
|
224
226
|
return {
|
|
225
227
|
contextView: {
|
|
226
228
|
label: 'contextView',
|
|
@@ -237,7 +239,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
237
239
|
...arrowBaseStyles,
|
|
238
240
|
display: 'block',
|
|
239
241
|
borderWidth: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} + ${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderWidth})`,
|
|
240
|
-
borderColor: arrowBackGroundVariants[background],
|
|
242
|
+
borderColor: borderColor || arrowBackGroundVariants[background],
|
|
241
243
|
...arrowPlacementVariant.main,
|
|
242
244
|
...getArrowCorrections(placement, componentTheme),
|
|
243
245
|
'&::after': {
|
package/es/View/props.js
CHANGED
|
@@ -44,7 +44,7 @@ const propTypes = {
|
|
|
44
44
|
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
45
45
|
borderWidth: ThemeablePropTypes.borderWidth,
|
|
46
46
|
borderRadius: ThemeablePropTypes.borderRadius,
|
|
47
|
-
borderColor: PropTypes.
|
|
47
|
+
borderColor: PropTypes.string,
|
|
48
48
|
background: PropTypes.oneOf(['transparent', 'primary', 'secondary', 'primary-inverse', 'brand', 'info', 'alert', 'success', 'danger', 'warning']),
|
|
49
49
|
shadow: ThemeablePropTypes.shadow,
|
|
50
50
|
stacking: ThemeablePropTypes.stacking,
|
package/es/View/styles.js
CHANGED
|
@@ -453,7 +453,9 @@ const generateStyle = (componentTheme, props) => {
|
|
|
453
453
|
} : {}),
|
|
454
454
|
...(withBorder(props) ? {
|
|
455
455
|
borderStyle: componentTheme.borderStyle,
|
|
456
|
-
...borderColorVariants[borderColor]
|
|
456
|
+
...(borderColorVariants[borderColor] || {
|
|
457
|
+
borderColor: borderColor
|
|
458
|
+
})
|
|
457
459
|
} : {}),
|
|
458
460
|
...(shouldUseFocusStyles ? focusStyles : {})
|
|
459
461
|
},
|
package/lib/ContextView/index.js
CHANGED
|
@@ -80,7 +80,8 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
80
80
|
stacking = _this$props3.stacking,
|
|
81
81
|
style = _this$props3.style,
|
|
82
82
|
textAlign = _this$props3.textAlign,
|
|
83
|
-
styles = _this$props3.styles
|
|
83
|
+
styles = _this$props3.styles,
|
|
84
|
+
borderColor = _this$props3.borderColor;
|
|
84
85
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, (0, _omitProps.omitProps)(this.props, ContextView.allowedProps), {
|
|
85
86
|
css: styles === null || styles === void 0 ? void 0 : styles.contextView,
|
|
86
87
|
style: style,
|
|
@@ -96,7 +97,7 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
96
97
|
display: "block",
|
|
97
98
|
borderRadius: "medium",
|
|
98
99
|
borderWidth: "small",
|
|
99
|
-
borderColor: background === 'default' ? 'primary' : 'transparent',
|
|
100
|
+
borderColor: borderColor || (background === 'default' ? 'primary' : 'transparent'),
|
|
100
101
|
background: background === 'default' ? 'primary' : 'primary-inverse',
|
|
101
102
|
withVisualDebug: debug,
|
|
102
103
|
height: height,
|
package/lib/ContextView/props.js
CHANGED
|
@@ -88,6 +88,11 @@ const propTypes = exports.propTypes = {
|
|
|
88
88
|
* Activate an outline around the component to make building your
|
|
89
89
|
* layout easier
|
|
90
90
|
*/
|
|
91
|
-
debug: _propTypes.default.bool
|
|
91
|
+
debug: _propTypes.default.bool,
|
|
92
|
+
/**
|
|
93
|
+
* Sets the color of the ContextView border.
|
|
94
|
+
* Accepts a color string value (e.g., "#FFFFFF", "red")
|
|
95
|
+
*/
|
|
96
|
+
borderColor: _propTypes.default.string
|
|
92
97
|
};
|
|
93
|
-
const allowedProps = exports.allowedProps = ['as', 'elementRef', 'margin', 'padding', 'height', 'width', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'children', 'textAlign', 'shadow', 'stacking', 'background', 'placement', 'debug'];
|
|
98
|
+
const allowedProps = exports.allowedProps = ['as', 'elementRef', 'margin', 'padding', 'height', 'width', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'children', 'textAlign', 'shadow', 'stacking', 'background', 'placement', 'debug', 'borderColor'];
|
|
@@ -96,9 +96,10 @@ const getArrowCorrections = (placement, theme) => {
|
|
|
96
96
|
}
|
|
97
97
|
return {};
|
|
98
98
|
};
|
|
99
|
-
const getArrowPlacementVariant = (placement, background, theme) => {
|
|
99
|
+
const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
100
100
|
const transformedPlacement = (0, _mirrorPlacement.mirrorPlacement)(placement, ' ');
|
|
101
101
|
const isInversed = background === 'inverse';
|
|
102
|
+
const borderColor = props.borderColor;
|
|
102
103
|
if (endPlacements.includes(transformedPlacement)) {
|
|
103
104
|
return {
|
|
104
105
|
main: {
|
|
@@ -108,7 +109,7 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
108
109
|
marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
|
|
109
110
|
borderInlineEndWidth: '0',
|
|
110
111
|
borderInlineEndColor: 'transparent',
|
|
111
|
-
borderInlineStartColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor,
|
|
112
|
+
borderInlineStartColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
|
|
112
113
|
borderTopColor: 'transparent',
|
|
113
114
|
borderBottomColor: 'transparent',
|
|
114
115
|
borderInlineStartWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
|
|
@@ -135,7 +136,7 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
135
136
|
marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
|
|
136
137
|
borderInlineStartWidth: '0',
|
|
137
138
|
borderInlineStartColor: 'transparent',
|
|
138
|
-
borderInlineEndColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor,
|
|
139
|
+
borderInlineEndColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
|
|
139
140
|
borderTopColor: 'transparent',
|
|
140
141
|
borderBottomColor: 'transparent',
|
|
141
142
|
borderInlineEndWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
|
|
@@ -211,7 +212,8 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
211
212
|
*/
|
|
212
213
|
const generateStyle = (componentTheme, props) => {
|
|
213
214
|
const placement = props.placement,
|
|
214
|
-
background = props.background
|
|
215
|
+
background = props.background,
|
|
216
|
+
borderColor = props.borderColor;
|
|
215
217
|
const arrowBaseStyles = {
|
|
216
218
|
content: '""',
|
|
217
219
|
height: '0',
|
|
@@ -226,7 +228,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
226
228
|
default: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColor,
|
|
227
229
|
inverse: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColorInverse
|
|
228
230
|
};
|
|
229
|
-
const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme);
|
|
231
|
+
const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
|
|
230
232
|
return {
|
|
231
233
|
contextView: {
|
|
232
234
|
label: 'contextView',
|
|
@@ -243,7 +245,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
243
245
|
...arrowBaseStyles,
|
|
244
246
|
display: 'block',
|
|
245
247
|
borderWidth: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} + ${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderWidth})`,
|
|
246
|
-
borderColor: arrowBackGroundVariants[background],
|
|
248
|
+
borderColor: borderColor || arrowBackGroundVariants[background],
|
|
247
249
|
...arrowPlacementVariant.main,
|
|
248
250
|
...getArrowCorrections(placement, componentTheme),
|
|
249
251
|
'&::after': {
|
package/lib/View/props.js
CHANGED
|
@@ -51,7 +51,7 @@ const propTypes = exports.propTypes = {
|
|
|
51
51
|
textAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
|
|
52
52
|
borderWidth: _emotion.ThemeablePropTypes.borderWidth,
|
|
53
53
|
borderRadius: _emotion.ThemeablePropTypes.borderRadius,
|
|
54
|
-
borderColor: _propTypes.default.
|
|
54
|
+
borderColor: _propTypes.default.string,
|
|
55
55
|
background: _propTypes.default.oneOf(['transparent', 'primary', 'secondary', 'primary-inverse', 'brand', 'info', 'alert', 'success', 'danger', 'warning']),
|
|
56
56
|
shadow: _emotion.ThemeablePropTypes.shadow,
|
|
57
57
|
stacking: _emotion.ThemeablePropTypes.stacking,
|
package/lib/View/styles.js
CHANGED
|
@@ -459,7 +459,9 @@ const generateStyle = (componentTheme, props) => {
|
|
|
459
459
|
} : {}),
|
|
460
460
|
...(withBorder(props) ? {
|
|
461
461
|
borderStyle: componentTheme.borderStyle,
|
|
462
|
-
...borderColorVariants[borderColor]
|
|
462
|
+
...(borderColorVariants[borderColor] || {
|
|
463
|
+
borderColor: borderColor
|
|
464
|
+
})
|
|
463
465
|
} : {}),
|
|
464
466
|
...(shouldUseFocusStyles ? focusStyles : {})
|
|
465
467
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-view",
|
|
3
|
-
"version": "10.5.1-snapshot-
|
|
3
|
+
"version": "10.5.1-snapshot-4",
|
|
4
4
|
"description": "A component for basic styles including spacing, sizing, borders, display, positioning, and focus states.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.25.6",
|
|
27
|
-
"@instructure/console": "10.5.1-snapshot-
|
|
28
|
-
"@instructure/emotion": "10.5.1-snapshot-
|
|
29
|
-
"@instructure/shared-types": "10.5.1-snapshot-
|
|
30
|
-
"@instructure/ui-color-utils": "10.5.1-snapshot-
|
|
31
|
-
"@instructure/ui-dom-utils": "10.5.1-snapshot-
|
|
32
|
-
"@instructure/ui-i18n": "10.5.1-snapshot-
|
|
33
|
-
"@instructure/ui-position": "10.5.1-snapshot-
|
|
34
|
-
"@instructure/ui-prop-types": "10.5.1-snapshot-
|
|
35
|
-
"@instructure/ui-react-utils": "10.5.1-snapshot-
|
|
27
|
+
"@instructure/console": "10.5.1-snapshot-4",
|
|
28
|
+
"@instructure/emotion": "10.5.1-snapshot-4",
|
|
29
|
+
"@instructure/shared-types": "10.5.1-snapshot-4",
|
|
30
|
+
"@instructure/ui-color-utils": "10.5.1-snapshot-4",
|
|
31
|
+
"@instructure/ui-dom-utils": "10.5.1-snapshot-4",
|
|
32
|
+
"@instructure/ui-i18n": "10.5.1-snapshot-4",
|
|
33
|
+
"@instructure/ui-position": "10.5.1-snapshot-4",
|
|
34
|
+
"@instructure/ui-prop-types": "10.5.1-snapshot-4",
|
|
35
|
+
"@instructure/ui-react-utils": "10.5.1-snapshot-4",
|
|
36
36
|
"prop-types": "^15.8.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@instructure/ui-axe-check": "10.5.1-snapshot-
|
|
40
|
-
"@instructure/ui-babel-preset": "10.5.1-snapshot-
|
|
41
|
-
"@instructure/ui-test-utils": "10.5.1-snapshot-
|
|
42
|
-
"@instructure/ui-themes": "10.5.1-snapshot-
|
|
39
|
+
"@instructure/ui-axe-check": "10.5.1-snapshot-4",
|
|
40
|
+
"@instructure/ui-babel-preset": "10.5.1-snapshot-4",
|
|
41
|
+
"@instructure/ui-test-utils": "10.5.1-snapshot-4",
|
|
42
|
+
"@instructure/ui-themes": "10.5.1-snapshot-4",
|
|
43
43
|
"@testing-library/jest-dom": "^6.4.6",
|
|
44
44
|
"@testing-library/react": "^16.0.1",
|
|
45
45
|
"vitest": "^2.1.1"
|
|
@@ -97,7 +97,8 @@ class ContextView extends Component<ContextViewProps> {
|
|
|
97
97
|
stacking,
|
|
98
98
|
style,
|
|
99
99
|
textAlign,
|
|
100
|
-
styles
|
|
100
|
+
styles,
|
|
101
|
+
borderColor
|
|
101
102
|
} = this.props
|
|
102
103
|
|
|
103
104
|
return (
|
|
@@ -118,7 +119,10 @@ class ContextView extends Component<ContextViewProps> {
|
|
|
118
119
|
display="block"
|
|
119
120
|
borderRadius="medium"
|
|
120
121
|
borderWidth="small"
|
|
121
|
-
borderColor={
|
|
122
|
+
borderColor={
|
|
123
|
+
borderColor ||
|
|
124
|
+
(background === 'default' ? 'primary' : 'transparent')
|
|
125
|
+
}
|
|
122
126
|
background={background === 'default' ? 'primary' : 'primary-inverse'}
|
|
123
127
|
withVisualDebug={debug}
|
|
124
128
|
height={height}
|
package/src/ContextView/props.ts
CHANGED
|
@@ -61,6 +61,7 @@ type ContextViewOwnProps = {
|
|
|
61
61
|
shadow?: Shadow
|
|
62
62
|
stacking?: Stacking
|
|
63
63
|
placement?: PlacementPropValues
|
|
64
|
+
borderColor?: string
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
type PropKeys = keyof ContextViewOwnProps
|
|
@@ -141,7 +142,13 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
141
142
|
* Activate an outline around the component to make building your
|
|
142
143
|
* layout easier
|
|
143
144
|
*/
|
|
144
|
-
debug: PropTypes.bool
|
|
145
|
+
debug: PropTypes.bool,
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Sets the color of the ContextView border.
|
|
149
|
+
* Accepts a color string value (e.g., "#FFFFFF", "red")
|
|
150
|
+
*/
|
|
151
|
+
borderColor: PropTypes.string
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
const allowedProps: AllowedPropKeys = [
|
|
@@ -161,7 +168,8 @@ const allowedProps: AllowedPropKeys = [
|
|
|
161
168
|
'stacking',
|
|
162
169
|
'background',
|
|
163
170
|
'placement',
|
|
164
|
-
'debug'
|
|
171
|
+
'debug',
|
|
172
|
+
'borderColor'
|
|
165
173
|
]
|
|
166
174
|
|
|
167
175
|
export type { ContextViewProps, ContextViewStyle }
|
|
@@ -126,10 +126,12 @@ const getArrowCorrections = (
|
|
|
126
126
|
const getArrowPlacementVariant = (
|
|
127
127
|
placement: PlacementPropValues,
|
|
128
128
|
background: ContextViewProps['background'],
|
|
129
|
-
theme: ContextViewTheme
|
|
129
|
+
theme: ContextViewTheme,
|
|
130
|
+
props: ContextViewProps
|
|
130
131
|
) => {
|
|
131
132
|
const transformedPlacement = mirrorPlacement(placement, ' ')
|
|
132
133
|
const isInversed = background === 'inverse'
|
|
134
|
+
const { borderColor } = props
|
|
133
135
|
|
|
134
136
|
if (endPlacements.includes(transformedPlacement)) {
|
|
135
137
|
return {
|
|
@@ -140,9 +142,11 @@ const getArrowPlacementVariant = (
|
|
|
140
142
|
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
141
143
|
borderInlineEndWidth: '0',
|
|
142
144
|
borderInlineEndColor: 'transparent',
|
|
143
|
-
borderInlineStartColor:
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
borderInlineStartColor:
|
|
146
|
+
borderColor ||
|
|
147
|
+
(isInversed
|
|
148
|
+
? theme?.arrowBorderColorInverse
|
|
149
|
+
: theme?.arrowBorderColor),
|
|
146
150
|
borderTopColor: 'transparent',
|
|
147
151
|
borderBottomColor: 'transparent',
|
|
148
152
|
borderInlineStartWidth: theme?.arrowSize
|
|
@@ -173,9 +177,11 @@ const getArrowPlacementVariant = (
|
|
|
173
177
|
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
174
178
|
borderInlineStartWidth: '0',
|
|
175
179
|
borderInlineStartColor: 'transparent',
|
|
176
|
-
borderInlineEndColor:
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
borderInlineEndColor:
|
|
181
|
+
borderColor ||
|
|
182
|
+
(isInversed
|
|
183
|
+
? theme?.arrowBorderColorInverse
|
|
184
|
+
: theme?.arrowBorderColor),
|
|
179
185
|
borderTopColor: 'transparent',
|
|
180
186
|
borderBottomColor: 'transparent',
|
|
181
187
|
borderInlineEndWidth: theme?.arrowSize
|
|
@@ -261,7 +267,7 @@ const generateStyle = (
|
|
|
261
267
|
componentTheme: ContextViewTheme,
|
|
262
268
|
props: ContextViewProps
|
|
263
269
|
): ContextViewStyle => {
|
|
264
|
-
const { placement, background } = props
|
|
270
|
+
const { placement, background, borderColor } = props
|
|
265
271
|
|
|
266
272
|
const arrowBaseStyles = {
|
|
267
273
|
content: '""',
|
|
@@ -282,7 +288,8 @@ const generateStyle = (
|
|
|
282
288
|
const arrowPlacementVariant = getArrowPlacementVariant(
|
|
283
289
|
placement!,
|
|
284
290
|
background,
|
|
285
|
-
componentTheme
|
|
291
|
+
componentTheme,
|
|
292
|
+
props
|
|
286
293
|
)
|
|
287
294
|
|
|
288
295
|
return {
|
|
@@ -301,7 +308,7 @@ const generateStyle = (
|
|
|
301
308
|
...arrowBaseStyles,
|
|
302
309
|
display: 'block',
|
|
303
310
|
borderWidth: `calc(${componentTheme?.arrowSize} + ${componentTheme?.arrowBorderWidth})`,
|
|
304
|
-
borderColor: arrowBackGroundVariants[background!],
|
|
311
|
+
borderColor: borderColor || arrowBackGroundVariants[background!],
|
|
305
312
|
...arrowPlacementVariant.main,
|
|
306
313
|
...getArrowCorrections(placement!, componentTheme),
|
|
307
314
|
'&::after': {
|
package/src/View/props.ts
CHANGED
|
@@ -47,6 +47,18 @@ import type {
|
|
|
47
47
|
StyleObject
|
|
48
48
|
} from '@instructure/emotion'
|
|
49
49
|
|
|
50
|
+
type BorderColor =
|
|
51
|
+
| string
|
|
52
|
+
| 'transparent'
|
|
53
|
+
| 'primary'
|
|
54
|
+
| 'secondary'
|
|
55
|
+
| 'brand'
|
|
56
|
+
| 'info'
|
|
57
|
+
| 'success'
|
|
58
|
+
| 'warning'
|
|
59
|
+
| 'alert'
|
|
60
|
+
| 'danger'
|
|
61
|
+
|
|
50
62
|
type ViewOwnProps = {
|
|
51
63
|
/**
|
|
52
64
|
* The element to render as the component root, `span` by default
|
|
@@ -84,18 +96,10 @@ type ViewOwnProps = {
|
|
|
84
96
|
*/
|
|
85
97
|
textAlign?: 'start' | 'center' | 'end'
|
|
86
98
|
/**
|
|
87
|
-
* Sets the color of the View border
|
|
99
|
+
* Sets the color of the View border.
|
|
100
|
+
* Accepts a color string value (e.g., "#FFFFFF", "red") or one of the predefined theme color options.
|
|
88
101
|
*/
|
|
89
|
-
borderColor?:
|
|
90
|
-
| 'transparent'
|
|
91
|
-
| 'primary'
|
|
92
|
-
| 'secondary'
|
|
93
|
-
| 'brand'
|
|
94
|
-
| 'info'
|
|
95
|
-
| 'success'
|
|
96
|
-
| 'warning'
|
|
97
|
-
| 'alert'
|
|
98
|
-
| 'danger'
|
|
102
|
+
borderColor?: BorderColor
|
|
99
103
|
/**
|
|
100
104
|
* Designates the background style of the `<View />`
|
|
101
105
|
*/
|
|
@@ -234,17 +238,7 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
234
238
|
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
235
239
|
borderWidth: ThemeablePropTypes.borderWidth,
|
|
236
240
|
borderRadius: ThemeablePropTypes.borderRadius,
|
|
237
|
-
borderColor: PropTypes.
|
|
238
|
-
'transparent',
|
|
239
|
-
'primary',
|
|
240
|
-
'secondary',
|
|
241
|
-
'brand',
|
|
242
|
-
'info',
|
|
243
|
-
'success',
|
|
244
|
-
'warning',
|
|
245
|
-
'alert',
|
|
246
|
-
'danger'
|
|
247
|
-
]),
|
|
241
|
+
borderColor: PropTypes.string,
|
|
248
242
|
background: PropTypes.oneOf([
|
|
249
243
|
'transparent',
|
|
250
244
|
'primary',
|
|
@@ -321,4 +315,4 @@ const allowedProps: AllowedPropKeys = [
|
|
|
321
315
|
]
|
|
322
316
|
|
|
323
317
|
export { propTypes, allowedProps }
|
|
324
|
-
export type { ViewProps, ViewOwnProps, ViewStyle }
|
|
318
|
+
export type { ViewProps, ViewOwnProps, ViewStyle, BorderColor }
|
package/src/View/styles.ts
CHANGED
|
@@ -36,7 +36,7 @@ import type {
|
|
|
36
36
|
PartialRecord,
|
|
37
37
|
ViewTheme
|
|
38
38
|
} from '@instructure/shared-types'
|
|
39
|
-
import type { ViewProps, ViewStyle } from './props'
|
|
39
|
+
import type { ViewProps, ViewStyle, BorderColor } from './props'
|
|
40
40
|
|
|
41
41
|
const getBorderStyle = ({
|
|
42
42
|
borderRadius,
|
|
@@ -468,7 +468,7 @@ const generateStyle = (
|
|
|
468
468
|
end: { textAlign: 'end' }
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
const borderColorVariants = {
|
|
471
|
+
const borderColorVariants: Record<BorderColor, { borderColor: string }> = {
|
|
472
472
|
transparent: {
|
|
473
473
|
borderColor: componentTheme.borderColorTransparent
|
|
474
474
|
},
|
|
@@ -596,7 +596,9 @@ const generateStyle = (
|
|
|
596
596
|
...(withBorder(props)
|
|
597
597
|
? {
|
|
598
598
|
borderStyle: componentTheme.borderStyle,
|
|
599
|
-
...borderColorVariants[borderColor!]
|
|
599
|
+
...(borderColorVariants[borderColor!] || {
|
|
600
|
+
borderColor: borderColor
|
|
601
|
+
})
|
|
600
602
|
}
|
|
601
603
|
: {}),
|
|
602
604
|
...(shouldUseFocusStyles ? focusStyles : {})
|