@mycause/ui 0.0.0-ce837d6b → 0.0.0-cf802939

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 (258) hide show
  1. package/CHANGELOG.md +225 -0
  2. package/README.md +9 -0
  3. package/dist/components/button-select/button-select.d.ts +12 -0
  4. package/dist/components/button-select/button-select.stories.d.ts +13 -0
  5. package/dist/components/button-select/index.d.ts +1 -0
  6. package/dist/components/campaign-card/campaign-card.d.ts +9 -0
  7. package/dist/components/campaign-card/campaign-card.stories.d.ts +14 -0
  8. package/dist/components/campaign-card/index.d.ts +1 -0
  9. package/dist/components/campaign-of-month/campaign-of-month.d.ts +14 -0
  10. package/dist/components/campaign-of-month/campaign-of-month.stories.d.ts +14 -0
  11. package/dist/components/campaign-of-month/index.d.ts +1 -0
  12. package/dist/components/charity-card/charity-card.d.ts +7 -0
  13. package/dist/components/charity-card/charity-card.stories.d.ts +14 -0
  14. package/dist/components/charity-card/index.d.ts +1 -0
  15. package/dist/components/combo-field/combo-field.d.ts +4 -1
  16. package/dist/components/comment-section/comment-section-v2/comment-section-v2.d.ts +31 -0
  17. package/dist/components/comment-section/comment-section-v2/sub-comments-v2.d.ts +11 -0
  18. package/dist/components/comment-section/comment-section.d.ts +24 -0
  19. package/dist/components/comment-section/comment-section.stories.d.ts +19 -0
  20. package/dist/components/comment-section/index.d.ts +2 -0
  21. package/dist/components/comment-section/sub-comments.d.ts +6 -0
  22. package/dist/components/cropper/cropper.d.ts +5 -4
  23. package/dist/components/cropper/cropper.stories.d.ts +1 -2
  24. package/dist/components/date-picker/single-date-picker.d.ts +3 -2
  25. package/dist/components/donate-card/donate-card.d.ts +8 -0
  26. package/dist/components/donate-card/donate-card.stories.d.ts +14 -0
  27. package/dist/components/donate-card/index.d.ts +1 -0
  28. package/dist/components/donation-form/donation-details.d.ts +12 -0
  29. package/dist/components/donation-form/donation-form-v2/donation-form-v2.d.ts +13 -0
  30. package/dist/components/donation-form/donation-form.d.ts +64 -0
  31. package/dist/components/donation-form/donation-form.stories.d.ts +18 -0
  32. package/dist/components/donation-form/donation-payment.d.ts +13 -0
  33. package/dist/components/donation-form/donation-select.d.ts +13 -0
  34. package/dist/components/donation-form/index.d.ts +2 -0
  35. package/dist/components/elevation/elevation.d.ts +2 -1
  36. package/dist/components/featured-campaign-card/featured-campaign-card.d.ts +17 -0
  37. package/dist/components/featured-campaign-card/featured-campaign-card.stories.d.ts +14 -0
  38. package/dist/components/featured-campaign-card/index.d.ts +1 -0
  39. package/dist/components/footerV2/footerV2.d.ts +32 -0
  40. package/dist/components/footerV2/footerV2.stories.d.ts +15 -0
  41. package/dist/components/footerV2/index.d.ts +1 -0
  42. package/dist/components/fundraising-section/fundraising-section.d.ts +9 -0
  43. package/dist/components/fundraising-section/fundraising-section.stories.d.ts +14 -0
  44. package/dist/components/fundraising-section/index.d.ts +1 -0
  45. package/dist/components/hero-banner/hero-banner.d.ts +9 -0
  46. package/dist/components/hero-banner/hero-banner.stories.d.ts +14 -0
  47. package/dist/components/hero-banner/index.d.ts +1 -0
  48. package/dist/components/horizontalbar/horizontalbar.d.ts +11 -0
  49. package/dist/components/horizontalbar/horizontalbar.stories.d.ts +26 -0
  50. package/dist/components/horizontalbar/index.d.ts +1 -0
  51. package/dist/components/icon/{toggle-button.d.ts → heart-toggle.d.ts} +3 -3
  52. package/dist/components/icon/{toggle-button.stories.d.ts → heart-toggle.stories.d.ts} +1 -1
  53. package/dist/components/icon/index.d.ts +1 -1
  54. package/dist/components/index.d.ts +18 -1
  55. package/dist/components/info-represent-campaign/index.d.ts +1 -0
  56. package/dist/components/info-represent-campaign/info-represent-campaign.d.ts +11 -0
  57. package/dist/components/{phone-number-field/phone-number-field.stories.d.ts → info-represent-campaign/info-represent-campaign.stories.d.ts} +1 -1
  58. package/dist/components/list/list.d.ts +29 -14
  59. package/dist/components/list/list.stories.d.ts +8 -2
  60. package/dist/components/login/index.d.ts +1 -0
  61. package/dist/components/login/login.d.ts +15 -0
  62. package/dist/components/login/login.stories.d.ts +19 -0
  63. package/dist/components/logo/logo-type.d.ts +2 -1
  64. package/dist/components/modal/modal.d.ts +4 -3
  65. package/dist/components/modal/modal.stories.d.ts +6 -0
  66. package/dist/components/nav/icons/IconBigger.d.ts +5 -0
  67. package/dist/components/nav/icons/IconSmaller.d.ts +5 -0
  68. package/dist/components/nav/index.d.ts +1 -0
  69. package/dist/components/nav/nav-actions.d.ts +5 -0
  70. package/dist/components/nav/nav-bar.d.ts +7 -0
  71. package/dist/components/nav/nav-call-to-action.d.ts +5 -0
  72. package/dist/components/nav/nav-expanded-charity.d.ts +13 -0
  73. package/dist/components/nav/nav-expanded.d.ts +14 -0
  74. package/dist/components/nav/nav-list.d.ts +29 -0
  75. package/dist/components/nav/nav-menu-control.d.ts +8 -0
  76. package/dist/components/nav/nav-menu.d.ts +12 -0
  77. package/dist/components/nav/nav-search-control.d.ts +8 -0
  78. package/dist/components/nav/nav-search.d.ts +10 -0
  79. package/dist/components/nav/nav-sign-in-control.d.ts +12 -0
  80. package/dist/components/nav/nav-user-menu-items.d.ts +20 -0
  81. package/dist/components/nav/nav-user-menu.d.ts +18 -0
  82. package/dist/components/nav/nav.d.ts +56 -0
  83. package/dist/components/nav/nav.stories.d.ts +11 -0
  84. package/dist/components/navigation/navigation-list.d.ts +3 -1
  85. package/dist/components/navigation/navigation-menu.d.ts +2 -1
  86. package/dist/components/navigation/navigation-sign-in-control.d.ts +6 -3
  87. package/dist/components/navigation/navigation.d.ts +12 -1
  88. package/dist/components/navigation/navigation.stories.d.ts +3 -21
  89. package/dist/components/phone-number-input/index.d.ts +2 -0
  90. package/dist/components/{phone-number-field/phone-number-field.d.ts → phone-number-input/phone-number-input.d.ts} +5 -3
  91. package/dist/components/phone-number-input/phone-number-input.stories.d.ts +13 -0
  92. package/dist/components/popup/index.d.ts +1 -0
  93. package/dist/components/popup/popup.d.ts +8 -0
  94. package/dist/components/popup/popup.stories.d.ts +14 -0
  95. package/dist/components/progressbar/index.d.ts +1 -0
  96. package/dist/components/progressbar/progressbar.d.ts +8 -0
  97. package/dist/components/progressbar/progressbar.stories.d.ts +14 -0
  98. package/dist/components/select/select.d.ts +2 -1
  99. package/dist/components/spinner/index.d.ts +1 -0
  100. package/dist/components/spinner/spinner.d.ts +8 -0
  101. package/dist/components/spinner/spinner.stories.d.ts +13 -0
  102. package/dist/components/start-campaign-card/index.d.ts +1 -0
  103. package/dist/components/start-campaign-card/start-campaign-card.d.ts +8 -0
  104. package/dist/components/start-campaign-card/start-campaign-card.stories.d.ts +14 -0
  105. package/dist/components/statistics/statistics.d.ts +2 -1
  106. package/dist/components/tabs/nav-tabs.d.ts +18 -0
  107. package/dist/components/tabs/tabs.d.ts +3 -1
  108. package/dist/components/text/text.d.ts +1 -1
  109. package/dist/components/text-field/text-field.d.ts +1 -0
  110. package/dist/index.esm.js +9570 -6554
  111. package/dist/index.js +9296 -6261
  112. package/dist/theme/theme.d.ts +4 -0
  113. package/dist/utils/parse-numbers.d.ts +2 -0
  114. package/package.json +4 -1
  115. package/styles/index.css +5 -0
  116. package/dist/components/anchor/anchor.jsx +0 -35
  117. package/dist/components/anchor/anchor.stories.jsx +0 -12
  118. package/dist/components/anchor/bold-anchor.jsx +0 -33
  119. package/dist/components/anchor/bold-anchor.stories.jsx +0 -11
  120. package/dist/components/anchor/index.js +0 -2
  121. package/dist/components/avatar/avatar.jsx +0 -14
  122. package/dist/components/avatar/avatar.stories.jsx +0 -17
  123. package/dist/components/avatar/image-avatar.jsx +0 -29
  124. package/dist/components/avatar/index.js +0 -1
  125. package/dist/components/avatar/text-avatar.jsx +0 -47
  126. package/dist/components/button/button.jsx +0 -85
  127. package/dist/components/button/button.stories.jsx +0 -118
  128. package/dist/components/button/index.js +0 -1
  129. package/dist/components/checkbox/checkbox.jsx +0 -39
  130. package/dist/components/checkbox/checkbox.stories.jsx +0 -42
  131. package/dist/components/checkbox/index.js +0 -1
  132. package/dist/components/chips/chip.jsx +0 -30
  133. package/dist/components/chips/chips.jsx +0 -16
  134. package/dist/components/chips/chips.stories.jsx +0 -35
  135. package/dist/components/chips/index.js +0 -3
  136. package/dist/components/chips/input-chips.jsx +0 -16
  137. package/dist/components/chips/input-chips.stories.jsx +0 -39
  138. package/dist/components/combo-field/combo-field-expander.jsx +0 -23
  139. package/dist/components/combo-field/combo-field.jsx +0 -93
  140. package/dist/components/combo-field/combo-field.stories.jsx +0 -62
  141. package/dist/components/combo-field/index.js +0 -2
  142. package/dist/components/cropper/cropper.jsx +0 -15
  143. package/dist/components/cropper/cropper.stories.jsx +0 -18
  144. package/dist/components/cropper/index.js +0 -1
  145. package/dist/components/date-picker/date-picker.jsx +0 -74
  146. package/dist/components/date-picker/date-picker.stories.jsx +0 -46
  147. package/dist/components/date-picker/index.js +0 -2
  148. package/dist/components/date-picker/single-date-picker.jsx +0 -81
  149. package/dist/components/elevation/elevation.jsx +0 -19
  150. package/dist/components/elevation/elevation.stories.jsx +0 -31
  151. package/dist/components/elevation/index.js +0 -1
  152. package/dist/components/field-helpers/field-helper-text.jsx +0 -42
  153. package/dist/components/field-helpers/field-label.jsx +0 -29
  154. package/dist/components/field-helpers/index.js +0 -2
  155. package/dist/components/icon/btn_google_light_normal_ios.svg.jsx +0 -21
  156. package/dist/components/icon/facebook_6.svg.jsx +0 -13
  157. package/dist/components/icon/icon-button-group.jsx +0 -51
  158. package/dist/components/icon/icon-button-group.stories.jsx +0 -26
  159. package/dist/components/icon/icon-button.jsx +0 -48
  160. package/dist/components/icon/icon-button.stories.jsx +0 -33
  161. package/dist/components/icon/icon.jsx +0 -49
  162. package/dist/components/icon/icon.stories.jsx +0 -78
  163. package/dist/components/icon/index.js +0 -4
  164. package/dist/components/icon/material-icon.jsx +0 -18
  165. package/dist/components/icon/toggle-button.jsx +0 -29
  166. package/dist/components/icon/toggle-button.stories.jsx +0 -16
  167. package/dist/components/index.js +0 -27
  168. package/dist/components/layout/box.jsx +0 -58
  169. package/dist/components/layout/flex.jsx +0 -55
  170. package/dist/components/layout/flex.stories.jsx +0 -44
  171. package/dist/components/layout/grid.jsx +0 -19
  172. package/dist/components/layout/grid.stories.jsx +0 -29
  173. package/dist/components/layout/index.js +0 -4
  174. package/dist/components/layout/stack.jsx +0 -33
  175. package/dist/components/layout/stack.stories.jsx +0 -40
  176. package/dist/components/list/index.js +0 -1
  177. package/dist/components/list/list.jsx +0 -52
  178. package/dist/components/list/list.stories.jsx +0 -135
  179. package/dist/components/logo/index.js +0 -1
  180. package/dist/components/logo/logo-type.jsx +0 -65
  181. package/dist/components/menu/index.js +0 -8
  182. package/dist/components/menu/menu-list-divider.jsx +0 -2
  183. package/dist/components/menu/menu-list-item-graphic.jsx +0 -2
  184. package/dist/components/menu/menu-list-item-meta.jsx +0 -2
  185. package/dist/components/menu/menu-list-item-text.jsx +0 -2
  186. package/dist/components/menu/menu-list-item.jsx +0 -11
  187. package/dist/components/menu/menu-list.jsx +0 -18
  188. package/dist/components/menu/menu-surface.jsx +0 -4
  189. package/dist/components/menu/menu.jsx +0 -2
  190. package/dist/components/menu/menu.stories.jsx +0 -42
  191. package/dist/components/modal/index.js +0 -1
  192. package/dist/components/modal/modal.jsx +0 -49
  193. package/dist/components/modal/modal.stories.jsx +0 -47
  194. package/dist/components/navigation/index.js +0 -1
  195. package/dist/components/navigation/navigation-actions.jsx +0 -8
  196. package/dist/components/navigation/navigation-bar.jsx +0 -42
  197. package/dist/components/navigation/navigation-call-to-action.jsx +0 -6
  198. package/dist/components/navigation/navigation-expanded.jsx +0 -165
  199. package/dist/components/navigation/navigation-list.jsx +0 -126
  200. package/dist/components/navigation/navigation-menu-control.jsx +0 -25
  201. package/dist/components/navigation/navigation-menu.jsx +0 -103
  202. package/dist/components/navigation/navigation-search-control.jsx +0 -8
  203. package/dist/components/navigation/navigation-search.jsx +0 -63
  204. package/dist/components/navigation/navigation-sign-in-control.jsx +0 -14
  205. package/dist/components/navigation/navigation-user-menu-items.jsx +0 -36
  206. package/dist/components/navigation/navigation-user-menu.jsx +0 -121
  207. package/dist/components/navigation/navigation.jsx +0 -137
  208. package/dist/components/navigation/navigation.stories.jsx +0 -260
  209. package/dist/components/phone-number-field/index.d.ts +0 -2
  210. package/dist/components/phone-number-field/index.js +0 -2
  211. package/dist/components/phone-number-field/phone-number-field.jsx +0 -50
  212. package/dist/components/phone-number-field/phone-number-field.stories.jsx +0 -23
  213. package/dist/components/phone-number-field/util.js +0 -19
  214. package/dist/components/radio/index.js +0 -2
  215. package/dist/components/radio/radio-group.jsx +0 -9
  216. package/dist/components/radio/radio-group.stories.jsx +0 -21
  217. package/dist/components/radio/radio.jsx +0 -31
  218. package/dist/components/radio/radio.stories.jsx +0 -44
  219. package/dist/components/select/index.js +0 -2
  220. package/dist/components/select/select-helper-text.jsx +0 -6
  221. package/dist/components/select/select.jsx +0 -152
  222. package/dist/components/select/select.stories.jsx +0 -40
  223. package/dist/components/statistics/index.js +0 -1
  224. package/dist/components/statistics/statistics.jsx +0 -61
  225. package/dist/components/statistics/statistics.stories.jsx +0 -34
  226. package/dist/components/switch/index.js +0 -1
  227. package/dist/components/switch/switch.jsx +0 -32
  228. package/dist/components/switch/switch.stories.jsx +0 -41
  229. package/dist/components/tabs/index.js +0 -1
  230. package/dist/components/tabs/tab-bar.jsx +0 -35
  231. package/dist/components/tabs/tab-text-label.jsx +0 -5
  232. package/dist/components/tabs/tab.jsx +0 -50
  233. package/dist/components/tabs/tabs.jsx +0 -65
  234. package/dist/components/tabs/tabs.stories.jsx +0 -27
  235. package/dist/components/text/index.js +0 -1
  236. package/dist/components/text/text.jsx +0 -138
  237. package/dist/components/text/text.stories.jsx +0 -262
  238. package/dist/components/text-field/index.js +0 -2
  239. package/dist/components/text-field/text-field-helper-text.jsx +0 -8
  240. package/dist/components/text-field/text-field.jsx +0 -124
  241. package/dist/components/text-field/text-field.stories.jsx +0 -32
  242. package/dist/components/uploader/index.js +0 -1
  243. package/dist/components/uploader/uploader.jsx +0 -96
  244. package/dist/input.d.ts +0 -1
  245. package/dist/input.js +0 -4
  246. package/dist/input.jsx +0 -4
  247. package/dist/theme/colors.js +0 -9
  248. package/dist/theme/index.js +0 -2
  249. package/dist/theme/mycause-theme.js +0 -33
  250. package/dist/theme/theme.jsx +0 -36
  251. package/dist/utils/browser.js +0 -19
  252. package/dist/utils/center-decorator.jsx +0 -15
  253. package/dist/utils/component-matrix.jsx +0 -39
  254. package/dist/utils/flags.js +0 -18
  255. package/dist/utils/grid-decorator.jsx +0 -27
  256. package/dist/utils/tap-event.js +0 -11
  257. package/dist/utils/wrap.js +0 -8
  258. /package/dist/components/{phone-number-field → phone-number-input}/util.d.ts +0 -0
@@ -1,51 +0,0 @@
1
- import React from "react";
2
- import classnames from "classnames";
3
- import { useTheme } from "../../theme/theme";
4
- import css from "styled-jsx/css";
5
- function IconButtonGroup({ children, size, isOutlinedOnFocus, }) {
6
- const theme = useTheme();
7
- children = React.Children.map(children, (child) => React.cloneElement(child, { size }));
8
- const scope = css.resolve `
9
- .icon-button-group.icon-button-group--outline-on-focus:focus-within::after {
10
- border-color: ${theme.color.foreground.primary};
11
- border-radius: 4px;
12
- }
13
- `;
14
- return (<div className={classnames("icon-button-group", {
15
- "icon-button-group--outline-on-focus": !!isOutlinedOnFocus,
16
- }, scope.className)}>
17
- {children}
18
- <style jsx>{`
19
- .icon-button-group {
20
- position: relative;
21
- display: flex;
22
- flex-direction: row;
23
- }
24
-
25
- .icon-button-group::after {
26
- content: "";
27
- position: absolute;
28
- display: block;
29
- top: 0;
30
- right: 0;
31
- bottom: 0;
32
- left: 0;
33
- border: 1px solid #9e9e9e;
34
- border-radius: 4px;
35
- pointer-events: none;
36
- }
37
-
38
- .icon-button-group:hover::after {
39
- border: 1px solid rgba(0, 0, 0, 0.87);
40
- }
41
-
42
- .icon-button-group.icon-button-group--outline-on-focus:focus-within::after {
43
- border-width: 2px;
44
- border-style: solid;
45
- border-radius: 4px;
46
- }
47
- `}</style>
48
- {scope.styles}
49
- </div>);
50
- }
51
- export default IconButtonGroup;
@@ -1,26 +0,0 @@
1
- import React, { useState } from "react";
2
- import CenterDecorator from "../../utils/center-decorator";
3
- import IconButton from "./icon-button";
4
- import IconButtonGroup from "./icon-button-group";
5
- import Icon from "./icon";
6
- export default {
7
- title: "IconButtonGroup",
8
- decorators: [CenterDecorator],
9
- };
10
- const options = [
11
- { value: "left", icon: "format_align_left" },
12
- { value: "center", icon: "format_align_center" },
13
- { value: "right", icon: "format_align_right" },
14
- { value: "justify", icon: "format_align_justify" },
15
- ];
16
- export const IconButtonGroupStory = () => {
17
- const [alignment, setAlignment] = useState("center");
18
- return (<IconButtonGroup>
19
- {options.map(option => (<IconButton pressed={option.value === alignment} onClick={() => setAlignment(option.value)} key={option.value}>
20
- <Icon icon={option.icon}/>
21
- </IconButton>))}
22
- </IconButtonGroup>);
23
- };
24
- IconButtonGroupStory.story = {
25
- name: "default",
26
- };
@@ -1,48 +0,0 @@
1
- import React, { forwardRef, useState } from "react";
2
- import css from "styled-jsx/css";
3
- import classnames from "classnames";
4
- import MDCIconButton from "@material/react-icon-button";
5
- import { tapEvent } from "../../utils/tap-event";
6
- const IconButton = forwardRef(function IconButton({ children, size, className, pressed, onBlur, ...rest }, ref) {
7
- const [count, update] = useState(0);
8
- // MDCIconButton currently makes all icon buttons toggle buttons
9
- // by toggling aria-pressed, and there is no way to make them
10
- // normal single trigger buttons.
11
- // By forcing a remount when the component blurs (by changing the key),
12
- // we the button's aria-pressed will be reset to false upon leaving the button.
13
- const handleBlur = tapEvent(() => {
14
- if (typeof pressed === "undefined") {
15
- update(c => c + 1);
16
- }
17
- }, onBlur);
18
- const scope = css.resolve `
19
- .mdc-icon-button {
20
- display: inline-flex;
21
- align-items: center;
22
- justify-content: center;
23
- }
24
-
25
- .toggle {
26
- transition: background-color 200ms ease;
27
- }
28
-
29
- .toggle--active {
30
- background-color: rgba(0, 0, 0, 0.1);
31
- border-radius: 4px;
32
- }
33
-
34
- .size {
35
- width: ${size || ""};
36
- height: ${size || ""};
37
- }
38
- `;
39
- return (<MDCIconButton key={count} className={classnames(className, scope.className, {
40
- toggle: typeof pressed !== "undefined",
41
- "toggle--active": pressed === true,
42
- size,
43
- })} ref={ref} onBlur={handleBlur} {...rest}>
44
- {children}
45
- {scope.styles}
46
- </MDCIconButton>);
47
- });
48
- export default IconButton;
@@ -1,33 +0,0 @@
1
- import React, { useState } from "react";
2
- import Matrix from "../../utils/component-matrix";
3
- import CenterDecorator from "../../utils/center-decorator";
4
- import IconButton from "./icon-button";
5
- import Icon from "./icon";
6
- export default {
7
- title: "IconButton",
8
- decorators: [CenterDecorator],
9
- };
10
- export const iconButton = () => {
11
- const props = {
12
- primary: [{ icon: "close" }, { icon: "today" }, { icon: "delete" }],
13
- };
14
- return (<Matrix {...props}>
15
- {props => (<IconButton>
16
- <Icon {...props}/>
17
- </IconButton>)}
18
- </Matrix>);
19
- };
20
- iconButton.story = {
21
- name: "default",
22
- };
23
- export const Toggle = () => {
24
- const [isPressed, setIsPressed] = useState(false);
25
- return (<>
26
- <IconButton pressed={isPressed} onClick={() => setIsPressed(!isPressed)}>
27
- <Icon icon="format_align_left"/>
28
- </IconButton>
29
- </>);
30
- };
31
- Toggle.story = {
32
- name: "toggle",
33
- };
@@ -1,49 +0,0 @@
1
- import React from "react";
2
- import classnames from "classnames";
3
- import css from "styled-jsx/css";
4
- import { useTheme, getColorToken } from "../../theme/theme";
5
- import MaterialIcon from "./material-icon";
6
- function Icon({ icon, iconSet, color = "neutral", invert, className, size, ...rest }) {
7
- const theme = useTheme();
8
- const foreground = getColorToken(theme, "foreground", color, { invert });
9
- const scope = css.resolve `
10
- .icon,
11
- :global(.mdc-text-field):not(.mdc-text-field--disabled)
12
- .mdc-text-field__icon {
13
- color: ${foreground};
14
- }
15
-
16
- svg {
17
- width: 24px;
18
- height: 24px;
19
- fill: currentColor;
20
- }
21
-
22
- .icon--sized {
23
- width: ${size};
24
- height: ${size};
25
- font-size: ${size};
26
- }
27
- `;
28
- const props = {
29
- className: classnames("icon", className, scope.className, {
30
- sized: !!size,
31
- }),
32
- ...rest,
33
- };
34
- if (typeof icon === "string") {
35
- return (<>
36
- <MaterialIcon icon={icon} iconSet={iconSet} size={size} {...props}/>
37
- {scope.styles}
38
- </>);
39
- }
40
- let elem = icon;
41
- return (<>
42
- {React.cloneElement(elem, {
43
- ...props,
44
- className: classnames(elem.props.className, props.className, "svg-icon"),
45
- })}
46
- {scope.styles}
47
- </>);
48
- }
49
- export default Icon;
@@ -1,78 +0,0 @@
1
- import React from "react";
2
- import Matrix from "../../utils/component-matrix";
3
- import CenterDecorator from "../../utils/center-decorator";
4
- import Icon from "./icon";
5
- import Google from "./btn_google_light_normal_ios.svg";
6
- import Facebook from "./facebook_6.svg";
7
- export default {
8
- title: "Icon",
9
- decorators: [CenterDecorator],
10
- };
11
- export const material = () => {
12
- const props = {
13
- primary: [
14
- { icon: "card_giftcard" },
15
- { icon: "favorite" },
16
- { icon: "favorite_border" },
17
- { icon: "close" },
18
- { icon: "chevron_right" },
19
- ],
20
- };
21
- return (<Matrix {...props}>
22
- {props => <Icon {...props}/>}
23
- </Matrix>);
24
- };
25
- material.story = {
26
- name: "material icons",
27
- };
28
- export const colors = () => {
29
- const props = {
30
- primary: [
31
- { icon: "card_giftcard" },
32
- { icon: "favorite" },
33
- { icon: "favorite_outline" },
34
- { icon: "close" },
35
- { icon: "chevron_right" },
36
- ],
37
- secondary: [
38
- { color: "neutral" },
39
- { color: "primary" },
40
- { color: "secondary" },
41
- { color: "accent" },
42
- { color: "#e0e0e0" },
43
- ],
44
- };
45
- return (<Matrix {...props}>
46
- {props => <Icon {...props}/>}
47
- </Matrix>);
48
- };
49
- colors.story = {
50
- name: "colors",
51
- };
52
- export const svg = () => {
53
- const props = {
54
- primary: [
55
- {
56
- color: "accent",
57
- icon: (<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
58
- <path d="M0 0h24v24H0z" fill="none"/>
59
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
60
- </svg>),
61
- },
62
- {
63
- color: { foreground: "#3C5A99", background: "white" },
64
- icon: <Facebook />,
65
- },
66
- {
67
- color: "neutral",
68
- icon: <Google />,
69
- },
70
- ],
71
- };
72
- return (<Matrix {...props}>
73
- {props => <Icon {...props}/>}
74
- </Matrix>);
75
- };
76
- svg.story = {
77
- name: "svg icons",
78
- };
@@ -1,4 +0,0 @@
1
- export { default as Icon } from "./icon";
2
- export { default as IconButton } from "./icon-button";
3
- export { default as IconButtonGroup } from "./icon-button-group";
4
- export { default as ToggleButton } from "./toggle-button";
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- import classnames from "classnames";
3
- import css from "styled-jsx/css";
4
- function MaterialIcon({ icon, iconSet, className, size = "24px", ...rest }) {
5
- const scope = css.resolve `
6
- i {
7
- font-size: ${size};
8
- }
9
- `;
10
- return (<i className={classnames(className, iconSet, scope.className)} {...rest}>
11
- {icon}
12
- {scope.styles}
13
- </i>);
14
- }
15
- MaterialIcon.defaultProps = {
16
- iconSet: "material-icons",
17
- };
18
- export default MaterialIcon;
@@ -1,29 +0,0 @@
1
- import React, { forwardRef, useState } from "react";
2
- import MDCIconButton, { IconToggle, } from "@material/react-icon-button";
3
- const ToggleButton = forwardRef(function ToggleButton({ active, inactive, value, onChange, onClick, ...rest }, ref) {
4
- const [initialValue] = useState(value);
5
- const handleClick = (e) => {
6
- if (onChange) {
7
- e.preventDefault();
8
- onChange(!value);
9
- }
10
- else {
11
- onClick(e);
12
- }
13
- };
14
- const props = {
15
- onClick: handleClick,
16
- ref,
17
- // aria-pressed controls whether or not the button is in the 'pressed' state
18
- // however the icon that shows does not respect this, the icon that is set to isOn will always show first,
19
- // regardless of the aria-pressed state
20
- // as a workaround the initial value is captured and used to decide which IconToggle represents the 'on' state
21
- "aria-pressed": value,
22
- ...rest,
23
- };
24
- return (<MDCIconButton {...props}>
25
- <IconToggle isOn={initialValue}>{active}</IconToggle>
26
- <IconToggle isOn={!initialValue}>{inactive}</IconToggle>
27
- </MDCIconButton>);
28
- });
29
- export default ToggleButton;
@@ -1,16 +0,0 @@
1
- import React, { useState } from "react";
2
- import CenterDecorator from "../../utils/center-decorator";
3
- import ToggleButton from "./toggle-button";
4
- import Icon from "./icon";
5
- function StatefulToggleButton(props) {
6
- const [state, setState] = useState(true);
7
- return <ToggleButton value={state} onChange={setState} {...props}/>;
8
- }
9
- export default {
10
- title: "ToggleButton",
11
- decorators: [CenterDecorator],
12
- };
13
- export const toggleButton = () => (<StatefulToggleButton active={<Icon icon="favorite_outline"/>} inactive={<Icon icon="favorite"/>}/>);
14
- toggleButton.story = {
15
- name: "default",
16
- };
@@ -1,27 +0,0 @@
1
- /* Public component exports */
2
- /* Please keep these sorted alphabetically */
3
- export * from "./anchor";
4
- export * from "./avatar";
5
- export * from "./button";
6
- export * from "./chips";
7
- export * from "./checkbox";
8
- export * from "./cropper";
9
- export * from "./combo-field";
10
- export * from "./date-picker";
11
- export * from "./elevation";
12
- export * from "./field-helpers";
13
- export * from "./icon";
14
- export * from "./layout";
15
- export * from "./list";
16
- export * from "./menu";
17
- export * from "./modal";
18
- export * from "./navigation";
19
- export * from "./phone-number-field";
20
- export * from "./radio";
21
- export * from "./select";
22
- export * from "./statistics";
23
- export * from "./switch";
24
- export * from "./tabs";
25
- export * from "./text-field";
26
- export * from "./text";
27
- export * from "./uploader";
@@ -1,58 +0,0 @@
1
- import React from "react";
2
- import cn from "classnames";
3
- import css from "styled-jsx/css";
4
- function Box({ as = "div", ma, mv, mh, mt, mr, mb, ml, pa, pv, ph, pt, pb, pl, pr, className, children, ...rest }) {
5
- const margin = getSpacingStyles("margin", "m", {
6
- ma,
7
- mv,
8
- mh,
9
- mt,
10
- mr,
11
- mb,
12
- ml,
13
- });
14
- const padding = getSpacingStyles("padding", "p", {
15
- pa,
16
- pv,
17
- ph,
18
- pt,
19
- pb,
20
- pl,
21
- pr,
22
- });
23
- const scope = css.resolve `
24
- .box {
25
- ${margin}
26
- ${padding}
27
- }
28
- `;
29
- return React.createElement(as, { className: cn("box", className, scope.className), ...rest }, children, scope.styles);
30
- }
31
- export default Box;
32
- function getSpacingStyles(attr, prefix, obj) {
33
- const result = [];
34
- if (obj[prefix + "a"]) {
35
- result.push(`${attr}: ${obj[prefix + "a"]};`);
36
- }
37
- if (obj[prefix + "v"]) {
38
- result.push(`${attr}-top: ${obj[prefix + "v"]};`);
39
- result.push(`${attr}-bottom: ${obj[prefix + "v"]};`);
40
- }
41
- if (obj[prefix + "h"]) {
42
- result.push(`${attr}-left: ${obj[prefix + "h"]};`);
43
- result.push(`${attr}-right: ${obj[prefix + "h"]};`);
44
- }
45
- if (obj[prefix + "t"]) {
46
- result.push(`${attr}-top: ${obj[prefix + "t"]};`);
47
- }
48
- if (obj[prefix + "r"]) {
49
- result.push(`${attr}-right: ${obj[prefix + "r"]};`);
50
- }
51
- if (obj[prefix + "b"]) {
52
- result.push(`${attr}-bottom: ${obj[prefix + "b"]};`);
53
- }
54
- if (obj[prefix + "l"]) {
55
- result.push(`${attr}-left: ${obj[prefix + "l"]};`);
56
- }
57
- return result.join("\n");
58
- }
@@ -1,55 +0,0 @@
1
- import React from "react";
2
- import classnames from "classnames";
3
- import css from "styled-jsx/css";
4
- import Box from "./box";
5
- function Flex({ direction = "row", justify = "start", align = "start", reverse = false, wrap = false, center, className, children, ...rest }) {
6
- if (center) {
7
- justify = "center";
8
- align = "center";
9
- }
10
- const scope = css.resolve `
11
- .flex {
12
- display: flex;
13
- flex-direction: ${getFlexDirection(direction, reverse)};
14
- justify-content: ${getFlexJustifyContent(justify)};
15
- align-items: ${getFlexAlignItems(align)};
16
- flex-wrap: ${getFlexWrap(wrap)};
17
- }
18
- `;
19
- return (<Box className={classnames("flex", className, scope.className)} {...rest}>
20
- {children}
21
- {scope.styles}
22
- </Box>);
23
- }
24
- Flex.defaultProps = {
25
- direction: "row",
26
- justify: "start",
27
- align: "start",
28
- reverse: false,
29
- wrap: false,
30
- };
31
- export default Flex;
32
- function getFlexDirection(direction, reverse) {
33
- return reverse ? direction + "-reverse" : direction;
34
- }
35
- function getFlexJustifyContent(justify) {
36
- switch (justify) {
37
- case "start":
38
- case "end":
39
- return "flex-" + justify;
40
- default:
41
- return justify;
42
- }
43
- }
44
- function getFlexAlignItems(align) {
45
- switch (align) {
46
- case "start":
47
- case "end":
48
- return "flex-" + align;
49
- default:
50
- return align;
51
- }
52
- }
53
- function getFlexWrap(wrap) {
54
- return wrap ? "wrap" : "nowrap";
55
- }
@@ -1,44 +0,0 @@
1
- import React from "react";
2
- import { withKnobs, select, boolean, number } from "@storybook/addon-knobs";
3
- import CenterDecorator from "../../utils/center-decorator";
4
- import Flex from "./flex";
5
- export default {
6
- title: "Flex",
7
- decorators: [CenterDecorator],
8
- };
9
- function Placeholder({ children }) {
10
- return (<div className="placeholder">
11
- {children}
12
- <style jsx>{`
13
- .placeholder {
14
- width: 120px;
15
- height: 2.5rem;
16
- border: 1px dotted #e0e0e0;
17
- display: flex;
18
- align-items: center;
19
- justify-content: center;
20
- }
21
- `}</style>
22
- </div>);
23
- }
24
- export const FlexStory = () => (<div style={{
25
- width: number("width", 300) + "px",
26
- height: number("height", 300) + "px",
27
- border: "1px dotted #e0e0e0",
28
- }}>
29
- <Flex direction={select("direction", ["row", "column"], "row")} justify={select("justify", [
30
- "center",
31
- "start",
32
- "end",
33
- "space-between",
34
- "space-around",
35
- "space-evenly",
36
- "stretch",
37
- ], "center")} align={select("align", ["center", "start", "end", "stretch"], "start")} reverse={boolean("reverse", false)} wrap={boolean("wrap", false)}>
38
- {[1, 2, 3, 4].map(n => (<Placeholder key={n}>{n}</Placeholder>))}
39
- </Flex>
40
- </div>);
41
- FlexStory.story = {
42
- name: "default",
43
- decorators: [withKnobs],
44
- };
@@ -1,19 +0,0 @@
1
- import React from "react";
2
- import cn from "classnames";
3
- import css from "styled-jsx/css";
4
- import Box from "./box";
5
- function Grid({ columns = "auto", rows = "auto", gap = "0", className, children, ...rest }) {
6
- const scope = css.resolve `
7
- .grid {
8
- display: grid;
9
- grid-template-columns: ${columns};
10
- grid-template-rows: ${rows};
11
- grid-gap: ${gap};
12
- }
13
- `;
14
- return (<Box className={cn("grid", scope.className, className)} {...rest}>
15
- {children}
16
- {scope.styles}
17
- </Box>);
18
- }
19
- export default Grid;
@@ -1,29 +0,0 @@
1
- import React from "react";
2
- import Grid from "./grid";
3
- import CenterDecorator from "../../utils/grid-decorator";
4
- export default {
5
- title: "Grid",
6
- decorators: [CenterDecorator],
7
- };
8
- export const GridStory = () => {
9
- return (<div>
10
- <Grid columns="repeat(2, 1fr)" gap="1rem">
11
- <div className="item"></div>
12
- <div className="item"></div>
13
- <div className="item"></div>
14
- <div className="item"></div>
15
- <div className="item"></div>
16
- </Grid>
17
- <style jsx>{`
18
- .item {
19
- width: 100px;
20
- height: 100px;
21
- border: 1px solid #e0e0e0;
22
- background-color: white;
23
- }
24
- `}</style>
25
- </div>);
26
- };
27
- GridStory.story = {
28
- name: "default",
29
- };
@@ -1,4 +0,0 @@
1
- export { default as Box } from "./box";
2
- export { default as Flex } from "./flex";
3
- export { default as Grid } from "./grid";
4
- export { default as Stack } from "./stack";
@@ -1,33 +0,0 @@
1
- import React from "react";
2
- import classnames from "classnames";
3
- import Flex from "./flex";
4
- import css from "styled-jsx/css";
5
- function Stack({ gap, direction, reverse, className, children, ...rest }) {
6
- const scope = css.resolve `
7
- .stack-row:not(.stack-reverse) > :global(*:not(:last-child)) {
8
- margin-right: ${gap};
9
- }
10
-
11
- .stack-row.stack-reverse > :global(*:not(:last-child)) {
12
- margin-left: ${gap};
13
- }
14
-
15
- .stack-column:not(.stack-reverse) > :global(*:not(:last-child)) {
16
- margin-bottom: ${gap};
17
- }
18
-
19
- .stack-column.stack-everse > :global(*:not(:last-child)) {
20
- margin-top: ${gap};
21
- }
22
- `;
23
- return (<Flex className={classnames("stack", `stack-${direction}`, reverse && "stack-reverse", className, scope.className)} reverse={reverse} direction={direction} {...rest}>
24
- {children}
25
- {scope.styles}
26
- </Flex>);
27
- }
28
- Stack.defaultProps = {
29
- gap: "1rem",
30
- direction: "row",
31
- reverse: false,
32
- };
33
- export default Stack;
@@ -1,40 +0,0 @@
1
- import React from "react";
2
- import CenterDecorator from "../../utils/center-decorator";
3
- import Stack from "./stack";
4
- export default {
5
- title: "Stack",
6
- decorators: [CenterDecorator],
7
- };
8
- function Placeholder({ children }) {
9
- return (<div className="placeholder">
10
- {children}
11
- <style jsx>{`
12
- .placeholder {
13
- width: 120px;
14
- height: 2.5rem;
15
- border: 1px dotted #e0e0e0;
16
- display: flex;
17
- align-items: center;
18
- justify-content: center;
19
- }
20
- `}</style>
21
- </div>);
22
- }
23
- export const stack = () => (<Stack>
24
- {[1, 2, 3, 4].map(n => (<Placeholder key={n}>{n}</Placeholder>))}
25
- </Stack>);
26
- stack.story = {
27
- name: "default",
28
- };
29
- export const reverse = () => (<Stack reverse>
30
- {[1, 2, 3, 4].map(n => (<Placeholder key={n}>{n}</Placeholder>))}
31
- </Stack>);
32
- reverse.story = {
33
- name: "reverse",
34
- };
35
- export const vertical = () => (<Stack direction="column">
36
- {[1, 2, 3, 4].map(n => (<Placeholder key={n}>{n}</Placeholder>))}
37
- </Stack>);
38
- vertical.story = {
39
- name: "vertical",
40
- };