@react-ui-org/react-ui 0.52.1 → 0.53.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.
Files changed (260) hide show
  1. package/CODEOWNERS +23 -0
  2. package/README.md +10 -7
  3. package/dist/react-ui.css +5 -3
  4. package/dist/react-ui.js +1 -1
  5. package/package.json +64 -77
  6. package/src/{lib/components → components}/Alert/Alert.jsx +1 -1
  7. package/src/{lib/components/Alert/README.mdx → components/Alert/README.md} +84 -100
  8. package/src/{lib/components → components}/Badge/Badge.jsx +1 -1
  9. package/src/{lib/components → components}/Badge/Badge.scss +1 -1
  10. package/src/components/Badge/README.md +103 -0
  11. package/src/{lib/components → components}/Button/Button.jsx +1 -1
  12. package/src/components/Button/README.md +580 -0
  13. package/src/{lib/components → components}/ButtonGroup/ButtonGroup.jsx +11 -9
  14. package/src/{lib/components/ButtonGroup/README.mdx → components/ButtonGroup/README.md} +128 -134
  15. package/src/{lib/components → components}/Card/Card.jsx +1 -1
  16. package/src/components/Card/README.md +314 -0
  17. package/src/{lib/components/CheckboxField/README.mdx → components/CheckboxField/README.md} +96 -108
  18. package/src/{lib/components/FileInputField/README.mdx → components/FileInputField/README.md} +83 -95
  19. package/src/{lib/components → components}/FormLayout/FormLayout.jsx +4 -4
  20. package/src/components/FormLayout/README.md +462 -0
  21. package/src/{lib/components → components}/Grid/Grid.jsx +2 -2
  22. package/src/components/Grid/README.md +281 -0
  23. package/src/{lib/components → components}/InputGroup/InputGroup.jsx +20 -19
  24. package/src/{lib/components → components}/InputGroup/InputGroup.scss +0 -5
  25. package/src/{lib/components/InputGroup/README.mdx → components/InputGroup/README.md} +145 -163
  26. package/src/{lib/components → components}/Modal/Modal.jsx +6 -6
  27. package/src/components/Modal/README.md +1090 -0
  28. package/src/components/Modal/_hooks/useModalScrollPrevention.js +37 -0
  29. package/src/{lib/components/Paper/README.mdx → components/Paper/README.md} +18 -30
  30. package/src/{lib/components/Popover/README.mdx → components/Popover/README.md} +102 -132
  31. package/src/{lib/components/Radio/README.mdx → components/Radio/README.md} +122 -134
  32. package/src/{lib/components → components}/Radio/Radio.jsx +11 -12
  33. package/src/{lib/components → components}/Radio/Radio.scss +0 -5
  34. package/src/components/ScrollView/README.md +503 -0
  35. package/src/{lib/components → components}/ScrollView/ScrollView.jsx +12 -3
  36. package/src/components/SelectField/README.md +681 -0
  37. package/src/components/Table/README.md +259 -0
  38. package/src/{lib/components → components}/Table/Table.jsx +4 -1
  39. package/src/{lib/components → components}/Table/_components/TableHeaderCell/TableHeaderCell.jsx +1 -1
  40. package/src/{lib/components/Tabs/README.mdx → components/Tabs/README.md} +117 -134
  41. package/src/{lib/components → components}/Tabs/TabsItem.jsx +3 -3
  42. package/src/components/Text/README.md +220 -0
  43. package/src/components/TextArea/README.md +359 -0
  44. package/src/{lib/components/TextField/README.mdx → components/TextField/README.md} +336 -342
  45. package/src/{lib/components/TextLink/README.mdx → components/TextLink/README.md} +19 -31
  46. package/src/{lib/components/Toggle/README.mdx → components/Toggle/README.md} +98 -110
  47. package/src/components/Toolbar/README.md +359 -0
  48. package/src/{lib/components → components}/Toolbar/_helpers/getAlignClassName.js +12 -4
  49. package/src/components/_helpers/getRootPriorityClassName.js +15 -0
  50. package/src/{lib/index.js → index.js} +6 -0
  51. package/src/{lib/provider → provider}/RUIProvider.jsx +17 -11
  52. package/src/{lib/styles → styles}/tools/_caret.scss +1 -1
  53. package/src/{lib/styles → styles}/tools/form-fields/_box-field-elements.scss +1 -1
  54. package/src/{lib/styles → styles}/tools/form-fields/_inline-field-elements.scss +2 -2
  55. package/src/{lib/theme.scss → theme.scss} +4 -3
  56. package/CONTRIBUTING.md +0 -137
  57. package/dist/lib.development.js +0 -3179
  58. package/dist/lib.js +0 -1
  59. package/public/racom.svg +0 -11
  60. package/src/lib/components/Badge/README.mdx +0 -126
  61. package/src/lib/components/Button/README.mdx +0 -581
  62. package/src/lib/components/Card/README.mdx +0 -326
  63. package/src/lib/components/FormLayout/README.mdx +0 -501
  64. package/src/lib/components/Grid/README.mdx +0 -299
  65. package/src/lib/components/Modal/README.mdx +0 -1360
  66. package/src/lib/components/Modal/_hooks/useModalScrollPrevention.js +0 -35
  67. package/src/lib/components/ScrollView/README.mdx +0 -521
  68. package/src/lib/components/SelectField/README.mdx +0 -693
  69. package/src/lib/components/Table/README.mdx +0 -275
  70. package/src/lib/components/Text/README.mdx +0 -241
  71. package/src/lib/components/TextArea/README.mdx +0 -366
  72. package/src/lib/components/Toolbar/README.mdx +0 -386
  73. package/src/{lib/components → components}/Alert/Alert.scss +0 -0
  74. package/src/{lib/components → components}/Alert/_settings.scss +0 -0
  75. package/src/{lib/components → components}/Alert/_theme.scss +0 -0
  76. package/src/{lib/components → components}/Alert/_tools.scss +0 -0
  77. package/src/{lib/components → components}/Alert/index.js +0 -0
  78. package/src/{lib/components → components}/Badge/index.js +0 -0
  79. package/src/{lib/components → components}/Button/Button.scss +0 -0
  80. package/src/{lib/components → components}/Button/_base.scss +0 -0
  81. package/src/{lib/components → components}/Button/_priorities.scss +0 -0
  82. package/src/{lib/components → components}/Button/_settings.scss +0 -0
  83. package/src/{lib/components → components}/Button/_theme.scss +0 -0
  84. package/src/{lib/components → components}/Button/_tools.scss +0 -0
  85. package/src/{lib/components → components}/Button/helpers/getRootLabelVisibilityClassName.js +0 -0
  86. package/src/{lib/components/_helpers → components/Button/helpers}/getRootPriorityClassName.js +0 -0
  87. package/src/{lib/components → components}/Button/index.js +0 -0
  88. package/src/{lib/components → components}/ButtonGroup/ButtonGroup.scss +0 -0
  89. package/src/{lib/components → components}/ButtonGroup/ButtonGroupContext.js +0 -0
  90. package/src/{lib/components → components}/ButtonGroup/_theme.scss +0 -0
  91. package/src/{lib/components → components}/ButtonGroup/index.js +0 -0
  92. package/src/{lib/components → components}/Card/Card.scss +0 -0
  93. package/src/{lib/components → components}/Card/CardBody.jsx +0 -0
  94. package/src/{lib/components → components}/Card/CardFooter.jsx +0 -0
  95. package/src/{lib/components → components}/Card/_theme.scss +0 -0
  96. package/src/{lib/components → components}/Card/_tools.scss +0 -0
  97. package/src/{lib/components → components}/Card/index.js +0 -0
  98. package/src/{lib/components → components}/CheckboxField/CheckboxField.jsx +0 -0
  99. package/src/{lib/components → components}/CheckboxField/CheckboxField.scss +0 -0
  100. package/src/{lib/components → components}/CheckboxField/index.js +0 -0
  101. package/src/{lib/components → components}/FileInputField/FileInputField.jsx +0 -0
  102. package/src/{lib/components → components}/FileInputField/FileInputField.scss +0 -0
  103. package/src/{lib/components → components}/FileInputField/index.js +0 -0
  104. package/src/{lib/components → components}/FormLayout/FormLayout.scss +0 -0
  105. package/src/{lib/components → components}/FormLayout/FormLayoutContext.js +0 -0
  106. package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.jsx +4 -4
  107. package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.scss +0 -0
  108. package/src/{lib/components → components}/FormLayout/_theme.scss +0 -0
  109. package/src/{lib/components → components}/FormLayout/index.js +0 -0
  110. package/src/{lib/components → components}/Grid/Grid.scss +0 -0
  111. package/src/{lib/components → components}/Grid/GridSpan.jsx +0 -0
  112. package/src/{lib/components → components}/Grid/_helpers/generateResponsiveCustomProperties.js +0 -0
  113. package/src/{lib/components → components}/Grid/_settings.scss +0 -0
  114. package/src/{lib/components → components}/Grid/_tools.scss +0 -0
  115. package/src/{lib/components → components}/Grid/index.js +0 -0
  116. package/src/{lib/components → components}/InputGroup/InputGroupContext.js +0 -0
  117. package/src/{lib/components → components}/InputGroup/_theme.scss +0 -0
  118. package/src/{lib/components → components}/InputGroup/index.js +0 -0
  119. package/src/{lib/components → components}/Modal/Modal.scss +0 -0
  120. package/src/{lib/components → components}/Modal/ModalBody.jsx +0 -0
  121. package/src/{lib/components → components}/Modal/ModalBody.scss +0 -0
  122. package/src/{lib/components → components}/Modal/ModalCloseButton.jsx +1 -1
  123. package/src/{lib/components → components}/Modal/ModalCloseButton.scss +0 -0
  124. package/src/{lib/components → components}/Modal/ModalContent.jsx +0 -0
  125. package/src/{lib/components → components}/Modal/ModalContent.scss +0 -0
  126. package/src/{lib/components → components}/Modal/ModalFooter.jsx +0 -0
  127. package/src/{lib/components → components}/Modal/ModalFooter.scss +0 -0
  128. package/src/{lib/components → components}/Modal/ModalHeader.jsx +0 -0
  129. package/src/{lib/components → components}/Modal/ModalHeader.scss +0 -0
  130. package/src/{lib/components → components}/Modal/ModalTitle.jsx +0 -0
  131. package/src/{lib/components → components}/Modal/ModalTitle.scss +0 -0
  132. package/src/{lib/components → components}/Modal/_helpers/getJustifyClassName.js +0 -0
  133. package/src/{lib/components → components}/Modal/_helpers/getPositionClassName.js +0 -0
  134. package/src/{lib/components → components}/Modal/_helpers/getScrollingClassName.js +0 -0
  135. package/src/{lib/components → components}/Modal/_helpers/getSizeClassName.js +0 -0
  136. package/src/{lib/components → components}/Modal/_hooks/useModalFocus.js +0 -0
  137. package/src/{lib/components → components}/Modal/_settings.scss +0 -0
  138. package/src/{lib/components → components}/Modal/_theme.scss +0 -0
  139. package/src/{lib/components → components}/Modal/index.js +0 -0
  140. package/src/{lib/components → components}/Paper/Paper.jsx +0 -0
  141. package/src/{lib/components → components}/Paper/Paper.scss +0 -0
  142. package/src/{lib/components → components}/Paper/_theme.scss +0 -0
  143. package/src/{lib/components → components}/Paper/index.js +0 -0
  144. package/src/{lib/components → components}/Popover/Popover.jsx +0 -0
  145. package/src/{lib/components → components}/Popover/Popover.scss +0 -0
  146. package/src/{lib/components → components}/Popover/PopoverWrapper.jsx +0 -0
  147. package/src/{lib/components → components}/Popover/PopoverWrapper.scss +0 -0
  148. package/src/{lib/components → components}/Popover/_helpers/getRootAlignmentClassName.js +0 -0
  149. package/src/{lib/components → components}/Popover/_helpers/getRootSideClassName.js +0 -0
  150. package/src/{lib/components → components}/Popover/_theme.scss +0 -0
  151. package/src/{lib/components → components}/Popover/index.js +0 -0
  152. package/src/{lib/components → components}/Radio/index.js +0 -0
  153. package/src/{lib/components → components}/ScrollView/ScrollView.scss +0 -0
  154. package/src/{lib/components → components}/ScrollView/_helpers/getElementsPositionDifference.js +0 -0
  155. package/src/{lib/components → components}/ScrollView/_hooks/useLoadResizeHook.js +0 -0
  156. package/src/{lib/components → components}/ScrollView/_hooks/useScrollPositionHook.js +0 -0
  157. package/src/{lib/components → components}/ScrollView/index.js +0 -0
  158. package/src/{lib/components → components}/SelectField/SelectField.jsx +0 -0
  159. package/src/{lib/components → components}/SelectField/SelectField.scss +0 -0
  160. package/src/{lib/components → components}/SelectField/_components/Option/Option.jsx +0 -0
  161. package/src/{lib/components → components}/SelectField/_components/Option/index.js +0 -0
  162. package/src/{lib/components → components}/SelectField/index.js +0 -0
  163. package/src/{lib/components → components}/Table/Table.scss +0 -0
  164. package/src/{lib/components → components}/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -0
  165. package/src/{lib/components → components}/Table/_components/TableBodyCell/index.js +0 -0
  166. package/src/{lib/components → components}/Table/_components/TableCell.scss +0 -0
  167. package/src/{lib/components → components}/Table/_components/TableHeaderCell/index.js +0 -0
  168. package/src/{lib/components → components}/Table/_settings.scss +0 -0
  169. package/src/{lib/components → components}/Table/index.js +0 -0
  170. package/src/{lib/components → components}/Tabs/Tabs.jsx +0 -0
  171. package/src/{lib/components → components}/Tabs/Tabs.scss +0 -0
  172. package/src/{lib/components → components}/Tabs/TabsItem.scss +0 -0
  173. package/src/{lib/components → components}/Tabs/_theme.scss +0 -0
  174. package/src/{lib/components → components}/Tabs/index.js +0 -0
  175. package/src/{lib/components → components}/Text/Text.jsx +0 -0
  176. package/src/{lib/components → components}/Text/Text.scss +0 -0
  177. package/src/{lib/components → components}/Text/_helpers/getRootClampClassName.js +0 -0
  178. package/src/{lib/components → components}/Text/_helpers/getRootHyphensClassName.js +0 -0
  179. package/src/{lib/components → components}/Text/_helpers/getRootWordWrappingClassName.js +0 -0
  180. package/src/{lib/components → components}/Text/index.js +0 -0
  181. package/src/{lib/components → components}/TextArea/TextArea.jsx +0 -0
  182. package/src/{lib/components → components}/TextArea/TextArea.scss +0 -0
  183. package/src/{lib/components → components}/TextArea/index.js +0 -0
  184. package/src/{lib/components → components}/TextField/TextField.jsx +0 -0
  185. package/src/{lib/components → components}/TextField/TextField.scss +0 -0
  186. package/src/{lib/components → components}/TextField/index.js +0 -0
  187. package/src/{lib/components → components}/TextLink/TextLink.jsx +1 -1
  188. /package/src/{lib/components → components}/TextLink/TextLink.scss +0 -0
  189. /package/src/{lib/components → components}/TextLink/_theme.scss +0 -0
  190. /package/src/{lib/components → components}/TextLink/index.js +0 -0
  191. /package/src/{lib/components → components}/Toggle/Toggle.jsx +0 -0
  192. /package/src/{lib/components → components}/Toggle/Toggle.scss +0 -0
  193. /package/src/{lib/components → components}/Toggle/index.js +0 -0
  194. /package/src/{lib/components → components}/Toolbar/Toolbar.jsx +0 -0
  195. /package/src/{lib/components → components}/Toolbar/Toolbar.scss +0 -0
  196. /package/src/{lib/components → components}/Toolbar/ToolbarGroup.jsx +0 -0
  197. /package/src/{lib/components → components}/Toolbar/ToolbarItem.jsx +0 -0
  198. /package/src/{lib/components → components}/Toolbar/_helpers/getJustifyClassName.js +0 -0
  199. /package/src/{lib/components → components}/Toolbar/_theme.scss +0 -0
  200. /package/src/{lib/components → components}/Toolbar/index.js +0 -0
  201. /package/src/{lib/components → components}/_helpers/getRootColorClassName.js +0 -0
  202. /package/src/{lib/components → components}/_helpers/getRootSizeClassName.js +0 -0
  203. /package/src/{lib/components → components}/_helpers/getRootValidationStateClassName.js +0 -0
  204. /package/src/{lib/components → components}/_helpers/isChildrenEmpty.js +0 -0
  205. /package/src/{lib/components → components}/_helpers/resolveContextOrProp.js +0 -0
  206. /package/src/{lib/components → components}/_helpers/transferProps.js +0 -0
  207. /package/src/{lib/foundation.scss → foundation.scss} +0 -0
  208. /package/src/{lib/helpers.scss → helpers.scss} +0 -0
  209. /package/src/{lib/provider → provider}/RUIContext.jsx +0 -0
  210. /package/src/{lib/provider → provider}/index.js +0 -0
  211. /package/src/{lib/provider → provider}/withGlobalProps.jsx +0 -0
  212. /package/src/{lib/styles → styles}/_utilities.scss +0 -0
  213. /package/src/{lib/styles → styles}/elements/_code.scss +0 -0
  214. /package/src/{lib/styles → styles}/elements/_links.scss +0 -0
  215. /package/src/{lib/styles → styles}/elements/_lists.scss +0 -0
  216. /package/src/{lib/styles → styles}/elements/_page.scss +0 -0
  217. /package/src/{lib/styles → styles}/elements/_rulers.scss +0 -0
  218. /package/src/{lib/styles → styles}/elements/_small.scss +0 -0
  219. /package/src/{lib/styles → styles}/generic/_box-sizing.scss +0 -0
  220. /package/src/{lib/styles → styles}/generic/_focus.scss +0 -0
  221. /package/src/{lib/styles → styles}/generic/_forms.scss +0 -0
  222. /package/src/{lib/styles → styles}/generic/_reset.scss +0 -0
  223. /package/src/{lib/styles → styles}/generic/_shared.scss +0 -0
  224. /package/src/{lib/styles → styles}/helpers/_animation.scss +0 -0
  225. /package/src/{lib/styles → styles}/settings/_animations.scss +0 -0
  226. /package/src/{lib/styles → styles}/settings/_breakpoints.scss +0 -0
  227. /package/src/{lib/styles → styles}/settings/_escaped-characters.scss +0 -0
  228. /package/src/{lib/styles → styles}/settings/_form-fields.scss +0 -0
  229. /package/src/{lib/styles → styles}/settings/_forms.scss +0 -0
  230. /package/src/{lib/styles → styles}/settings/_utilities.scss +0 -0
  231. /package/src/{lib/styles → styles}/settings/_z-indexes.scss +0 -0
  232. /package/src/{lib/styles → styles}/theme/_accessibility.scss +0 -0
  233. /package/src/{lib/styles → styles}/theme/_borders.scss +0 -0
  234. /package/src/{lib/styles → styles}/theme/_code.scss +0 -0
  235. /package/src/{lib/styles → styles}/theme/_form-fields.scss +0 -0
  236. /package/src/{lib/styles → styles}/theme/_links.scss +0 -0
  237. /package/src/{lib/styles → styles}/theme/_lists.scss +0 -0
  238. /package/src/{lib/styles → styles}/theme/_page.scss +0 -0
  239. /package/src/{lib/styles → styles}/theme/_spacing.scss +0 -0
  240. /package/src/{lib/styles → styles}/theme/_typography.scss +0 -0
  241. /package/src/{lib/styles → styles}/theme-constants/_breakpoints.scss +0 -0
  242. /package/src/{lib/styles → styles}/theme-constants/_colors.scss +0 -0
  243. /package/src/{lib/styles → styles}/theme-constants/_svg.scss +0 -0
  244. /package/src/{lib/styles → styles}/tools/_accessibility.scss +0 -0
  245. /package/src/{lib/styles → styles}/tools/_breakpoint.scss +0 -0
  246. /package/src/{lib/styles → styles}/tools/_colors.scss +0 -0
  247. /package/src/{lib/styles → styles}/tools/_reset.scss +0 -0
  248. /package/src/{lib/styles → styles}/tools/_scrollbar.scss +0 -0
  249. /package/src/{lib/styles → styles}/tools/_spacing.scss +0 -0
  250. /package/src/{lib/styles → styles}/tools/_string.scss +0 -0
  251. /package/src/{lib/styles → styles}/tools/_svg.scss +0 -0
  252. /package/src/{lib/styles → styles}/tools/_transition.scss +0 -0
  253. /package/src/{lib/styles → styles}/tools/_utilities.scss +0 -0
  254. /package/src/{lib/styles → styles}/tools/form-fields/_box-field-layout.scss +0 -0
  255. /package/src/{lib/styles → styles}/tools/form-fields/_box-field-sizes.scss +0 -0
  256. /package/src/{lib/styles → styles}/tools/form-fields/_foundation.scss +0 -0
  257. /package/src/{lib/styles → styles}/tools/form-fields/_inline-field-layout.scss +0 -0
  258. /package/src/{lib/styles → styles}/tools/form-fields/_variants.scss +0 -0
  259. /package/src/{lib/translations → translations}/en.js +0 -0
  260. /package/src/{lib/utils → utils}/classNames.js +0 -0
@@ -0,0 +1,580 @@
1
+ # Button
2
+
3
+ Buttons allow users to take actions.
4
+
5
+ ## Basic Usage
6
+
7
+ To implement the Button component, you need to import it first:
8
+
9
+ ```js
10
+ import { Button } from '@react-ui-org/react-ui';
11
+ ```
12
+
13
+ And use it:
14
+
15
+ ```docoff-react-preview
16
+ <Button label="My button" />
17
+ ```
18
+
19
+ See [API](#api) for all available options.
20
+
21
+ ## General Guidelines
22
+
23
+ - Use **short yet comprehensible labels** to make buttons fit small screens.
24
+
25
+ - Since buttons are there to take actions, **use a verb** to make it obvious
26
+ what your buttons do.
27
+
28
+ - **Don't overwhelm your UI** with too many high-emphasis actions. There should
29
+ always be one but chances are that having more of them is not necessary.
30
+
31
+ ## Priorities
32
+
33
+ There are three **visual priorities** of buttons to choose from, from highest to
34
+ lowest:
35
+
36
+ 1. filled
37
+ 2. outline
38
+ 3. flat
39
+
40
+ All priorities come in supported
41
+ [component colors](/docs/foundation/colors#component-colors).
42
+
43
+ ### Filled
44
+
45
+ The default, high-emphasis priority should be used for primary actions of your
46
+ app. Use it sparingly but remember there should always be one on a screen.
47
+
48
+ ```docoff-react-preview
49
+ <Button label="Primary" />
50
+ <Button label="Secondary" color="secondary" />
51
+ <Button label="Selected" color="selected" />
52
+ <Button label="Success" color="success" />
53
+ <Button label="Warning" color="warning" />
54
+ <Button label="Danger" color="danger" />
55
+ <Button label="Help" color="help" />
56
+ <Button label="Info" color="info" />
57
+ <Button label="Note" color="note" />
58
+ <docoff-placeholder dark inline>
59
+ <Button label="Light" color="light" />
60
+ </docoff-placeholder>
61
+ <Button label="Dark" color="dark" />
62
+ ```
63
+
64
+ Default, unconfigured button comes in **medium** size, **filled** visual
65
+ priority, and **primary** color variant.
66
+
67
+ ### Outline
68
+
69
+ Medium-emphasis buttons. They are designed to contain actions that are
70
+ important but not primary in your app.
71
+
72
+ ```docoff-react-preview
73
+ <Button priority="outline" label="Primary" />
74
+ <Button priority="outline" label="Secondary" color="secondary" />
75
+ <Button priority="outline" label="Selected" color="selected" />
76
+ <Button priority="outline" label="Success" color="success" />
77
+ <Button priority="outline" label="Warning" color="warning" />
78
+ <Button priority="outline" label="Danger" color="danger" />
79
+ <Button priority="outline" label="Help" color="help" />
80
+ <Button priority="outline" label="Info" color="info" />
81
+ <Button priority="outline" label="Note" color="note" />
82
+ <docoff-placeholder dark inline>
83
+ <Button priority="outline" label="Light" color="light" />
84
+ </docoff-placeholder>
85
+ <Button priority="outline" label="Dark" color="dark" />
86
+ ```
87
+
88
+ ### Flat
89
+
90
+ Flat buttons are designed for less pronounced actions to help maintain focus on
91
+ the content.
92
+
93
+ ```docoff-react-preview
94
+ <Button priority="flat" label="Primary" />
95
+ <Button priority="flat" label="Secondary" color="secondary" />
96
+ <Button priority="flat" label="Selected" color="selected" />
97
+ <Button priority="flat" label="Success" color="success" />
98
+ <Button priority="flat" label="Warning" color="warning" />
99
+ <Button priority="flat" label="Danger" color="danger" />
100
+ <Button priority="flat" label="Help" color="help" />
101
+ <Button priority="flat" label="Info" color="info" />
102
+ <Button priority="flat" label="Note" color="note" />
103
+ <docoff-placeholder dark inline>
104
+ <Button priority="flat" label="Light" color="light" />
105
+ </docoff-placeholder>
106
+ <Button priority="flat" label="Dark" color="dark" />
107
+ ```
108
+
109
+ ## Sizes
110
+
111
+ Aside from the default (medium) size, two additional sizes are available: small
112
+ and large.
113
+
114
+ ```docoff-react-preview
115
+ <Button label="Small" size="small" />
116
+ <Button label="Medium" />
117
+ <Button label="Large" size="large" />
118
+ ```
119
+
120
+ Block buttons span the full width of a parent:
121
+
122
+ ```docoff-react-preview
123
+ <Button label="Block button" block />
124
+ ```
125
+
126
+ ## Buttons with Icons
127
+
128
+ To improve clarity or to draw attention to the action, icons can be added
129
+ before or after the button's label.
130
+
131
+ 👉 Please note there are no icons pre-packed in React UI. Visit
132
+ [Icons](/docs/foundation/icons) to see how to include them.
133
+
134
+ ```docoff-react-preview
135
+ <Button
136
+ label="Icon before label"
137
+ beforeLabel={<rui-icon icon="star" />}
138
+ />
139
+ <Button
140
+ label="Icon after label"
141
+ afterLabel={<rui-icon icon="star" />}
142
+ />
143
+ ```
144
+
145
+ ### Icon Buttons
146
+
147
+ For clear and simple actions, buttons can visually consist just of an icon.
148
+ Label remains mandatory to keep the button accessible.
149
+
150
+ ```docoff-react-preview
151
+ <Button
152
+ label="Icon button"
153
+ labelVisibility="none"
154
+ beforeLabel={<rui-icon icon="pencil" />}
155
+ />
156
+ ```
157
+
158
+ Icon buttons can optionally enhance on a [breakpoint](/docs/foundation/breakpoints)
159
+ of your choice and display label once you know there is enough room for it.
160
+
161
+ 📐 Try resizing your browser to see how label visibility changes.
162
+
163
+ ```docoff-react-preview
164
+ <Button
165
+ label="Label visible from sm up"
166
+ labelVisibility="sm"
167
+ beforeLabel={<rui-icon icon="pencil" />}
168
+ />
169
+ <Button
170
+ label="Label visible from md up"
171
+ labelVisibility="md"
172
+ beforeLabel={<rui-icon icon="pencil" />}
173
+ />
174
+ <Button
175
+ label="Label visible from lg up"
176
+ labelVisibility="lg"
177
+ beforeLabel={<rui-icon icon="pencil" />}
178
+ />
179
+ <Button
180
+ label="Label visible from xl up"
181
+ labelVisibility="xl"
182
+ beforeLabel={<rui-icon icon="pencil" />}
183
+ />
184
+ <Button
185
+ label="Label visible from x2l up"
186
+ labelVisibility="x2l"
187
+ beforeLabel={<rui-icon icon="pencil" />}
188
+ />
189
+ <Button
190
+ label="Label visible from x3l up"
191
+ labelVisibility="x3l"
192
+ beforeLabel={<rui-icon icon="pencil" />}
193
+ />
194
+ ```
195
+
196
+ ## Buttons with Badges
197
+
198
+ A [Badge](/components/Badge) can be added to buttons to provide additional
199
+ information or to draw user's attention.
200
+
201
+ ```docoff-react-preview
202
+ <Button
203
+ label="Badge before"
204
+ beforeLabel={<Badge label={'3'} priority="outline" color="light" />}
205
+ />
206
+ <Button
207
+ label="Badge before, on top"
208
+ startCorner={<Badge label={'3'} />}
209
+ />
210
+ <Button
211
+ label="Badge after, on top"
212
+ endCorner={<Badge label={'3'} />}
213
+ priority="outline"
214
+ />
215
+ <Button
216
+ label="Badge after"
217
+ afterLabel={<Badge label="new" color="warning" />}
218
+ priority="outline"
219
+ />
220
+ ```
221
+
222
+ ### Icon Buttons with a Badge
223
+
224
+ Badges play nicely with icon buttons, too:
225
+
226
+ ```docoff-react-preview
227
+ <Button
228
+ label="Icon button with badge"
229
+ labelVisibility="none"
230
+ priority="outline"
231
+ beforeLabel={<rui-icon icon="warning-sign" />}
232
+ startCorner={<Badge label={'3'} color="warning" />}
233
+ />
234
+ <Button
235
+ label="Icon button with badge"
236
+ labelVisibility="md"
237
+ priority="outline"
238
+ beforeLabel={<rui-icon icon="warning-sign" />}
239
+ startCorner={<Badge label={'3'} color="danger" />}
240
+ />
241
+ ```
242
+
243
+ ## States
244
+
245
+ ### Disabled State
246
+
247
+ Disabled state makes the action unavailable.
248
+
249
+ ```docoff-react-preview
250
+ <Button label="Disabled filled button" disabled />
251
+ <Button label="Disabled outline button" priority="outline" disabled />
252
+ <Button label="Disabled flat button" priority="flat" disabled />
253
+ ```
254
+
255
+ ### Feedback State
256
+
257
+ When user's action triggers an asynchronous process on background, the button's
258
+ feedback state (not to be mistaken with
259
+ [feedback colors](/docs/foundation/colors#component-colors)) can be indicated by
260
+ showing an icon. The icon replaces button's label while retaining original
261
+ dimensions of the button. Buttons in feedback state are automatically disabled
262
+ to prevent unwanted interaction.
263
+
264
+ Filled buttons in feedback state:
265
+
266
+ ```docoff-react-preview
267
+ <Button
268
+ label="Success"
269
+ color="success"
270
+ feedbackIcon={<rui-icon icon="success" />}
271
+ />
272
+ <Button
273
+ label="Success"
274
+ labelVisibility="none"
275
+ color="success"
276
+ feedbackIcon={<rui-icon icon="success" />}
277
+ endCorner={<Badge color="danger" label={'3'} />}
278
+ />
279
+ <docoff-placeholder dark inline>
280
+ <Button
281
+ label="Light"
282
+ color="light"
283
+ feedbackIcon={<rui-icon icon="success" />}
284
+ />
285
+ </docoff-placeholder>
286
+ <Button
287
+ label="Dark"
288
+ color="dark"
289
+ feedbackIcon={<rui-icon icon="success" />}
290
+ />
291
+ <Button
292
+ label="Primary"
293
+ feedbackIcon={(
294
+ <span className="d-inline-flex animation-spin-counterclockwise">
295
+ <rui-icon icon="loading" />
296
+ </span>
297
+ )}
298
+ />
299
+ ```
300
+
301
+ Outline buttons in feedback state:
302
+
303
+ ```docoff-react-preview
304
+ <Button
305
+ label="Success"
306
+ priority="outline"
307
+ color="success"
308
+ feedbackIcon={<rui-icon icon="success" />}
309
+ />
310
+ <Button
311
+ label="Success"
312
+ labelVisibility="none"
313
+ priority="outline"
314
+ color="success"
315
+ feedbackIcon={<rui-icon icon="success" />}
316
+ endCorner={<Badge color="danger" label={'3'} />}
317
+ />
318
+ <docoff-placeholder dark inline>
319
+ <Button
320
+ label="Light"
321
+ priority="outline"
322
+ color="light"
323
+ feedbackIcon={<rui-icon icon="success" />}
324
+ />
325
+ </docoff-placeholder>
326
+ <Button
327
+ label="Dark"
328
+ priority="outline"
329
+ color="dark"
330
+ feedbackIcon={<rui-icon icon="success" />}
331
+ />
332
+ <Button
333
+ label="Primary"
334
+ priority="outline"
335
+ feedbackIcon={(
336
+ <span className="d-inline-flex animation-spin-counterclockwise">
337
+ <rui-icon icon="loading" />
338
+ </span>
339
+ )}
340
+ />
341
+ ```
342
+
343
+ Flat buttons in feedback state:
344
+
345
+ ```docoff-react-preview
346
+ <Button
347
+ label="Success"
348
+ priority="flat"
349
+ color="success"
350
+ feedbackIcon={<rui-icon icon="success" />}
351
+ />
352
+ <Button
353
+ label="Success"
354
+ labelVisibility="none"
355
+ priority="flat"
356
+ color="success"
357
+ feedbackIcon={<rui-icon icon="success" />}
358
+ endCorner={<Badge color="danger" label={'3'} />}
359
+ />
360
+ <docoff-placeholder dark inline>
361
+ <Button
362
+ label="Light"
363
+ priority="flat"
364
+ color="light"
365
+ feedbackIcon={<rui-icon icon="success" />}
366
+ />
367
+ </docoff-placeholder>
368
+ <Button
369
+ label="Dark"
370
+ priority="flat"
371
+ color="dark"
372
+ feedbackIcon={<rui-icon icon="success" />}
373
+ />
374
+ <Button
375
+ label="Primary"
376
+ priority="flat"
377
+ feedbackIcon={(
378
+ <span className="d-inline-flex animation-spin-counterclockwise">
379
+ <rui-icon icon="loading" />
380
+ </span>
381
+ )}
382
+ />
383
+ ```
384
+
385
+ 👉 Visit the [CSS Helpers](/docs/css-helpers/animation) section to see how the icon
386
+ animation is made.
387
+
388
+ ## Forwarding HTML Attributes
389
+
390
+ In addition to the options below in the [component's API](#api) section, you
391
+ can specify [React synthetic events] or **any HTML attribute you like.** All
392
+ attributes that don't interfere with the API are forwarded to the native HTML
393
+ `<button>`. This enables making the component interactive and helps to improve
394
+ its accessibility.
395
+
396
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
397
+ [button] element.
398
+
399
+ ## Forwarding ref
400
+
401
+ If you provide [ref], it is forwarded to the native HTML `<button>` element.
402
+
403
+ ## API
404
+
405
+ <docoff-react-props src="/components/Button/Button.jsx"></docoff-react-props>
406
+
407
+ ## Theming
408
+
409
+ ### Common Theming Options
410
+
411
+ | Custom Property | Description |
412
+ |--------------------------------|----------------------------------------------|
413
+ | `--rui-Button__font-weight` | Font weight |
414
+ | `--rui-Button__text-transform` | Text transform, e.g. uppercase or small-caps |
415
+ | `--rui-Button__letter-spacing` | Spacing between letters |
416
+ | `--rui-Button__border-width` | Border width |
417
+ | `--rui-Button__border-radius` | Corner radius |
418
+
419
+ ### Theming Priorities and Color Variants
420
+
421
+ It's possible to adjust the theme for specific priority, color variant, and
422
+ state. Naming convention looks as follows:
423
+
424
+ `--rui-Button--<PRIORITY>--<COLOR>--<INTERACTION STATE>__<PROPERTY>`
425
+
426
+ Where:
427
+
428
+ - `<PRIORITY>` is one of `filled`, `outline`, or `flat` (see
429
+ [Priorities](#priorities) and [API](#api)),
430
+ - `<COLOR>` is one of supported
431
+ [component colors](/docs/foundation/colors#component-colors)
432
+ (see color variants of [each priority](#priorities) and [API](#api)),
433
+ - `<INTERACTION STATE>` is one of `default`, `hover`, `active`, or `disabled`
434
+ (the last one being optional),
435
+ - `<PROPERTY>` is one of:
436
+ - `color`, `border-color`, `background`, or `box-shadow` for the `filled`
437
+ priority,
438
+ - `color`, `border-color`, or `background` for the `outline` priority,
439
+ - `color` or `background` for the `flat` priority.
440
+
441
+ ### Theming Sizes
442
+
443
+ Available sizes can be adjusted as follows:
444
+
445
+ `--rui-Button--<SIZE>__<PROPERTY>`
446
+
447
+ Where:
448
+
449
+ - `<SIZE>` is one of `small`, `medium`, or `large` (see [Sizes](#sizes) and
450
+ [API](#api))
451
+ - `<PROPERTY>` is one of `height`, `padding-x`, `padding-y`, or `font-size`
452
+
453
+ 👉 Button sizes are linked to
454
+ [box field sizes](/docs/customize/theming/forms#box-field-sizes) sizes so they align
455
+ nicely when placed in row.
456
+
457
+ ### Example Theme
458
+
459
+ ```docoff-react-preview
460
+ <style type="text/css">
461
+ {`
462
+ .example {
463
+ margin: 0;
464
+ }
465
+
466
+ .example > * {
467
+ margin: 4px;
468
+ }
469
+
470
+ .example--themed-buttons {
471
+ --rui-Button__font-weight: bold;
472
+ --rui-Button__letter-spacing: 0.05em;
473
+ --rui-Button__text-transform: uppercase;
474
+ --rui-Button__border-radius: 0;
475
+ --rui-Button--filled--primary--default__box-shadow:
476
+ 0.1em 0.1em 0.5em rgba(0, 0, 0, 0.3);
477
+ --rui-Button--medium__height: 3rem;
478
+ --rui-Button--medium__padding-x: 1.25rem;
479
+ --rui-Button--medium__padding-y: 0.25rem;
480
+ }
481
+ `}
482
+ </style>
483
+ <Button label="Default filled button" />
484
+ <Button label="Default outline button" priority="outline" />
485
+ <div className="example example--themed-buttons">
486
+ <Button label="Themed filled button" />
487
+ <Button label="Themed outline button" priority="outline" />
488
+ </div>
489
+ ```
490
+
491
+ ### Theming Disabled State
492
+
493
+ The `disabled` state offers a bit more of design flexibility compared to other
494
+ interaction states. Firstly, there are a few common options for this state:
495
+
496
+ | Custom Property | Description |
497
+ |-----------------------------------|---------------------------------------------|
498
+ | `--rui-Button--disabled__opacity` | Opacity of disabled buttons |
499
+ | `--rui-Button--disabled__cursor` | Cursor to show on hovering disabled buttons |
500
+
501
+ Secondly, it can be further adjusted using priority and color variant specific
502
+ options for the disabled state:
503
+
504
+ `--rui-Button--<PRIORITY>--<COLOR>--disabled__<PROPERTY>`
505
+
506
+ Undefined theming options are inherited from the `default` interaction state.
507
+
508
+ Example:
509
+
510
+ ```docoff-react-preview
511
+ <style type="text/css">
512
+ {`
513
+ .example {
514
+ margin: 0;
515
+ }
516
+
517
+ .example > * {
518
+ margin: 4px;
519
+ }
520
+
521
+ .example--themed-disabled-buttons {
522
+ --rui-Button__border-radius: 0;
523
+ --rui-Button--disabled__opacity: 0.4;
524
+ --rui-Button--disabled__cursor: default;
525
+ --rui-Button--filled--primary--disabled__color: slate;
526
+ --rui-Button--filled--primary--disabled__border-color: silver;
527
+ --rui-Button--filled--primary--disabled__background: silver;
528
+ --rui-Button--filled--success--disabled__color: slate;
529
+ --rui-Button--filled--success--disabled__border-color: silver;
530
+ --rui-Button--filled--success--disabled__background: silver;
531
+ --rui-Button--outline--primary--disabled__color: slate;
532
+ --rui-Button--outline--primary--disabled__border-color: silver;
533
+ }
534
+ `}
535
+ </style>
536
+ <Button
537
+ label="Default filled primary button, disabled"
538
+ disabled
539
+ />
540
+ <Button
541
+ label="Default filled success button, disabled"
542
+ color="success"
543
+ disabled
544
+ />
545
+ <Button
546
+ label="Default outline primary button, disabled"
547
+ priority="outline"
548
+ disabled
549
+ />
550
+ <div className="example example--themed-disabled-buttons">
551
+ <Button
552
+ label="Themed filled primary button, disabled"
553
+ disabled
554
+ />
555
+ <Button
556
+ label="Themed filled success button, disabled"
557
+ color="success"
558
+ disabled
559
+ />
560
+ <Button
561
+ label="Themed outline primary button, disabled"
562
+ priority="outline"
563
+ disabled
564
+ />
565
+ </div>
566
+ ```
567
+
568
+ ### Theming Feedback State
569
+
570
+ Similarly to disabled state, opacity and cursor can be set for buttons in
571
+ feedback state.
572
+
573
+ | Custom Property | Description |
574
+ |-----------------------------------|------------------------------------------------------|
575
+ | `--rui-Button--feedback__opacity` | Opacity of buttons in feedback state |
576
+ | `--rui-Button--feedback__cursor` | Cursor to show on hovering buttons in feedback state |
577
+
578
+ [React synthetic events]: https://reactjs.org/docs/events.html
579
+ [button]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes
580
+ [ref]: https://reactjs.org/docs/refs-and-the-dom.html
@@ -1,5 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
- import React from 'react';
2
+ import React, {
3
+ useMemo,
4
+ } from 'react';
3
5
  import { withGlobalProps } from '../../provider';
4
6
  import { classNames } from '../../utils/classNames';
5
7
  import getRootPriorityClassName from '../_helpers/getRootPriorityClassName';
@@ -16,6 +18,13 @@ export const ButtonGroup = ({
16
18
  size,
17
19
  ...restProps
18
20
  }) => {
21
+ const childProps = useMemo(() => ({
22
+ block,
23
+ disabled,
24
+ priority,
25
+ size,
26
+ }), [block, disabled, priority, size]);
27
+
19
28
  if (isChildrenEmpty(children)) {
20
29
  return null;
21
30
  }
@@ -30,14 +39,7 @@ export const ButtonGroup = ({
30
39
  )}
31
40
  disabled={disabled}
32
41
  >
33
- <ButtonGroupContext.Provider
34
- value={{
35
- block,
36
- disabled,
37
- priority,
38
- size,
39
- }}
40
- >
42
+ <ButtonGroupContext.Provider value={childProps}>
41
43
  {children}
42
44
  </ButtonGroupContext.Provider>
43
45
  </fieldset>