@ohos-ports/instructure-ui-toggle-details 11.7.5-beta.1

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 (91) hide show
  1. package/CHANGELOG.md +1323 -0
  2. package/LICENSE.md +28 -0
  3. package/README.md +42 -0
  4. package/es/ToggleDetails/v1/index.js +177 -0
  5. package/es/ToggleDetails/v1/props.js +26 -0
  6. package/es/ToggleDetails/v1/styles.js +196 -0
  7. package/es/ToggleDetails/v1/theme.js +75 -0
  8. package/es/ToggleDetails/v2/index.js +181 -0
  9. package/es/ToggleDetails/v2/props.js +26 -0
  10. package/es/ToggleDetails/v2/styles.js +188 -0
  11. package/es/ToggleGroup/v1/index.js +172 -0
  12. package/es/ToggleGroup/v1/props.js +26 -0
  13. package/es/ToggleGroup/v1/styles.js +40 -0
  14. package/es/ToggleGroup/v1/theme.js +41 -0
  15. package/es/ToggleGroup/v2/index.js +178 -0
  16. package/es/ToggleGroup/v2/props.js +26 -0
  17. package/es/ToggleGroup/v2/styles.js +40 -0
  18. package/es/exports/a.js +26 -0
  19. package/es/exports/b.js +26 -0
  20. package/lib/ToggleDetails/v1/index.js +184 -0
  21. package/lib/ToggleDetails/v1/props.js +31 -0
  22. package/lib/ToggleDetails/v1/styles.js +202 -0
  23. package/lib/ToggleDetails/v1/theme.js +81 -0
  24. package/lib/ToggleDetails/v2/index.js +187 -0
  25. package/lib/ToggleDetails/v2/props.js +31 -0
  26. package/lib/ToggleDetails/v2/styles.js +194 -0
  27. package/lib/ToggleGroup/v1/index.js +180 -0
  28. package/lib/ToggleGroup/v1/props.js +31 -0
  29. package/lib/ToggleGroup/v1/styles.js +46 -0
  30. package/lib/ToggleGroup/v1/theme.js +47 -0
  31. package/lib/ToggleGroup/v2/index.js +185 -0
  32. package/lib/ToggleGroup/v2/props.js +31 -0
  33. package/lib/ToggleGroup/v2/styles.js +46 -0
  34. package/lib/exports/a.js +19 -0
  35. package/lib/exports/b.js +19 -0
  36. package/lib/package.json +1 -0
  37. package/package.json +94 -0
  38. package/src/ToggleDetails/v1/README.md +233 -0
  39. package/src/ToggleDetails/v1/index.tsx +204 -0
  40. package/src/ToggleDetails/v1/props.ts +114 -0
  41. package/src/ToggleDetails/v1/styles.ts +190 -0
  42. package/src/ToggleDetails/v1/theme.ts +80 -0
  43. package/src/ToggleDetails/v2/README.md +233 -0
  44. package/src/ToggleDetails/v2/index.tsx +206 -0
  45. package/src/ToggleDetails/v2/props.ts +115 -0
  46. package/src/ToggleDetails/v2/styles.ts +188 -0
  47. package/src/ToggleGroup/v1/README.md +93 -0
  48. package/src/ToggleGroup/v1/index.tsx +206 -0
  49. package/src/ToggleGroup/v1/props.ts +115 -0
  50. package/src/ToggleGroup/v1/styles.ts +47 -0
  51. package/src/ToggleGroup/v1/theme.ts +43 -0
  52. package/src/ToggleGroup/v2/README.md +93 -0
  53. package/src/ToggleGroup/v2/index.tsx +214 -0
  54. package/src/ToggleGroup/v2/props.ts +115 -0
  55. package/src/ToggleGroup/v2/styles.ts +47 -0
  56. package/src/exports/a.ts +29 -0
  57. package/src/exports/b.ts +29 -0
  58. package/tsconfig.build.json +26 -0
  59. package/tsconfig.json +4 -0
  60. package/types/ToggleDetails/v1/index.d.ts +56 -0
  61. package/types/ToggleDetails/v1/index.d.ts.map +1 -0
  62. package/types/ToggleDetails/v1/props.d.ts +55 -0
  63. package/types/ToggleDetails/v1/props.d.ts.map +1 -0
  64. package/types/ToggleDetails/v1/styles.d.ts +15 -0
  65. package/types/ToggleDetails/v1/styles.d.ts.map +1 -0
  66. package/types/ToggleDetails/v1/theme.d.ts +10 -0
  67. package/types/ToggleDetails/v1/theme.d.ts.map +1 -0
  68. package/types/ToggleDetails/v2/index.d.ts +55 -0
  69. package/types/ToggleDetails/v2/index.d.ts.map +1 -0
  70. package/types/ToggleDetails/v2/props.d.ts +56 -0
  71. package/types/ToggleDetails/v2/props.d.ts.map +1 -0
  72. package/types/ToggleDetails/v2/styles.d.ts +16 -0
  73. package/types/ToggleDetails/v2/styles.d.ts.map +1 -0
  74. package/types/ToggleGroup/v1/index.d.ts +55 -0
  75. package/types/ToggleGroup/v1/index.d.ts.map +1 -0
  76. package/types/ToggleGroup/v1/props.d.ts +65 -0
  77. package/types/ToggleGroup/v1/props.d.ts.map +1 -0
  78. package/types/ToggleGroup/v1/styles.d.ts +15 -0
  79. package/types/ToggleGroup/v1/styles.d.ts.map +1 -0
  80. package/types/ToggleGroup/v1/theme.d.ts +10 -0
  81. package/types/ToggleGroup/v1/theme.d.ts.map +1 -0
  82. package/types/ToggleGroup/v2/index.d.ts +54 -0
  83. package/types/ToggleGroup/v2/index.d.ts.map +1 -0
  84. package/types/ToggleGroup/v2/props.d.ts +66 -0
  85. package/types/ToggleGroup/v2/props.d.ts.map +1 -0
  86. package/types/ToggleGroup/v2/styles.d.ts +15 -0
  87. package/types/ToggleGroup/v2/styles.d.ts.map +1 -0
  88. package/types/exports/a.d.ts +5 -0
  89. package/types/exports/a.d.ts.map +1 -0
  90. package/types/exports/b.d.ts +5 -0
  91. package/types/exports/b.d.ts.map +1 -0
package/LICENSE.md ADDED
@@ -0,0 +1,28 @@
1
+ ---
2
+ title: The MIT License (MIT)
3
+ category: Getting Started
4
+ order: 9
5
+ isWIP: true
6
+ ---
7
+
8
+ # The MIT License (MIT)
9
+
10
+ Copyright (c) 2015 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.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ ## ui-toggle-details
2
+
3
+ [![npm][npm]][npm-url]
4
+ [![MIT License][license-badge]][license]
5
+ [![Code of Conduct][coc-badge]][coc]
6
+
7
+ A styled toggleable, accordion-like component.
8
+
9
+ ### Components
10
+
11
+ The `ui-toggle-details` package contains the following:
12
+
13
+ - [ToggleDetails](ToggleDetails)
14
+ - [ToggleGroup](ToggleGroup)
15
+
16
+ ### Installation
17
+
18
+ ```sh
19
+ npm install @instructure/ui-toggle-details
20
+ ```
21
+
22
+ ### Usage
23
+
24
+ ```js
25
+ import React from 'react'
26
+ import { ToggleDetails } from '@instructure/ui-toggle-details'
27
+
28
+ const MyToggleDetails = () => {
29
+ return (
30
+ <ToggleDetails summary="Hello toggle">
31
+ <Text>Hello details</Text>
32
+ </ToggleDetails>
33
+ )
34
+ }
35
+ ```
36
+
37
+ [npm]: https://img.shields.io/npm/v/@instructure/ui-toggle-details.svg
38
+ [npm-url]: https://npmjs.com/package/@instructure/ui-toggle-details
39
+ [license-badge]: https://img.shields.io/npm/l/instructure-ui.svg?style=flat-square
40
+ [license]: https://github.com/instructure/instructure-ui/blob/master/LICENSE.md
41
+ [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
42
+ [coc]: https://github.com/instructure/instructure-ui/blob/master/CODE_OF_CONDUCT.md
@@ -0,0 +1,177 @@
1
+ var _dec, _class;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component, createRef } from 'react';
27
+ import { Button } from '@instructure/ui-buttons/v11_6';
28
+ import { IconArrowOpenEndSolid, IconArrowOpenDownSolid } from '@instructure/ui-icons';
29
+ import { Expandable } from '@instructure/ui-expandable';
30
+ import { omitProps, pickProps } from '@instructure/ui-react-utils';
31
+ import { isActiveElement } from '@instructure/ui-dom-utils';
32
+ import { withStyle } from '@instructure/emotion';
33
+ import generateStyle from './styles.js';
34
+ import generateComponentTheme from './theme.js';
35
+ import { allowedProps } from './props.js';
36
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
37
+ /**
38
+ ---
39
+ category: components
40
+ ---
41
+ **/
42
+ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = class ToggleDetails extends Component {
43
+ static displayName = 'ToggleDetails';
44
+ static componentId = 'ToggleDetails';
45
+ static allowedProps = allowedProps;
46
+ static defaultProps = {
47
+ variant: 'default',
48
+ size: 'medium',
49
+ fluidWidth: false,
50
+ icon: IconArrowOpenEndSolid,
51
+ iconExpanded: IconArrowOpenDownSolid,
52
+ iconPosition: 'start',
53
+ defaultExpanded: false,
54
+ children: null
55
+ };
56
+ _buttonNode = null;
57
+ ref = /*#__PURE__*/createRef();
58
+
59
+ // TODO this solution was generated with Gemini, should be tested if it works as fine as before
60
+ setButtonRef = node => {
61
+ this._buttonNode = node;
62
+ };
63
+ get focused() {
64
+ return isActiveElement(this._buttonNode);
65
+ }
66
+ focus() {
67
+ this._buttonNode?.focus();
68
+ }
69
+ componentDidMount() {
70
+ this.props.makeStyles?.();
71
+ }
72
+ componentDidUpdate() {
73
+ this.props.makeStyles?.();
74
+ }
75
+ renderSummary(expanded) {
76
+ const {
77
+ summary,
78
+ iconPosition
79
+ } = this.props;
80
+ return _jsxs("span", {
81
+ css: this.props.styles?.summary,
82
+ children: [iconPosition === 'start' && this.renderIcon(expanded), _jsx("span", {
83
+ css: this.props.styles?.summaryText,
84
+ children: summary
85
+ }), iconPosition === 'end' && this.renderIcon(expanded)]
86
+ });
87
+ }
88
+ renderToggle(toggleProps, expanded) {
89
+ const {
90
+ variant
91
+ } = this.props;
92
+ const tProps = this.props.children ? toggleProps : {
93
+ onClick: toggleProps.onClick
94
+ };
95
+ const props = {
96
+ ...omitProps(this.props, ToggleDetails.allowedProps),
97
+ ...tProps,
98
+ children: this.renderSummary(expanded)
99
+ };
100
+ const summary = this.renderSummary(expanded);
101
+ if (variant === 'filled') {
102
+ return _jsx(Button, {
103
+ ...props,
104
+ display: "block",
105
+ textAlign: "start",
106
+ elementRef: this.setButtonRef,
107
+ children: summary
108
+ });
109
+ } else if (props.href) {
110
+ return _jsx("a", {
111
+ ...props,
112
+ css: this.props.styles?.toggle,
113
+ ref: this.setButtonRef,
114
+ children: summary
115
+ });
116
+ } else {
117
+ return _jsx("button", {
118
+ ...props,
119
+ type: "button",
120
+ css: this.props.styles?.toggle,
121
+ ref: this.setButtonRef,
122
+ children: summary
123
+ });
124
+ }
125
+ }
126
+ renderIcon(expanded) {
127
+ const Icon = expanded ? this.props.iconExpanded : this.props.icon;
128
+ return this.props.children && Icon ? _jsx("span", {
129
+ css: this.props.styles?.icon,
130
+ children: _jsx(Icon, {})
131
+ }) : null;
132
+ }
133
+ renderDetails(expanded, detailsProps) {
134
+ if (!this.props.children) return null;
135
+ const expandedStyles = expanded ? {
136
+ display: 'block'
137
+ } : {
138
+ display: 'none'
139
+ };
140
+ return _jsx("div", {
141
+ ...detailsProps,
142
+ css: [this.props.styles?.details, expandedStyles],
143
+ children: expanded && this.renderContent()
144
+ });
145
+ }
146
+ renderContent() {
147
+ return _jsx("div", {
148
+ css: this.props.styles?.content,
149
+ children: this.props.children
150
+ });
151
+ }
152
+ handleToggle = (event, expanded) => {
153
+ if (typeof this.props.onToggle === 'function') {
154
+ this.props.onToggle(event, expanded);
155
+ }
156
+ };
157
+ render() {
158
+ return _jsx(Expandable, {
159
+ ...pickProps(this.props, Expandable.allowedProps),
160
+ onToggle: this.handleToggle,
161
+ children: ({
162
+ expanded,
163
+ getToggleProps,
164
+ getDetailsProps
165
+ }) => {
166
+ return _jsxs("div", {
167
+ css: this.props.styles?.toggleDetails,
168
+ ref: this.ref,
169
+ "data-cid": "ToggleDetails",
170
+ children: [this.renderToggle(getToggleProps(), expanded), this.renderDetails(expanded, getDetailsProps())]
171
+ });
172
+ }
173
+ });
174
+ }
175
+ }) || _class);
176
+ export default ToggleDetails;
177
+ export { ToggleDetails };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['variant', 'summary', 'expanded', 'defaultExpanded', 'onToggle', 'icon', 'iconExpanded', 'iconPosition', 'fluidWidth', 'children', 'size'];
26
+ export { allowedProps };
@@ -0,0 +1,196 @@
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 { keyframes } from '@instructure/emotion';
26
+ const contentAnimation = keyframes`
27
+ to {
28
+ opacity: 1;
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, _state) => {
42
+ const {
43
+ fluidWidth,
44
+ iconPosition,
45
+ size,
46
+ variant
47
+ } = props;
48
+ const positionIconAtEnd = iconPosition === 'end' && (variant === 'filled' || fluidWidth);
49
+ const fluidWidthStyles = fluidWidth ? {
50
+ display: 'block',
51
+ width: '100%'
52
+ } : {};
53
+ const iconPositionStyles = {
54
+ start: {
55
+ marginInlineEnd: componentTheme.iconMargin,
56
+ marginInlineStart: 0
57
+ },
58
+ end: {
59
+ marginInlineStart: componentTheme.iconMargin,
60
+ marginInlineEnd: 0
61
+ }
62
+ };
63
+ const fontSizeStyles = {
64
+ small: {
65
+ fontSize: componentTheme.fontSizeSmall
66
+ },
67
+ medium: {
68
+ fontSize: componentTheme.fontSizeMedium
69
+ },
70
+ large: {
71
+ fontSize: componentTheme.fontSizeLarge
72
+ }
73
+ };
74
+ const iconSizeStyles = {
75
+ small: {
76
+ fontSize: componentTheme.smallIconSize
77
+ },
78
+ medium: {
79
+ fontSize: componentTheme.mediumIconSize
80
+ },
81
+ large: {
82
+ fontSize: componentTheme.largeIconSize
83
+ }
84
+ };
85
+ const indentDetailsStyles = iconPosition === 'start' && !fluidWidth ? {
86
+ small: {
87
+ paddingInlineStart: `calc(${componentTheme.smallIconSize} + ${componentTheme.togglePadding})`,
88
+ paddingInlineEnd: '0'
89
+ },
90
+ medium: {
91
+ paddingInlineStart: `calc(${componentTheme.mediumIconSize} + ${componentTheme.togglePadding})`,
92
+ paddingInlineEnd: '0'
93
+ },
94
+ large: {
95
+ paddingInlineStart: `calc(${componentTheme.largeIconSize} + ${componentTheme.togglePadding})`,
96
+ paddingInlineEnd: '0'
97
+ }
98
+ } : {
99
+ small: {},
100
+ medium: {},
101
+ large: {}
102
+ };
103
+ return {
104
+ toggleDetails: {
105
+ label: 'toggleDetails',
106
+ fontFamily: componentTheme.fontFamily,
107
+ fontWeight: componentTheme.fontWeight,
108
+ lineHeight: componentTheme.lineHeight
109
+ },
110
+ summary: {
111
+ label: 'toggleDetails__summary',
112
+ position: 'relative',
113
+ display: 'flex',
114
+ alignItems: 'center',
115
+ boxSizing: 'border-box',
116
+ textAlign: 'start'
117
+ },
118
+ summaryText: {
119
+ label: 'toggleDetails__summaryText',
120
+ minWidth: '0.0625rem',
121
+ flexGrow: 1,
122
+ ...(positionIconAtEnd ? {
123
+ flex: 1
124
+ } : {})
125
+ },
126
+ toggle: {
127
+ label: 'toggleDetails__toggle',
128
+ fontFamily: componentTheme.fontFamily,
129
+ appearance: 'none',
130
+ cursor: 'pointer',
131
+ userSelect: 'none',
132
+ touchAction: 'manipulation',
133
+ position: 'relative',
134
+ overflow: 'visible',
135
+ boxSizing: 'border-box',
136
+ padding: '0',
137
+ margin: '0',
138
+ outline: 'none',
139
+ border: 'none',
140
+ background: 'transparent',
141
+ color: componentTheme.textColor,
142
+ '&::-moz-focus-inner': {
143
+ padding: '0',
144
+ margin: '0'
145
+ },
146
+ '&::before': {
147
+ content: '""',
148
+ position: 'absolute',
149
+ top: '-0.375rem',
150
+ left: '-0.375rem',
151
+ right: '-0.375rem',
152
+ bottom: '-0.375rem',
153
+ border: `${componentTheme.toggleBorderWidth} ${componentTheme.toggleBorderStyle} ${componentTheme.toggleFocusBorderColor}`,
154
+ borderRadius: `calc(${componentTheme.toggleBorderRadius} * 1.5)`,
155
+ opacity: 0,
156
+ pointerEvents: 'none'
157
+ },
158
+ '&:focus': {
159
+ '&::before': {
160
+ opacity: 1
161
+ }
162
+ },
163
+ '&:focus, &:hover, &:active': {
164
+ textDecoration: 'none',
165
+ color: componentTheme.textColor
166
+ },
167
+ textDecoration: 'none',
168
+ ...fluidWidthStyles,
169
+ ...fontSizeStyles[size]
170
+ },
171
+ icon: {
172
+ label: 'toggleDetails__icon',
173
+ '& > svg': {
174
+ display: 'block' /* fix vertical alignment of icon */
175
+ },
176
+ ...iconPositionStyles[iconPosition],
177
+ ...iconSizeStyles[size]
178
+ },
179
+ details: {
180
+ label: 'toggleDetails__details',
181
+ boxSizing: 'border-box',
182
+ paddingTop: componentTheme.togglePadding,
183
+ color: componentTheme.textColor,
184
+ ...fontSizeStyles[size],
185
+ ...indentDetailsStyles[size]
186
+ },
187
+ content: {
188
+ label: 'toggleDetails__content',
189
+ opacity: 0.01,
190
+ animationName: contentAnimation,
191
+ animationFillMode: 'forwards',
192
+ animationDuration: '.3s'
193
+ }
194
+ };
195
+ };
196
+ export default generateStyle;
@@ -0,0 +1,75 @@
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
+ const {
32
+ colors,
33
+ spacing,
34
+ borders,
35
+ typography,
36
+ key: themeName
37
+ } = theme;
38
+ const themeSpecificStyle = {
39
+ canvas: {
40
+ toggleFocusBorderColor: theme['ic-brand-primary'],
41
+ iconColor: theme['ic-brand-font-color-dark'],
42
+ textColor: theme['ic-brand-font-color-dark']
43
+ }
44
+ };
45
+ const componentVariables = {
46
+ fontFamily: typography?.fontFamily,
47
+ fontWeight: typography?.fontWeightNormal,
48
+ lineHeight: typography?.lineHeight,
49
+ textColor: colors?.contrasts?.grey125125,
50
+ fontSizeSmall: typography?.fontSizeSmall,
51
+ fontSizeMedium: typography?.fontSizeMedium,
52
+ fontSizeLarge: typography?.fontSizeLarge,
53
+ smallIconSize: '0.5rem',
54
+ mediumIconSize: '0.75rem',
55
+ largeIconSize: '1rem',
56
+ iconMargin: spacing?.xxSmall,
57
+ iconColor: colors?.contrasts?.grey125125,
58
+ togglePadding: spacing?.xxSmall,
59
+ toggleBorderRadius: borders?.radiusMedium,
60
+ toggleBorderWidth: borders?.widthMedium,
61
+ toggleBorderStyle: borders?.style,
62
+ toggleFocusBorderColor: colors?.contrasts?.blue4570,
63
+ filledBackgroundColor: colors?.contrasts?.grey1111,
64
+ filledBorderWidth: borders?.widthSmall,
65
+ filledBorderStyle: borders?.style,
66
+ filledBorderColor: colors?.contrasts?.grey1424,
67
+ filledBorderRadius: borders?.radiusMedium,
68
+ filledPadding: spacing?.small
69
+ };
70
+ return {
71
+ ...componentVariables,
72
+ ...themeSpecificStyle[themeName]
73
+ };
74
+ };
75
+ export default generateComponentTheme;