@madie/madie-design-system 1.0.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 (316) hide show
  1. package/.babelrc +10 -0
  2. package/.editorconfig +22 -0
  3. package/.eslintignore +5 -0
  4. package/.eslintrc.js +31 -0
  5. package/.storybook/.babelrc +4 -0
  6. package/.storybook/main.js +89 -0
  7. package/.storybook/preview-head.html +9 -0
  8. package/.storybook/preview.js +5 -0
  9. package/README.md +5 -0
  10. package/components/Accordion/Accordion.stories.js +20 -0
  11. package/components/Accordion/index.jsx +93 -0
  12. package/components/Alert/Alert.stories.js +61 -0
  13. package/components/Alert/index.js +46 -0
  14. package/components/Breadcrumb/Breadcrumb.md +28 -0
  15. package/components/Breadcrumb/Breadcrumb.stories.js +76 -0
  16. package/components/Breadcrumb/index.js +83 -0
  17. package/components/Button/Button.stories.js +121 -0
  18. package/components/Button/index.js +90 -0
  19. package/components/CalloutBox/CalloutBox.stories.js +94 -0
  20. package/components/CalloutBox/index.js +109 -0
  21. package/components/Card/Card.stories.js +163 -0
  22. package/components/Card/index.js +137 -0
  23. package/components/Dropdown/Dropdown.stories.js +94 -0
  24. package/components/Dropdown/index.js +85 -0
  25. package/components/Error/Collapsible.jsx +88 -0
  26. package/components/Error/ErrorUI.jsx +31 -0
  27. package/components/Error/error.js +26 -0
  28. package/components/FlashNotification/FlashNotificationUI.jsx +91 -0
  29. package/components/FlashNotification/index.js +30 -0
  30. package/components/Footer/Footer.stories.js +20 -0
  31. package/components/Footer/FooterUI.jsx +269 -0
  32. package/components/Footer/LegacyFooterUI.jsx +194 -0
  33. package/components/Footer/SocialLinks.jsx +60 -0
  34. package/components/Footer/Subscribe.jsx +34 -0
  35. package/components/Footer/footer.js +30 -0
  36. package/components/Header/Header.md +111 -0
  37. package/components/Header/Header.stories.js +32 -0
  38. package/components/Header/HeaderAccountMenu.jsx +169 -0
  39. package/components/Header/HeaderCancel.jsx +16 -0
  40. package/components/Header/HeaderContainer.jsx +63 -0
  41. package/components/Header/HeaderLogo.jsx +42 -0
  42. package/components/Header/HeaderMenuButton.js +50 -0
  43. package/components/Header/HeaderMenuItem.jsx +232 -0
  44. package/components/Header/HeaderMenuLink.js +50 -0
  45. package/components/Header/HeaderMenuSignOutButton.js +62 -0
  46. package/components/Header/HeaderMobileButton.js +37 -0
  47. package/components/Header/HeaderUI.jsx +167 -0
  48. package/components/Header/HelpIcon.jsx +32 -0
  49. package/components/Header/ImpersonatorBanner.jsx +57 -0
  50. package/components/Header/NavigationButtonIcon.jsx +27 -0
  51. package/components/Header/default-content.json +280 -0
  52. package/components/Header/header.js +40 -0
  53. package/components/Header/hooks.js +52 -0
  54. package/components/Header/utag-helpers.js +9 -0
  55. package/components/Infotip/Infotip.jsx +75 -0
  56. package/components/Infotip/Infotip.stories.js +50 -0
  57. package/components/Infotip/InfotipIcon.jsx +41 -0
  58. package/components/Infotip/index.js +3 -0
  59. package/components/Link/Link.stories.js +81 -0
  60. package/components/Link/index.js +61 -0
  61. package/components/Modal/LegacyModal.jsx +72 -0
  62. package/components/Modal/Modal.jsx +140 -0
  63. package/components/Modal/Modal.stories.js +159 -0
  64. package/components/Modal/index.jsx +22 -0
  65. package/components/NotificationBanner/NotificationBanner.stories.js +23 -0
  66. package/components/NotificationBanner/index.js +265 -0
  67. package/components/SanitizedContent/index.jsx +200 -0
  68. package/components/Search/Search.stories.js +21 -0
  69. package/components/Search/index.js +85 -0
  70. package/components/SessionDialog/sessionDialog.js +26 -0
  71. package/components/SessionDialogUI.jsx +261 -0
  72. package/components/SideNav/AnimationGroup/AnimationGroup.jsx +27 -0
  73. package/components/SideNav/Chart/ScoreChart.jsx +268 -0
  74. package/components/SideNav/Chart/__tests__/ScoreChart.test.js +22 -0
  75. package/components/SideNav/Chart/__tests__/__snapshots__/ScoreChart.test.js.snap +173 -0
  76. package/components/SideNav/Chart/index.js +3 -0
  77. package/components/SideNav/Content/LevelOneContent.jsx +208 -0
  78. package/components/SideNav/Content/LevelTwoContent.jsx +216 -0
  79. package/components/SideNav/Content/index.js +4 -0
  80. package/components/SideNav/Details/IndividualDetails.jsx +18 -0
  81. package/components/SideNav/Details/PracticeDetails.jsx +45 -0
  82. package/components/SideNav/Details/index.js +4 -0
  83. package/components/SideNav/Links/CmsSwitchLink.jsx +41 -0
  84. package/components/SideNav/Links/NavItemInline.jsx +54 -0
  85. package/components/SideNav/Links/NavLinkContainer.jsx +38 -0
  86. package/components/SideNav/Links/NavLinkDrawer.jsx +249 -0
  87. package/components/SideNav/Links/NavLinkInline.jsx +107 -0
  88. package/components/SideNav/Links/NavLinkToggle.jsx +34 -0
  89. package/components/SideNav/Links/index.js +13 -0
  90. package/components/SideNav/SideNav.md +50 -0
  91. package/components/SideNav/SideNav.stories.js +379 -0
  92. package/components/SideNav/UI/SideNavUI.jsx +333 -0
  93. package/components/SideNav/UI/default-content.json +99 -0
  94. package/components/SideNav/UI/index.js +3 -0
  95. package/components/SideNav/helpers.js +49 -0
  96. package/components/SideNav/index.js +53 -0
  97. package/components/Spinner/index.js +9 -0
  98. package/components/Tabs/Tab.js +26 -0
  99. package/components/Tabs/TabPanel.js +34 -0
  100. package/components/Tabs/Tabs.stories.js +120 -0
  101. package/components/Tabs/index.js +95 -0
  102. package/components/TextInput/TextInput.stories.js +118 -0
  103. package/components/TextInput/index.js +137 -0
  104. package/components/Tooltip/Tooltip.jsx +88 -0
  105. package/components/Tooltip/Tooltip.stories.js +80 -0
  106. package/components/Tooltip/index.js +3 -0
  107. package/components/Tooltip/position.js +68 -0
  108. package/components/UnwrappedSpinner/index.js +8 -0
  109. package/components/hooks/useGetConfig.js +74 -0
  110. package/components/index.js +126 -0
  111. package/dist/browser.js +3 -0
  112. package/dist/browser.js.LICENSE.txt +54 -0
  113. package/dist/browser.js.map +1 -0
  114. package/dist/index.js +3 -0
  115. package/dist/index.js.LICENSE.txt +54 -0
  116. package/dist/index.js.map +1 -0
  117. package/dist/react/index.js +3 -0
  118. package/dist/react/index.js.LICENSE.txt +71 -0
  119. package/dist/react/index.js.map +1 -0
  120. package/fonts/FontAwesome.otf +0 -0
  121. package/fonts/OFL.txt +92 -0
  122. package/fonts/Rubik-Black.ttf +0 -0
  123. package/fonts/Rubik-BlackItalic.ttf +0 -0
  124. package/fonts/Rubik-Bold.ttf +0 -0
  125. package/fonts/Rubik-BoldItalic.ttf +0 -0
  126. package/fonts/Rubik-Italic.ttf +0 -0
  127. package/fonts/Rubik-Light.ttf +0 -0
  128. package/fonts/Rubik-LightItalic.ttf +0 -0
  129. package/fonts/Rubik-Medium.ttf +0 -0
  130. package/fonts/Rubik-MediumItalic.ttf +0 -0
  131. package/fonts/Rubik-Regular.ttf +0 -0
  132. package/fonts/fontawesome-webfont.eot +0 -0
  133. package/fonts/fontawesome-webfont.svg +2671 -0
  134. package/fonts/fontawesome-webfont.ttf +0 -0
  135. package/fonts/fontawesome-webfont.woff +0 -0
  136. package/fonts/fontawesome-webfont.woff2 +0 -0
  137. package/images/favicon/android-chrome-192x192.png +0 -0
  138. package/images/favicon/android-chrome-256x256.png +0 -0
  139. package/images/favicon/apple-touch-icon.png +0 -0
  140. package/images/favicon/browserconfig.xml +9 -0
  141. package/images/favicon/favicon-16x16.png +0 -0
  142. package/images/favicon/favicon-32x32.png +0 -0
  143. package/images/favicon/favicon.ico +0 -0
  144. package/images/favicon/manifest.json +18 -0
  145. package/images/favicon/mstile-150x150.png +0 -0
  146. package/images/favicon/safari-pinned-tab.svg +32 -0
  147. package/images/hhs-logo-black.svg +10 -0
  148. package/images/hhs-logo-white.svg +10 -0
  149. package/images/icons/close-x.svg +6 -0
  150. package/images/icons/help-headset.svg +21 -0
  151. package/images/icons/svg/arrow-down.svg +1 -0
  152. package/images/icons/svg/arrow-download.svg +1 -0
  153. package/images/icons/svg/arrow-right.svg +1 -0
  154. package/images/icons/svg/calendar.svg +1 -0
  155. package/images/icons/svg/close.svg +1 -0
  156. package/images/icons/svg/download.svg +1 -0
  157. package/images/icons/svg/external.svg +1 -0
  158. package/images/icons/svg/file-upload.svg +1 -0
  159. package/images/icons/svg/print.svg +1 -0
  160. package/images/icons/svg/search.svg +7 -0
  161. package/images/icons/svg/tooltip-question.svg +6 -0
  162. package/images/icons/svg/trash.svg +1 -0
  163. package/images/icons/svg/upload.svg +1 -0
  164. package/images/qpp_logo_reversed.png +0 -0
  165. package/images/qpp_logo_rgb_color.png +0 -0
  166. package/index.js +31 -0
  167. package/jest/mediaFileTransformer.js +9 -0
  168. package/jest.config.js +188 -0
  169. package/lib/Chevron.jsx +32 -0
  170. package/lib/SvgComponents.jsx +539 -0
  171. package/lib/svg-definitions.svg +125 -0
  172. package/package.json +125 -0
  173. package/session/index.js +5 -0
  174. package/session/logout.js +65 -0
  175. package/session/refresh.js +49 -0
  176. package/session/ttl.js +37 -0
  177. package/styles/_global.scss +106 -0
  178. package/styles/_main.scss +15 -0
  179. package/styles/_paths.scss +1 -0
  180. package/styles/_qpp-style.scss +31 -0
  181. package/styles/components/_accordion.scss +289 -0
  182. package/styles/components/_alerts.scss +54 -0
  183. package/styles/components/_autocomplete.scss +47 -0
  184. package/styles/components/_breadcrumbs.scss +64 -0
  185. package/styles/components/_buttons.scss +580 -0
  186. package/styles/components/_error-page.scss +56 -0
  187. package/styles/components/_flash-notification.scss +98 -0
  188. package/styles/components/_fonts.scss +42 -0
  189. package/styles/components/_forms.scss +277 -0
  190. package/styles/components/_grid.scss +37 -0
  191. package/styles/components/_info-modal.scss +139 -0
  192. package/styles/components/_links.scss +12 -0
  193. package/styles/components/_modals.scss +18 -0
  194. package/styles/components/_notification-banner.scss +165 -0
  195. package/styles/components/_panels.scss +61 -0
  196. package/styles/components/_pie-chart.scss +13 -0
  197. package/styles/components/_score-chart.scss +164 -0
  198. package/styles/components/_spinner.scss +7 -0
  199. package/styles/components/_tables.scss +111 -0
  200. package/styles/components/_tabs.scss +69 -0
  201. package/styles/components/_text.scss +150 -0
  202. package/styles/components/_toggles.scss +3 -0
  203. package/styles/components/_tooltip.scss +23 -0
  204. package/styles/components/_variables.scss +157 -0
  205. package/styles/components/_wells.scss +92 -0
  206. package/styles/qppds/README.md +0 -0
  207. package/styles/qppds/base/_backgrounds.scss +7 -0
  208. package/styles/qppds/base/_fonts.scss +26 -0
  209. package/styles/qppds/base/_icon.scss +23 -0
  210. package/styles/qppds/base/_layout.scss +5 -0
  211. package/styles/qppds/base/_typography.scss +85 -0
  212. package/styles/qppds/base/index.scss +8 -0
  213. package/styles/qppds/components/_alert.scss +95 -0
  214. package/styles/qppds/components/_breadcrumbs.scss +70 -0
  215. package/styles/qppds/components/_button.scss +292 -0
  216. package/styles/qppds/components/_card.scss +175 -0
  217. package/styles/qppds/components/_dropdown.scss +55 -0
  218. package/styles/qppds/components/_footer.scss +597 -0
  219. package/styles/qppds/components/_header.scss +892 -0
  220. package/styles/qppds/components/_link.scss +52 -0
  221. package/styles/qppds/components/_modal.scss +118 -0
  222. package/styles/qppds/components/_page-header.scss +67 -0
  223. package/styles/qppds/components/_pagination.scss +227 -0
  224. package/styles/qppds/components/_search.scss +112 -0
  225. package/styles/qppds/components/_sidebar.scss +9 -0
  226. package/styles/qppds/components/_table.scss +139 -0
  227. package/styles/qppds/components/_tabs.scss +197 -0
  228. package/styles/qppds/components/_text-input.scss +60 -0
  229. package/styles/qppds/components/index.scss +16 -0
  230. package/styles/qppds/components/sidebar/_animations.scss +38 -0
  231. package/styles/qppds/components/sidebar/_cms.scss +61 -0
  232. package/styles/qppds/components/sidebar/_details.scss +58 -0
  233. package/styles/qppds/components/sidebar/_links.scss +444 -0
  234. package/styles/qppds/components/sidebar/_sidebar-animation.scss +125 -0
  235. package/styles/qppds/components/sidebar/_sidebar-tooltip.scss +33 -0
  236. package/styles/qppds/components/sidebar/_sidebar.scss +146 -0
  237. package/styles/qppds/components/sidebar/project-specific/_wi.scss +42 -0
  238. package/styles/qppds/index.scss +4 -0
  239. package/styles/qppds/settings/_functions.scss +4 -0
  240. package/styles/qppds/settings/_index.scss +3 -0
  241. package/styles/qppds/settings/mixins/_borders.scss +6 -0
  242. package/styles/qppds/settings/mixins/_focus.scss +28 -0
  243. package/styles/qppds/settings/mixins/_icons.scss +33 -0
  244. package/styles/qppds/settings/mixins/_index.scss +8 -0
  245. package/styles/qppds/settings/mixins/_layout.scss +74 -0
  246. package/styles/qppds/settings/mixins/_lists.scss +12 -0
  247. package/styles/qppds/settings/mixins/_table.scss +91 -0
  248. package/styles/qppds/settings/mixins/_type.scss +65 -0
  249. package/styles/qppds/settings/mixins/_visually-hidden.scss +30 -0
  250. package/styles/qppds/settings/variables/_color.scss +86 -0
  251. package/styles/qppds/settings/variables/_index.scss +3 -0
  252. package/styles/qppds/settings/variables/_layout.scss +67 -0
  253. package/styles/qppds/settings/variables/_type.scss +132 -0
  254. package/styles/qppds/utilities/_background-color.scss +134 -0
  255. package/styles/qppds/utilities/_color.scss +32 -0
  256. package/styles/qppds/utilities/_display-visibility.scss +83 -0
  257. package/styles/qppds/utilities/_flexbox.scss +240 -0
  258. package/styles/qppds/utilities/_font-family.scss +9 -0
  259. package/styles/qppds/utilities/_font-size.scss +8 -0
  260. package/styles/qppds/utilities/_font-weight.scss +8 -0
  261. package/styles/qppds/utilities/_height.scss +38 -0
  262. package/styles/qppds/utilities/_margin.scss +136 -0
  263. package/styles/qppds/utilities/_padding.scss +76 -0
  264. package/styles/qppds/utilities/_position.scss +24 -0
  265. package/styles/qppds/utilities/_text-align.scss +40 -0
  266. package/styles/qppds/utilities/_text-transform.scss +7 -0
  267. package/styles/qppds/utilities/_truncate.scss +8 -0
  268. package/styles/qppds/utilities/_width.scss +79 -0
  269. package/styles/qppds/utilities/index.scss +15 -0
  270. package/styles/qppds.scss +2 -0
  271. package/styles/third-party/_legacy-bootstrap.scss +19 -0
  272. package/styles/third-party/legacy-bootstrap/_buttons.scss +126 -0
  273. package/styles/third-party/legacy-bootstrap/_dropdowns.scss +211 -0
  274. package/styles/third-party/legacy-bootstrap/_forms.scss +510 -0
  275. package/styles/third-party/legacy-bootstrap/_grid.scss +73 -0
  276. package/styles/third-party/legacy-bootstrap/_mixins.scss +27 -0
  277. package/styles/third-party/legacy-bootstrap/_navbar.scss +644 -0
  278. package/styles/third-party/legacy-bootstrap/_navs.scss +193 -0
  279. package/styles/third-party/legacy-bootstrap/_normalize.scss +385 -0
  280. package/styles/third-party/legacy-bootstrap/_scaffolding.scss +116 -0
  281. package/styles/third-party/legacy-bootstrap/_variables.scss +858 -0
  282. package/styles/third-party/legacy-bootstrap/mixins/_buttons.scss +70 -0
  283. package/styles/third-party/legacy-bootstrap/mixins/_clearfix.scss +22 -0
  284. package/styles/third-party/legacy-bootstrap/mixins/_forms.scss +108 -0
  285. package/styles/third-party/legacy-bootstrap/mixins/_grid-framework.scss +86 -0
  286. package/styles/third-party/legacy-bootstrap/mixins/_grid.scss +112 -0
  287. package/styles/third-party/legacy-bootstrap/mixins/_labels.scss +12 -0
  288. package/styles/third-party/legacy-bootstrap/mixins/_nav-divider.scss +10 -0
  289. package/styles/third-party/legacy-bootstrap/mixins/_nav-vertical-align.scss +9 -0
  290. package/styles/third-party/legacy-bootstrap/mixins/_opacity.scss +7 -0
  291. package/styles/third-party/legacy-bootstrap/mixins/_panels.scss +30 -0
  292. package/styles/third-party/legacy-bootstrap/mixins/_reset-filter.scss +7 -0
  293. package/styles/third-party/legacy-bootstrap/mixins/_reset-text.scss +18 -0
  294. package/styles/third-party/legacy-bootstrap/mixins/_resize.scss +6 -0
  295. package/styles/third-party/legacy-bootstrap/mixins/_responsive-visibility.scss +25 -0
  296. package/styles/third-party/legacy-bootstrap/mixins/_size.scss +10 -0
  297. package/styles/third-party/legacy-bootstrap/mixins/_tab-focus.scss +9 -0
  298. package/styles/third-party/legacy-bootstrap/mixins/_table-row.scss +28 -0
  299. package/styles/third-party/legacy-bootstrap/mixins/_text-emphasis.scss +12 -0
  300. package/styles/third-party/legacy-bootstrap/mixins/_text-overflow.scss +8 -0
  301. package/styles/third-party/legacy-bootstrap/mixins/_vendor-prefixes.scss +182 -0
  302. package/styles/utility/_mixins.scss +46 -0
  303. package/styles/utility/_utilities.scss +73 -0
  304. package/test/components/Accordion.test.js +12 -0
  305. package/test/components/ErrorUI.test.js +33 -0
  306. package/test/components/FooterUI.test.js +90 -0
  307. package/test/components/HeaderUI.test.js +45 -0
  308. package/test/components/Infotip.test.js +73 -0
  309. package/test/components/SessionDialogUI.test.js +339 -0
  310. package/test/components/SideNavUI.test.js +23 -0
  311. package/test/components/Tooltip.test.js +147 -0
  312. package/test/index.test.js +8 -0
  313. package/test/session/session.test.js +221 -0
  314. package/test-setup.js +9 -0
  315. package/webpack.config.js +147 -0
  316. package/webpack.config.react.js +86 -0
@@ -0,0 +1,120 @@
1
+ import React, { useState } from 'react';
2
+ import { withKnobs } from '@storybook/addon-knobs';
3
+
4
+ import Tabs from './index';
5
+ import TabPanel from './TabPanel';
6
+ import Button from '../Button';
7
+
8
+ export default {
9
+ title: 'Tabs',
10
+ component: Tabs,
11
+ decorators: [withKnobs],
12
+ };
13
+
14
+ export const Default = () => {
15
+ return (
16
+ <div className="qpp-u-padding--12">
17
+ <Tabs>
18
+ <TabPanel id="summary" tab="Summary" className="my-summary-class">
19
+ The Bill of Rights is the first ten amendments to the United States
20
+ Constitution.
21
+ </TabPanel>
22
+ <TabPanel id="preamble" tab="Preamble">
23
+ We the People of the United States, in Order to form a more perfect
24
+ Union, establish Justice, insure domestic Tranquility, provide for the
25
+ common defence, promote the general Welfare, and secure the Blessings
26
+ of Liberty to ourselves and our Posterity, do ordain and establish
27
+ this Constitution for the United States of America.
28
+ </TabPanel>
29
+ <TabPanel id="amendments" tab="Amendments">
30
+ <h2 className="ds-h4">Bill of Rights</h2>
31
+ <ol className="ds-c-list">
32
+ <li>Freedoms, Petitions, Assembly</li>
33
+ <li>Right to bear arms</li>
34
+ <li>Quartering of soldiers</li>
35
+ <li>Search and arrest</li>
36
+ <li>Rights in criminal cases</li>
37
+ <li>Right to a fair trial</li>
38
+ <li>Rights in civil cases</li>
39
+ <li>Bail, fines, punishment</li>
40
+ <li>Rights retained by the People</li>
41
+ <li>States’ rights</li>
42
+ </ol>
43
+
44
+ <h2 className="ds-h4">Later Amendments</h2>
45
+ <ol className="ds-c-list" start="11">
46
+ <li>Lawsuits against states</li>
47
+ <li>Presidential elections</li>
48
+ <li>Abolition of slavery</li>
49
+ <li>Civil rights</li>
50
+ <li>Black suffrage</li>
51
+ <li>Income taxes</li>
52
+ <li>Senatorial elections</li>
53
+ <li>Prohibition of liquor</li>
54
+ <li>Women’s suffrage</li>
55
+ <li>Terms of office</li>
56
+ <li>Repeal of Prohibition</li>
57
+ <li>Term Limits for the Presidency</li>
58
+ <li>Washington, D.C., suffrage</li>
59
+ <li>Abolition of poll taxes</li>
60
+ <li>Presidential succession</li>
61
+ <li>18-year-old suffrage</li>
62
+ <li>Congressional pay raises</li>
63
+ </ol>
64
+
65
+ <h2 className="ds-h4">Even Later Amendments</h2>
66
+ <ol className="ds-c-list">
67
+ <li>Thou must count to three</li>
68
+ <li>
69
+ Three shall be the number of the counting and the number of the
70
+ counting shall be three
71
+ </li>
72
+ <li>Four shalt thou not count</li>
73
+ <li>
74
+ Neither shalt thou count two, excepting that thou then proceedeth
75
+ to three
76
+ </li>
77
+ <li>Five is right out</li>
78
+ </ol>
79
+ </TabPanel>
80
+ <TabPanel id="disabled" tab="Disabled" disabled>
81
+ You should not see this.
82
+ </TabPanel>
83
+ </Tabs>
84
+ </div>
85
+ );
86
+ };
87
+
88
+ export const ControlledTabs = () => {
89
+ const [selectedId, setSelectedId] = useState('preamble');
90
+ return (
91
+ <div className="qpp-u-padding--12">
92
+ <Tabs selected={selectedId} onChange={(id) => setSelectedId(id)}>
93
+ <TabPanel id="summary" tab="Summary" className="my-summary-class">
94
+ The Bill of Rights is the first ten amendments to the United States
95
+ Constitution.
96
+ </TabPanel>
97
+ <TabPanel id="preamble" tab="Preamble">
98
+ We the People of the United States, in Order to form a more perfect
99
+ Union, establish Justice, insure domestic Tranquility, provide for the
100
+ common defence, promote the general Welfare, and secure the Blessings
101
+ of Liberty to ourselves and our Posterity, do ordain and establish
102
+ this Constitution for the United States of America.
103
+ </TabPanel>
104
+ <TabPanel id="amendments" tab="Amendments">
105
+ All of the amendments
106
+ <br />
107
+ <Button
108
+ className="qpp-u-margin-top--16"
109
+ onClick={() => setSelectedId('summary')}
110
+ >
111
+ Go to Summary
112
+ </Button>
113
+ </TabPanel>
114
+ <TabPanel id="disabled" tab="Disabled" disabled>
115
+ You should not see this.
116
+ </TabPanel>
117
+ </Tabs>
118
+ </div>
119
+ );
120
+ };
@@ -0,0 +1,95 @@
1
+ import React, { useEffect, useState } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import MuiTabs from '@material-ui/core/Tabs'
4
+ import TabPanel from './TabPanel'
5
+ import LinkTab from './Tab'
6
+
7
+ const isTabPanel = (child) => child?.type === TabPanel
8
+
9
+ const getPanelChildren = (children) => {
10
+ return React.Children.toArray(children).filter(isTabPanel)
11
+ };
12
+
13
+ const Tabs = ({ children, onChange, selected, defaultSelectedId, ariaLabel }) => {
14
+ const [value, setValue] = useState(defaultSelectedId || selected)
15
+
16
+ useEffect(() => {
17
+ if (selected) {
18
+ setValue(selected)
19
+ }
20
+ }, [selected])
21
+
22
+ if (!children) return null
23
+
24
+ const handleChange = (event, newValue) => {
25
+ if (onChange) {
26
+ onChange(tabList[newValue]?.id, event)
27
+ }
28
+ if (setValue) {
29
+ setValue(tabList[newValue]?.id)
30
+ }
31
+ }
32
+
33
+ const renderChildren = () => {
34
+ return React.Children.map(children, (child, index) => {
35
+ if (isTabPanel(child)) {
36
+ return React.cloneElement(child, { index, value: tabIndex })
37
+ }
38
+ return child
39
+ })
40
+ }
41
+
42
+ const panels = getPanelChildren(children)
43
+
44
+ const tabList = panels.map(
45
+ (panel) => {
46
+ const { id, tab, tabHref, disabled } = panel?.props || {}
47
+ return { tab, tabHref, disabled, id }
48
+ },
49
+ )
50
+
51
+ const foundIndex = tabList.findIndex(({ id }) => id === value)
52
+
53
+ const tabIndex = foundIndex >= 0 ? foundIndex : 0
54
+
55
+ return (
56
+ <>
57
+ <div className="qpp-c-tabs qpp-c-tabs--mui">
58
+ <MuiTabs value={tabIndex} onChange={handleChange} aria-label={ariaLabel}>
59
+ {tabList.map(({ tab, tabHref, disabled, id }, index) => (
60
+ <LinkTab
61
+ index={index}
62
+ key={`link-tab-${tab}`}
63
+ label={tab}
64
+ href={tabHref}
65
+ disabled={disabled}
66
+ id={`qpp-c-tabs__item--${id}`}
67
+ />
68
+ ))}
69
+ </MuiTabs>
70
+ </div>
71
+ {renderChildren()}
72
+ </>
73
+ )
74
+ }
75
+
76
+ Tabs.propTypes = {
77
+ ariaLabel: PropTypes.string,
78
+ selected: PropTypes.string,
79
+ defaultSelectedId: PropTypes.string,
80
+ onChange: PropTypes.func,
81
+ children: PropTypes.oneOfType([
82
+ PropTypes.node,
83
+ PropTypes.array,
84
+ ])
85
+ }
86
+
87
+ Tabs.defaultProps = {
88
+ ariaLabel: 'qpp tabs',
89
+ selected: null,
90
+ defaultSelectedId: null,
91
+ onChange: null,
92
+ children: null,
93
+ }
94
+
95
+ export default Tabs
@@ -0,0 +1,118 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import TextInput from './index';
4
+ import { withKnobs } from '@storybook/addon-knobs';
5
+
6
+ export default {
7
+ title: 'Text Input',
8
+ component: TextInput,
9
+ decorators: [withKnobs],
10
+ };
11
+
12
+ const optionalProps = {
13
+ 'aria-label': 'example label',
14
+ };
15
+
16
+ const Wrapper = ({ children }) => (
17
+ <div className="qpp-u-padding--16">{children}</div>
18
+ );
19
+ Wrapper.propTypes = {
20
+ children: PropTypes.node,
21
+ };
22
+
23
+ export const InputField = () => (
24
+ <Wrapper>
25
+ <TextInput
26
+ style={{ width: 'auto' }}
27
+ id="example"
28
+ name="single-example"
29
+ value="Example value"
30
+ label="Input Field"
31
+ {...optionalProps}
32
+ />
33
+ </Wrapper>
34
+ );
35
+
36
+ export const InputFieldWithPlaceholder = () => (
37
+ <Wrapper>
38
+ <TextInput
39
+ id="placeholder-example"
40
+ name="placheholder"
41
+ label="Placeholder Example"
42
+ placeholder="Placeholder value"
43
+ />
44
+ </Wrapper>
45
+ );
46
+ export const DisabledInputField = () => (
47
+ <Wrapper>
48
+ <TextInput
49
+ disabled={true}
50
+ id="disabled-example"
51
+ name="disabled_example"
52
+ value="Example value"
53
+ label="Disabled Example"
54
+ />
55
+ </Wrapper>
56
+ );
57
+
58
+ export const FocusedInputField = () => (
59
+ <Wrapper>
60
+ <TextInput
61
+ id="focused-example"
62
+ name="focused_example"
63
+ value="Example value"
64
+ label="Focused Example"
65
+ className="qpp-c-text-input--focus"
66
+ />
67
+ </Wrapper>
68
+ );
69
+
70
+ export const ErrorInputField = () => (
71
+ <Wrapper>
72
+ <TextInput
73
+ className="qpp-u-margin-bottom--8"
74
+ id="error-example"
75
+ name="error_example"
76
+ value="Example value"
77
+ error="Error Message"
78
+ label="Error Example"
79
+ />
80
+ </Wrapper>
81
+ );
82
+
83
+ export const SuccessInputField = () => (
84
+ <Wrapper>
85
+ <TextInput
86
+ variant="success"
87
+ id="success-example"
88
+ name="success"
89
+ value="Example value"
90
+ label="Success Example"
91
+ />
92
+ </Wrapper>
93
+ );
94
+
95
+ export const InputFieldWithHint = () => (
96
+ <Wrapper>
97
+ <TextInput
98
+ className="qpp-u-margin-bottom--8"
99
+ id="hint-example"
100
+ name="hint"
101
+ value="Example value"
102
+ label="Hint Example"
103
+ hint="Hint Message"
104
+ />
105
+ </Wrapper>
106
+ );
107
+
108
+ export const BigInput = () => (
109
+ <Wrapper>
110
+ <TextInput
111
+ id="big-example"
112
+ name="hint"
113
+ value="Example value"
114
+ label="Big Example"
115
+ size="big"
116
+ />
117
+ </Wrapper>
118
+ );
@@ -0,0 +1,137 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const TextInput = ({
5
+ id,
6
+ name,
7
+ placeholder,
8
+ disabled,
9
+ required,
10
+ size,
11
+ className,
12
+ label,
13
+ minLength,
14
+ maxLength,
15
+ hint,
16
+ errorLabel,
17
+ error,
18
+ autoComplete,
19
+ onChange,
20
+ onKeyPress,
21
+ style,
22
+ dataTestId,
23
+ type,
24
+ innerRef,
25
+ number,
26
+ variant,
27
+ parentElement,
28
+ ...props
29
+ }) => {
30
+ const ContainerElement = parentElement || 'span';
31
+ const numberProps = {
32
+ pattern: '[0-9]*',
33
+ };
34
+
35
+ const textInputClass = [
36
+ 'qpp-c-text-input',
37
+ variant === 'success' && !error && 'qpp-c-text-input--success',
38
+ error && 'qpp-c-text-input--error',
39
+ size === 'big' && 'qpp-c-text-input--big',
40
+ className,
41
+ ]
42
+ .filter(Boolean)
43
+ .join(' ');
44
+
45
+ return (
46
+ <ContainerElement className="qppds ds-text-input-container">
47
+ {label && (
48
+ <label className="qpp-u-margin-bottom--8" htmlFor={id}>
49
+ {label}
50
+ </label>
51
+ )}
52
+ <input
53
+ {...(number ? numberProps : {})}
54
+ style={style}
55
+ data-testid={dataTestId}
56
+ type={type}
57
+ className={textInputClass || ''}
58
+ id={id}
59
+ name={name}
60
+ placeholder={placeholder}
61
+ disabled={disabled}
62
+ minLength={minLength}
63
+ maxLength={maxLength}
64
+ required={required}
65
+ autoComplete={autoComplete}
66
+ onChange={onChange}
67
+ onKeyPress={onKeyPress}
68
+ ref={innerRef}
69
+ {...props}
70
+ />
71
+ {hint && <span className="qpp-hint-message">{hint}</span>}
72
+ {error && (
73
+ <span
74
+ aria-label={errorLabel}
75
+ role="alert"
76
+ className="qpp-error-message"
77
+ >
78
+ {error}
79
+ </span>
80
+ )}
81
+ </ContainerElement>
82
+ );
83
+ };
84
+
85
+ TextInput.propTypes = {
86
+ id: PropTypes.string,
87
+ name: PropTypes.string,
88
+ placeholder: PropTypes.string,
89
+ disabled: PropTypes.bool,
90
+ required: PropTypes.bool,
91
+ className: PropTypes.string,
92
+ minLength: PropTypes.string,
93
+ maxLength: PropTypes.string,
94
+ hint: PropTypes.string,
95
+ errorLabel: PropTypes.string,
96
+ error: PropTypes.string,
97
+ autoComplete: PropTypes.string,
98
+ onChange: PropTypes.func,
99
+ onKeyPress: PropTypes.func,
100
+ style: PropTypes.object,
101
+ dataTestId: PropTypes.string,
102
+ type: PropTypes.string,
103
+ innerRef: PropTypes.string,
104
+ number: PropTypes.bool,
105
+ variant: PropTypes.oneOf(['success']),
106
+ parentElement: PropTypes.string,
107
+ label: PropTypes.string,
108
+ size: PropTypes.oneOf(['big'])
109
+ };
110
+
111
+ TextInput.defaultProps = {
112
+ id: '',
113
+ name: '',
114
+ placeholder: null,
115
+ disabled: false,
116
+ required: false,
117
+ className: '',
118
+ minLength: '',
119
+ maxLength: '',
120
+ error: null,
121
+ errorLabel: null,
122
+ hint: null,
123
+ autoComplete: 'on',
124
+ onChange: () => null,
125
+ onKeyPress: () => null,
126
+ style: null,
127
+ dataTestId: '',
128
+ type: 'text',
129
+ innerRef: null,
130
+ number: false,
131
+ variant: null,
132
+ parentElement: 'span',
133
+ label: null,
134
+ size: null,
135
+ };
136
+
137
+ export default TextInput;
@@ -0,0 +1,88 @@
1
+ import React, { cloneElement, useLayoutEffect, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import positionTip, { positionTriangle } from './position';
4
+ import { useTooltip, TooltipPopup } from '@reach/tooltip';
5
+ import Portal from '@reach/portal';
6
+
7
+ // TODO: investigate ways to allow more styling via css? the triangle
8
+ // positioning effect issue may need to be resolved to allow for this.
9
+ const TEXT_COLOR = '#FFF';
10
+ const BACKGROUND_COLOR = '#333';
11
+
12
+ /**
13
+ * Generic styled tooltip component.
14
+ * Corresponding styles: /styles/components/_tooltip.scss
15
+ *
16
+ * Extends implementation from @reach/tooltip:
17
+ * https://reacttraining.com/reach-ui/tooltip
18
+ */
19
+ const Tooltip = ({ children, label, ariaLabel, DEBUG_STYLE }) => {
20
+ const [trigger, tooltip] = useTooltip({ DEBUG_STYLE });
21
+ const { isVisible, triggerRect } = tooltip;
22
+ const tooltipPopupRef = useRef();
23
+ const triangleRef = useRef();
24
+
25
+ useLayoutEffect(() => {
26
+ // For some reason, the forwardRef for the tooltipPopup points to an undefined
27
+ // dom element when we first render the portal containing the triangle. Using
28
+ // an effect here will ensure that the ref is available when applying styles.
29
+ // TODO: investigate and make issue for @reach-ui/tooltip?
30
+ if (isVisible && tooltipPopupRef.current && triggerRect) {
31
+ const tooltipRect = tooltipPopupRef.current.getBoundingClientRect();
32
+ const positionCssText = positionTriangle(triggerRect, tooltipRect);
33
+ const cssText = `
34
+ position: absolute;
35
+ width: 0;
36
+ height: 0;
37
+ ${positionCssText}
38
+ border-top-color: ${BACKGROUND_COLOR};
39
+ border-bottom-color: ${BACKGROUND_COLOR};
40
+ z-index: 1;
41
+ `;
42
+ triangleRef.current.style.cssText = cssText;
43
+ }
44
+ });
45
+
46
+ return (
47
+ <>
48
+ {cloneElement(children, trigger)}
49
+ <TooltipPopup
50
+ {...tooltip}
51
+ label={label}
52
+ ariaLabel={ariaLabel}
53
+ style={{
54
+ background: BACKGROUND_COLOR,
55
+ color: TEXT_COLOR,
56
+ }}
57
+ ref={tooltipPopupRef}
58
+ position={positionTip}
59
+ />
60
+ {isVisible && (
61
+ <Portal>
62
+ <div
63
+ ref={triangleRef}
64
+ style={{
65
+ position: 'absolute',
66
+ width: 0,
67
+ height: 0,
68
+ }}
69
+ />
70
+ </Portal>
71
+ )}
72
+ </>
73
+ );
74
+ };
75
+
76
+ Tooltip.propTypes = {
77
+ children: PropTypes.node.isRequired,
78
+ label: PropTypes.node.isRequired,
79
+ ariaLabel: PropTypes.string,
80
+ DEBUG_STYLE: PropTypes.bool,
81
+ };
82
+
83
+ Tooltip.defaultProps = {
84
+ ariaLabel: undefined,
85
+ DEBUG_STYLE: undefined,
86
+ };
87
+
88
+ export default Tooltip;
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import Tooltip from './index';
3
+
4
+ const offsetDecorator = (storyFn) => (
5
+ <div style={{ margin: '80px' }}>{storyFn()}</div>
6
+ );
7
+
8
+ export default {
9
+ title: 'Tooltip',
10
+ component: Tooltip,
11
+ };
12
+
13
+ export const ExampleTooltip = () => (
14
+ <Tooltip label="FOOBAR">
15
+ <button>
16
+ <span>Tooltip Trigger</span>
17
+ </button>
18
+ </Tooltip>
19
+ );
20
+
21
+ ExampleTooltip.storyName = 'example Tooltip';
22
+ ExampleTooltip.decorators = [offsetDecorator];
23
+
24
+ export const AriaLabelTooltip = () => (
25
+ <Tooltip label="FOOBAR" ariaLabel="foobar">
26
+ <button>
27
+ <span>Tooltip Trigger</span>
28
+ </button>
29
+ </Tooltip>
30
+ );
31
+
32
+ AriaLabelTooltip.storyName = 'using ariaLabel';
33
+ AriaLabelTooltip.decorators = [offsetDecorator];
34
+
35
+ export const MultipleTooltip = () => (
36
+ <>
37
+ <Tooltip label="Tooltip 1">
38
+ <button>
39
+ <span>Tooltip 1 Trigger</span>
40
+ </button>
41
+ </Tooltip>
42
+ <Tooltip label="Tooltip 2">
43
+ <button>
44
+ <span>Tooltip 2 Trigger</span>
45
+ </button>
46
+ </Tooltip>
47
+ <Tooltip label="Tooltip 3">
48
+ <button>
49
+ <span>Tooltip 3 Trigger</span>
50
+ </button>
51
+ </Tooltip>
52
+ </>
53
+ );
54
+
55
+ MultipleTooltip.storyName = 'multiple Tooltips';
56
+ MultipleTooltip.decorators = [offsetDecorator];
57
+
58
+ export const InputElementTooltip = () => (
59
+ <form>
60
+ <label htmlFor="foobar" style={{ marginRight: '5px ' }}>
61
+ Text Input
62
+ </label>
63
+ <Tooltip label="example input label tooltip">
64
+ <input type="text" name="foobar" />
65
+ </Tooltip>
66
+ </form>
67
+ );
68
+
69
+ InputElementTooltip.storyName = 'on text input';
70
+ InputElementTooltip.decorators = [offsetDecorator];
71
+
72
+ export const PositionedBelowTargetTooltip = () => (
73
+ <Tooltip label="FOOBAR">
74
+ <button>
75
+ <span>Tooltip Trigger</span>
76
+ </button>
77
+ </Tooltip>
78
+ );
79
+
80
+ PositionedBelowTargetTooltip.storyName = 'positioned below trigger';
@@ -0,0 +1,3 @@
1
+ import Tooltip from './Tooltip';
2
+
3
+ export default Tooltip;