@mycause/ui 0.0.0-c7de8cef → 0.0.0-c7f1270a

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 +106 -0
  2. package/README.md +9 -0
  3. package/dist/components/campaign-card/campaign-card.d.ts +9 -0
  4. package/dist/components/campaign-card/campaign-card.stories.d.ts +14 -0
  5. package/dist/components/campaign-card/index.d.ts +1 -0
  6. package/dist/components/campaign-of-month/campaign-of-month.d.ts +14 -0
  7. package/dist/components/campaign-of-month/campaign-of-month.stories.d.ts +14 -0
  8. package/dist/components/campaign-of-month/index.d.ts +1 -0
  9. package/dist/components/charity-card/charity-card.d.ts +7 -0
  10. package/dist/components/charity-card/charity-card.stories.d.ts +14 -0
  11. package/dist/components/charity-card/index.d.ts +1 -0
  12. package/dist/components/combo-field/combo-field.d.ts +4 -1
  13. package/dist/components/comment-section/comment-section-v2/comment-section-v2.d.ts +31 -0
  14. package/dist/components/comment-section/comment-section-v2/sub-comments-v2.d.ts +11 -0
  15. package/dist/components/comment-section/comment-section.d.ts +1 -0
  16. package/dist/components/comment-section/comment-section.stories.d.ts +6 -0
  17. package/dist/components/comment-section/index.d.ts +1 -0
  18. package/dist/components/date-picker/single-date-picker.d.ts +3 -2
  19. package/dist/components/donate-card/donate-card.d.ts +8 -0
  20. package/dist/components/donate-card/donate-card.stories.d.ts +14 -0
  21. package/dist/components/donate-card/index.d.ts +1 -0
  22. package/dist/components/donation-form/donation-details.d.ts +12 -0
  23. package/dist/components/donation-form/donation-form-v2/donation-form-v2.d.ts +13 -0
  24. package/dist/components/donation-form/donation-form.d.ts +64 -0
  25. package/dist/components/donation-form/donation-form.stories.d.ts +18 -0
  26. package/dist/components/donation-form/donation-payment.d.ts +13 -0
  27. package/dist/components/donation-form/donation-select.d.ts +13 -0
  28. package/dist/components/donation-form/index.d.ts +2 -0
  29. package/dist/components/featured-campaign-card/featured-campaign-card.d.ts +17 -0
  30. package/dist/components/featured-campaign-card/featured-campaign-card.stories.d.ts +14 -0
  31. package/dist/components/featured-campaign-card/index.d.ts +1 -0
  32. package/dist/components/footerV2/footerV2.d.ts +35 -0
  33. package/dist/components/footerV2/footerV2.stories.d.ts +15 -0
  34. package/dist/components/footerV2/index.d.ts +1 -0
  35. package/dist/components/fundraising-section/fundraising-section.d.ts +9 -0
  36. package/dist/components/fundraising-section/fundraising-section.stories.d.ts +14 -0
  37. package/dist/components/fundraising-section/index.d.ts +1 -0
  38. package/dist/components/hero-banner/hero-banner.d.ts +9 -0
  39. package/dist/components/hero-banner/hero-banner.stories.d.ts +14 -0
  40. package/dist/components/hero-banner/index.d.ts +1 -0
  41. package/dist/components/horizontalbar/horizontalbar.d.ts +11 -0
  42. package/dist/components/horizontalbar/horizontalbar.stories.d.ts +26 -0
  43. package/dist/components/horizontalbar/index.d.ts +1 -0
  44. package/dist/components/icon/{toggle-button.d.ts → heart-toggle.d.ts} +3 -3
  45. package/dist/components/icon/{toggle-button.stories.d.ts → heart-toggle.stories.d.ts} +1 -1
  46. package/dist/components/icon/index.d.ts +1 -1
  47. package/dist/components/index.d.ts +14 -0
  48. package/dist/components/info-represent-campaign/index.d.ts +1 -0
  49. package/dist/components/info-represent-campaign/info-represent-campaign.d.ts +11 -0
  50. package/dist/components/{phone-number-field/phone-number-field.stories.d.ts → info-represent-campaign/info-represent-campaign.stories.d.ts} +1 -1
  51. package/dist/components/list/list.d.ts +7 -2
  52. package/dist/components/list/list.stories.d.ts +2 -2
  53. package/dist/components/logo/logo-type.d.ts +2 -1
  54. package/dist/components/modal/modal.d.ts +1 -1
  55. package/dist/components/nav/icons/IconBigger.d.ts +5 -0
  56. package/dist/components/nav/icons/IconSmaller.d.ts +5 -0
  57. package/dist/components/nav/index.d.ts +1 -0
  58. package/dist/components/nav/nav-actions.d.ts +5 -0
  59. package/dist/components/nav/nav-bar.d.ts +7 -0
  60. package/dist/components/nav/nav-call-to-action.d.ts +5 -0
  61. package/dist/components/nav/nav-expanded-charity.d.ts +13 -0
  62. package/dist/components/nav/nav-expanded.d.ts +14 -0
  63. package/dist/components/nav/nav-list.d.ts +29 -0
  64. package/dist/components/nav/nav-menu-control.d.ts +8 -0
  65. package/dist/components/nav/nav-menu.d.ts +12 -0
  66. package/dist/components/nav/nav-search-control.d.ts +8 -0
  67. package/dist/components/nav/nav-search.d.ts +10 -0
  68. package/dist/components/nav/nav-sign-in-control.d.ts +12 -0
  69. package/dist/components/nav/nav-user-menu-items.d.ts +20 -0
  70. package/dist/components/nav/nav-user-menu.d.ts +18 -0
  71. package/dist/components/nav/nav.d.ts +56 -0
  72. package/dist/components/nav/nav.stories.d.ts +11 -0
  73. package/dist/components/navigation/navigation-list.d.ts +3 -1
  74. package/dist/components/navigation/navigation-sign-in-control.d.ts +3 -2
  75. package/dist/components/navigation/navigation.d.ts +2 -0
  76. package/dist/components/navigation/navigation.stories.d.ts +6 -0
  77. package/dist/components/partner-dashboard-chart/chart.d.ts +3 -0
  78. package/dist/components/{phone-number-input/phone-number-field.stories.d.ts → partner-dashboard-chart/chart.stories.d.ts} +2 -1
  79. package/dist/components/partner-dashboard-chart/index.d.ts +1 -0
  80. package/dist/components/phone-number-input/phone-number-input.d.ts +2 -1
  81. package/dist/components/popup/index.d.ts +1 -0
  82. package/dist/components/popup/popup.d.ts +8 -0
  83. package/dist/components/popup/popup.stories.d.ts +14 -0
  84. package/dist/components/progressbar/index.d.ts +1 -0
  85. package/dist/components/progressbar/progressbar.d.ts +8 -0
  86. package/dist/components/progressbar/progressbar.stories.d.ts +14 -0
  87. package/dist/components/select/select.d.ts +2 -1
  88. package/dist/components/start-campaign-card/index.d.ts +1 -0
  89. package/dist/components/start-campaign-card/start-campaign-card.d.ts +8 -0
  90. package/dist/components/start-campaign-card/start-campaign-card.stories.d.ts +14 -0
  91. package/dist/components/statistics/statistics.d.ts +2 -1
  92. package/dist/components/tabs/nav-tabs.d.ts +18 -0
  93. package/dist/components/text-field/index.d.ts +1 -0
  94. package/dist/components/text-field/text-field-search.d.ts +9 -0
  95. package/dist/components/text-field/text-field.d.ts +1 -0
  96. package/dist/components/text-field/text-field.stories.d.ts +6 -0
  97. package/dist/index.esm.js +21647 -1735
  98. package/dist/index.js +21664 -1735
  99. package/dist/theme/theme.d.ts +4 -0
  100. package/package.json +1 -1
  101. package/styles/index.css +4 -0
  102. package/dist/components/anchor/anchor.jsx +0 -35
  103. package/dist/components/anchor/anchor.stories.jsx +0 -12
  104. package/dist/components/anchor/bold-anchor.jsx +0 -33
  105. package/dist/components/anchor/bold-anchor.stories.jsx +0 -11
  106. package/dist/components/anchor/index.js +0 -2
  107. package/dist/components/avatar/avatar.jsx +0 -14
  108. package/dist/components/avatar/avatar.stories.jsx +0 -17
  109. package/dist/components/avatar/image-avatar.jsx +0 -29
  110. package/dist/components/avatar/index.js +0 -1
  111. package/dist/components/avatar/text-avatar.jsx +0 -47
  112. package/dist/components/button/button.jsx +0 -85
  113. package/dist/components/button/button.stories.jsx +0 -118
  114. package/dist/components/button/index.js +0 -1
  115. package/dist/components/button-select/button-select.jsx +0 -34
  116. package/dist/components/button-select/button-select.stories.jsx +0 -39
  117. package/dist/components/button-select/index.js +0 -1
  118. package/dist/components/checkbox/checkbox.jsx +0 -39
  119. package/dist/components/checkbox/checkbox.stories.jsx +0 -42
  120. package/dist/components/checkbox/index.js +0 -1
  121. package/dist/components/chips/chip.jsx +0 -30
  122. package/dist/components/chips/chips.jsx +0 -16
  123. package/dist/components/chips/chips.stories.jsx +0 -35
  124. package/dist/components/chips/index.js +0 -3
  125. package/dist/components/chips/input-chips.jsx +0 -16
  126. package/dist/components/chips/input-chips.stories.jsx +0 -39
  127. package/dist/components/combo-field/combo-field-expander.jsx +0 -23
  128. package/dist/components/combo-field/combo-field.jsx +0 -93
  129. package/dist/components/combo-field/combo-field.stories.jsx +0 -62
  130. package/dist/components/combo-field/index.js +0 -2
  131. package/dist/components/comment-section/comment-section.jsx +0 -95
  132. package/dist/components/comment-section/comment-section.stories.jsx +0 -97
  133. package/dist/components/comment-section/index.js +0 -1
  134. package/dist/components/cropper/cropper.jsx +0 -10
  135. package/dist/components/cropper/cropper.stories.jsx +0 -18
  136. package/dist/components/cropper/index.js +0 -1
  137. package/dist/components/date-picker/date-picker.jsx +0 -74
  138. package/dist/components/date-picker/date-picker.stories.jsx +0 -46
  139. package/dist/components/date-picker/index.js +0 -2
  140. package/dist/components/date-picker/single-date-picker.jsx +0 -81
  141. package/dist/components/elevation/elevation.jsx +0 -24
  142. package/dist/components/elevation/elevation.stories.jsx +0 -31
  143. package/dist/components/elevation/index.js +0 -1
  144. package/dist/components/field-helpers/field-helper-text.jsx +0 -42
  145. package/dist/components/field-helpers/field-label.jsx +0 -29
  146. package/dist/components/field-helpers/index.js +0 -2
  147. package/dist/components/icon/btn_google_light_normal_ios.svg.jsx +0 -22
  148. package/dist/components/icon/facebook_6.svg.jsx +0 -14
  149. package/dist/components/icon/icon-button-group.jsx +0 -51
  150. package/dist/components/icon/icon-button-group.stories.jsx +0 -26
  151. package/dist/components/icon/icon-button.jsx +0 -48
  152. package/dist/components/icon/icon-button.stories.jsx +0 -33
  153. package/dist/components/icon/icon.jsx +0 -49
  154. package/dist/components/icon/icon.stories.jsx +0 -78
  155. package/dist/components/icon/index.js +0 -4
  156. package/dist/components/icon/material-icon.jsx +0 -18
  157. package/dist/components/icon/toggle-button.jsx +0 -29
  158. package/dist/components/icon/toggle-button.stories.jsx +0 -16
  159. package/dist/components/index.js +0 -28
  160. package/dist/components/layout/box.jsx +0 -58
  161. package/dist/components/layout/flex.jsx +0 -55
  162. package/dist/components/layout/flex.stories.jsx +0 -44
  163. package/dist/components/layout/grid.jsx +0 -19
  164. package/dist/components/layout/grid.stories.jsx +0 -29
  165. package/dist/components/layout/index.js +0 -4
  166. package/dist/components/layout/stack.jsx +0 -33
  167. package/dist/components/layout/stack.stories.jsx +0 -40
  168. package/dist/components/list/index.js +0 -1
  169. package/dist/components/list/list.jsx +0 -55
  170. package/dist/components/list/list.stories.jsx +0 -135
  171. package/dist/components/logo/index.js +0 -1
  172. package/dist/components/logo/logo-type.jsx +0 -65
  173. package/dist/components/menu/index.js +0 -8
  174. package/dist/components/menu/menu-list-divider.jsx +0 -2
  175. package/dist/components/menu/menu-list-item-graphic.jsx +0 -2
  176. package/dist/components/menu/menu-list-item-meta.jsx +0 -2
  177. package/dist/components/menu/menu-list-item-text.jsx +0 -2
  178. package/dist/components/menu/menu-list-item.jsx +0 -11
  179. package/dist/components/menu/menu-list.jsx +0 -18
  180. package/dist/components/menu/menu-surface.jsx +0 -4
  181. package/dist/components/menu/menu.jsx +0 -2
  182. package/dist/components/menu/menu.stories.jsx +0 -42
  183. package/dist/components/modal/index.js +0 -1
  184. package/dist/components/modal/modal.jsx +0 -49
  185. package/dist/components/modal/modal.stories.jsx +0 -59
  186. package/dist/components/navigation/index.js +0 -1
  187. package/dist/components/navigation/navigation-actions.jsx +0 -8
  188. package/dist/components/navigation/navigation-bar.jsx +0 -42
  189. package/dist/components/navigation/navigation-call-to-action.jsx +0 -6
  190. package/dist/components/navigation/navigation-expanded.jsx +0 -165
  191. package/dist/components/navigation/navigation-list.jsx +0 -126
  192. package/dist/components/navigation/navigation-menu-control.jsx +0 -25
  193. package/dist/components/navigation/navigation-menu.jsx +0 -126
  194. package/dist/components/navigation/navigation-search-control.jsx +0 -8
  195. package/dist/components/navigation/navigation-search.jsx +0 -63
  196. package/dist/components/navigation/navigation-sign-in-control.jsx +0 -14
  197. package/dist/components/navigation/navigation-user-menu-items.jsx +0 -36
  198. package/dist/components/navigation/navigation-user-menu.jsx +0 -121
  199. package/dist/components/navigation/navigation.jsx +0 -137
  200. package/dist/components/navigation/navigation.stories.jsx +0 -270
  201. package/dist/components/phone-number-field/index.d.ts +0 -2
  202. package/dist/components/phone-number-field/index.js +0 -2
  203. package/dist/components/phone-number-field/phone-number-field.d.ts +0 -23
  204. package/dist/components/phone-number-field/phone-number-field.jsx +0 -50
  205. package/dist/components/phone-number-field/phone-number-field.stories.jsx +0 -23
  206. package/dist/components/phone-number-field/util.d.ts +0 -2
  207. package/dist/components/phone-number-field/util.js +0 -19
  208. package/dist/components/phone-number-input/index.js +0 -2
  209. package/dist/components/phone-number-input/phone-number-field.d.ts +0 -23
  210. package/dist/components/phone-number-input/phone-number-field.jsx +0 -50
  211. package/dist/components/phone-number-input/phone-number-field.stories.jsx +0 -16
  212. package/dist/components/phone-number-input/phone-number-input.jsx +0 -75
  213. package/dist/components/phone-number-input/phone-number-input.stories.jsx +0 -23
  214. package/dist/components/phone-number-input/util.js +0 -19
  215. package/dist/components/radio/index.js +0 -2
  216. package/dist/components/radio/radio-group.jsx +0 -9
  217. package/dist/components/radio/radio-group.stories.jsx +0 -21
  218. package/dist/components/radio/radio.jsx +0 -31
  219. package/dist/components/radio/radio.stories.jsx +0 -44
  220. package/dist/components/select/index.js +0 -2
  221. package/dist/components/select/select-helper-text.jsx +0 -6
  222. package/dist/components/select/select.jsx +0 -150
  223. package/dist/components/select/select.stories.jsx +0 -40
  224. package/dist/components/statistics/index.js +0 -1
  225. package/dist/components/statistics/statistics.jsx +0 -61
  226. package/dist/components/statistics/statistics.stories.jsx +0 -34
  227. package/dist/components/switch/index.js +0 -1
  228. package/dist/components/switch/switch.jsx +0 -32
  229. package/dist/components/switch/switch.stories.jsx +0 -41
  230. package/dist/components/tabs/index.js +0 -1
  231. package/dist/components/tabs/tab-bar.jsx +0 -35
  232. package/dist/components/tabs/tab-text-label.jsx +0 -5
  233. package/dist/components/tabs/tab.jsx +0 -50
  234. package/dist/components/tabs/tabs.jsx +0 -65
  235. package/dist/components/tabs/tabs.stories.jsx +0 -27
  236. package/dist/components/text/index.js +0 -1
  237. package/dist/components/text/text.jsx +0 -138
  238. package/dist/components/text/text.stories.jsx +0 -262
  239. package/dist/components/text-field/index.js +0 -2
  240. package/dist/components/text-field/text-field-helper-text.jsx +0 -8
  241. package/dist/components/text-field/text-field.jsx +0 -124
  242. package/dist/components/text-field/text-field.stories.jsx +0 -32
  243. package/dist/components/uploader/index.js +0 -1
  244. package/dist/components/uploader/uploader.jsx +0 -96
  245. package/dist/input.d.ts +0 -1
  246. package/dist/input.js +0 -4
  247. package/dist/input.jsx +0 -4
  248. package/dist/theme/colors.js +0 -9
  249. package/dist/theme/index.js +0 -2
  250. package/dist/theme/mycause-theme.js +0 -33
  251. package/dist/theme/theme.jsx +0 -36
  252. package/dist/utils/browser.js +0 -19
  253. package/dist/utils/center-decorator.jsx +0 -15
  254. package/dist/utils/component-matrix.jsx +0 -39
  255. package/dist/utils/flags.js +0 -18
  256. package/dist/utils/grid-decorator.jsx +0 -27
  257. package/dist/utils/tap-event.js +0 -11
  258. package/dist/utils/wrap.js +0 -8
@@ -1,14 +0,0 @@
1
- import React from "react";
2
- import classnames from "classnames";
3
- import { Button } from "../button";
4
- import { IconButton, Icon } from "../icon";
5
- function NavigationSignInControl({ analyticsId, onRequestSignIn, compact, className, ...rest }) {
6
- return (<div className={classnames("sign-in-control", className)} {...rest}>
7
- {!compact ? (<Button analyticsId={analyticsId} className="sign-in-button" color="neutral" icon={<Icon icon="perm_identity" color="accent"/>} onClick={() => onRequestSignIn()} display>
8
- Login
9
- </Button>) : (<IconButton id={analyticsId} title="Sign in" color="accent" onClick={() => onRequestSignIn()}>
10
- <Icon icon="perm_identity"/>
11
- </IconButton>)}
12
- </div>);
13
- }
14
- export default NavigationSignInControl;
@@ -1,36 +0,0 @@
1
- import React, { Fragment, useState } from "react";
2
- import Icon from "../icon/icon";
3
- import { MenuListItem, MenuListItemText, MenuListItemGraphic, MenuListItemMeta, } from "../menu";
4
- function NavigationUserMenuItem({ icon, label, onClick, submenu, isSubmenuOpen, ...rest }) {
5
- return (<Fragment>
6
- <MenuListItem onClick={onClick} {...rest}>
7
- <MenuListItemGraphic graphic={<Icon color="primary" {...icon}/>}/>
8
- <MenuListItemText primaryText={label}/>
9
- {submenu ? (<MenuListItemMeta meta={<Icon color="primary" icon={isSubmenuOpen ? "keyboard_arrow_up" : "keyboard_arrow_down"}/>}/>) : null}
10
- </MenuListItem>
11
- {submenu && isSubmenuOpen
12
- ? submenu.map(subItem => (<MenuListItem key={subItem.id || subItem.href} {...subItem}>
13
- <MenuListItemText primaryText={subItem.label} className="icon-submenu"/>
14
- </MenuListItem>))
15
- : null}
16
- </Fragment>);
17
- }
18
- function NavigationUserMenuItems({ items }) {
19
- // To keep track of which submenu (if any) is open at any time
20
- // There can be only one open at a time
21
- const [activeSubmenu, setActiveSubmenu] = useState(-1);
22
- const handleClick = (index, item) => {
23
- if (item.submenu) {
24
- setActiveSubmenu(activeSubmenu === index ? -1 : index);
25
- }
26
- else if (item.onClick) {
27
- item.onClick();
28
- }
29
- };
30
- return (<Fragment>
31
- {items.map((item, i) => {
32
- return (<NavigationUserMenuItem key={item.id || item.href || i} id={item.id || item.href} isSubmenuOpen={item.submenu && activeSubmenu === i} {...item} onClick={() => handleClick(i, item)}/>);
33
- })}
34
- </Fragment>);
35
- }
36
- export default NavigationUserMenuItems;
@@ -1,121 +0,0 @@
1
- import React, { useState, useEffect } from "react";
2
- import classnames from "classnames";
3
- import useMedia from "use-media";
4
- import Avatar from "../avatar/avatar";
5
- import { useTheme } from "../../theme/theme";
6
- import { MenuList, MenuListItem, MenuListItemText } from "../menu";
7
- import NavigationUserMenuItems from "./navigation-user-menu-items";
8
- function NavigationUserMenu({ user, items, isOpen, onChangeOpen, }) {
9
- const theme = useTheme();
10
- // Allow users with pointing devices to open/close the menu by hovering in/out
11
- const [isHovered, bind] = useHover();
12
- useEffect(() => {
13
- onChangeOpen(isHovered);
14
- }, [onChangeOpen, isHovered]);
15
- return (<div className={classnames("menu-anchor", {
16
- compact: useMedia("screen and (max-width: 425px)"),
17
- })} {...bind()}>
18
- <div className={classnames("menu-trigger", { open: isOpen })}>
19
- <Avatar name={user.name} src={user.avatar ? user.avatar.src : undefined} onClick={() => onChangeOpen(!isOpen)}/>
20
- </div>
21
- {items && isOpen && (<div className="user-menu">
22
- <MenuList>
23
- <MenuListItem>
24
- <MenuListItemText primaryText={<strong>Hello {user.name}!</strong>}/>
25
- </MenuListItem>
26
- <NavigationUserMenuItems items={items}/>
27
- </MenuList>
28
- </div>)}
29
- <style jsx>{`
30
- .menu-trigger {
31
- cursor: pointer;
32
- width: 3rem;
33
- height: 3rem;
34
- display: flex;
35
- justify-content: center;
36
- align-items: center;
37
- border-radius: 0.25rem;
38
- }
39
-
40
- .open {
41
- background-color: #efefef;
42
- }
43
-
44
- .menu-anchor {
45
- position: relative;
46
- overflow: visible;
47
- }
48
-
49
- .menu-anchor.compact {
50
- position: initial;
51
- }
52
-
53
- .user-menu {
54
- position: absolute;
55
- z-index: 1;
56
- top: 100%;
57
- right: 0;
58
- background-color: white;
59
- border-radius: 0.25rem;
60
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12),
61
- 0 1px 4px rgba(0, 0, 0, 0.24);
62
- overflow-x: scroll;
63
- max-height: calc(100vh - 64px);
64
- }
65
-
66
- /* arrow */
67
- .user-menu::before {
68
- display: block;
69
- content: "";
70
- width: 0;
71
- height: 0;
72
- border-left: 8px solid transparent;
73
- border-right: 8px solid transparent;
74
- border-bottom: 8px solid white;
75
- position: absolute;
76
- top: -8px;
77
- right: calc((3rem / 2) - 8px);
78
- }
79
-
80
- .compact .user-menu {
81
- left: 8px;
82
- right: 8px;
83
- top: 3.5rem;
84
- }
85
-
86
- .compact .user-menu::before {
87
- right: calc((3rem / 2) - 8px + 4.5rem);
88
- }
89
-
90
- .user-menu :global(.mdc-list-item__graphic) {
91
- margin-right: 1rem;
92
- }
93
-
94
- .user-menu :global(.mdc-list-item:not(:last-of-type)) {
95
- border-bottom: 1px solid #e0e0e0;
96
- }
97
- `}</style>
98
- <style jsx>{`
99
- .user-menu :global(.mdc-list) {
100
- font-family: ${theme.typography.fontFamily.brand};
101
- }
102
-
103
- strong {
104
- color: ${theme.color.foreground.primary};
105
- }
106
- `}</style>
107
- </div>);
108
- }
109
- export default NavigationUserMenu;
110
- function useHover() {
111
- const [isHovered, setIsHovered] = useState();
112
- const bind = () => ({
113
- onMouseOver: () => {
114
- setIsHovered(true);
115
- },
116
- onMouseLeave: () => {
117
- setIsHovered(false);
118
- },
119
- });
120
- return [isHovered, bind];
121
- }
@@ -1,137 +0,0 @@
1
- import React, { useState } from "react";
2
- import useMedia from "use-media";
3
- import { WHITE } from "../../theme/colors";
4
- import Tabs from "../tabs/tabs";
5
- import NavigationMenu from "./navigation-menu";
6
- import NavigationBar from "./navigation-bar";
7
- import NavigationExpanded from "./navigation-expanded";
8
- import { Statistics } from "../statistics";
9
- import NavigationActions from "./navigation-actions";
10
- import NavigationSearch from "./navigation-search";
11
- import NavigationSearchControl from "./navigation-search-control";
12
- import NavigationSignInControl from "./navigation-sign-in-control";
13
- import NavigationCallToAction from "./navigation-call-to-action";
14
- import NavigationMenuControl from "./navigation-menu-control";
15
- import NavigationUserMenu from "./navigation-user-menu";
16
- function Navigation({ logo, menus, links, stats, cta, user, userMenu, search, login, isSticky, isCompactHeight, }) {
17
- const [isSearchOpen, setSearchOpen] = useState(false);
18
- const [isUserMenuOpen, setUserMenuOpen] = useState();
19
- const [query, setQuery] = useState("");
20
- const [active, setActive] = useState([null, null]);
21
- const isCompact = useMedia("screen and (max-width: 720px)");
22
- const isMedium = useMedia("screen and (max-width: 960px)");
23
- const menu = active[0] && menus ? menus.find(menu => menu.id === active[0]) : null;
24
- const submenu = active[1]
25
- ? menu.items.find(item => "id" in item && item.id === active[1]) &&
26
- menu.items.find(item => "id" in item && item.id === active[1]).submenu
27
- : null;
28
- const handleChangeMenuOpen = (isOpen) => {
29
- if (isOpen) {
30
- setActive(replace(active, 0, menus[0].id));
31
- }
32
- else {
33
- setActive([null, null]);
34
- }
35
- };
36
- return (<nav className="navigation">
37
- <NavigationBar isCompactHeight={isCompactHeight}>
38
- {!(isCompact && isSearchOpen) ? (<div className="logo-wrap">{logo}</div>) : null}
39
- {isSearchOpen && search ? (<>
40
- <NavigationSearch value={query} onChange={setQuery} onSubmit={() => search.onSearch(query)} onCancel={() => setSearchOpen(false)}/>
41
- </>) : (<>
42
- <div className="desktop-tabs">
43
- <Tabs tabs={menus
44
- ? menus.map(item => ({
45
- key: item.id,
46
- label: item.label,
47
- analyticsId: item.analyticsId,
48
- }))
49
- : []} active={active[0]} isCompactHeight={isCompactHeight} onActiveUpdate={id => setActive(replace(active, 0, id))} isMinWidth isMinWidthIndicator large/>
50
- </div>
51
- <NavigationActions>
52
- {search && (<NavigationSearchControl onChangeSearchOpen={setSearchOpen} analyticsId={search.analyticsId}/>)}
53
- {user ? (<NavigationUserMenu user={user} items={userMenu} isOpen={isUserMenuOpen} onChangeOpen={setUserMenuOpen} isCompact={isCompact}/>) : (login && (<NavigationSignInControl compact={isCompact} onRequestSignIn={login.onLogin} analyticsId={login.analyticsId}/>))}
54
- {!isMedium && cta ? <NavigationCallToAction {...cta}/> : null}
55
- {isMedium && menus ? (<NavigationMenuControl isMenuOpen={!!menu} onChangeMenuOpen={handleChangeMenuOpen}/>) : null}
56
- </NavigationActions>
57
- </>)}
58
- </NavigationBar>
59
- {menu ? (<NavigationExpanded links={links} onRequestClose={() => setActive([null, null])} className="navigation-float" banner={stats ? (<Statistics stats={stats} title="We support your cause"/>) : null}>
60
- <div className="mobile-tabs">
61
- <Tabs tabs={menus
62
- ? menus.map(item => ({ key: item.id, label: item.label }))
63
- : []} active={active[0]} onActiveUpdate={id => setActive(replace(active, 0, id))}/>
64
- </div>
65
- <NavigationMenu key={menu.id} links={menu.items.map(item => ({
66
- ...item,
67
- more: !!item.submenu,
68
- }))} sublinks={submenu || null} action={menu.action || null} actionRaised={menu.actionRaised || null} active={active[1]} onClickItem={id => setActive(() => {
69
- if (active[1])
70
- return [active[0], null];
71
- else
72
- return replace(active, 1, id);
73
- })}/>
74
- </NavigationExpanded>) : null}
75
- <style jsx>{`
76
- .navigation {
77
- background-color: ${WHITE};
78
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12),
79
- 0 1px 4px rgba(0, 0, 0, 0.24);
80
- top: 0;
81
- z-index: 10;
82
- position: ${isSticky ? "fixed" : "relative"};
83
- width: 100%;
84
- }
85
-
86
- .logo-wrap {
87
- display: flex;
88
- align-items: center;
89
- justify-content: center;
90
- margin-right: 1rem;
91
- }
92
-
93
- .desktop-tabs {
94
- margin-left: 1rem;
95
- display: none;
96
- }
97
-
98
- .mobile-tabs {
99
- margin: 0 -1rem;
100
- }
101
-
102
- .navigation :global(.navigation-float) {
103
- position: absolute;
104
- top: 100%;
105
- left: 0;
106
- right: 0;
107
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12),
108
- 0 1px 4px rgba(0, 0, 0, 0.24);
109
- }
110
-
111
- @media (min-width: 960px) {
112
- .navigation {
113
- position: relative;
114
- }
115
-
116
- .mobile-tabs {
117
- display: none;
118
- }
119
-
120
- .desktop-tabs {
121
- display: block;
122
- }
123
- }
124
- `}</style>
125
- </nav>);
126
- }
127
- function replace(arr, x, val) {
128
- return arr.map((item, i) => {
129
- if (i === x)
130
- return val;
131
- if (x > 0)
132
- return item;
133
- else
134
- return null;
135
- });
136
- }
137
- export default Navigation;
@@ -1,270 +0,0 @@
1
- import React, { useState } from "react";
2
- import { action } from "@storybook/addon-actions";
3
- import useMedia from "use-media";
4
- import { LogoType } from "../logo";
5
- import Navigation from "./navigation";
6
- import NavigationList from "./navigation-list";
7
- import NavigationMenu from "./navigation-menu";
8
- import NavigationExpanded from "./navigation-expanded";
9
- import NavigationSearch from "./navigation-search";
10
- import avatar from "../avatar/ipet-photo-CfDAo3C3bvQ-unsplash.jpg";
11
- import circle from "../statistics/circle.svg";
12
- function Logo() {
13
- return (<LogoType size={useMedia("screen and (min-width: 720px") ? "large" : undefined}/>);
14
- }
15
- function BackgroundContainer({ children }) {
16
- return (<div className="container">
17
- <div className="content">{children}</div>
18
- <style jsx>{`
19
- .container {
20
- min-height: 100vh;
21
- display: flex;
22
- align-items: center;
23
- justify-content: center;
24
- }
25
-
26
- .content {
27
- width: 100%;
28
- max-width: 1024px;
29
- padding: 2rem 1rem;
30
- background-color: rgba(0, 0, 0, 0.01);
31
- }
32
-
33
- @media (min-width: 720px) {
34
- .content {
35
- padding: 4rem;
36
- }
37
- }
38
- `}</style>
39
- </div>);
40
- }
41
- export default {
42
- title: "Navigation",
43
- };
44
- function NavigationSearchDemo() {
45
- const [value, setValue] = useState("");
46
- return (<NavigationSearch value={value} onChange={setValue} onSubmit={action("search")} onCancel={action("cancel")}/>);
47
- }
48
- function NavigationDemo() {
49
- const [isSignedIn, setSignedIn] = useState(false);
50
- return (<Navigation logo={<Logo />} isSticky={true} menus={[
51
- {
52
- label: "Fundraise",
53
- id: "fundraise",
54
- analyticsId: "fundraise",
55
- items: [
56
- { label: "For a person", id: "person", analyticsId: "person" },
57
- { label: "For a charity", id: "charity" },
58
- { label: "Find a charity", id: "find_charity" },
59
- {
60
- label: "Fundraising ideas",
61
- id: "fundraising_ideas",
62
- submenu: [
63
- { label: "Schools", id: "schools" },
64
- { label: "Cancer", id: "cancer" },
65
- { label: "Pets & animals", id: "pets_animals" },
66
- { label: "Help a friend", id: "help_friend" },
67
- { label: "Marathon runs", id: "marathon" },
68
- { label: "See all fundraising ideas", id: "see all" },
69
- ],
70
- },
71
- { label: "Team fundraising", id: "team_fundraising" },
72
- { label: "How it works", id: "how_it_works" },
73
- ],
74
- actionRaised: {
75
- label: "Are you a charity? Learn More",
76
- id: "expandedRedirect",
77
- analyticsId: "expandedRedirect",
78
- },
79
- },
80
- {
81
- label: "Donate",
82
- id: "donate",
83
- analyticsId: "donate",
84
- items: [
85
- { label: "Donate to a charity", id: "donate" },
86
- { label: "Send a gift card/voucher", id: "gift_card" },
87
- { label: "Pledge your birthday", id: "birthday" },
88
- { label: "Start a giving portfolio", id: "giving_portfolio" },
89
- ],
90
- actionRaised: {
91
- label: "Are you a charity? Learn More",
92
- id: "expandedRedirect",
93
- analyticsId: "expandedRedirect",
94
- },
95
- },
96
- {
97
- label: "Organisation",
98
- id: "organisation",
99
- analyticsId: "organisation",
100
- items: [
101
- {
102
- label: "For your organisation",
103
- id: "organisation",
104
- submenu: [
105
- { label: "Schools", id: "schools" },
106
- { label: "Clubs", id: "clubs" },
107
- { label: "Charity", id: "charity" },
108
- { label: "Event manager", id: "event_manager" },
109
- { label: "Corporate", id: "corporate" },
110
- ],
111
- },
112
- { label: "Fundraising events", id: "events" },
113
- { label: "Donating services", id: "donating_services" },
114
- { label: "Giving days", id: "giving_days" },
115
- { label: "Crowdfunding & appeals", id: "crowdfunding" },
116
- { label: "Peer 2 peer fundraising", id: "peer_fundraising" },
117
- ],
118
- action: {
119
- label: "Become a partner (free)",
120
- id: "become_a_partner",
121
- analyticsId: "becomeAPartner",
122
- },
123
- },
124
- ]} links={[
125
- { label: "About", id: "about" },
126
- { label: "Help", id: "help" },
127
- { label: "Blog & Press", id: "blog-press" },
128
- ]} stats={[
129
- {
130
- label: "Members",
131
- id: "nav-expand-members",
132
- value: "302, 657",
133
- logo: circle,
134
- },
135
- {
136
- label: "Causes",
137
- id: "nav-expand-causes",
138
- value: "68, 553",
139
- logo: circle,
140
- },
141
- {
142
- label: "Raised",
143
- id: "nav-expand-raised",
144
- value: "$100 Million +",
145
- logo: circle,
146
- },
147
- ]} cta={{
148
- color: "primary",
149
- onClick: action("onClick"),
150
- children: "Start fundraising",
151
- analyticsId: "startFundraising",
152
- }} user={isSignedIn
153
- ? {
154
- name: "Adorable Puppy",
155
- avatar: {
156
- src: avatar,
157
- },
158
- }
159
- : null} search={{ onSearch: action("search") }} login={{ onLogin: () => setSignedIn(true) }} userMenu={[
160
- {
161
- icon: { icon: "perm_identity" },
162
- label: "My dashboard",
163
- onClick: action("dashboard"),
164
- },
165
- {
166
- icon: { icon: "favorite_border" },
167
- label: "Activity",
168
- onClick: action("activity"),
169
- submenu: [
170
- {
171
- label: "Fundraising pages",
172
- },
173
- {
174
- label: "Favourite charities",
175
- },
176
- ],
177
- },
178
- {
179
- icon: { icon: "favorite_border" },
180
- label: "My campaigns",
181
- onClick: action("my campaigns"),
182
- },
183
- {
184
- icon: { icon: "settings", iconSet: "material-icons-outlined" },
185
- label: "Account settings",
186
- onClick: action("settings"),
187
- submenu: [
188
- {
189
- label: "Profile",
190
- },
191
- {
192
- label: "Manage Connections",
193
- },
194
- ],
195
- },
196
- {
197
- icon: { icon: "exit_to_app" },
198
- label: "Sign out",
199
- onClick: () => setSignedIn(false),
200
- },
201
- ]}/>);
202
- }
203
- export const full = () => <NavigationDemo />;
204
- full.story = {
205
- name: "full navigation",
206
- };
207
- export const list = () => (<BackgroundContainer>
208
- <NavigationList items={[
209
- { label: "Schools", id: "schools" },
210
- { label: "Cancer", id: "cancer" },
211
- { label: "Pets & animals", id: "pets_animals" },
212
- { label: "Help a friend", id: "help_friend" },
213
- { label: "Marathon runs", id: "marathon" },
214
- { label: "See all fundraising ideas", id: "see all" },
215
- ].map(item => ({ ...item, onClick: () => action("click")(item.id) }))}/>
216
- </BackgroundContainer>);
217
- list.story = {
218
- name: "navigation list",
219
- };
220
- export const listLarge = () => (<BackgroundContainer>
221
- <NavigationList size="large" items={[
222
- { label: "Schools", id: "schools" },
223
- { label: "Cancer", id: "cancer" },
224
- { label: "Pets & animals", id: "pets_animals" },
225
- { label: "Help a friend", id: "help_friend" },
226
- { label: "Marathon runs", id: "marathon" },
227
- { label: "See all fundraising ideas", id: "see all" },
228
- ].map(item => ({ ...item, onClick: () => action("click")(item.id) }))}/>
229
- </BackgroundContainer>);
230
- listLarge.story = {
231
- name: "navigation list (large)",
232
- };
233
- export const menu = () => (<BackgroundContainer>
234
- <NavigationMenu links={[
235
- { label: "For a person", id: "person" },
236
- { label: "For a charity", id: "charity" },
237
- { label: "Find a charity", id: "find_charity" },
238
- { label: "Fundraising ideas", id: "fundraising_ideas", more: true },
239
- { label: "Team fundraising", id: "team_fundraising" },
240
- { label: "How it works", id: "how_it_works" },
241
- ].map(link => ({ ...link, onClick: () => action("click")(link.id) }))} sublinks={[
242
- { label: "Schools", id: "schools" },
243
- { label: "Cancer", id: "cancer" },
244
- { label: "Pets & animals", id: "pets_animals" },
245
- { label: "Help a friend", id: "help_friend" },
246
- { label: "Marathon runs", id: "marathon" },
247
- { label: "See all fundraising ideas", id: "see all" },
248
- ].map(link => ({ ...link, onClick: () => action("click")(link.id) }))} action={{
249
- label: "Start fundraising",
250
- id: "start_fundraising",
251
- onClick: () => action("click")("start_fundraising"),
252
- }} active="fundraising_ideas" onClickItem={action("click")}/>
253
- </BackgroundContainer>);
254
- menu.story = {
255
- name: "navigation menu",
256
- };
257
- export const expanded = () => (<NavigationExpanded links={[
258
- { label: "About", id: "about" },
259
- { label: "Help", id: "help" },
260
- { label: "Blog & Press", id: "blog-press" },
261
- ].map(link => ({ ...link, onClick: () => action("click")(link.id) }))} onRequestClose={() => { }}/>);
262
- expanded.story = {
263
- name: "navigation expanded",
264
- };
265
- export const search = () => (<BackgroundContainer>
266
- <NavigationSearchDemo />
267
- </BackgroundContainer>);
268
- search.story = {
269
- name: "navigation search",
270
- };
@@ -1,2 +0,0 @@
1
- export { default as PhoneNumberField } from "./phone-number-field";
2
- export * from "./util";
@@ -1,2 +0,0 @@
1
- export { default as PhoneNumberField } from "./phone-number-field";
2
- export * from "./util";
@@ -1,23 +0,0 @@
1
- import React from "react";
2
- import { CountryCode } from "libphonenumber-js";
3
- declare type PhoneNumberFieldProps = {
4
- values: {
5
- number: string;
6
- countryCallingCode: string;
7
- country: string;
8
- };
9
- names?: {
10
- number: string;
11
- countryCallingCode: string;
12
- country: string;
13
- };
14
- onChange: (value: string, name: string) => void;
15
- label?: React.ReactNode;
16
- error?: string | null;
17
- onBlur?: (e: React.FocusEvent) => void;
18
- helperText?: React.ReactNode;
19
- required?: boolean;
20
- defaultCountry?: CountryCode;
21
- };
22
- declare function PhoneNumberField({ onChange, values, names, error, onBlur, helperText, label, required, defaultCountry, }: PhoneNumberFieldProps): JSX.Element;
23
- export default PhoneNumberField;
@@ -1,50 +0,0 @@
1
- import React from "react";
2
- import countries from "i18n-iso-countries";
3
- import en from "i18n-iso-countries/langs/en.json";
4
- import { AsYouType } from "libphonenumber-js";
5
- import { FieldLabel, FieldHelperText } from "../field-helpers";
6
- import { ComboField, ComboFieldExpander } from "../combo-field";
7
- import { Box } from "../layout";
8
- import { Select } from "../select";
9
- import { TextField } from "../text-field";
10
- countries.registerLocale(en);
11
- const COUNTRY_CODES = Object.keys(countries.getAlpha2Codes()).sort();
12
- function PhoneNumberField({ onChange, values, names = {
13
- number: "number",
14
- countryCallingCode: "countryCallingCode",
15
- country: "country",
16
- }, error, onBlur, helperText, label, required, defaultCountry = "AU", }) {
17
- const format = (text, c) => {
18
- const typer = new AsYouType(c || defaultCountry);
19
- const formatted = typer.input(text);
20
- let result = typer.getNumber();
21
- if (result && result.isValid()) {
22
- // When the user has typed in a full valid number,
23
- // emit the country calling code and set the country explicitly
24
- onChange(result.country, names.country);
25
- onChange(result.format("NATIONAL"), names.number);
26
- onChange(result.countryCallingCode, names.countryCallingCode);
27
- }
28
- else {
29
- onChange(formatted, names.number);
30
- }
31
- };
32
- const handleCountryChange = (e) => {
33
- onChange(e.target.value || "", names.country);
34
- format(values.number, e.target.value);
35
- };
36
- const handleTextChange = (e) => {
37
- format(e.target.value, values.country);
38
- };
39
- return (<Box>
40
- {label ? <FieldLabel required={required}>{label}</FieldLabel> : null}
41
- <ComboField>
42
- <Select options={COUNTRY_CODES} value={values.country} onChange={handleCountryChange} noArrow onBlur={onBlur} required={required}/>
43
- <ComboFieldExpander>
44
- <TextField type="tel" value={values.number} onChange={handleTextChange} name={names.number} onBlur={onBlur} error={!!error} required={required}/>
45
- </ComboFieldExpander>
46
- </ComboField>
47
- {helperText ? (<FieldHelperText error={error}>{helperText}</FieldHelperText>) : null}
48
- </Box>);
49
- }
50
- export default PhoneNumberField;