@instructure/ui-buttons 11.6.0 → 11.6.1-snapshot-129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +57 -323
  2. package/es/BaseButton/{index.js → v1/index.js} +2 -2
  3. package/es/BaseButton/v2/index.js +304 -0
  4. package/es/BaseButton/v2/props.js +26 -0
  5. package/es/BaseButton/v2/styles.js +578 -0
  6. package/es/Button/{index.js → v1/index.js} +2 -2
  7. package/es/{CondensedButton → Button/v1}/theme.js +1 -1
  8. package/es/Button/v2/index.js +121 -0
  9. package/es/Button/v2/props.js +26 -0
  10. package/es/CloseButton/{index.js → v1/index.js} +2 -2
  11. package/es/CloseButton/v2/index.js +130 -0
  12. package/es/CloseButton/v2/props.js +26 -0
  13. package/es/CloseButton/v2/styles.js +68 -0
  14. package/es/CondensedButton/{index.js → v1/index.js} +2 -2
  15. package/es/{Button → CondensedButton/v1}/theme.js +1 -1
  16. package/es/CondensedButton/v2/index.js +111 -0
  17. package/es/CondensedButton/v2/props.js +26 -0
  18. package/es/IconButton/{index.js → v1/index.js} +2 -2
  19. package/es/IconButton/{theme.js → v1/theme.js} +1 -1
  20. package/es/IconButton/v2/index.js +121 -0
  21. package/es/IconButton/v2/props.js +26 -0
  22. package/es/ToggleButton/{index.js → v1/index.js} +2 -2
  23. package/es/ToggleButton/v2/index.js +121 -0
  24. package/es/ToggleButton/v2/props.js +26 -0
  25. package/es/exports/a.js +29 -0
  26. package/es/exports/b.js +29 -0
  27. package/lib/BaseButton/{index.js → v1/index.js} +3 -3
  28. package/lib/BaseButton/v2/index.js +311 -0
  29. package/lib/BaseButton/v2/props.js +31 -0
  30. package/lib/BaseButton/v2/styles.js +584 -0
  31. package/lib/Button/v1/index.js +128 -0
  32. package/lib/Button/{theme.js → v1/theme.js} +1 -1
  33. package/lib/Button/{index.js → v2/index.js} +3 -4
  34. package/lib/Button/v2/props.js +31 -0
  35. package/lib/CloseButton/{index.js → v1/index.js} +4 -4
  36. package/lib/CloseButton/v2/index.js +136 -0
  37. package/lib/CloseButton/v2/props.js +31 -0
  38. package/lib/CloseButton/v2/styles.js +74 -0
  39. package/lib/CondensedButton/{index.js → v1/index.js} +3 -3
  40. package/lib/CondensedButton/{theme.js → v1/theme.js} +1 -1
  41. package/lib/CondensedButton/v2/index.js +116 -0
  42. package/lib/CondensedButton/v2/props.js +31 -0
  43. package/lib/IconButton/{index.js → v1/index.js} +3 -3
  44. package/lib/IconButton/{theme.js → v1/theme.js} +1 -1
  45. package/lib/IconButton/v2/index.js +126 -0
  46. package/lib/IconButton/v2/props.js +31 -0
  47. package/lib/ToggleButton/{index.js → v1/index.js} +4 -4
  48. package/lib/ToggleButton/v2/index.js +127 -0
  49. package/lib/ToggleButton/v2/props.js +31 -0
  50. package/lib/{index.js → exports/a.js} +12 -12
  51. package/lib/exports/b.js +47 -0
  52. package/package.json +46 -24
  53. package/src/BaseButton/{index.tsx → v1/index.tsx} +3 -3
  54. package/src/BaseButton/{props.ts → v1/props.ts} +1 -1
  55. package/src/BaseButton/v2/README.md +15 -0
  56. package/src/BaseButton/v2/index.tsx +343 -0
  57. package/src/BaseButton/v2/props.ts +226 -0
  58. package/src/BaseButton/v2/styles.ts +640 -0
  59. package/src/Button/{index.tsx → v1/index.tsx} +2 -2
  60. package/src/Button/{props.ts → v1/props.ts} +1 -1
  61. package/src/{CondensedButton → Button/v1}/theme.ts +1 -1
  62. package/src/Button/v2/README.md +338 -0
  63. package/src/Button/v2/index.tsx +137 -0
  64. package/src/Button/v2/props.ts +159 -0
  65. package/src/CloseButton/{index.tsx → v1/index.tsx} +2 -2
  66. package/src/CloseButton/{props.ts → v1/props.ts} +1 -1
  67. package/src/CloseButton/v2/README.md +70 -0
  68. package/src/CloseButton/v2/index.tsx +142 -0
  69. package/src/CloseButton/v2/props.ts +148 -0
  70. package/src/CloseButton/v2/styles.ts +81 -0
  71. package/src/CondensedButton/{index.tsx → v1/index.tsx} +2 -2
  72. package/src/CondensedButton/{props.ts → v1/props.ts} +1 -1
  73. package/src/{Button → CondensedButton/v1}/theme.ts +1 -1
  74. package/src/CondensedButton/v2/README.md +75 -0
  75. package/src/CondensedButton/v2/index.tsx +129 -0
  76. package/src/CondensedButton/v2/props.ts +134 -0
  77. package/src/IconButton/{index.tsx → v1/index.tsx} +2 -2
  78. package/src/IconButton/{props.ts → v1/props.ts} +1 -1
  79. package/src/IconButton/{theme.ts → v1/theme.ts} +1 -1
  80. package/src/IconButton/v2/README.md +86 -0
  81. package/src/IconButton/v2/index.tsx +138 -0
  82. package/src/IconButton/v2/props.ts +166 -0
  83. package/src/ToggleButton/{index.tsx → v1/index.tsx} +2 -2
  84. package/src/ToggleButton/{props.ts → v1/props.ts} +1 -1
  85. package/src/ToggleButton/v2/README.md +85 -0
  86. package/src/ToggleButton/v2/index.tsx +133 -0
  87. package/src/ToggleButton/v2/props.ts +143 -0
  88. package/src/exports/a.ts +40 -0
  89. package/src/exports/b.ts +40 -0
  90. package/tsconfig.build.tsbuildinfo +1 -1
  91. package/types/BaseButton/{index.d.ts → v1/index.d.ts} +1 -1
  92. package/types/BaseButton/v1/index.d.ts.map +1 -0
  93. package/types/BaseButton/{props.d.ts → v1/props.d.ts} +1 -1
  94. package/types/BaseButton/v1/props.d.ts.map +1 -0
  95. package/types/BaseButton/v1/styles.d.ts.map +1 -0
  96. package/types/BaseButton/v1/theme.d.ts.map +1 -0
  97. package/types/BaseButton/v2/index.d.ts +48 -0
  98. package/types/BaseButton/v2/index.d.ts.map +1 -0
  99. package/types/BaseButton/v2/props.d.ts +118 -0
  100. package/types/BaseButton/v2/props.d.ts.map +1 -0
  101. package/types/BaseButton/v2/styles.d.ts +5 -0
  102. package/types/BaseButton/v2/styles.d.ts.map +1 -0
  103. package/types/Button/{index.d.ts → v1/index.d.ts} +2 -2
  104. package/types/Button/v1/index.d.ts.map +1 -0
  105. package/types/Button/{props.d.ts → v1/props.d.ts} +1 -1
  106. package/types/Button/v1/props.d.ts.map +1 -0
  107. package/types/Button/v1/theme.d.ts +2 -0
  108. package/types/Button/v1/theme.d.ts.map +1 -0
  109. package/types/Button/v2/index.d.ts +51 -0
  110. package/types/Button/v2/index.d.ts.map +1 -0
  111. package/types/Button/v2/props.d.ts +82 -0
  112. package/types/Button/v2/props.d.ts.map +1 -0
  113. package/types/CloseButton/{index.d.ts → v1/index.d.ts} +1 -1
  114. package/types/CloseButton/v1/index.d.ts.map +1 -0
  115. package/types/CloseButton/{props.d.ts → v1/props.d.ts} +1 -1
  116. package/types/CloseButton/v1/props.d.ts.map +1 -0
  117. package/types/CloseButton/v1/styles.d.ts.map +1 -0
  118. package/types/CloseButton/v1/theme.d.ts.map +1 -0
  119. package/types/CloseButton/v2/index.d.ts +46 -0
  120. package/types/CloseButton/v2/index.d.ts.map +1 -0
  121. package/types/CloseButton/v2/props.d.ts +77 -0
  122. package/types/CloseButton/v2/props.d.ts.map +1 -0
  123. package/types/CloseButton/v2/styles.d.ts +15 -0
  124. package/types/CloseButton/v2/styles.d.ts.map +1 -0
  125. package/types/CondensedButton/{index.d.ts → v1/index.d.ts} +2 -2
  126. package/types/CondensedButton/v1/index.d.ts.map +1 -0
  127. package/types/CondensedButton/{props.d.ts → v1/props.d.ts} +1 -1
  128. package/types/CondensedButton/v1/props.d.ts.map +1 -0
  129. package/types/CondensedButton/v1/theme.d.ts +2 -0
  130. package/types/CondensedButton/v1/theme.d.ts.map +1 -0
  131. package/types/CondensedButton/v2/index.d.ts +45 -0
  132. package/types/CondensedButton/v2/index.d.ts.map +1 -0
  133. package/types/CondensedButton/v2/props.d.ts +69 -0
  134. package/types/CondensedButton/v2/props.d.ts.map +1 -0
  135. package/types/IconButton/{index.d.ts → v1/index.d.ts} +2 -2
  136. package/types/IconButton/v1/index.d.ts.map +1 -0
  137. package/types/IconButton/{props.d.ts → v1/props.d.ts} +1 -1
  138. package/types/IconButton/v1/props.d.ts.map +1 -0
  139. package/types/IconButton/v1/theme.d.ts +2 -0
  140. package/types/IconButton/v1/theme.d.ts.map +1 -0
  141. package/types/IconButton/v2/index.d.ts +51 -0
  142. package/types/IconButton/v2/index.d.ts.map +1 -0
  143. package/types/IconButton/v2/props.d.ts +85 -0
  144. package/types/IconButton/v2/props.d.ts.map +1 -0
  145. package/types/ToggleButton/{index.d.ts → v1/index.d.ts} +1 -1
  146. package/types/ToggleButton/v1/index.d.ts.map +1 -0
  147. package/types/ToggleButton/{props.d.ts → v1/props.d.ts} +1 -1
  148. package/types/ToggleButton/v1/props.d.ts.map +1 -0
  149. package/types/ToggleButton/v2/index.d.ts +43 -0
  150. package/types/ToggleButton/v2/index.d.ts.map +1 -0
  151. package/types/ToggleButton/v2/props.d.ts +75 -0
  152. package/types/ToggleButton/v2/props.d.ts.map +1 -0
  153. package/types/exports/a.d.ts +13 -0
  154. package/types/exports/a.d.ts.map +1 -0
  155. package/types/exports/b.d.ts +13 -0
  156. package/types/exports/b.d.ts.map +1 -0
  157. package/es/index.js +0 -29
  158. package/src/index.ts +0 -37
  159. package/types/BaseButton/index.d.ts.map +0 -1
  160. package/types/BaseButton/props.d.ts.map +0 -1
  161. package/types/BaseButton/styles.d.ts.map +0 -1
  162. package/types/BaseButton/theme.d.ts.map +0 -1
  163. package/types/Button/index.d.ts.map +0 -1
  164. package/types/Button/props.d.ts.map +0 -1
  165. package/types/Button/theme.d.ts +0 -2
  166. package/types/Button/theme.d.ts.map +0 -1
  167. package/types/CloseButton/index.d.ts.map +0 -1
  168. package/types/CloseButton/props.d.ts.map +0 -1
  169. package/types/CloseButton/styles.d.ts.map +0 -1
  170. package/types/CloseButton/theme.d.ts.map +0 -1
  171. package/types/CondensedButton/index.d.ts.map +0 -1
  172. package/types/CondensedButton/props.d.ts.map +0 -1
  173. package/types/CondensedButton/theme.d.ts +0 -2
  174. package/types/CondensedButton/theme.d.ts.map +0 -1
  175. package/types/IconButton/index.d.ts.map +0 -1
  176. package/types/IconButton/props.d.ts.map +0 -1
  177. package/types/IconButton/theme.d.ts +0 -2
  178. package/types/IconButton/theme.d.ts.map +0 -1
  179. package/types/ToggleButton/index.d.ts.map +0 -1
  180. package/types/ToggleButton/props.d.ts.map +0 -1
  181. package/types/index.d.ts +0 -13
  182. package/types/index.d.ts.map +0 -1
  183. /package/es/BaseButton/{props.js → v1/props.js} +0 -0
  184. /package/es/BaseButton/{styles.js → v1/styles.js} +0 -0
  185. /package/es/BaseButton/{theme.js → v1/theme.js} +0 -0
  186. /package/es/Button/{props.js → v1/props.js} +0 -0
  187. /package/es/CloseButton/{props.js → v1/props.js} +0 -0
  188. /package/es/CloseButton/{styles.js → v1/styles.js} +0 -0
  189. /package/es/CloseButton/{theme.js → v1/theme.js} +0 -0
  190. /package/es/CondensedButton/{props.js → v1/props.js} +0 -0
  191. /package/es/IconButton/{props.js → v1/props.js} +0 -0
  192. /package/es/ToggleButton/{props.js → v1/props.js} +0 -0
  193. /package/lib/BaseButton/{props.js → v1/props.js} +0 -0
  194. /package/lib/BaseButton/{styles.js → v1/styles.js} +0 -0
  195. /package/lib/BaseButton/{theme.js → v1/theme.js} +0 -0
  196. /package/lib/Button/{props.js → v1/props.js} +0 -0
  197. /package/lib/CloseButton/{props.js → v1/props.js} +0 -0
  198. /package/lib/CloseButton/{styles.js → v1/styles.js} +0 -0
  199. /package/lib/CloseButton/{theme.js → v1/theme.js} +0 -0
  200. /package/lib/CondensedButton/{props.js → v1/props.js} +0 -0
  201. /package/lib/IconButton/{props.js → v1/props.js} +0 -0
  202. /package/lib/ToggleButton/{props.js → v1/props.js} +0 -0
  203. /package/src/BaseButton/{README.md → v1/README.md} +0 -0
  204. /package/src/BaseButton/{styles.ts → v1/styles.ts} +0 -0
  205. /package/src/BaseButton/{theme.ts → v1/theme.ts} +0 -0
  206. /package/src/Button/{README.md → v1/README.md} +0 -0
  207. /package/src/CloseButton/{README.md → v1/README.md} +0 -0
  208. /package/src/CloseButton/{styles.ts → v1/styles.ts} +0 -0
  209. /package/src/CloseButton/{theme.ts → v1/theme.ts} +0 -0
  210. /package/src/CondensedButton/{README.md → v1/README.md} +0 -0
  211. /package/src/IconButton/{README.md → v1/README.md} +0 -0
  212. /package/src/ToggleButton/{README.md → v1/README.md} +0 -0
  213. /package/types/BaseButton/{styles.d.ts → v1/styles.d.ts} +0 -0
  214. /package/types/BaseButton/{theme.d.ts → v1/theme.d.ts} +0 -0
  215. /package/types/CloseButton/{styles.d.ts → v1/styles.d.ts} +0 -0
  216. /package/types/CloseButton/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,338 @@
1
+ ---
2
+ describes: Button
3
+ ---
4
+
5
+ Button allows users to perform actions or trigger changes. If selecting the Button causes the user to navigate to a different location, consider using the [Link](Link) component instead.
6
+
7
+ ```js
8
+ ---
9
+ type: example
10
+ ---
11
+ <Button>Hello Instructure</Button>
12
+ ```
13
+
14
+ ### Color
15
+
16
+ The `color` prop will change the Button's color scheme.
17
+
18
+ ```js
19
+ ---
20
+ type: example
21
+ ---
22
+ <View display="block">
23
+ <Button color="primary" margin="small">Primary</Button>
24
+ <Button color="secondary" margin="small">Secondary</Button>
25
+ <Button color="success" margin="small">Success</Button>
26
+ <Button color="danger" margin="small">Danger</Button>
27
+ <Button color="ai-primary" margin="small">AI Primary</Button>
28
+ <Button color="ai-secondary" margin="small">AI Secondary</Button>
29
+ </View>
30
+ ```
31
+
32
+ ### Primary Inverse
33
+
34
+ The `primary-inverse` color is designed for use on colored backgrounds. It provides adequate contrast when placed on colored surfaces.
35
+
36
+ ```js
37
+ ---
38
+ type: example
39
+ ---
40
+ <View display="block" background="brand" padding="small">
41
+ <Button color="primary-inverse" margin="small">Primary Inverse</Button>
42
+ </View>
43
+ ```
44
+
45
+ ### AI buttons
46
+
47
+ There is a specific need for `AI buttons`, which has an icon and gradient colors for `background` and `borders`. Here are the preset examples you can use. (the `IconButton` examples are also included for convenience)
48
+
49
+ ```js
50
+ ---
51
+ type: example
52
+ ---
53
+ <View display="block">
54
+ <Button color="ai-primary" renderIcon={IgniteaiLogoInstUIIcon} margin="small">AI Primary</Button>
55
+ <Button color="ai-secondary" renderIcon={IgniteaiLogoInstUIIcon} margin="small">AI Secondary</Button>
56
+ <IconButton color="ai-primary" screenReaderLabel="AI button" margin="small"><IgniteaiLogoInstUIIcon/></IconButton>
57
+ <IconButton shape='circle' color="ai-secondary" screenReaderLabel="AI button" margin="small"><IgniteaiLogoInstUIIcon/></IconButton>
58
+ <IconButton shape='circle' color="ai-primary" screenReaderLabel="AI button" margin="small"><IgniteaiLogoInstUIIcon/></IconButton>
59
+ <IconButton color="ai-secondary" screenReaderLabel="AI button" margin="small"><IgniteaiLogoInstUIIcon/></IconButton>
60
+ </View>
61
+ ```
62
+
63
+ ### Size
64
+
65
+ To specify the Button `size`, set the size prop to `small`, `medium` (default) or `large`.
66
+
67
+ ```js
68
+ ---
69
+ type: example
70
+ ---
71
+ <View display="block">
72
+ <Button size="small" margin="small">Small</Button>
73
+ <Button margin="small">Medium</Button>
74
+ <Button size="large" margin="small">Large</Button>
75
+ </View>
76
+ ```
77
+
78
+ There are also two condensed size variants for compact layouts: `condensedSmall` and `condensedMedium`.
79
+
80
+ ```js
81
+ ---
82
+ type: example
83
+ ---
84
+ <View display="block">
85
+ <Button size="condensedSmall" margin="small">Condensed Small</Button>
86
+ <Button size="condensedMedium" margin="small">Condensed Medium</Button>
87
+ </View>
88
+ ```
89
+
90
+ ### Rendering icons in Buttons
91
+
92
+ An icon can be rendered alongside the Button content using the `renderIcon` prop. Use [IconButton](IconButton) instead if your Button only displays an Icon with no other visual content.
93
+
94
+ ```js
95
+ ---
96
+ type: example
97
+ ---
98
+ <Button renderIcon={SaveInstUIIcon}>Save</Button>
99
+ ```
100
+
101
+ ### Text wrapping
102
+
103
+ Just like native HTML buttons, the Button text will wrap to the next line when it does not have enough room.
104
+
105
+ ```js
106
+ ---
107
+ type: example
108
+ ---
109
+ <View
110
+ display="block"
111
+ width="10rem"
112
+ margin="small"
113
+ padding="small none"
114
+ withVisualDebug
115
+ >
116
+ <Button color="primary">
117
+ A Button With a Whole Lot of Text
118
+ </Button>
119
+ </View>
120
+ ```
121
+
122
+ If you need to prevent text wrapping, you can use the [TruncateText](TruncateText) util. You can also conditionally render a [Tooltip](Tooltip) with the full text when truncation occurs.
123
+
124
+ ```js
125
+ ---
126
+ type: example
127
+ ---
128
+ const Example = ({ message }) => {
129
+ const [isTruncated, setIsTruncated] = useState(false)
130
+
131
+ const handleUpdate = (shouldBeTruncated) => {
132
+ if (isTruncated !== shouldBeTruncated) {
133
+ setIsTruncated(shouldBeTruncated)
134
+ }
135
+ }
136
+
137
+ const renderButton = () => {
138
+ return (
139
+ <Button color="primary">
140
+ <TruncateText onUpdate={handleUpdate}>{message}</TruncateText>
141
+ </Button>
142
+ )
143
+ }
144
+
145
+ return (
146
+ <View
147
+ display="block"
148
+ width="10rem"
149
+ margin="small"
150
+ padding="small none"
151
+ withVisualDebug
152
+ >
153
+ {isTruncated ? (
154
+ <Tooltip
155
+ renderTip={message}
156
+ mountNode={() => document.getElementById('main')}
157
+ >
158
+ {renderButton()}
159
+ </Tooltip>
160
+ ) : (
161
+ renderButton()
162
+ )}
163
+ </View>
164
+ )
165
+ }
166
+
167
+ render(<Example message="A Button With a Whole Lot of Text" />)
168
+ ```
169
+
170
+ ### Display
171
+
172
+ By default, the Button displays inline with other elements. If you need it to expand to fill the width of it's container, set the `display` prop to `block`.
173
+
174
+ ```js
175
+ ---
176
+ type: example
177
+ ---
178
+ <View
179
+ display="block"
180
+ width="30rem"
181
+ margin="small"
182
+ padding="small none"
183
+ withVisualDebug
184
+ >
185
+ <Button
186
+ renderIcon={UserInstUIIcon}
187
+ display="block"
188
+ textAlign="center"
189
+ color="success"
190
+ >
191
+ User Details
192
+ </Button>
193
+ </View>
194
+ ```
195
+
196
+ ### Rendering Buttons without backgrounds
197
+
198
+ Use backgroundless buttons when there is a need to deemphasize the button. Be sure to use border/text colors that meet the proper contrast ratios with whatever background they are placed on.
199
+
200
+ ```js
201
+ ---
202
+ type: example
203
+ ---
204
+ <View display="block">
205
+ <Button renderIcon={PlusInstUIIcon} withBackground={false} color="secondary" margin="small">Click here</Button>
206
+ </View>
207
+ ```
208
+
209
+ ### Styling buttons
210
+
211
+ [Button](Button) and [IconButton](IconButton) share the same styling mechanics (they are `BaseButton`s underneath). You need to set the theme based on their `color` and `withBackground` prop:
212
+
213
+ ```js
214
+ ---
215
+ type: example
216
+ ---
217
+ class Example extends React.Component {
218
+ state = {
219
+ withBackground: true,
220
+ color : "secondary"
221
+ }
222
+ toggleWithBackground = (event) => this.setState({ withBackground: !this.state.withBackground })
223
+ changeColor = (event,color) => {this.setState({color})}
224
+ render() {
225
+ const overrides = {
226
+ borderWidth: "0.3rem",
227
+ // what to override depends on the 'color' value (by default 'secondary')
228
+ // if withBackground is true:
229
+ secondaryColor: '#000000', // icon color
230
+ secondaryBackground: '#ff00ff',
231
+ secondaryBorderColor: 'brown',
232
+
233
+ secondaryActiveBackground: '#000000', // &:active CSS, e.g. space is pressed, not hovered, see https://developer.mozilla.org/en-US/docs/Web/CSS/:active
234
+ secondaryActiveBoxShadow: '10px 5px 5px red',
235
+
236
+ secondaryHoverBackground: '#00FF00',
237
+ // if withBackground is false:
238
+ secondaryGhostColor: '#0000FF',
239
+ secondaryGhostBackground: 'transparent',
240
+ secondaryGhostBorderColor: '#FF00FF',
241
+
242
+ secondaryGhostActiveBackground: '#FF0000',
243
+ secondaryGhostActiveBoxShadow: '10px 5px 5px green',
244
+
245
+ secondaryGhostHoverBackground: '#00FFFF',
246
+
247
+ secondaryBoxShadow: '0 0 0.4875rem 0.625rem yellow',
248
+ secondaryHoverBoxShadow: '0 0 0.1875rem 0.625rem lime',
249
+ secondaryActiveBoxShadow: '0 0px 0px 25px red',
250
+ secondaryGhostHoverBoxShadow: '0 0 0.7875rem 0.625rem pink',
251
+ secondaryGhostBoxShadow: '0 0 0.2875rem 0.625rem green',
252
+ secondaryGhostActiveBoxShadow: '10px 5px 5px blue'
253
+
254
+ }
255
+ return (
256
+ <>
257
+ <FormFieldGroup description="In this example 'secondary' colors are overridden">
258
+ <Checkbox
259
+ checked={this.state.withBackground}
260
+ label="withBackground?"
261
+ onChange={this.toggleWithBackground}
262
+ />
263
+ </FormFieldGroup>
264
+ <View display="block" margin="small none">
265
+ <RadioInputGroup
266
+ name="color"
267
+ defaultValue="secondary"
268
+ description="Color:"
269
+ variant="toggle"
270
+ size="small"
271
+ onChange={this.changeColor} >
272
+ <RadioInput label="Primary" value="primary"/>
273
+ <RadioInput label="secondary" value="secondary" />
274
+ </RadioInputGroup>
275
+ </View>
276
+ <Flex margin="none none medium" gap="medium">
277
+ <Flex.Item>
278
+ <Button withBackground={this.state.withBackground}
279
+ color={this.state.color}
280
+ themeOverride={overrides}
281
+ >
282
+ Button
283
+ </Button>
284
+ </Flex.Item>
285
+ <Flex.Item>
286
+ <IconButton screenReaderLabel="View user profile"
287
+ withBackground={this.state.withBackground}
288
+ color={this.state.color}
289
+ themeOverride={overrides}>
290
+ <UserInstUIIcon />
291
+ </IconButton>
292
+ </Flex.Item>
293
+ </Flex>
294
+ </>
295
+ )
296
+ }
297
+ }
298
+ render(<Example />)
299
+ ```
300
+
301
+ ### Guidelines
302
+
303
+ ```js
304
+ ---
305
+ type: embed
306
+ ---
307
+ <Guidelines>
308
+ <Figure recommendation="yes" title="Do">
309
+ <Figure.Item>Use 'Title Case' for button text</Figure.Item>
310
+ <Figure.Item>Use buttons with color set to <code>primary</code> only once for each section of content</Figure.Item>
311
+ <Figure.Item>Use buttons with color set to <code>primary</code> when the task of the view requires an action to be taken</Figure.Item>
312
+ <Figure.Item>Use the <code>success</code> and <code>danger</code> colors for grading activities</Figure.Item>
313
+ <Figure.Item>Use the <code>danger</code> color to warn the user of potentially destructive actions</Figure.Item>
314
+ <Figure.Item>Use a button with color set to <code>secondary</code> as a secondary or tertiary option for actions such as Cancel</Figure.Item>
315
+ <Figure.Item>The <code>primary-inverse</code> color can be used as a secondary option instead of the <code>secondary</code> color when the background would otherwise match the <code>secondary</code> button color (example: ModalFooter). Set the focusColor to `info` as well with this configuration.</Figure.Item>
316
+ <Figure.Item>The maximum string length of any button, including spaces, should be 20 characters</Figure.Item>
317
+ </Figure>
318
+ <Figure recommendation="no" title="Don't">
319
+ <Figure.Item>Use more than one button with color set to <code>primary</code> per section of content
320
+ </Figure.Item>
321
+ <Figure.Item>Use buttons without backgrounds excessively</Figure.Item>
322
+ </Figure>
323
+ </Guidelines>
324
+ ```
325
+
326
+ ```js
327
+ ---
328
+ type: embed
329
+ ---
330
+ <Guidelines>
331
+ <Figure recommendation="a11y" title="Accessibility">
332
+ <Figure.Item>When using buttons on a dark background, use the <code>primary-inverse</code> color to ensure adequate contrast</Figure.Item>
333
+ <Figure.Item>Buttons are activated with both Enter and Spacebar keys, and either key press will fire an `onClick` event</Figure.Item>
334
+ <Figure.Item>Disabled buttons do not need to meet color contrast ratio requirements or receive keyboard focus but will be read as "disabled" or "dimmed" by screen readers</Figure.Item>
335
+ <Figure.Item>Icon only buttons must have ScreenReaderContent added so screen readers indicate what the button is used for</Figure.Item>
336
+ </Figure>
337
+ </Guidelines>
338
+ ```
@@ -0,0 +1,137 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Component } from 'react'
26
+
27
+ import { getInteraction, passthroughProps } from '@instructure/ui-react-utils'
28
+
29
+ import { withStyle } from '@instructure/emotion'
30
+ import { BaseButton } from '../../BaseButton/v2'
31
+
32
+ import { allowedProps } from './props'
33
+ import type { ButtonProps } from './props'
34
+
35
+ /**
36
+ ---
37
+ category: components
38
+ ---
39
+ **/
40
+ // needed for listing the available theme variables on docs page
41
+ @withStyle(null, 'BaseButton')
42
+ class Button extends Component<ButtonProps> {
43
+ static readonly componentId = 'Button'
44
+
45
+ static allowedProps = allowedProps
46
+ static defaultProps = {
47
+ type: 'button',
48
+ size: 'medium',
49
+ as: 'button',
50
+ // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
51
+ interaction: undefined,
52
+ color: 'secondary',
53
+ display: 'inline-block',
54
+ textAlign: 'center',
55
+ withBackground: true,
56
+ margin: '0',
57
+ cursor: 'pointer'
58
+ }
59
+
60
+ _buttonComponent: BaseButton | null = null
61
+
62
+ ref: Element | null = null
63
+
64
+ get focused() {
65
+ return this._buttonComponent && this._buttonComponent.focused
66
+ }
67
+
68
+ focus() {
69
+ this._buttonComponent && this._buttonComponent.focus()
70
+ }
71
+
72
+ handleElementRef = (el: Element | null) => {
73
+ const { elementRef } = this.props
74
+
75
+ this.ref = el
76
+
77
+ if (typeof elementRef === 'function') {
78
+ elementRef(el)
79
+ }
80
+ }
81
+
82
+ handleButtonRef = (component: BaseButton | null) => {
83
+ this._buttonComponent = component
84
+ }
85
+
86
+ render() {
87
+ const {
88
+ children,
89
+ type,
90
+ size,
91
+ as,
92
+ color,
93
+ focusColor,
94
+ display,
95
+ textAlign,
96
+ withBackground,
97
+ margin,
98
+ cursor,
99
+ href,
100
+ renderIcon,
101
+ ...props
102
+ } = this.props
103
+
104
+ const interaction = getInteraction({ props })
105
+
106
+ const themeOverride = this.props.themeOverride
107
+
108
+ const buttonProps = {
109
+ ...passthroughProps(props),
110
+ type,
111
+ size,
112
+ elementRef: this.handleElementRef,
113
+ ref: this.handleButtonRef,
114
+ as,
115
+ color,
116
+ interaction,
117
+ focusColor,
118
+ display,
119
+ textAlign,
120
+ withBackground,
121
+ margin,
122
+ cursor,
123
+ href,
124
+ renderIcon,
125
+ themeOverride
126
+ }
127
+
128
+ return (
129
+ <BaseButton {...buttonProps} data-cid="Button">
130
+ {children}
131
+ </BaseButton>
132
+ )
133
+ }
134
+ }
135
+
136
+ export default Button
137
+ export { Button }
@@ -0,0 +1,159 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import type { Spacing, WithStyleProps } from '@instructure/emotion'
27
+ import type {
28
+ ToProp,
29
+ AsElementType,
30
+ BaseButtonTheme,
31
+ OtherHTMLAttributes
32
+ } from '@instructure/shared-types'
33
+ import type { Cursor } from '@instructure/shared-types'
34
+ import type { ViewProps } from '@instructure/ui-view/latest'
35
+
36
+ type ButtonOwnProps = {
37
+ /**
38
+ * Specifies the `Button` children.
39
+ */
40
+ children?: React.ReactNode
41
+
42
+ /**
43
+ * Specifies the type of the `Button`'s underlying html element.
44
+ */
45
+ type?: 'button' | 'submit' | 'reset'
46
+
47
+ /**
48
+ * The size of the `Button`
49
+ */
50
+ size?: 'small' | 'medium' | 'large' | 'condensedSmall' | 'condensedMedium'
51
+
52
+ /**
53
+ * Provides a reference to the `Button`'s underlying html element.
54
+ */
55
+ elementRef?: (element: Element | null) => void
56
+
57
+ /**
58
+ * The element to render as the component root, `Button` by default.
59
+ */
60
+ as?: AsElementType
61
+
62
+ /**
63
+ * Specifies if interaction with the `Button` is enabled, disabled, or readonly.
64
+ */
65
+ interaction?: 'enabled' | 'disabled' | 'readonly'
66
+
67
+ /**
68
+ * Specifies the color for the `Button`.
69
+ */
70
+ color?:
71
+ | 'primary'
72
+ | 'primary-inverse'
73
+ | 'secondary'
74
+ | 'success'
75
+ | 'danger'
76
+ | 'ai-primary'
77
+ | 'ai-secondary'
78
+
79
+ /**
80
+ * Override the `Button`'s default focus outline color.
81
+ */
82
+ focusColor?: 'info' | 'inverse'
83
+
84
+ /**
85
+ * The `Button` display property. When set to `inline-block`, the `Button` displays inline with other elements.
86
+ * When set to block, the `Button` expands to fill the width of the container.
87
+ */
88
+ display?: 'inline-block' | 'block'
89
+
90
+ /**
91
+ * Sets the alignment of the `Button` children and/or icon.
92
+ */
93
+ textAlign?: 'start' | 'center'
94
+
95
+ /**
96
+ * Specifies if the `Button` should render with a solid background. When false, the background is transparent.
97
+ */
98
+ withBackground?: boolean
99
+
100
+ /**
101
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
102
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
103
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
104
+ */
105
+ margin?: Spacing
106
+
107
+ /**
108
+ * Specify a mouse cursor to use when hovering over the button.
109
+ * The `pointer` cursor is used by default.
110
+ */
111
+ cursor?: Cursor
112
+
113
+ /**
114
+ * Specifies an href attribute for the `Button`'s underlying html element.
115
+ */
116
+ href?: string
117
+
118
+ /**
119
+ * An icon, or function that returns an icon.
120
+ */
121
+ renderIcon?: React.ReactNode | (() => React.ReactNode)
122
+
123
+ /**
124
+ * Callback fired when the `Button` is clicked.
125
+ */
126
+ onClick?: (
127
+ event: React.KeyboardEvent<ViewProps> | React.MouseEvent<ViewProps>
128
+ ) => void
129
+ }
130
+
131
+ type PropKeys = keyof ButtonOwnProps
132
+
133
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
134
+
135
+ type ButtonProps = ButtonOwnProps &
136
+ WithStyleProps<BaseButtonTheme, null> &
137
+ OtherHTMLAttributes<ButtonOwnProps> &
138
+ ToProp
139
+ const allowedProps: AllowedPropKeys = [
140
+ 'as',
141
+ 'children',
142
+ 'color',
143
+ 'cursor',
144
+ 'display',
145
+ 'elementRef',
146
+ 'focusColor',
147
+ 'href',
148
+ 'interaction',
149
+ 'margin',
150
+ 'renderIcon',
151
+ 'size',
152
+ 'textAlign',
153
+ 'type',
154
+ 'withBackground',
155
+ 'onClick'
156
+ ]
157
+
158
+ export type { ButtonProps }
159
+ export { allowedProps }
@@ -28,11 +28,11 @@ import { IconXSolid } from '@instructure/ui-icons'
28
28
  import { ScreenReaderContent } from '@instructure/ui-a11y-content'
29
29
  import { getInteraction, passthroughProps } from '@instructure/ui-react-utils'
30
30
 
31
- import { withStyle } from '@instructure/emotion'
31
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
32
32
 
33
33
  import generateStyle from './styles'
34
34
  import generateComponentTheme from './theme'
35
- import { BaseButton } from '../BaseButton'
35
+ import { BaseButton } from '../../BaseButton/v1'
36
36
 
37
37
  import { allowedProps } from './props'
38
38
  import type { CloseButtonProps } from './props'
@@ -35,7 +35,7 @@ import type {
35
35
  OtherHTMLAttributes
36
36
  } from '@instructure/shared-types'
37
37
  import type { Cursor } from '@instructure/shared-types'
38
- import type { ViewProps } from '@instructure/ui-view'
38
+ import type { ViewProps } from '@instructure/ui-view/v11_6'
39
39
 
40
40
  type CloseButtonOwnProps = {
41
41
  /**