@mycause/ui 0.0.0-ce837d6b → 0.0.0-cf96d552
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.
- package/CHANGELOG.md +225 -0
- package/README.md +9 -0
- package/dist/components/button-select/button-select.d.ts +12 -0
- package/dist/components/button-select/button-select.stories.d.ts +13 -0
- package/dist/components/button-select/index.d.ts +1 -0
- package/dist/components/campaign-card/campaign-card.d.ts +9 -0
- package/dist/components/campaign-card/campaign-card.stories.d.ts +14 -0
- package/dist/components/campaign-card/index.d.ts +1 -0
- package/dist/components/campaign-of-month/campaign-of-month.d.ts +12 -0
- package/dist/components/campaign-of-month/campaign-of-month.stories.d.ts +14 -0
- package/dist/components/campaign-of-month/index.d.ts +1 -0
- package/dist/components/campain-card/campain-card.d.ts +9 -0
- package/dist/components/campain-card/campain-card.stories.d.ts +14 -0
- package/dist/components/charity-card/charity-card.d.ts +7 -0
- package/dist/components/charity-card/charity-card.stories.d.ts +14 -0
- package/dist/components/charity-card/index.d.ts +1 -0
- package/dist/components/combo-field/combo-field.d.ts +4 -1
- package/dist/components/comment-section/comment-section.d.ts +23 -0
- package/dist/components/comment-section/comment-section.stories.d.ts +13 -0
- package/dist/components/comment-section/index.d.ts +1 -0
- package/dist/components/comment-section/sub-comments.d.ts +6 -0
- package/dist/components/cropper/cropper.d.ts +5 -4
- package/dist/components/cropper/cropper.stories.d.ts +1 -2
- package/dist/components/date-picker/single-date-picker.d.ts +3 -2
- package/dist/components/donate-card/donate-card.d.ts +8 -0
- package/dist/components/donate-card/donate-card.stories.d.ts +14 -0
- package/dist/components/donate-card/index.d.ts +1 -0
- package/dist/components/donation-form/donation-details.d.ts +12 -0
- package/dist/components/donation-form/donation-form.d.ts +64 -0
- package/dist/components/{phone-number-field/phone-number-field.stories.d.ts → donation-form/donation-form.stories.d.ts} +1 -1
- package/dist/components/donation-form/donation-payment.d.ts +13 -0
- package/dist/components/donation-form/donation-select.d.ts +13 -0
- package/dist/components/donation-form/index.d.ts +1 -0
- package/dist/components/elevation/elevation.d.ts +2 -1
- package/dist/components/featured-campaign-card /featured-campaign-card.d.ts +14 -0
- package/dist/components/featured-campaign-card /featured-campaign-card.stories.d.ts +14 -0
- package/dist/components/featured-campaign-card /index.d.ts +1 -0
- package/dist/components/featured-campain-card /featured-campain-card .stories.d.ts +14 -0
- package/dist/components/featured-campain-card /featured-campain-card.d.ts +14 -0
- package/dist/components/fundraising-section/fundraising-section.d.ts +9 -0
- package/dist/components/fundraising-section/fundraising-section.stories.d.ts +14 -0
- package/dist/components/fundraising-section/index.d.ts +1 -0
- package/dist/components/hero-banner/hero-banner.d.ts +9 -0
- package/dist/components/hero-banner/hero-banner.stories.d.ts +14 -0
- package/dist/components/hero-banner/index.d.ts +1 -0
- package/dist/components/horizontalbar/horizontalbar.d.ts +11 -0
- package/dist/components/horizontalbar/horizontalbar.stories.d.ts +26 -0
- package/dist/components/horizontalbar/index.d.ts +1 -0
- package/dist/components/icon/heart-toggle.d.ts +11 -0
- package/dist/components/icon/heart-toggle.stories.d.ts +13 -0
- package/dist/components/icon/index.d.ts +1 -1
- package/dist/components/index.d.ts +6 -1
- package/dist/components/list/list.d.ts +29 -14
- package/dist/components/list/list.stories.d.ts +8 -2
- package/dist/components/login/index.d.ts +1 -0
- package/dist/components/login/login.d.ts +15 -0
- package/dist/components/login/login.stories.d.ts +19 -0
- package/dist/components/modal/modal.d.ts +4 -3
- package/dist/components/modal/modal.stories.d.ts +6 -0
- package/dist/components/nav/index.d.ts +1 -0
- package/dist/components/nav/nav-actions.d.ts +5 -0
- package/dist/components/nav/nav-bar.d.ts +7 -0
- package/dist/components/nav/nav-call-to-action.d.ts +5 -0
- package/dist/components/nav/nav-expanded.d.ts +11 -0
- package/dist/components/nav/nav-list.d.ts +27 -0
- package/dist/components/nav/nav-menu-control.d.ts +7 -0
- package/dist/components/nav/nav-menu.d.ts +12 -0
- package/dist/components/nav/nav-search-control.d.ts +7 -0
- package/dist/components/nav/nav-search.d.ts +9 -0
- package/dist/components/nav/nav-sign-in-control.d.ts +11 -0
- package/dist/components/nav/nav-user-menu-items.d.ts +20 -0
- package/dist/components/nav/nav-user-menu.d.ts +18 -0
- package/dist/components/nav/nav.d.ts +55 -0
- package/dist/components/nav/nav.stories.d.ts +11 -0
- package/dist/components/navigation/navigation-list.d.ts +3 -1
- package/dist/components/navigation/navigation-menu.d.ts +2 -1
- package/dist/components/navigation/navigation-sign-in-control.d.ts +6 -3
- package/dist/components/navigation/navigation.d.ts +12 -1
- package/dist/components/navigation/navigation.stories.d.ts +3 -21
- package/dist/components/phone-number-input/index.d.ts +2 -0
- package/dist/components/{phone-number-field/phone-number-field.d.ts → phone-number-input/phone-number-input.d.ts} +5 -3
- package/dist/components/phone-number-input/phone-number-input.stories.d.ts +13 -0
- package/dist/components/{phone-number-field → phone-number-input}/util.d.ts +0 -0
- package/dist/components/popup/index.d.ts +1 -0
- package/dist/components/popup/popup.d.ts +8 -0
- package/dist/components/popup/popup.stories.d.ts +14 -0
- package/dist/components/progressbar/index.d.ts +1 -0
- package/dist/components/progressbar/progressbar.d.ts +8 -0
- package/dist/components/progressbar/progressbar.stories.d.ts +14 -0
- package/dist/components/select/select.d.ts +2 -1
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/spinner.d.ts +8 -0
- package/dist/components/spinner/spinner.stories.d.ts +13 -0
- package/dist/components/start-campaign-card/index.d.ts +1 -0
- package/dist/components/start-campaign-card/start-campaign-card.d.ts +8 -0
- package/dist/components/start-campaign-card/start-campaign-card.stories.d.ts +14 -0
- package/dist/components/start-campain-card/start-campain-card.d.ts +8 -0
- package/dist/components/start-campain-card/start-campain-card.stories.d.ts +14 -0
- package/dist/components/statistics/statistics.d.ts +2 -1
- package/dist/components/tabs/tabs.d.ts +3 -1
- package/dist/components/text/text.d.ts +1 -1
- package/dist/components/text-field/text-field.d.ts +1 -0
- package/dist/index.esm.js +5298 -4190
- package/dist/index.js +4872 -3759
- package/dist/utils/parse-numbers.d.ts +2 -0
- package/package.json +4 -1
- package/styles/index.css +1 -0
- package/dist/components/anchor/anchor.jsx +0 -35
- package/dist/components/anchor/anchor.stories.jsx +0 -12
- package/dist/components/anchor/bold-anchor.jsx +0 -33
- package/dist/components/anchor/bold-anchor.stories.jsx +0 -11
- package/dist/components/anchor/index.js +0 -2
- package/dist/components/avatar/avatar.jsx +0 -14
- package/dist/components/avatar/avatar.stories.jsx +0 -17
- package/dist/components/avatar/image-avatar.jsx +0 -29
- package/dist/components/avatar/index.js +0 -1
- package/dist/components/avatar/text-avatar.jsx +0 -47
- package/dist/components/button/button.jsx +0 -85
- package/dist/components/button/button.stories.jsx +0 -118
- package/dist/components/button/index.js +0 -1
- package/dist/components/checkbox/checkbox.jsx +0 -39
- package/dist/components/checkbox/checkbox.stories.jsx +0 -42
- package/dist/components/checkbox/index.js +0 -1
- package/dist/components/chips/chip.jsx +0 -30
- package/dist/components/chips/chips.jsx +0 -16
- package/dist/components/chips/chips.stories.jsx +0 -35
- package/dist/components/chips/index.js +0 -3
- package/dist/components/chips/input-chips.jsx +0 -16
- package/dist/components/chips/input-chips.stories.jsx +0 -39
- package/dist/components/combo-field/combo-field-expander.jsx +0 -23
- package/dist/components/combo-field/combo-field.jsx +0 -93
- package/dist/components/combo-field/combo-field.stories.jsx +0 -62
- package/dist/components/combo-field/index.js +0 -2
- package/dist/components/cropper/cropper.jsx +0 -15
- package/dist/components/cropper/cropper.stories.jsx +0 -18
- package/dist/components/cropper/index.js +0 -1
- package/dist/components/date-picker/date-picker.jsx +0 -74
- package/dist/components/date-picker/date-picker.stories.jsx +0 -46
- package/dist/components/date-picker/index.js +0 -2
- package/dist/components/date-picker/single-date-picker.jsx +0 -81
- package/dist/components/elevation/elevation.jsx +0 -19
- package/dist/components/elevation/elevation.stories.jsx +0 -31
- package/dist/components/elevation/index.js +0 -1
- package/dist/components/field-helpers/field-helper-text.jsx +0 -42
- package/dist/components/field-helpers/field-label.jsx +0 -29
- package/dist/components/field-helpers/index.js +0 -2
- package/dist/components/icon/btn_google_light_normal_ios.svg.jsx +0 -21
- package/dist/components/icon/facebook_6.svg.jsx +0 -13
- package/dist/components/icon/icon-button-group.jsx +0 -51
- package/dist/components/icon/icon-button-group.stories.jsx +0 -26
- package/dist/components/icon/icon-button.jsx +0 -48
- package/dist/components/icon/icon-button.stories.jsx +0 -33
- package/dist/components/icon/icon.jsx +0 -49
- package/dist/components/icon/icon.stories.jsx +0 -78
- package/dist/components/icon/index.js +0 -4
- package/dist/components/icon/material-icon.jsx +0 -18
- package/dist/components/icon/toggle-button.jsx +0 -29
- package/dist/components/icon/toggle-button.stories.jsx +0 -16
- package/dist/components/index.js +0 -27
- package/dist/components/layout/box.jsx +0 -58
- package/dist/components/layout/flex.jsx +0 -55
- package/dist/components/layout/flex.stories.jsx +0 -44
- package/dist/components/layout/grid.jsx +0 -19
- package/dist/components/layout/grid.stories.jsx +0 -29
- package/dist/components/layout/index.js +0 -4
- package/dist/components/layout/stack.jsx +0 -33
- package/dist/components/layout/stack.stories.jsx +0 -40
- package/dist/components/list/index.js +0 -1
- package/dist/components/list/list.jsx +0 -52
- package/dist/components/list/list.stories.jsx +0 -135
- package/dist/components/logo/index.js +0 -1
- package/dist/components/logo/logo-type.jsx +0 -65
- package/dist/components/menu/index.js +0 -8
- package/dist/components/menu/menu-list-divider.jsx +0 -2
- package/dist/components/menu/menu-list-item-graphic.jsx +0 -2
- package/dist/components/menu/menu-list-item-meta.jsx +0 -2
- package/dist/components/menu/menu-list-item-text.jsx +0 -2
- package/dist/components/menu/menu-list-item.jsx +0 -11
- package/dist/components/menu/menu-list.jsx +0 -18
- package/dist/components/menu/menu-surface.jsx +0 -4
- package/dist/components/menu/menu.jsx +0 -2
- package/dist/components/menu/menu.stories.jsx +0 -42
- package/dist/components/modal/index.js +0 -1
- package/dist/components/modal/modal.jsx +0 -49
- package/dist/components/modal/modal.stories.jsx +0 -47
- package/dist/components/navigation/index.js +0 -1
- package/dist/components/navigation/navigation-actions.jsx +0 -8
- package/dist/components/navigation/navigation-bar.jsx +0 -42
- package/dist/components/navigation/navigation-call-to-action.jsx +0 -6
- package/dist/components/navigation/navigation-expanded.jsx +0 -165
- package/dist/components/navigation/navigation-list.jsx +0 -126
- package/dist/components/navigation/navigation-menu-control.jsx +0 -25
- package/dist/components/navigation/navigation-menu.jsx +0 -103
- package/dist/components/navigation/navigation-search-control.jsx +0 -8
- package/dist/components/navigation/navigation-search.jsx +0 -63
- package/dist/components/navigation/navigation-sign-in-control.jsx +0 -14
- package/dist/components/navigation/navigation-user-menu-items.jsx +0 -36
- package/dist/components/navigation/navigation-user-menu.jsx +0 -121
- package/dist/components/navigation/navigation.jsx +0 -137
- package/dist/components/navigation/navigation.stories.jsx +0 -260
- package/dist/components/phone-number-field/index.d.ts +0 -2
- package/dist/components/phone-number-field/index.js +0 -2
- package/dist/components/phone-number-field/phone-number-field.jsx +0 -50
- package/dist/components/phone-number-field/phone-number-field.stories.jsx +0 -23
- package/dist/components/phone-number-field/util.js +0 -19
- package/dist/components/radio/index.js +0 -2
- package/dist/components/radio/radio-group.jsx +0 -9
- package/dist/components/radio/radio-group.stories.jsx +0 -21
- package/dist/components/radio/radio.jsx +0 -31
- package/dist/components/radio/radio.stories.jsx +0 -44
- package/dist/components/select/index.js +0 -2
- package/dist/components/select/select-helper-text.jsx +0 -6
- package/dist/components/select/select.jsx +0 -152
- package/dist/components/select/select.stories.jsx +0 -40
- package/dist/components/statistics/index.js +0 -1
- package/dist/components/statistics/statistics.jsx +0 -61
- package/dist/components/statistics/statistics.stories.jsx +0 -34
- package/dist/components/switch/index.js +0 -1
- package/dist/components/switch/switch.jsx +0 -32
- package/dist/components/switch/switch.stories.jsx +0 -41
- package/dist/components/tabs/index.js +0 -1
- package/dist/components/tabs/tab-bar.jsx +0 -35
- package/dist/components/tabs/tab-text-label.jsx +0 -5
- package/dist/components/tabs/tab.jsx +0 -50
- package/dist/components/tabs/tabs.jsx +0 -65
- package/dist/components/tabs/tabs.stories.jsx +0 -27
- package/dist/components/text/index.js +0 -1
- package/dist/components/text/text.jsx +0 -138
- package/dist/components/text/text.stories.jsx +0 -262
- package/dist/components/text-field/index.js +0 -2
- package/dist/components/text-field/text-field-helper-text.jsx +0 -8
- package/dist/components/text-field/text-field.jsx +0 -124
- package/dist/components/text-field/text-field.stories.jsx +0 -32
- package/dist/components/uploader/index.js +0 -1
- package/dist/components/uploader/uploader.jsx +0 -96
- package/dist/input.d.ts +0 -1
- package/dist/input.js +0 -4
- package/dist/input.jsx +0 -4
- package/dist/theme/colors.js +0 -9
- package/dist/theme/index.js +0 -2
- package/dist/theme/mycause-theme.js +0 -33
- package/dist/theme/theme.jsx +0 -36
- package/dist/utils/browser.js +0 -19
- package/dist/utils/center-decorator.jsx +0 -15
- package/dist/utils/component-matrix.jsx +0 -39
- package/dist/utils/flags.js +0 -18
- package/dist/utils/grid-decorator.jsx +0 -27
- package/dist/utils/tap-event.js +0 -11
- package/dist/utils/wrap.js +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mycause/ui",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-cf96d552",
|
|
4
4
|
"author": "Marc Porciuncula <marc@mycause.com.au>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,9 +29,11 @@
|
|
|
29
29
|
"@babel/preset-env": "^7.5.5",
|
|
30
30
|
"@babel/preset-react": "^7.0.0",
|
|
31
31
|
"@babel/preset-typescript": "^7.6.0",
|
|
32
|
+
"@rollup/plugin-image": "^2.0.4",
|
|
32
33
|
"@rollup/plugin-json": "^4.0.0",
|
|
33
34
|
"@storybook/addon-actions": "^5.2.1",
|
|
34
35
|
"@storybook/addon-knobs": "^5.2.5",
|
|
36
|
+
"@storybook/addon-storysource": "^5.3.14",
|
|
35
37
|
"@storybook/react": "^5.2.1",
|
|
36
38
|
"@types/classnames": "^2.2.9",
|
|
37
39
|
"@types/node": "^12.7.5",
|
|
@@ -100,6 +102,7 @@
|
|
|
100
102
|
"classnames": "^2.2.6",
|
|
101
103
|
"html5-file-selector": "^2.1.0",
|
|
102
104
|
"i18n-iso-countries": "^4.3.1",
|
|
105
|
+
"js-cookie": "^2.2.1",
|
|
103
106
|
"libphonenumber-js": "^1.7.29",
|
|
104
107
|
"nanoid": "^2.1.6",
|
|
105
108
|
"ramda": "^0.26.1",
|
package/styles/index.css
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import cn from "classnames";
|
|
3
|
-
import css from "styled-jsx/css";
|
|
4
|
-
import { useTheme, getColorToken } from "../../theme/theme";
|
|
5
|
-
/* A standard text anchor */
|
|
6
|
-
const Anchor = forwardRef(function Anchor({ href, children, color = "primary", invert, className, ...rest }, ref) {
|
|
7
|
-
const theme = useTheme();
|
|
8
|
-
const foreground = getColorToken(theme, "foreground", color, { invert });
|
|
9
|
-
const scope = css.resolve `
|
|
10
|
-
a,
|
|
11
|
-
a:visited {
|
|
12
|
-
color: ${foreground};
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
return (<a href={href || "#"} className={cn(className, scope.className)} {...rest} ref={ref}>
|
|
16
|
-
{children}
|
|
17
|
-
<style jsx>{`
|
|
18
|
-
a:hover,
|
|
19
|
-
a:focus {
|
|
20
|
-
text-decoration: underline;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
a:focus,
|
|
24
|
-
a:active {
|
|
25
|
-
outline: none;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
a:active {
|
|
29
|
-
text-decoration: none;
|
|
30
|
-
}
|
|
31
|
-
`}</style>
|
|
32
|
-
{scope.styles}
|
|
33
|
-
</a>);
|
|
34
|
-
});
|
|
35
|
-
export default Anchor;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import { Anchor } from "./index";
|
|
4
|
-
export default {
|
|
5
|
-
title: "Anchor",
|
|
6
|
-
decorators: [CenterDecorator],
|
|
7
|
-
component: Anchor,
|
|
8
|
-
};
|
|
9
|
-
export const anchor = () => <Anchor href="#">Start fundraising</Anchor>;
|
|
10
|
-
anchor.story = {
|
|
11
|
-
name: "default",
|
|
12
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import cn from "classnames";
|
|
3
|
-
import { useTheme, getColorToken } from "../../theme/theme";
|
|
4
|
-
import css from "styled-jsx/css";
|
|
5
|
-
/* A bold anchor that turns green when active/focused */
|
|
6
|
-
const BoldAnchor = forwardRef(function EmboldenAnchor({ className, href, children, active, color = "primary", invert, analyticsId, id, ...rest }, ref) {
|
|
7
|
-
const theme = useTheme();
|
|
8
|
-
if (process.env.NODE_ENV !== "production") {
|
|
9
|
-
if (id && analyticsId) {
|
|
10
|
-
console.warn("[BoldAnchor] only one of the `id` and `analyticsId` props can be passed. Please remove one as `analyticsId` will override the id.");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const scope = css.resolve `
|
|
14
|
-
a {
|
|
15
|
-
position: relative;
|
|
16
|
-
text-decoration: none;
|
|
17
|
-
color: inherit;
|
|
18
|
-
font-weight: 500;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
a:hover,
|
|
22
|
-
a:focus,
|
|
23
|
-
a:active,
|
|
24
|
-
a.active {
|
|
25
|
-
color: ${getColorToken(theme, "foreground", color, { invert })};
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
return (<a ref={ref} href={href || "#"} className={cn("bold-anchor", className, scope.className, { active })} id={analyticsId || id} {...rest}>
|
|
29
|
-
{children}
|
|
30
|
-
{scope.styles}
|
|
31
|
-
</a>);
|
|
32
|
-
});
|
|
33
|
-
export default BoldAnchor;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import { BoldAnchor } from "./index";
|
|
4
|
-
export default {
|
|
5
|
-
title: "BoldAnchor",
|
|
6
|
-
decorators: [CenterDecorator],
|
|
7
|
-
};
|
|
8
|
-
export const boldAnchor = () => (<BoldAnchor href="#">Start fundraising</BoldAnchor>);
|
|
9
|
-
boldAnchor.story = {
|
|
10
|
-
name: "default",
|
|
11
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ImageAvatar from "./image-avatar";
|
|
3
|
-
import TextAvatar from "./text-avatar";
|
|
4
|
-
/* Used to represent a user */
|
|
5
|
-
function Avatar(props) {
|
|
6
|
-
if (isImageAvatar(props)) {
|
|
7
|
-
return <ImageAvatar {...props}/>;
|
|
8
|
-
}
|
|
9
|
-
return <TextAvatar {...props}/>;
|
|
10
|
-
}
|
|
11
|
-
function isImageAvatar(props) {
|
|
12
|
-
return "src" in props && typeof props.src !== "undefined";
|
|
13
|
-
}
|
|
14
|
-
export default Avatar;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import ImageAvatar from "./image-avatar";
|
|
4
|
-
import TextAvatar from "./text-avatar";
|
|
5
|
-
import src from "./ipet-photo-CfDAo3C3bvQ-unsplash.jpg";
|
|
6
|
-
export default {
|
|
7
|
-
title: "Avatar",
|
|
8
|
-
decorators: [CenterDecorator],
|
|
9
|
-
};
|
|
10
|
-
export const imageAvatar = () => (<ImageAvatar name="Adorable Puppy" src={src}/>);
|
|
11
|
-
imageAvatar.story = {
|
|
12
|
-
name: "image avatar",
|
|
13
|
-
};
|
|
14
|
-
export const textAvatar = () => <TextAvatar name="Adorable Puppy"/>;
|
|
15
|
-
textAvatar.story = {
|
|
16
|
-
name: "text avatar",
|
|
17
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import css from "styled-jsx/css";
|
|
3
|
-
import cn from "classnames";
|
|
4
|
-
import { ON_BACKGROUND_GREY_GREY } from "../../theme/colors";
|
|
5
|
-
/* An avatar with an image */
|
|
6
|
-
function ImageAvatar({ name, src, size = "2.5rem", ...rest }) {
|
|
7
|
-
const scope = css.resolve `
|
|
8
|
-
.avatar {
|
|
9
|
-
border-radius: 100%;
|
|
10
|
-
display: inline-block;
|
|
11
|
-
overflow: hidden;
|
|
12
|
-
border: 1px solid ${ON_BACKGROUND_GREY_GREY};
|
|
13
|
-
line-height: 0;
|
|
14
|
-
vertical-align: top;
|
|
15
|
-
width: ${size};
|
|
16
|
-
height: ${size};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
img {
|
|
20
|
-
width: 100%;
|
|
21
|
-
height: 100%;
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
return (<span className={cn("avatar", scope.className)} title={name} {...rest}>
|
|
25
|
-
<img className={scope.className} alt={name} src={src}/>
|
|
26
|
-
{scope.styles}
|
|
27
|
-
</span>);
|
|
28
|
-
}
|
|
29
|
-
export default ImageAvatar;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Avatar } from "./avatar";
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import css from "styled-jsx/css";
|
|
3
|
-
import cn from "classnames";
|
|
4
|
-
import { useTheme, getColorToken } from "../../theme/theme";
|
|
5
|
-
/* An avatar that shows initials, usually for when there is no photo available */
|
|
6
|
-
function TextAvatar({ name, initials, color = "primary", invert, size = "2.5rem", ...rest }) {
|
|
7
|
-
const theme = useTheme();
|
|
8
|
-
if (!initials) {
|
|
9
|
-
initials = name
|
|
10
|
-
.split(/\s+/)
|
|
11
|
-
.filter(str => str.length)
|
|
12
|
-
.map(str => str[0].toUpperCase())
|
|
13
|
-
.join("");
|
|
14
|
-
}
|
|
15
|
-
const foreground = getColorToken(theme, "foreground", color, { invert });
|
|
16
|
-
const background = getColorToken(theme, "background", color, { invert });
|
|
17
|
-
const scope = css.resolve `
|
|
18
|
-
.text-avatar {
|
|
19
|
-
width: ${size};
|
|
20
|
-
height: ${size};
|
|
21
|
-
background-color: ${foreground};
|
|
22
|
-
color: ${background};
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
return (<span className={cn("text-avatar", scope.className)} title={name} {...rest}>
|
|
26
|
-
<span className="name">{initials}</span>
|
|
27
|
-
<style jsx>{`
|
|
28
|
-
.text-avatar {
|
|
29
|
-
border-radius: 100%;
|
|
30
|
-
display: inline-flex;
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
line-height: 0;
|
|
33
|
-
vertical-align: top;
|
|
34
|
-
|
|
35
|
-
justify-content: center;
|
|
36
|
-
align-items: center;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.name {
|
|
40
|
-
font-size: 1rem;
|
|
41
|
-
user-select: none;
|
|
42
|
-
}
|
|
43
|
-
`}</style>
|
|
44
|
-
{scope.styles}
|
|
45
|
-
</span>);
|
|
46
|
-
}
|
|
47
|
-
export default TextAvatar;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import classnames from "classnames";
|
|
3
|
-
import css from "styled-jsx/css";
|
|
4
|
-
import MDCButton from "@material/react-button";
|
|
5
|
-
import { useTheme, getColorToken } from "../../theme/theme";
|
|
6
|
-
import { tapEvent } from "../../utils/tap-event";
|
|
7
|
-
/**
|
|
8
|
-
* Button
|
|
9
|
-
*
|
|
10
|
-
* Customised version of @material/react-button
|
|
11
|
-
* see: https://github.com/material-components/material-components-web-react/tree/master/packages/button
|
|
12
|
-
*
|
|
13
|
-
* When using this button you must also include the accompanying `button.scss`.
|
|
14
|
-
*/
|
|
15
|
-
function Button({ control, display, large, color = "primary", invert, raised, unelevated, outlined, className, icon, trailingIcon, onMouseOver, onMouseOut, analyticsId, id, ...rest }) {
|
|
16
|
-
const theme = useTheme();
|
|
17
|
-
if (process.env.NODE_ENV !== "production") {
|
|
18
|
-
if (id && analyticsId) {
|
|
19
|
-
console.warn("[Button] only one of the `id` and `analyticsId` props can be passed. Please remove one as `analyticsId` will override the id.");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const [hovered, setHovered] = useState();
|
|
23
|
-
const handleMouseOver = tapEvent(() => setHovered(true), onMouseOver);
|
|
24
|
-
const handleMouseOut = tapEvent(() => setHovered(false), onMouseOut);
|
|
25
|
-
// Handle icon colors
|
|
26
|
-
const foreground = getColorToken(theme, "foreground", color, {
|
|
27
|
-
invert,
|
|
28
|
-
});
|
|
29
|
-
const background = getColorToken(theme, "background", color, {
|
|
30
|
-
invert,
|
|
31
|
-
});
|
|
32
|
-
icon = setIconColor(icon, {
|
|
33
|
-
color,
|
|
34
|
-
invert,
|
|
35
|
-
unelevated,
|
|
36
|
-
raised,
|
|
37
|
-
outlined,
|
|
38
|
-
hovered,
|
|
39
|
-
});
|
|
40
|
-
trailingIcon = setIconColor(trailingIcon, {
|
|
41
|
-
color,
|
|
42
|
-
invert,
|
|
43
|
-
unelevated,
|
|
44
|
-
raised,
|
|
45
|
-
outlined,
|
|
46
|
-
hovered,
|
|
47
|
-
});
|
|
48
|
-
const scope = css.resolve `
|
|
49
|
-
.button {
|
|
50
|
-
--mdc-theme-primary: ${foreground};
|
|
51
|
-
--mdc-theme-on-primary: ${background};
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
const props = {
|
|
55
|
-
className: classnames("button", {
|
|
56
|
-
"mdc-button--display": display,
|
|
57
|
-
"mdc-button--large": large,
|
|
58
|
-
"mdc-button--control": control,
|
|
59
|
-
}, className, scope.className),
|
|
60
|
-
id: analyticsId || id,
|
|
61
|
-
raised,
|
|
62
|
-
unelevated,
|
|
63
|
-
outlined: outlined,
|
|
64
|
-
icon: icon,
|
|
65
|
-
trailingIcon: trailingIcon,
|
|
66
|
-
onMouseOver: handleMouseOver,
|
|
67
|
-
onMouseOut: handleMouseOut,
|
|
68
|
-
...rest,
|
|
69
|
-
};
|
|
70
|
-
return (<>
|
|
71
|
-
<MDCButton {...props}/>
|
|
72
|
-
{scope.styles}
|
|
73
|
-
</>);
|
|
74
|
-
}
|
|
75
|
-
export default Button;
|
|
76
|
-
function setIconColor(icon, { color, invert, unelevated, raised, outlined, hovered, }) {
|
|
77
|
-
if (!icon) {
|
|
78
|
-
return icon;
|
|
79
|
-
}
|
|
80
|
-
icon = React.cloneElement(icon, { color: icon.props.color || color });
|
|
81
|
-
if (unelevated || raised || (hovered && outlined)) {
|
|
82
|
-
icon = React.cloneElement(icon, { invert: !invert });
|
|
83
|
-
}
|
|
84
|
-
return icon;
|
|
85
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import Matrix from "../../utils/component-matrix";
|
|
4
|
-
import Button from "./button";
|
|
5
|
-
import Icon from "../icon/icon";
|
|
6
|
-
export default {
|
|
7
|
-
title: "Button",
|
|
8
|
-
decorators: [CenterDecorator],
|
|
9
|
-
};
|
|
10
|
-
export const types = () => {
|
|
11
|
-
let props = {
|
|
12
|
-
primary: [
|
|
13
|
-
{ children: "Text button" },
|
|
14
|
-
{ children: "Outlined button", outlined: true },
|
|
15
|
-
{ children: "Unelevated button", unelevated: true },
|
|
16
|
-
{ children: "Raised button", raised: true },
|
|
17
|
-
],
|
|
18
|
-
secondary: [{}],
|
|
19
|
-
};
|
|
20
|
-
return (<Matrix {...props}>
|
|
21
|
-
{props => <Button {...props}/>}
|
|
22
|
-
</Matrix>);
|
|
23
|
-
};
|
|
24
|
-
types.story = {
|
|
25
|
-
name: "types",
|
|
26
|
-
};
|
|
27
|
-
export const disabled = () => {
|
|
28
|
-
let props = {
|
|
29
|
-
primary: [
|
|
30
|
-
{ children: "Text button" },
|
|
31
|
-
{ children: "Outlined button", outlined: true },
|
|
32
|
-
{ children: "Unelevated button", unelevated: true },
|
|
33
|
-
{ children: "Raised button", raised: true },
|
|
34
|
-
],
|
|
35
|
-
secondary: [{ disabled: true }],
|
|
36
|
-
};
|
|
37
|
-
return (<Matrix {...props}>
|
|
38
|
-
{props => <Button {...props}/>}
|
|
39
|
-
</Matrix>);
|
|
40
|
-
};
|
|
41
|
-
disabled.story = {
|
|
42
|
-
name: "disabled",
|
|
43
|
-
};
|
|
44
|
-
export const sizes = () => {
|
|
45
|
-
let props = {
|
|
46
|
-
primary: [
|
|
47
|
-
{ children: "Dense", dense: true },
|
|
48
|
-
{ children: "Normal" },
|
|
49
|
-
{ children: "Display", display: true },
|
|
50
|
-
{ children: "Large", large: true },
|
|
51
|
-
],
|
|
52
|
-
secondary: [{}, { outlined: true }, { unelevated: true }, { raised: true }],
|
|
53
|
-
};
|
|
54
|
-
return (<Matrix {...props}>
|
|
55
|
-
{props => <Button {...props}/>}
|
|
56
|
-
</Matrix>);
|
|
57
|
-
};
|
|
58
|
-
sizes.story = {
|
|
59
|
-
name: "sizes",
|
|
60
|
-
};
|
|
61
|
-
export const colors = () => {
|
|
62
|
-
let props = {
|
|
63
|
-
primary: [
|
|
64
|
-
{ children: "Neutral", color: "neutral" },
|
|
65
|
-
{ children: "Primary", color: "primary" },
|
|
66
|
-
{ children: "Secondary", color: "secondary" },
|
|
67
|
-
{ children: "Accent", color: "accent" },
|
|
68
|
-
{
|
|
69
|
-
children: "Custom",
|
|
70
|
-
color: { foreground: "#3C5A99", background: "#ffffff" },
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
secondary: [{}, { outlined: true }, { unelevated: true }, { raised: true }],
|
|
74
|
-
};
|
|
75
|
-
return (<Matrix {...props}>
|
|
76
|
-
{props => <Button {...props}/>}
|
|
77
|
-
</Matrix>);
|
|
78
|
-
};
|
|
79
|
-
colors.story = {
|
|
80
|
-
name: "colors",
|
|
81
|
-
};
|
|
82
|
-
export const icon = () => {
|
|
83
|
-
let props = {
|
|
84
|
-
primary: [
|
|
85
|
-
{ icon: <Icon icon="card_giftcard"/>, children: "Voucher" },
|
|
86
|
-
{ trailingIcon: <Icon icon="favorite_border"/>, children: "Thanks" },
|
|
87
|
-
],
|
|
88
|
-
secondary: [{}, { outlined: true }, { unelevated: true }, { raised: true }],
|
|
89
|
-
};
|
|
90
|
-
return (<Matrix {...props}>
|
|
91
|
-
{props => <Button {...props}/>}
|
|
92
|
-
</Matrix>);
|
|
93
|
-
};
|
|
94
|
-
icon.story = {
|
|
95
|
-
name: "with icon",
|
|
96
|
-
};
|
|
97
|
-
export const controlButton = () => <Button control>Control</Button>;
|
|
98
|
-
controlButton.story = {
|
|
99
|
-
name: "control button",
|
|
100
|
-
};
|
|
101
|
-
export const controlButtonDense = () => (<Button control dense>
|
|
102
|
-
Control
|
|
103
|
-
</Button>);
|
|
104
|
-
controlButtonDense.story = {
|
|
105
|
-
name: "control button dense",
|
|
106
|
-
};
|
|
107
|
-
export const example1 = () => (<Button raised display color="secondary">
|
|
108
|
-
Start fundraising
|
|
109
|
-
</Button>);
|
|
110
|
-
example1.story = {
|
|
111
|
-
name: "start fundraising",
|
|
112
|
-
};
|
|
113
|
-
export const example2 = () => (<Button outlined display color="primary">
|
|
114
|
-
Become a partner (free)
|
|
115
|
-
</Button>);
|
|
116
|
-
example2.story = {
|
|
117
|
-
name: "become a partner",
|
|
118
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Button } from "./button";
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import classnames from "classnames";
|
|
3
|
-
import css from "styled-jsx/css";
|
|
4
|
-
import nanoid from "nanoid";
|
|
5
|
-
import { useTheme, getColorToken } from "../../theme/theme";
|
|
6
|
-
import { Flex } from "../layout";
|
|
7
|
-
import { Text } from "../text";
|
|
8
|
-
import MDCCheckbox from "@material/react-checkbox";
|
|
9
|
-
const Checkbox = ({ id, label, color = "primary", checked, className, ...rest }) => {
|
|
10
|
-
const theme = useTheme();
|
|
11
|
-
const [mainId, setmainId] = useState("");
|
|
12
|
-
const setColor = getColorToken(theme, "foreground", color);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
setmainId(id ? id : nanoid());
|
|
15
|
-
}, [id, setmainId]);
|
|
16
|
-
const scope = css.resolve `
|
|
17
|
-
.checkbox {
|
|
18
|
-
--mdc-theme-primary: ${setColor};
|
|
19
|
-
--mdc-theme-secondary: ${setColor};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.checkbox-label {
|
|
23
|
-
flex-grow: 1;
|
|
24
|
-
flex-shrink: 1;
|
|
25
|
-
margin-left: 0.25rem;
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
return (<Flex align="center">
|
|
30
|
-
<MDCCheckbox className={classnames(className, "checkbox", scope.className)} checked={checked} nativeControlId={mainId} {...rest}/>
|
|
31
|
-
{label && (<label className={classnames(scope.className, "checkbox-label")} htmlFor={mainId}>
|
|
32
|
-
<Text font="brand" kind="sub" span>
|
|
33
|
-
{label}
|
|
34
|
-
</Text>
|
|
35
|
-
</label>)}
|
|
36
|
-
{scope.styles}
|
|
37
|
-
</Flex>);
|
|
38
|
-
};
|
|
39
|
-
export default Checkbox;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React, { useState, Fragment } from "react";
|
|
2
|
-
import CheckBox from "./checkbox";
|
|
3
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
4
|
-
export default {
|
|
5
|
-
title: "CheckBox",
|
|
6
|
-
decorators: [CenterDecorator],
|
|
7
|
-
};
|
|
8
|
-
export const CheckBoxStoriesDefault = () => {
|
|
9
|
-
const [isChecked, setChecked] = useState(true);
|
|
10
|
-
const handleClick = (event) => {
|
|
11
|
-
setChecked(event.target.checked);
|
|
12
|
-
};
|
|
13
|
-
return (<Fragment>
|
|
14
|
-
<CheckBox onChange={handleClick} checked={isChecked} color="primary"/>
|
|
15
|
-
<CheckBox onChange={handleClick} checked={isChecked} color="secondary"/>
|
|
16
|
-
<CheckBox onChange={handleClick} checked={isChecked} color="muted"/>
|
|
17
|
-
</Fragment>);
|
|
18
|
-
};
|
|
19
|
-
CheckBoxStoriesDefault.story = {
|
|
20
|
-
name: "default",
|
|
21
|
-
};
|
|
22
|
-
export const CheckBoxStoriesLabel = () => {
|
|
23
|
-
const [isChecked, setChecked] = useState(true);
|
|
24
|
-
const handleClick = (event) => {
|
|
25
|
-
setChecked(event.target.checked);
|
|
26
|
-
};
|
|
27
|
-
return (<Fragment>
|
|
28
|
-
<CheckBox label="Checkbox Story" onChange={handleClick} checked={isChecked}/>
|
|
29
|
-
</Fragment>);
|
|
30
|
-
};
|
|
31
|
-
CheckBoxStoriesLabel.story = {
|
|
32
|
-
name: "with label",
|
|
33
|
-
};
|
|
34
|
-
export const CheckBoxStoriesDisabled = () => {
|
|
35
|
-
return (<Fragment>
|
|
36
|
-
<CheckBox disabled={true} checked={false}/>
|
|
37
|
-
<CheckBox disabled={true} checked={true}/>
|
|
38
|
-
</Fragment>);
|
|
39
|
-
};
|
|
40
|
-
CheckBoxStoriesDisabled.story = {
|
|
41
|
-
name: "disabled",
|
|
42
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Checkbox } from "./checkbox";
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import classnames from "classnames";
|
|
3
|
-
import css from "styled-jsx/css";
|
|
4
|
-
import { Chip as MDCChip, } from "@material/react-chips";
|
|
5
|
-
import { useTheme } from "../../theme/theme";
|
|
6
|
-
function Chip({ className, leadingIcon, trailingIcon, ...props }) {
|
|
7
|
-
const theme = useTheme();
|
|
8
|
-
const scope = css.resolve `
|
|
9
|
-
.mdc-chip {
|
|
10
|
-
font-family: ${theme.typography.fontFamily.brand};
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
// default icon sizes to 18px
|
|
14
|
-
if (leadingIcon) {
|
|
15
|
-
leadingIcon = React.cloneElement(leadingIcon, {
|
|
16
|
-
size: leadingIcon.props.size || "18px",
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
if (trailingIcon) {
|
|
20
|
-
trailingIcon = React.cloneElement(trailingIcon, {
|
|
21
|
-
size: trailingIcon.props.size || "18px",
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return (<>
|
|
25
|
-
<MDCChip className={classnames(scope.className, className)} leadingIcon={leadingIcon} trailingIcon={trailingIcon} {...props}/>
|
|
26
|
-
{scope.styles}
|
|
27
|
-
</>);
|
|
28
|
-
}
|
|
29
|
-
Chip.defaultProps = MDCChip.defaultProps;
|
|
30
|
-
export default Chip;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ChipSet } from "@material/react-chips";
|
|
3
|
-
import Chip from "./chip";
|
|
4
|
-
function Chips({ value, onChange, options, children, ...rest }) {
|
|
5
|
-
if (options) {
|
|
6
|
-
children = options.map(option => <Chip key={option.id} {...option}/>);
|
|
7
|
-
}
|
|
8
|
-
const props = {
|
|
9
|
-
selectedChipIds: value,
|
|
10
|
-
handleSelect: onChange,
|
|
11
|
-
children: children,
|
|
12
|
-
...rest,
|
|
13
|
-
};
|
|
14
|
-
return <ChipSet {...props}/>;
|
|
15
|
-
}
|
|
16
|
-
export default Chips;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import Chips from "./chips";
|
|
4
|
-
import Chip from "./chip";
|
|
5
|
-
export default {
|
|
6
|
-
title: "Chips",
|
|
7
|
-
decorators: [CenterDecorator],
|
|
8
|
-
};
|
|
9
|
-
export const chips = () => (<Chips>
|
|
10
|
-
<Chip id="summer" label="Summer"/>
|
|
11
|
-
<Chip id="winter" label="Winter"/>
|
|
12
|
-
</Chips>);
|
|
13
|
-
chips.story = {
|
|
14
|
-
name: "default",
|
|
15
|
-
};
|
|
16
|
-
export const ChoiceChips = () => {
|
|
17
|
-
const [selected, setSelected] = useState(["summer"]);
|
|
18
|
-
return (<Chips choice value={selected} onChange={setSelected} options={[
|
|
19
|
-
{ id: "summer", label: "Summer" },
|
|
20
|
-
{ id: "winter", label: "Winter" },
|
|
21
|
-
]}></Chips>);
|
|
22
|
-
};
|
|
23
|
-
ChoiceChips.story = {
|
|
24
|
-
name: "choice",
|
|
25
|
-
};
|
|
26
|
-
export const FilterChips = () => {
|
|
27
|
-
const [selected, setSelected] = useState(["summer"]);
|
|
28
|
-
return (<Chips filter value={selected} onChange={setSelected}>
|
|
29
|
-
<Chip id="summer" label="Summer"/>
|
|
30
|
-
<Chip id="winter" label="Winter"/>
|
|
31
|
-
</Chips>);
|
|
32
|
-
};
|
|
33
|
-
FilterChips.story = {
|
|
34
|
-
name: "filter",
|
|
35
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ChipSet } from "@material/react-chips";
|
|
3
|
-
/**
|
|
4
|
-
* A form control for adding and removing items to a set.
|
|
5
|
-
*/
|
|
6
|
-
function InputChips({ onChange, ...rest }) {
|
|
7
|
-
const handleUpdateChips = (chips) => {
|
|
8
|
-
onChange(chips.map((chip) => chip.id));
|
|
9
|
-
};
|
|
10
|
-
const props = {
|
|
11
|
-
updateChips: handleUpdateChips,
|
|
12
|
-
...rest,
|
|
13
|
-
};
|
|
14
|
-
return <ChipSet {...props}/>;
|
|
15
|
-
}
|
|
16
|
-
export default InputChips;
|