@instructure/ui-popover 10.5.1-snapshot-5 → 10.6.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 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-5](https://github.com/instructure/instructure-ui/compare/v10.5.0...v10.5.1-snapshot-5) (2024-11-14)
6
+ # [10.6.0](https://github.com/instructure/instructure-ui/compare/v10.5.0...v10.6.0) (2024-11-18)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-popover
8
+
9
+ ### Bug Fixes
10
+
11
+ * **many:** adjust border colors to meet a11y contrast standards ([2f47e06](https://github.com/instructure/instructure-ui/commit/2f47e066f7107c67e37ce8b7aff483586cf7a6b7))
9
12
 
10
13
 
11
14
 
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _dec3, _class, _Popover;
1
+ var _dec, _dec2, _dec3, _dec4, _class, _Popover;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -35,6 +35,9 @@ import { createChainedFunction, shallowEqual, px } from '@instructure/ui-utils';
35
35
  import { logError as error } from '@instructure/console';
36
36
  import { testable } from '@instructure/ui-testable';
37
37
  import { FocusRegion } from '@instructure/ui-a11y-utils';
38
+ import { withStyle } from '@instructure/emotion';
39
+ import generateStyle from './styles';
40
+ import generateComponentTheme from './theme';
38
41
  import { allowedProps, propTypes } from './props';
39
42
  /**
40
43
  ---
@@ -42,7 +45,7 @@ category: components
42
45
  tags: overlay, portal, dialog
43
46
  ---
44
47
  **/
45
- let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsumer(), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_Popover = class Popover extends Component {
48
+ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsumer(), _dec3 = withStyle(generateStyle, generateComponentTheme), _dec4 = testable(), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = (_Popover = class Popover extends Component {
46
49
  constructor(props) {
47
50
  super(props);
48
51
  this._handleMouseOver = void 0;
@@ -411,6 +414,7 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
411
414
  };
412
415
  }
413
416
  const placement = this.state.placement;
417
+ const styles = this.props.styles;
414
418
  if (this.props.withArrow) {
415
419
  viewProps = {
416
420
  ...viewProps,
@@ -418,7 +422,9 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
418
422
  background: color === 'primary' ? 'default' : 'inverse',
419
423
  placement: this.props.dir === textDirectionContextConsumer.DIRECTION.rtl ? mirrorHorizontalPlacement(placement, ' ') : placement
420
424
  };
421
- return /*#__PURE__*/React.createElement(ContextView, viewProps, content);
425
+ return /*#__PURE__*/React.createElement(ContextView, Object.assign({}, viewProps, {
426
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
427
+ }), content);
422
428
  } else {
423
429
  viewProps = {
424
430
  ...viewProps,
@@ -428,7 +434,9 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
428
434
  borderColor: 'transparent'
429
435
  })
430
436
  };
431
- return /*#__PURE__*/React.createElement(View, viewProps, content);
437
+ return /*#__PURE__*/React.createElement(View, Object.assign({}, viewProps, {
438
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
439
+ }), content);
432
440
  }
433
441
  } else {
434
442
  return null;
@@ -467,6 +475,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
467
475
  shouldCloseOnDocumentClick: true,
468
476
  shouldFocusContentOnTriggerBlur: false,
469
477
  shouldCloseOnEscape: true
470
- }, _Popover)) || _class) || _class) || _class);
478
+ }, _Popover)) || _class) || _class) || _class) || _class);
471
479
  export default Popover;
472
480
  export { Popover };
@@ -0,0 +1,40 @@
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} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = componentTheme => {
36
+ return {
37
+ borderColor: componentTheme.borderColor
38
+ };
39
+ };
40
+ export default generateStyle;
@@ -0,0 +1,40 @@
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
+ * Generates the theme object for the component from the theme and provided additional information
27
+ * @param {Object} theme The actual theme object.
28
+ * @return {Object} The final theme object with the overrides and component variables
29
+ */
30
+ const generateComponentTheme = theme => {
31
+ var _colors$contrasts;
32
+ const colors = theme.colors;
33
+ const componentVariables = {
34
+ borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey3045
35
+ };
36
+ return {
37
+ ...componentVariables
38
+ };
39
+ };
40
+ export default generateComponentTheme;
@@ -28,8 +28,11 @@ var _px = require("@instructure/ui-utils/lib/px.js");
28
28
  var _console = require("@instructure/console");
29
29
  var _testable = require("@instructure/ui-testable/lib/testable.js");
30
30
  var _FocusRegion = require("@instructure/ui-a11y-utils/lib/FocusRegion.js");
31
+ var _emotion = require("@instructure/emotion");
32
+ var _styles = _interopRequireDefault(require("./styles"));
33
+ var _theme = _interopRequireDefault(require("./theme"));
31
34
  var _props = require("./props");
32
- var _dec, _dec2, _dec3, _class, _Popover;
35
+ var _dec, _dec2, _dec3, _dec4, _class, _Popover;
33
36
  /*
34
37
  * The MIT License (MIT)
35
38
  *
@@ -59,7 +62,7 @@ category: components
59
62
  tags: overlay, portal, dialog
60
63
  ---
61
64
  **/
62
- let Popover = exports.Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_Popover = class Popover extends _react.Component {
65
+ let Popover = exports.Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec3 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec4 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = (_Popover = class Popover extends _react.Component {
63
66
  constructor(props) {
64
67
  super(props);
65
68
  this._handleMouseOver = void 0;
@@ -428,6 +431,7 @@ let Popover = exports.Popover = (_dec = (0, _withDeterministicId.withDeterminist
428
431
  };
429
432
  }
430
433
  const placement = this.state.placement;
434
+ const styles = this.props.styles;
431
435
  if (this.props.withArrow) {
432
436
  viewProps = {
433
437
  ...viewProps,
@@ -435,7 +439,9 @@ let Popover = exports.Popover = (_dec = (0, _withDeterministicId.withDeterminist
435
439
  background: color === 'primary' ? 'default' : 'inverse',
436
440
  placement: this.props.dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl ? (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ') : placement
437
441
  };
438
- return /*#__PURE__*/_react.default.createElement(_ContextView.ContextView, viewProps, content);
442
+ return /*#__PURE__*/_react.default.createElement(_ContextView.ContextView, Object.assign({}, viewProps, {
443
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
444
+ }), content);
439
445
  } else {
440
446
  viewProps = {
441
447
  ...viewProps,
@@ -445,7 +451,9 @@ let Popover = exports.Popover = (_dec = (0, _withDeterministicId.withDeterminist
445
451
  borderColor: 'transparent'
446
452
  })
447
453
  };
448
- return /*#__PURE__*/_react.default.createElement(_View.View, viewProps, content);
454
+ return /*#__PURE__*/_react.default.createElement(_View.View, Object.assign({}, viewProps, {
455
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
456
+ }), content);
449
457
  }
450
458
  } else {
451
459
  return null;
@@ -484,5 +492,5 @@ let Popover = exports.Popover = (_dec = (0, _withDeterministicId.withDeterminist
484
492
  shouldCloseOnDocumentClick: true,
485
493
  shouldFocusContentOnTriggerBlur: false,
486
494
  shouldCloseOnEscape: true
487
- }, _Popover)) || _class) || _class) || _class);
495
+ }, _Popover)) || _class) || _class) || _class) || _class);
488
496
  var _default = exports.default = Popover;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ /**
32
+ * ---
33
+ * private: true
34
+ * ---
35
+ * Generates the style object from the theme and provided additional information
36
+ * @param {Object} componentTheme The theme variable object.
37
+ * @param {Object} props the props of the component, the style is applied to
38
+ * @param {Object} state the state of the component, the style is applied to
39
+ * @return {Object} The final style object, which will be used in the component
40
+ */
41
+ const generateStyle = componentTheme => {
42
+ return {
43
+ borderColor: componentTheme.borderColor
44
+ };
45
+ };
46
+ var _default = exports.default = generateStyle;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ /**
32
+ * Generates the theme object for the component from the theme and provided additional information
33
+ * @param {Object} theme The actual theme object.
34
+ * @return {Object} The final theme object with the overrides and component variables
35
+ */
36
+ const generateComponentTheme = theme => {
37
+ var _colors$contrasts;
38
+ const colors = theme.colors;
39
+ const componentVariables = {
40
+ borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey3045
41
+ };
42
+ return {
43
+ ...componentVariables
44
+ };
45
+ };
46
+ var _default = exports.default = generateComponentTheme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-popover",
3
- "version": "10.5.1-snapshot-5",
3
+ "version": "10.6.0",
4
4
  "description": "A component for hiding or showing content based on user interaction.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,29 +24,29 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.25.6",
27
- "@instructure/console": "10.5.1-snapshot-5",
28
- "@instructure/emotion": "10.5.1-snapshot-5",
29
- "@instructure/shared-types": "10.5.1-snapshot-5",
30
- "@instructure/ui-a11y-utils": "10.5.1-snapshot-5",
31
- "@instructure/ui-dialog": "10.5.1-snapshot-5",
32
- "@instructure/ui-dom-utils": "10.5.1-snapshot-5",
33
- "@instructure/ui-i18n": "10.5.1-snapshot-5",
34
- "@instructure/ui-position": "10.5.1-snapshot-5",
35
- "@instructure/ui-prop-types": "10.5.1-snapshot-5",
36
- "@instructure/ui-react-utils": "10.5.1-snapshot-5",
37
- "@instructure/ui-testable": "10.5.1-snapshot-5",
38
- "@instructure/ui-utils": "10.5.1-snapshot-5",
39
- "@instructure/ui-view": "10.5.1-snapshot-5",
40
- "@instructure/uid": "10.5.1-snapshot-5",
27
+ "@instructure/console": "10.6.0",
28
+ "@instructure/emotion": "10.6.0",
29
+ "@instructure/shared-types": "10.6.0",
30
+ "@instructure/ui-a11y-utils": "10.6.0",
31
+ "@instructure/ui-dialog": "10.6.0",
32
+ "@instructure/ui-dom-utils": "10.6.0",
33
+ "@instructure/ui-i18n": "10.6.0",
34
+ "@instructure/ui-position": "10.6.0",
35
+ "@instructure/ui-prop-types": "10.6.0",
36
+ "@instructure/ui-react-utils": "10.6.0",
37
+ "@instructure/ui-testable": "10.6.0",
38
+ "@instructure/ui-utils": "10.6.0",
39
+ "@instructure/ui-view": "10.6.0",
40
+ "@instructure/uid": "10.6.0",
41
41
  "keycode": "^2.2.1",
42
42
  "prop-types": "^15.8.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@instructure/ui-babel-preset": "10.5.1-snapshot-5",
46
- "@instructure/ui-color-utils": "10.5.1-snapshot-5",
47
- "@instructure/ui-test-locator": "10.5.1-snapshot-5",
48
- "@instructure/ui-test-queries": "10.5.1-snapshot-5",
49
- "@instructure/ui-test-utils": "10.5.1-snapshot-5",
45
+ "@instructure/ui-babel-preset": "10.6.0",
46
+ "@instructure/ui-color-utils": "10.6.0",
47
+ "@instructure/ui-test-locator": "10.6.0",
48
+ "@instructure/ui-test-queries": "10.6.0",
49
+ "@instructure/ui-test-utils": "10.6.0",
50
50
  "@testing-library/jest-dom": "^6.4.6",
51
51
  "@testing-library/react": "^16.0.1",
52
52
  "@testing-library/user-event": "^14.5.2",
@@ -55,10 +55,14 @@ import type { ViewProps, ContextViewProps } from '@instructure/ui-view'
55
55
  import type { PositionProps } from '@instructure/ui-position'
56
56
  import type { DialogProps } from '@instructure/ui-dialog'
57
57
 
58
+ import { withStyle } from '@instructure/emotion'
59
+
60
+ import generateStyle from './styles'
61
+ import generateComponentTheme from './theme'
62
+
58
63
  import type { PopoverProps, PopoverState } from './props'
59
64
  import { allowedProps, propTypes } from './props'
60
65
  import type { Renderable } from '@instructure/shared-types'
61
-
62
66
  /**
63
67
  ---
64
68
  category: components
@@ -67,6 +71,7 @@ tags: overlay, portal, dialog
67
71
  **/
68
72
  @withDeterministicId()
69
73
  @textDirectionContextConsumer()
74
+ @withStyle(generateStyle, generateComponentTheme)
70
75
  @testable()
71
76
  class Popover extends Component<PopoverProps, PopoverState> {
72
77
  static readonly componentId = 'Popover'
@@ -558,6 +563,7 @@ class Popover extends Component<PopoverProps, PopoverState> {
558
563
  }
559
564
 
560
565
  const { placement } = this.state
566
+ const { styles } = this.props
561
567
 
562
568
  if (this.props.withArrow) {
563
569
  viewProps = {
@@ -570,7 +576,11 @@ class Popover extends Component<PopoverProps, PopoverState> {
570
576
  : placement
571
577
  } as Partial<ContextViewProps> & { ref: any }
572
578
 
573
- return <ContextView {...viewProps}>{content}</ContextView>
579
+ return (
580
+ <ContextView {...viewProps} borderColor={styles?.borderColor}>
581
+ {content}
582
+ </ContextView>
583
+ )
574
584
  } else {
575
585
  viewProps = {
576
586
  ...viewProps,
@@ -579,7 +589,11 @@ class Popover extends Component<PopoverProps, PopoverState> {
579
589
  ...(color === 'primary-inverse' && { borderColor: 'transparent' })
580
590
  } as Partial<ViewProps> & { ref: any }
581
591
 
582
- return <View {...viewProps}>{content}</View>
592
+ return (
593
+ <View {...viewProps} borderColor={styles?.borderColor}>
594
+ {content}
595
+ </View>
596
+ )
583
597
  }
584
598
  } else {
585
599
  return null
@@ -28,7 +28,7 @@ import { element } from '@instructure/ui-prop-types'
28
28
  import { ThemeablePropTypes } from '@instructure/emotion'
29
29
  import { PositionPropTypes } from '@instructure/ui-position'
30
30
 
31
- import type { Shadow, Stacking } from '@instructure/emotion'
31
+ import type { Shadow, Stacking, WithStyleProps } from '@instructure/emotion'
32
32
 
33
33
  import type {
34
34
  PlacementPropValues,
@@ -41,7 +41,8 @@ import type {
41
41
  PropValidators,
42
42
  LiveRegion,
43
43
  UIElement,
44
- Renderable
44
+ Renderable,
45
+ PopoverTheme
45
46
  } from '@instructure/shared-types'
46
47
  import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
47
48
 
@@ -278,7 +279,8 @@ type PopoverOwnProps = {
278
279
 
279
280
  type PopoverProps = PopoverOwnProps &
280
281
  TextDirectionContextConsumerProps &
281
- WithDeterministicIdProps
282
+ WithDeterministicIdProps &
283
+ WithStyleProps<PopoverTheme, PopoverStyle>
282
284
 
283
285
  type PopoverState = {
284
286
  placement: PopoverOwnProps['placement']
@@ -291,6 +293,8 @@ type PropKeys = keyof PopoverOwnProps
291
293
 
292
294
  type AllowedPropKeys = Readonly<Array<PropKeys>>
293
295
 
296
+ type PopoverStyle = { borderColor: string }
297
+
294
298
  const propTypes: PropValidators<PropKeys> = {
295
299
  isShowingContent: PropTypes.bool,
296
300
  defaultIsShowingContent: PropTypes.bool,
@@ -388,5 +392,5 @@ const allowedProps: AllowedPropKeys = [
388
392
  'elementRef'
389
393
  ]
390
394
 
391
- export type { PopoverOwnProps, PopoverProps, PopoverState }
395
+ export type { PopoverOwnProps, PopoverProps, PopoverState, PopoverStyle }
392
396
  export { propTypes, allowedProps }
@@ -0,0 +1,44 @@
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 { PopoverTheme } from '@instructure/shared-types'
26
+ import type { PopoverStyle } 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
+ * @param {Object} state the state of the component, the style is applied to
36
+ * @return {Object} The final style object, which will be used in the component
37
+ */
38
+ const generateStyle = (componentTheme: PopoverTheme): PopoverStyle => {
39
+ return {
40
+ borderColor: componentTheme.borderColor
41
+ }
42
+ }
43
+
44
+ export default generateStyle
@@ -0,0 +1,43 @@
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 { Theme } from '@instructure/ui-themes'
26
+ import { PopoverTheme } from '@instructure/shared-types'
27
+
28
+ /**
29
+ * Generates the theme object for the component from the theme and provided additional information
30
+ * @param {Object} theme The actual theme object.
31
+ * @return {Object} The final theme object with the overrides and component variables
32
+ */
33
+ const generateComponentTheme = (theme: Theme): PopoverTheme => {
34
+ const { colors } = theme
35
+
36
+ const componentVariables: PopoverTheme = {
37
+ borderColor: colors?.contrasts?.grey3045
38
+ }
39
+ return {
40
+ ...componentVariables
41
+ }
42
+ }
43
+ export default generateComponentTheme