@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,134 @@
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 CondensedButtonOwnProps = {
37
+ /**
38
+ * Specifies the `CondensedButton` children.
39
+ */
40
+ children?: React.ReactNode
41
+
42
+ /**
43
+ * Specifies the type of the `CondensedButton`'s underlying html element.
44
+ */
45
+ type?: 'button' | 'submit' | 'reset'
46
+
47
+ /**
48
+ * The size of the `CondensedButton`
49
+ */
50
+ size?: 'small' | 'medium' | 'large' | 'condensedSmall' | 'condensedMedium'
51
+
52
+ /**
53
+ * Provides a reference to the `CondensedButton`'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 `CondensedButton` is enabled, disabled, or readonly.
64
+ */
65
+ interaction?: 'enabled' | 'disabled' | 'readonly'
66
+
67
+ /**
68
+ * Specifies the color for the `CondensedButton`.
69
+ */
70
+ color?: 'primary' | 'primary-inverse' | 'secondary'
71
+
72
+ /**
73
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
74
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
75
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
76
+ */
77
+ margin?: Spacing
78
+
79
+ /**
80
+ * Specify a mouse cursor to use when hovering over the button.
81
+ * The `pointer` cursor is used by default.
82
+ */
83
+ cursor?: Cursor
84
+
85
+ /**
86
+ * Specifies an href attribute for the `CondensedButton`'s underlying html element.
87
+ */
88
+ href?: string
89
+
90
+ /**
91
+ * An icon, or function that returns an icon.
92
+ */
93
+ renderIcon?: React.ReactNode | (() => React.ReactNode)
94
+
95
+ /**
96
+ * Callback fired when the `CondensedButton` is clicked.
97
+ */
98
+ onClick?: (
99
+ event: React.KeyboardEvent<ViewProps> | React.MouseEvent<ViewProps>
100
+ ) => void
101
+
102
+ /**
103
+ * The CSS display property of the button, `inline-block` or `block`
104
+ */
105
+ display?: 'inline-block' | 'block'
106
+ }
107
+
108
+ type PropKeys = keyof CondensedButtonOwnProps
109
+
110
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
111
+
112
+ type CondensedButtonProps = CondensedButtonOwnProps &
113
+ WithStyleProps<BaseButtonTheme, null> &
114
+ OtherHTMLAttributes<CondensedButtonOwnProps> &
115
+ ToProp
116
+
117
+ const allowedProps: AllowedPropKeys = [
118
+ 'as',
119
+ 'children',
120
+ 'color',
121
+ 'cursor',
122
+ 'elementRef',
123
+ 'href',
124
+ 'interaction',
125
+ 'margin',
126
+ 'renderIcon',
127
+ 'size',
128
+ 'type',
129
+ 'onClick',
130
+ 'display'
131
+ ]
132
+
133
+ export type { CondensedButtonProps }
134
+ export { allowedProps }
@@ -28,10 +28,10 @@ import { passthroughProps } from '@instructure/ui-react-utils'
28
28
  import { ScreenReaderContent } from '@instructure/ui-a11y-content'
29
29
  import { combineDataCid } from '@instructure/ui-utils'
30
30
 
31
- import { withStyle } from '@instructure/emotion'
31
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
32
32
 
33
33
  import generateComponentTheme from './theme'
34
- import { BaseButton } from '../BaseButton'
34
+ import { BaseButton } from '../../BaseButton/v1'
35
35
 
36
36
  import { allowedProps } from './props'
37
37
  import type { IconButtonProps } from './props'
@@ -33,7 +33,7 @@ import type {
33
33
  Renderable
34
34
  } from '@instructure/shared-types'
35
35
  import type { Cursor } from '@instructure/shared-types'
36
- import type { ViewProps } from '@instructure/ui-view'
36
+ import type { ViewProps } from '@instructure/ui-view/v11_6'
37
37
 
38
38
  type IconButtonOwnProps = {
39
39
  /**
@@ -22,4 +22,4 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export { default } from '../BaseButton/theme'
25
+ export { default } from '../../BaseButton/v1/theme'
@@ -0,0 +1,86 @@
1
+ ---
2
+ describes: IconButton
3
+ ---
4
+
5
+ An IconButton can be used when the Button only renders an Icon and does not have other visual elements or text content.
6
+ It is not recommended to set the size of an icon inside an IconButton. Only use the `size` property of the IconButton.
7
+
8
+ ```js
9
+ ---
10
+ type: example
11
+ ---
12
+ <IconButton screenReaderLabel="Add User"><PlusInstUIIcon /></IconButton>
13
+ ```
14
+
15
+ ### Accessibility
16
+
17
+ Because the IconButton visually only renders an icon, a description is necessary for assistive technologies. The `screenReaderLabel` prop is required for this purpose, and should consist of a complete description of the action.
18
+
19
+ ```js
20
+ ---
21
+ type: example
22
+ ---
23
+ <IconButton color="primary" screenReaderLabel="Add blog post"><PlusInstUIIcon /></IconButton>
24
+ ```
25
+
26
+ Using [Tooltip](Tooltip) in conjunction with IconButton can also provide necessary context when the IconButton alone would be insufficient.
27
+
28
+ ```js
29
+ ---
30
+ type: example
31
+ ---
32
+ <Tooltip
33
+ renderTip="View user profile"
34
+ on={['hover', 'focus']}
35
+ placement="bottom"
36
+ >
37
+ <IconButton screenReaderLabel="View user profile"><UserInstUIIcon /></IconButton>
38
+ </Tooltip>
39
+ ```
40
+
41
+ ### AI Icon buttons
42
+
43
+ ```js
44
+ ---
45
+ type: example
46
+ ---
47
+ <View display="block">
48
+ <IconButton color="ai-primary" screenReaderLabel="AI button" margin="small"><IgniteaiLogoInstUIIcon/></IconButton>
49
+ <IconButton color="ai-secondary" screenReaderLabel="AI button" margin="small"><IgniteaiLogoInstUIIcon/></IconButton>
50
+ </View>
51
+ ```
52
+
53
+ ### Shaping
54
+
55
+ The `shape` prop specifies if the IconButton will render as a `rectangle` or `circle`.
56
+
57
+ ```js
58
+ ---
59
+ type: example
60
+ ---
61
+ <View display="block">
62
+ <IconButton shape="rectangle" screenReaderLabel="Delete tag" margin="small"><XInstUIIcon /></IconButton>
63
+ <IconButton shape="circle" screenReaderLabel="Delete tag" margin="small"><XInstUIIcon /></IconButton>
64
+ </View>
65
+ ```
66
+
67
+ ### Rendering only the icon
68
+
69
+ The background and border can be optionally removed as needed by setting the `withBorder` and `withBackground` props to `false`
70
+
71
+ ```js
72
+ ---
73
+ type: example
74
+ ---
75
+ <View display="block">
76
+ <View display="inline-block" background="primary">
77
+ <IconButton withBackground={false} withBorder={false} screenReaderLabel="Delete tag" margin="large">
78
+ <XInstUIIcon />
79
+ </IconButton>
80
+ </View>
81
+ </View>
82
+ ```
83
+
84
+ ### Styling
85
+
86
+ For an example see [Button](Button/#Styling%20buttons)
@@ -0,0 +1,138 @@
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 { passthroughProps } from '@instructure/ui-react-utils'
28
+ import { ScreenReaderContent } from '@instructure/ui-a11y-content'
29
+ import { combineDataCid } from '@instructure/ui-utils'
30
+
31
+ import { withStyle } from '@instructure/emotion'
32
+ import { BaseButton } from '../../BaseButton/v2'
33
+
34
+ import { allowedProps } from './props'
35
+ import type { IconButtonProps } from './props'
36
+
37
+ /**
38
+ ---
39
+ category: components
40
+ ---
41
+ **/
42
+
43
+ // needed for listing the available theme variables on docs page
44
+ @withStyle(null, 'BaseButton')
45
+ class IconButton extends Component<IconButtonProps> {
46
+ static readonly componentId = 'IconButton'
47
+
48
+ static allowedProps = allowedProps
49
+ static defaultProps = {
50
+ type: 'button',
51
+ size: 'medium',
52
+ as: 'button',
53
+ // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
54
+ interaction: undefined,
55
+ color: 'secondary',
56
+ shape: 'rectangle',
57
+ withBackground: true,
58
+ withBorder: true,
59
+ margin: '0',
60
+ cursor: 'pointer'
61
+ }
62
+
63
+ _baseButton: BaseButton | null = null
64
+
65
+ ref: Element | null = null
66
+
67
+ handleRef = (el: Element | null) => {
68
+ const { elementRef } = this.props
69
+
70
+ this.ref = el
71
+
72
+ if (typeof elementRef === 'function') {
73
+ elementRef(el)
74
+ }
75
+ }
76
+
77
+ get focused() {
78
+ return this._baseButton && this._baseButton.focused
79
+ }
80
+
81
+ focus() {
82
+ this._baseButton && this._baseButton.focus()
83
+ }
84
+
85
+ render() {
86
+ const {
87
+ children,
88
+ renderIcon,
89
+ screenReaderLabel,
90
+ type,
91
+ size,
92
+ elementRef,
93
+ as,
94
+ interaction,
95
+ color,
96
+ focusColor,
97
+ shape,
98
+ withBackground,
99
+ withBorder,
100
+ margin,
101
+ cursor,
102
+ href,
103
+ ...props
104
+ } = this.props
105
+
106
+ const themeOverride = this.props.themeOverride
107
+
108
+ return (
109
+ <BaseButton
110
+ {...passthroughProps(props)}
111
+ type={type}
112
+ size={size}
113
+ elementRef={this.handleRef}
114
+ as={as}
115
+ interaction={interaction}
116
+ color={color}
117
+ focusColor={focusColor}
118
+ shape={shape}
119
+ withBackground={withBackground}
120
+ withBorder={withBorder}
121
+ margin={margin}
122
+ cursor={cursor}
123
+ href={href}
124
+ renderIcon={children || renderIcon}
125
+ themeOverride={themeOverride}
126
+ ref={(component) => {
127
+ this._baseButton = component
128
+ }}
129
+ data-cid={combineDataCid('IconButton', this.props)}
130
+ >
131
+ <ScreenReaderContent>{screenReaderLabel}</ScreenReaderContent>
132
+ </BaseButton>
133
+ )
134
+ }
135
+ }
136
+
137
+ export default IconButton
138
+ export { IconButton }
@@ -0,0 +1,166 @@
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 { ReactNode } from 'react'
26
+
27
+ import type { Spacing, WithStyleProps } from '@instructure/emotion'
28
+ import type {
29
+ ToProp,
30
+ AsElementType,
31
+ BaseButtonTheme,
32
+ OtherHTMLAttributes,
33
+ Renderable
34
+ } from '@instructure/shared-types'
35
+ import type { Cursor } from '@instructure/shared-types'
36
+ import type { ViewProps } from '@instructure/ui-view/latest'
37
+
38
+ type IconButtonOwnProps = {
39
+ /**
40
+ * An icon, or function returning an icon (identical to the `renderIcon` prop).
41
+ */
42
+ children?: Renderable
43
+
44
+ /**
45
+ * An icon, or function that returns an icon (identical to the `children` prop).
46
+ */
47
+ renderIcon?: Renderable
48
+
49
+ /**
50
+ * An accessible label for the `IconButton`.
51
+ */
52
+ screenReaderLabel: ReactNode
53
+
54
+ /**
55
+ * Specifies the type of the `IconButton`'s underlying html element.
56
+ */
57
+ type?: 'button' | 'submit' | 'reset'
58
+
59
+ /**
60
+ * The size of the `IconButton`
61
+ */
62
+ size?: 'small' | 'medium' | 'large'
63
+
64
+ /**
65
+ * Provides a reference to the `IconButton`'s underlying html element.
66
+ */
67
+ elementRef?: (element: Element | null) => void
68
+
69
+ /**
70
+ * The element to render as the component root, `button` by default.
71
+ */
72
+ as?: AsElementType
73
+
74
+ /**
75
+ * Specifies if interaction with the `IconButton` is enabled, disabled, or readonly.
76
+ */
77
+ interaction?: 'enabled' | 'disabled' | 'readonly'
78
+
79
+ /**
80
+ * Specifies the color for the `IconButton`.
81
+ */
82
+ color?:
83
+ | 'primary'
84
+ | 'primary-inverse'
85
+ | 'secondary'
86
+ | 'success'
87
+ | 'danger'
88
+ | 'ai-primary'
89
+ | 'ai-secondary'
90
+
91
+ /**
92
+ * Override the `Button`'s default focus outline color.
93
+ */
94
+ focusColor?: 'info' | 'inverse'
95
+
96
+ /**
97
+ * Specifies if the `IconButton` shape should be a circle or rectangle.
98
+ */
99
+ shape?: 'rectangle' | 'circle'
100
+
101
+ /**
102
+ * Specifies if the `IconButton` should render with a solid background. When false, the background is transparent.
103
+ */
104
+ withBackground?: boolean
105
+
106
+ /**
107
+ * Specifies if the `IconButton` should render with a border.
108
+ */
109
+ withBorder?: boolean
110
+
111
+ /**
112
+ * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
113
+ * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
114
+ * familiar CSS-like shorthand. For example: `margin="small auto large"`.
115
+ */
116
+ margin?: Spacing
117
+
118
+ /**
119
+ * Specify a mouse cursor to use when hovering over the button.
120
+ * The `pointer` cursor is used by default.
121
+ */
122
+ cursor?: Cursor
123
+
124
+ /**
125
+ * Specifies an href attribute for the `IconButton`'s underlying html element.
126
+ */
127
+ href?: string
128
+
129
+ /**
130
+ * Callback fired when the `Button` is clicked.
131
+ */
132
+ onClick?: (
133
+ event: React.KeyboardEvent<ViewProps> | React.MouseEvent<ViewProps>
134
+ ) => void
135
+ }
136
+
137
+ type PropKeys = keyof IconButtonOwnProps
138
+
139
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
140
+
141
+ type IconButtonProps = IconButtonOwnProps &
142
+ WithStyleProps<BaseButtonTheme, null> &
143
+ OtherHTMLAttributes<IconButtonOwnProps> &
144
+ ToProp
145
+ const allowedProps: AllowedPropKeys = [
146
+ 'as',
147
+ 'children',
148
+ 'color',
149
+ 'cursor',
150
+ 'elementRef',
151
+ 'focusColor',
152
+ 'href',
153
+ 'interaction',
154
+ 'margin',
155
+ 'renderIcon',
156
+ 'screenReaderLabel',
157
+ 'shape',
158
+ 'size',
159
+ 'type',
160
+ 'withBackground',
161
+ 'withBorder',
162
+ 'onClick'
163
+ ]
164
+
165
+ export type { IconButtonProps }
166
+ export { allowedProps }
@@ -26,8 +26,8 @@ import { Component } from 'react'
26
26
 
27
27
  import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
28
28
 
29
- import { Tooltip } from '@instructure/ui-tooltip'
30
- import { IconButton } from '../IconButton'
29
+ import { Tooltip } from '@instructure/ui-tooltip/v11_6'
30
+ import { IconButton } from '../../IconButton/v1'
31
31
 
32
32
  import { allowedProps } from './props'
33
33
  import type { ToggleButtonProps, ToggleButtonState } from './props'
@@ -33,7 +33,7 @@ import type {
33
33
  PositionConstraint,
34
34
  PositionMountNode
35
35
  } from '@instructure/ui-position'
36
- import type { ViewProps } from '@instructure/ui-view'
36
+ import type { ViewProps } from '@instructure/ui-view/v11_6'
37
37
  import { Renderable } from '@instructure/shared-types'
38
38
 
39
39
  type ToggleButtonOwnProps = {
@@ -0,0 +1,85 @@
1
+ ---
2
+ describes: ToggleButton
3
+ ---
4
+
5
+ `ToggleButton` is a controlled button component used for toggling a status or setting
6
+ between one of two states (locked/unlocked, published/unpublished, etc.).
7
+
8
+ ```js
9
+ ---
10
+ type: example
11
+ ---
12
+ const Example = () => {
13
+ const [locked, setLocked] = useState(false)
14
+
15
+ const handleLocked = () => {
16
+ setLocked(!locked)
17
+ }
18
+
19
+ return (
20
+ <View as="div" padding="x-large" id="toggleContainer">
21
+ <ToggleButton
22
+ status={locked ? 'pressed' : 'unpressed'}
23
+ color={locked ? 'danger' : 'secondary'}
24
+ renderIcon={locked ? LockInstUIIcon : UnlockInstUIIcon}
25
+ screenReaderLabel={locked ? 'Unlock assignment' : 'Lock assignment'}
26
+ renderTooltipContent={locked ? 'Unlock' : 'Lock'}
27
+ onClick={handleLocked}
28
+ />
29
+ </View>
30
+ )
31
+ }
32
+
33
+ render(<Example />)
34
+ ```
35
+
36
+ ### Inverse ToggleButton
37
+
38
+ ```js
39
+ ---
40
+ type: example
41
+ ---
42
+ const InverseExample = () => {
43
+ const [locked, setLocked] = useState(false)
44
+
45
+ const handleLocked = () => {
46
+ setLocked(!locked)
47
+ }
48
+
49
+ return (
50
+ <View
51
+ as="div"
52
+ padding="xx-large"
53
+ background="primary-inverse"
54
+ id="inverseToggleContainer"
55
+ >
56
+ <ToggleButton
57
+ status={locked ? 'pressed' : 'unpressed'}
58
+ color="primary-inverse"
59
+ renderIcon={locked ? LockInstUIIcon : UnlockInstUIIcon}
60
+ screenReaderLabel={locked ? 'Unlock assignment' : 'Lock assignment'}
61
+ renderTooltipContent={locked ? 'Unlock' : 'Lock'}
62
+ onClick={handleLocked}
63
+ />
64
+ </View>
65
+ )
66
+ }
67
+ render(<InverseExample />)
68
+ ```
69
+
70
+ ### Guidelines
71
+
72
+ ```js
73
+ ---
74
+ type: embed
75
+ ---
76
+ <Guidelines>
77
+ <Figure recommendation="yes" title="Do">
78
+ <Figure.Item>Use for toggling a setting or status between one of two states</Figure.Item>
79
+ <Figure.Item>Use <code>color="primary-inverse"</code> on dark backgrounds so your icon and tooltip are visible</Figure.Item>
80
+ </Figure>
81
+ <Figure recommendation="no" title="Don't">
82
+ <Figure.Item>Use text inside a <code>ToggleButton</code></Figure.Item>
83
+ </Figure>
84
+ </Guidelines>
85
+ ```