@instructure/ui-toggle-details 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-toggle-details
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, _class, _ToggleGroup;
1
+ var _dec, _dec2, _class, _ToggleGroup;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -34,13 +34,16 @@ import { View } from '@instructure/ui-view';
34
34
  import { IconArrowOpenEndSolid, IconArrowOpenDownSolid } from '@instructure/ui-icons';
35
35
  import { testable } from '@instructure/ui-testable';
36
36
  import { allowedProps, propTypes } from './props';
37
+ import { withStyle } from '@instructure/emotion';
38
+ import generateStyle from './styles';
39
+ import generateComponentTheme from './theme';
37
40
 
38
41
  /**
39
42
  ---
40
43
  category: components
41
44
  ---
42
45
  **/
43
- let ToggleGroup = (_dec = testable(), _dec(_class = (_ToggleGroup = class ToggleGroup extends Component {
46
+ let ToggleGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_ToggleGroup = class ToggleGroup extends Component {
44
47
  constructor(...args) {
45
48
  super(...args);
46
49
  this.ref = null;
@@ -67,14 +70,18 @@ let ToggleGroup = (_dec = testable(), _dec(_class = (_ToggleGroup = class Toggle
67
70
  componentDidMount() {
68
71
  this._shouldTransition = true;
69
72
  }
73
+ componentDidUpdate() {
74
+ var _this$props$makeStyle, _this$props;
75
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.state);
76
+ }
70
77
  renderIcon(expanded) {
71
78
  const Icon = expanded ? this.props.iconExpanded : this.props.icon;
72
79
  return Icon ? callRenderProp(Icon) : null;
73
80
  }
74
81
  renderToggle(toggleProps, expanded) {
75
- const _this$props = this.props,
76
- toggleLabel = _this$props.toggleLabel,
77
- size = _this$props.size;
82
+ const _this$props2 = this.props,
83
+ toggleLabel = _this$props2.toggleLabel,
84
+ size = _this$props2.size;
78
85
  let label;
79
86
  if (typeof toggleLabel === 'function') {
80
87
  label = toggleLabel(expanded);
@@ -93,9 +100,11 @@ let ToggleGroup = (_dec = testable(), _dec(_class = (_ToggleGroup = class Toggle
93
100
  }), this.renderIcon(expanded));
94
101
  }
95
102
  renderDetails(detailsProps) {
103
+ const styles = this.props.styles;
96
104
  return /*#__PURE__*/React.createElement(View, Object.assign({}, detailsProps, {
97
105
  display: "block",
98
- borderWidth: "small none none none"
106
+ borderWidth: "small none none none",
107
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
99
108
  }), this.props.transition && this._shouldTransition ? /*#__PURE__*/React.createElement(Transition, {
100
109
  transitionOnMount: true,
101
110
  in: true,
@@ -104,6 +113,7 @@ let ToggleGroup = (_dec = testable(), _dec(_class = (_ToggleGroup = class Toggle
104
113
  }
105
114
  render() {
106
115
  const Element = getElementType(ToggleGroup, this.props);
116
+ const styles = this.props.styles;
107
117
  return /*#__PURE__*/React.createElement(Expandable, pickProps(this.props, Expandable.allowedProps), ({
108
118
  expanded,
109
119
  getToggleProps,
@@ -115,7 +125,8 @@ let ToggleGroup = (_dec = testable(), _dec(_class = (_ToggleGroup = class Toggle
115
125
  elementRef: this.handleRef,
116
126
  display: "block",
117
127
  borderRadius: "medium",
118
- background: "primary"
128
+ background: "primary",
129
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
119
130
  }), /*#__PURE__*/React.createElement(Flex, {
120
131
  padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small'
121
132
  }, /*#__PURE__*/React.createElement(Flex.Item, null, this.renderToggle(getToggleProps(), expanded)), /*#__PURE__*/React.createElement(Flex.Item, {
@@ -133,6 +144,6 @@ let ToggleGroup = (_dec = testable(), _dec(_class = (_ToggleGroup = class Toggle
133
144
  transition: true,
134
145
  as: 'span',
135
146
  border: true
136
- }, _ToggleGroup)) || _class);
147
+ }, _ToggleGroup)) || _class) || _class);
137
148
  export default ToggleGroup;
138
149
  export { ToggleGroup };
@@ -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, _props) => {
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;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -20,7 +21,10 @@ var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEnd
20
21
  var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/IconArrowOpenDownSolid.js");
21
22
  var _testable = require("@instructure/ui-testable/lib/testable.js");
22
23
  var _props = require("./props");
23
- var _dec, _class, _ToggleGroup;
24
+ var _emotion = require("@instructure/emotion");
25
+ var _styles = _interopRequireDefault(require("./styles"));
26
+ var _theme = _interopRequireDefault(require("./theme"));
27
+ var _dec, _dec2, _class, _ToggleGroup;
24
28
  /*
25
29
  * The MIT License (MIT)
26
30
  *
@@ -49,7 +53,7 @@ var _dec, _class, _ToggleGroup;
49
53
  category: components
50
54
  ---
51
55
  **/
52
- let ToggleGroup = exports.ToggleGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_ToggleGroup = class ToggleGroup extends _react.Component {
56
+ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_ToggleGroup = class ToggleGroup extends _react.Component {
53
57
  constructor(...args) {
54
58
  super(...args);
55
59
  this.ref = null;
@@ -76,14 +80,18 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _testable.testable)(), _dec(
76
80
  componentDidMount() {
77
81
  this._shouldTransition = true;
78
82
  }
83
+ componentDidUpdate() {
84
+ var _this$props$makeStyle, _this$props;
85
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.state);
86
+ }
79
87
  renderIcon(expanded) {
80
88
  const Icon = expanded ? this.props.iconExpanded : this.props.icon;
81
89
  return Icon ? (0, _callRenderProp.callRenderProp)(Icon) : null;
82
90
  }
83
91
  renderToggle(toggleProps, expanded) {
84
- const _this$props = this.props,
85
- toggleLabel = _this$props.toggleLabel,
86
- size = _this$props.size;
92
+ const _this$props2 = this.props,
93
+ toggleLabel = _this$props2.toggleLabel,
94
+ size = _this$props2.size;
87
95
  let label;
88
96
  if (typeof toggleLabel === 'function') {
89
97
  label = toggleLabel(expanded);
@@ -102,9 +110,11 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _testable.testable)(), _dec(
102
110
  }), this.renderIcon(expanded));
103
111
  }
104
112
  renderDetails(detailsProps) {
113
+ const styles = this.props.styles;
105
114
  return /*#__PURE__*/_react.default.createElement(_View.View, Object.assign({}, detailsProps, {
106
115
  display: "block",
107
- borderWidth: "small none none none"
116
+ borderWidth: "small none none none",
117
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
108
118
  }), this.props.transition && this._shouldTransition ? /*#__PURE__*/_react.default.createElement(_Transition.Transition, {
109
119
  transitionOnMount: true,
110
120
  in: true,
@@ -113,6 +123,7 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _testable.testable)(), _dec(
113
123
  }
114
124
  render() {
115
125
  const Element = (0, _getElementType.getElementType)(ToggleGroup, this.props);
126
+ const styles = this.props.styles;
116
127
  return /*#__PURE__*/_react.default.createElement(_Expandable.Expandable, (0, _pickProps.pickProps)(this.props, _Expandable.Expandable.allowedProps), ({
117
128
  expanded,
118
129
  getToggleProps,
@@ -124,7 +135,8 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _testable.testable)(), _dec(
124
135
  elementRef: this.handleRef,
125
136
  display: "block",
126
137
  borderRadius: "medium",
127
- background: "primary"
138
+ background: "primary",
139
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor
128
140
  }), /*#__PURE__*/_react.default.createElement(_Flex.Flex, {
129
141
  padding: this.props.size === 'small' ? 'x-small' : 'small small small x-small'
130
142
  }, /*#__PURE__*/_react.default.createElement(_Flex.Flex.Item, null, this.renderToggle(getToggleProps(), expanded)), /*#__PURE__*/_react.default.createElement(_Flex.Flex.Item, {
@@ -142,5 +154,5 @@ let ToggleGroup = exports.ToggleGroup = (_dec = (0, _testable.testable)(), _dec(
142
154
  transition: true,
143
155
  as: 'span',
144
156
  border: true
145
- }, _ToggleGroup)) || _class);
157
+ }, _ToggleGroup)) || _class) || _class);
146
158
  var _default = exports.default = ToggleGroup;
@@ -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, _props) => {
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-toggle-details",
3
- "version": "10.5.1-snapshot-5",
3
+ "version": "10.6.0",
4
4
  "description": "A styled toggleable, accordion-like component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,28 +23,28 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "10.5.1-snapshot-5",
27
- "@instructure/ui-test-locator": "10.5.1-snapshot-5",
28
- "@instructure/ui-test-queries": "10.5.1-snapshot-5",
29
- "@instructure/ui-test-utils": "10.5.1-snapshot-5",
30
- "@instructure/ui-themes": "10.5.1-snapshot-5"
26
+ "@instructure/ui-babel-preset": "10.6.0",
27
+ "@instructure/ui-test-locator": "10.6.0",
28
+ "@instructure/ui-test-queries": "10.6.0",
29
+ "@instructure/ui-test-utils": "10.6.0",
30
+ "@instructure/ui-themes": "10.6.0"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.25.6",
34
- "@instructure/emotion": "10.5.1-snapshot-5",
35
- "@instructure/shared-types": "10.5.1-snapshot-5",
36
- "@instructure/ui-buttons": "10.5.1-snapshot-5",
37
- "@instructure/ui-dom-utils": "10.5.1-snapshot-5",
38
- "@instructure/ui-expandable": "10.5.1-snapshot-5",
39
- "@instructure/ui-flex": "10.5.1-snapshot-5",
40
- "@instructure/ui-icons": "10.5.1-snapshot-5",
41
- "@instructure/ui-motion": "10.5.1-snapshot-5",
42
- "@instructure/ui-prop-types": "10.5.1-snapshot-5",
43
- "@instructure/ui-react-utils": "10.5.1-snapshot-5",
44
- "@instructure/ui-testable": "10.5.1-snapshot-5",
45
- "@instructure/ui-utils": "10.5.1-snapshot-5",
46
- "@instructure/ui-view": "10.5.1-snapshot-5",
47
- "@instructure/uid": "10.5.1-snapshot-5",
34
+ "@instructure/emotion": "10.6.0",
35
+ "@instructure/shared-types": "10.6.0",
36
+ "@instructure/ui-buttons": "10.6.0",
37
+ "@instructure/ui-dom-utils": "10.6.0",
38
+ "@instructure/ui-expandable": "10.6.0",
39
+ "@instructure/ui-flex": "10.6.0",
40
+ "@instructure/ui-icons": "10.6.0",
41
+ "@instructure/ui-motion": "10.6.0",
42
+ "@instructure/ui-prop-types": "10.6.0",
43
+ "@instructure/ui-react-utils": "10.6.0",
44
+ "@instructure/ui-testable": "10.6.0",
45
+ "@instructure/ui-utils": "10.6.0",
46
+ "@instructure/ui-view": "10.6.0",
47
+ "@instructure/uid": "10.6.0",
48
48
  "prop-types": "^15.8.1"
49
49
  },
50
50
  "peerDependencies": {
@@ -45,11 +45,17 @@ import { testable } from '@instructure/ui-testable'
45
45
  import type { ToggleGroupProps } from './props'
46
46
  import { allowedProps, propTypes } from './props'
47
47
 
48
+ import { withStyle } from '@instructure/emotion'
49
+
50
+ import generateStyle from './styles'
51
+ import generateComponentTheme from './theme'
52
+
48
53
  /**
49
54
  ---
50
55
  category: components
51
56
  ---
52
57
  **/
58
+ @withStyle(generateStyle, generateComponentTheme)
53
59
  @testable()
54
60
  class ToggleGroup extends Component<ToggleGroupProps> {
55
61
  static readonly componentId = 'ToggleGroup'
@@ -97,6 +103,10 @@ class ToggleGroup extends Component<ToggleGroupProps> {
97
103
  this._shouldTransition = true
98
104
  }
99
105
 
106
+ componentDidUpdate() {
107
+ this.props.makeStyles?.(this.state)
108
+ }
109
+
100
110
  renderIcon(expanded: boolean) {
101
111
  const Icon = expanded ? this.props.iconExpanded : this.props.icon
102
112
  return Icon ? callRenderProp(Icon) : null
@@ -130,11 +140,13 @@ class ToggleGroup extends Component<ToggleGroupProps> {
130
140
  }
131
141
 
132
142
  renderDetails(detailsProps: { id: string }) {
143
+ const { styles } = this.props
133
144
  return (
134
145
  <View
135
146
  {...detailsProps}
136
147
  display="block"
137
148
  borderWidth="small none none none"
149
+ borderColor={styles?.borderColor}
138
150
  >
139
151
  {this.props.transition && this._shouldTransition ? (
140
152
  <Transition transitionOnMount in type="fade">
@@ -149,7 +161,7 @@ class ToggleGroup extends Component<ToggleGroupProps> {
149
161
 
150
162
  render() {
151
163
  const Element = getElementType(ToggleGroup, this.props)
152
-
164
+ const { styles } = this.props
153
165
  return (
154
166
  <Expandable {...pickProps(this.props, Expandable.allowedProps)}>
155
167
  {({ expanded, getToggleProps, getDetailsProps }) => {
@@ -162,6 +174,7 @@ class ToggleGroup extends Component<ToggleGroupProps> {
162
174
  display="block"
163
175
  borderRadius="medium"
164
176
  background="primary"
177
+ borderColor={styles?.borderColor}
165
178
  >
166
179
  <Flex
167
180
  padding={
@@ -31,9 +31,12 @@ import {
31
31
  AsElementType,
32
32
  OtherHTMLAttributes,
33
33
  PropValidators,
34
- Renderable
34
+ Renderable,
35
+ ToggleGroupTheme
35
36
  } from '@instructure/shared-types'
36
37
 
38
+ import type { WithStyleProps } from '@instructure/emotion'
39
+
37
40
  type ToggleGroupOwnProps = {
38
41
  /**
39
42
  * the content to show and hide
@@ -91,8 +94,11 @@ type PropKeys = keyof ToggleGroupOwnProps
91
94
 
92
95
  type AllowedPropKeys = Readonly<Array<PropKeys>>
93
96
 
97
+ type ToggleGroupStyle = { borderColor: string }
98
+
94
99
  type ToggleGroupProps = ToggleGroupOwnProps &
95
- OtherHTMLAttributes<ToggleGroupOwnProps>
100
+ OtherHTMLAttributes<ToggleGroupOwnProps> &
101
+ WithStyleProps<ToggleGroupTheme, ToggleGroupStyle>
96
102
 
97
103
  const propTypes: PropValidators<PropKeys> = {
98
104
  children: PropTypes.node.isRequired,
@@ -126,5 +132,5 @@ const allowedProps: AllowedPropKeys = [
126
132
  'border'
127
133
  ]
128
134
 
129
- export type { ToggleGroupProps }
135
+ export type { ToggleGroupProps, ToggleGroupStyle }
130
136
  export { propTypes, allowedProps }
@@ -0,0 +1,47 @@
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 { ToggleGroupTheme } from '@instructure/shared-types'
26
+ import type { ToggleGroupProps, ToggleGroupStyle } 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 = (
39
+ componentTheme: ToggleGroupTheme,
40
+ _props: ToggleGroupProps
41
+ ): ToggleGroupStyle => {
42
+ return {
43
+ borderColor: componentTheme.borderColor
44
+ }
45
+ }
46
+
47
+ 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 { ToggleGroupTheme } 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): ToggleGroupTheme => {
34
+ const { colors } = theme
35
+
36
+ const componentVariables: ToggleGroupTheme = {
37
+ borderColor: colors?.contrasts?.grey3045
38
+ }
39
+ return {
40
+ ...componentVariables
41
+ }
42
+ }
43
+ export default generateComponentTheme