@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.
- package/CHANGELOG.md +106 -0
- package/README.md +9 -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 +14 -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/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-v2/comment-section-v2.d.ts +31 -0
- package/dist/components/comment-section/comment-section-v2/sub-comments-v2.d.ts +11 -0
- package/dist/components/comment-section/comment-section.d.ts +1 -0
- package/dist/components/comment-section/comment-section.stories.d.ts +6 -0
- package/dist/components/comment-section/index.d.ts +1 -0
- 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-v2/donation-form-v2.d.ts +13 -0
- package/dist/components/donation-form/donation-form.d.ts +64 -0
- package/dist/components/donation-form/donation-form.stories.d.ts +18 -0
- 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 +2 -0
- package/dist/components/featured-campaign-card/featured-campaign-card.d.ts +17 -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/footerV2/footerV2.d.ts +35 -0
- package/dist/components/footerV2/footerV2.stories.d.ts +15 -0
- package/dist/components/footerV2/index.d.ts +1 -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/{toggle-button.d.ts → heart-toggle.d.ts} +3 -3
- package/dist/components/icon/{toggle-button.stories.d.ts → heart-toggle.stories.d.ts} +1 -1
- package/dist/components/icon/index.d.ts +1 -1
- package/dist/components/index.d.ts +14 -0
- package/dist/components/info-represent-campaign/index.d.ts +1 -0
- package/dist/components/info-represent-campaign/info-represent-campaign.d.ts +11 -0
- package/dist/components/{phone-number-field/phone-number-field.stories.d.ts → info-represent-campaign/info-represent-campaign.stories.d.ts} +1 -1
- package/dist/components/list/list.d.ts +7 -2
- package/dist/components/list/list.stories.d.ts +2 -2
- package/dist/components/logo/logo-type.d.ts +2 -1
- package/dist/components/modal/modal.d.ts +1 -1
- package/dist/components/nav/icons/IconBigger.d.ts +5 -0
- package/dist/components/nav/icons/IconSmaller.d.ts +5 -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-charity.d.ts +13 -0
- package/dist/components/nav/nav-expanded.d.ts +14 -0
- package/dist/components/nav/nav-list.d.ts +29 -0
- package/dist/components/nav/nav-menu-control.d.ts +8 -0
- package/dist/components/nav/nav-menu.d.ts +12 -0
- package/dist/components/nav/nav-search-control.d.ts +8 -0
- package/dist/components/nav/nav-search.d.ts +10 -0
- package/dist/components/nav/nav-sign-in-control.d.ts +12 -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 +56 -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-sign-in-control.d.ts +3 -2
- package/dist/components/navigation/navigation.d.ts +2 -0
- package/dist/components/navigation/navigation.stories.d.ts +6 -0
- package/dist/components/partner-dashboard-chart/chart.d.ts +3 -0
- package/dist/components/{phone-number-input/phone-number-field.stories.d.ts → partner-dashboard-chart/chart.stories.d.ts} +2 -1
- package/dist/components/partner-dashboard-chart/index.d.ts +1 -0
- package/dist/components/phone-number-input/phone-number-input.d.ts +2 -1
- 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/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/statistics/statistics.d.ts +2 -1
- package/dist/components/tabs/nav-tabs.d.ts +18 -0
- package/dist/components/text-field/index.d.ts +1 -0
- package/dist/components/text-field/text-field-search.d.ts +9 -0
- package/dist/components/text-field/text-field.d.ts +1 -0
- package/dist/components/text-field/text-field.stories.d.ts +6 -0
- package/dist/index.esm.js +21647 -1735
- package/dist/index.js +21664 -1735
- package/dist/theme/theme.d.ts +4 -0
- package/package.json +1 -1
- package/styles/index.css +4 -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/button-select/button-select.jsx +0 -34
- package/dist/components/button-select/button-select.stories.jsx +0 -39
- package/dist/components/button-select/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/comment-section/comment-section.jsx +0 -95
- package/dist/components/comment-section/comment-section.stories.jsx +0 -97
- package/dist/components/comment-section/index.js +0 -1
- package/dist/components/cropper/cropper.jsx +0 -10
- 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 -24
- 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 -22
- package/dist/components/icon/facebook_6.svg.jsx +0 -14
- 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 -28
- 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 -55
- 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 -59
- 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 -126
- 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 -270
- 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.d.ts +0 -23
- 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.d.ts +0 -2
- package/dist/components/phone-number-field/util.js +0 -19
- package/dist/components/phone-number-input/index.js +0 -2
- package/dist/components/phone-number-input/phone-number-field.d.ts +0 -23
- package/dist/components/phone-number-input/phone-number-field.jsx +0 -50
- package/dist/components/phone-number-input/phone-number-field.stories.jsx +0 -16
- package/dist/components/phone-number-input/phone-number-input.jsx +0 -75
- package/dist/components/phone-number-input/phone-number-input.stories.jsx +0 -23
- package/dist/components/phone-number-input/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 -150
- 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
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import Statistics from "./statistics";
|
|
4
|
-
import placeholder from "./circle.svg";
|
|
5
|
-
export default {
|
|
6
|
-
title: "Statistics",
|
|
7
|
-
decorators: [CenterDecorator],
|
|
8
|
-
};
|
|
9
|
-
export const StatisticsStory = () => {
|
|
10
|
-
const stats = [
|
|
11
|
-
{
|
|
12
|
-
label: "Members",
|
|
13
|
-
id: "nav-expand-members",
|
|
14
|
-
value: "302, 657",
|
|
15
|
-
logo: placeholder,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
label: "Causes",
|
|
19
|
-
id: "nav-expand-causes",
|
|
20
|
-
value: "68, 553",
|
|
21
|
-
logo: placeholder,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
label: "Raised",
|
|
25
|
-
id: "nav-expand-raised",
|
|
26
|
-
value: "$100 Million +",
|
|
27
|
-
logo: placeholder,
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
return <Statistics stats={stats} title="We support your cause"/>;
|
|
31
|
-
};
|
|
32
|
-
StatisticsStory.story = {
|
|
33
|
-
name: "default",
|
|
34
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Switch } from "./switch";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { Fragment, useState, useEffect } from "react";
|
|
2
|
-
import MDCSwitch from "@material/react-switch";
|
|
3
|
-
import nanoid from "nanoid";
|
|
4
|
-
import classnames from "classnames";
|
|
5
|
-
import css from "styled-jsx/css";
|
|
6
|
-
import { useTheme, getColorToken } from "../../theme/theme";
|
|
7
|
-
const Switch = ({ id, label, color = "primary", className, ...rest }) => {
|
|
8
|
-
const [mainId, setmainId] = useState("");
|
|
9
|
-
const theme = useTheme();
|
|
10
|
-
const setColor = getColorToken(theme, "foreground", color);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
setmainId(id ? id : nanoid());
|
|
13
|
-
}, [id, setmainId]);
|
|
14
|
-
const scope = css.resolve `
|
|
15
|
-
.switchStyle {
|
|
16
|
-
--mdc-theme-secondary: ${setColor};
|
|
17
|
-
}
|
|
18
|
-
.switch-label {
|
|
19
|
-
font-family: ${theme.typography.fontFamily.brand} !important;
|
|
20
|
-
margin-right: 10px;
|
|
21
|
-
cursor: pointer;
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
return (<Fragment>
|
|
25
|
-
{label && (<label className={classnames("switch-label", scope.className)} htmlFor={mainId}>
|
|
26
|
-
{label}
|
|
27
|
-
</label>)}
|
|
28
|
-
<MDCSwitch className={classnames(className, "switchStyle", scope.className)} nativeControlId={mainId} checked={true} {...rest}/>
|
|
29
|
-
{scope.styles}
|
|
30
|
-
</Fragment>);
|
|
31
|
-
};
|
|
32
|
-
export default Switch;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import { Stack } from "../layout";
|
|
4
|
-
import Switch from "./switch";
|
|
5
|
-
export default {
|
|
6
|
-
title: "Switch",
|
|
7
|
-
decorators: [CenterDecorator],
|
|
8
|
-
};
|
|
9
|
-
export const SwitchDefault = () => {
|
|
10
|
-
const [switchChecked, setSwitchChecked] = useState(false);
|
|
11
|
-
const handleClick = (event) => {
|
|
12
|
-
setSwitchChecked(event.target.checked);
|
|
13
|
-
};
|
|
14
|
-
return (<Stack>
|
|
15
|
-
<Switch checked={switchChecked} onChange={handleClick}/>
|
|
16
|
-
<Switch checked={switchChecked} onChange={handleClick} color="secondary"/>
|
|
17
|
-
<Switch checked={switchChecked} onChange={handleClick} color="muted"/>
|
|
18
|
-
</Stack>);
|
|
19
|
-
};
|
|
20
|
-
SwitchDefault.story = {
|
|
21
|
-
name: "default",
|
|
22
|
-
};
|
|
23
|
-
export const SwitchWithLabel = () => {
|
|
24
|
-
const [switchChecked, setSwitchChecked] = useState(false);
|
|
25
|
-
const handleClick = (event) => {
|
|
26
|
-
setSwitchChecked(event.target.checked);
|
|
27
|
-
};
|
|
28
|
-
return (<Switch checked={switchChecked} onChange={handleClick} label="With Label"/>);
|
|
29
|
-
};
|
|
30
|
-
SwitchWithLabel.story = {
|
|
31
|
-
name: "with label",
|
|
32
|
-
};
|
|
33
|
-
export const SwitchDisabled = () => {
|
|
34
|
-
return (<Stack>
|
|
35
|
-
<Switch checked={false} disabled={true}/>
|
|
36
|
-
<Switch checked={true} disabled={true}/>
|
|
37
|
-
</Stack>);
|
|
38
|
-
};
|
|
39
|
-
SwitchDisabled.story = {
|
|
40
|
-
name: "disabled",
|
|
41
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Tabs } from "./tabs";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useCallback } from "react";
|
|
2
|
-
import css from "styled-jsx/css";
|
|
3
|
-
import classnames from "classnames";
|
|
4
|
-
import MDCTabBar from "@material/react-tab-bar";
|
|
5
|
-
import { setRef } from "../../utils/set-ref";
|
|
6
|
-
const scope = css.resolve `
|
|
7
|
-
* :global(.mdc-tab) {
|
|
8
|
-
padding: 0 1rem;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
* :global(.mdc-tab__text-label) {
|
|
12
|
-
font-weight: 600;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.mdc-tab-bar--large :global(.mdc-tab) {
|
|
16
|
-
height: 6rem;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.mdc-tab-bar--large :global(.mdc-tab__text-label) {
|
|
20
|
-
font-size: 1rem;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
const TabBar = forwardRef(function TabBar({ large, className, ...props }, ref_) {
|
|
24
|
-
// useCallback to ensure there is a stable ref
|
|
25
|
-
// The <MDCTabBar> component has a `tabBarRef` property which
|
|
26
|
-
// is a ref to the tab bar element
|
|
27
|
-
let ref = useCallback(setRef(ref_, instance => instance.tabBarRef.current), [ref_]);
|
|
28
|
-
return (<>
|
|
29
|
-
<MDCTabBar className={classnames(scope.className, className, {
|
|
30
|
-
"mdc-tab-bar--large": large,
|
|
31
|
-
})} ref={ref} {...props}/>
|
|
32
|
-
{scope.styles}
|
|
33
|
-
</>);
|
|
34
|
-
});
|
|
35
|
-
export default TabBar;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useEffect, useRef } from "react";
|
|
2
|
-
import MDCTab from "@material/react-tab";
|
|
3
|
-
import classnames from "classnames";
|
|
4
|
-
import css from "styled-jsx/css";
|
|
5
|
-
import { tapRef } from "../../utils/tap-ref";
|
|
6
|
-
const Tab = forwardRef(function Tab({ children, className, isCompactHeight, isMinWidth, id, analyticsId, ...props }, ref) {
|
|
7
|
-
const [mounted, setMounted] = useState(false);
|
|
8
|
-
const scope = css.resolve `
|
|
9
|
-
.mdc-tab--min-width {
|
|
10
|
-
flex-grow: 0;
|
|
11
|
-
}
|
|
12
|
-
.mdc-tab--compact-height {
|
|
13
|
-
height: 64px !important;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
setMounted(true);
|
|
18
|
-
}, []);
|
|
19
|
-
const intermediateRef = useRef(null);
|
|
20
|
-
const finalRef = tapRef(ref, intermediateRef);
|
|
21
|
-
// Because the ripple is the element that gets clicked (not the button)
|
|
22
|
-
// we need to put the analyticsId onto the ripple instead.
|
|
23
|
-
// there is no way to get to the ripple supported by @material/react-tab
|
|
24
|
-
// so we have to do it manually
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (mounted) {
|
|
27
|
-
if (intermediateRef.current && intermediateRef.current.tabRef.current) {
|
|
28
|
-
const tabNode = intermediateRef.current.tabRef.current;
|
|
29
|
-
let rippleNode = tabNode.querySelector(".mdc-tab__ripple");
|
|
30
|
-
setAttribute(rippleNode, "id", analyticsId);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, [mounted, analyticsId]);
|
|
34
|
-
return (<MDCTab className={classnames(className, scope.className, {
|
|
35
|
-
"mdc-tab--min-width": isMinWidth,
|
|
36
|
-
"mdc-tab--compact-height": isCompactHeight,
|
|
37
|
-
})} id={id} ref={finalRef} {...props}>
|
|
38
|
-
{children}
|
|
39
|
-
{scope.styles}
|
|
40
|
-
</MDCTab>);
|
|
41
|
-
});
|
|
42
|
-
export default Tab;
|
|
43
|
-
function setAttribute(node, attr, val) {
|
|
44
|
-
if (typeof val !== "undefined") {
|
|
45
|
-
node.setAttribute(attr, val);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
node.removeAttribute(attr);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import classnames from "classnames";
|
|
3
|
-
import css from "styled-jsx/css";
|
|
4
|
-
import TabBar from "./tab-bar";
|
|
5
|
-
import Tab from "./tab";
|
|
6
|
-
import TabTextLabel from "./tab-text-label";
|
|
7
|
-
const scope = css.resolve `
|
|
8
|
-
.tab--noselect {
|
|
9
|
-
width: 0;
|
|
10
|
-
padding: 0;
|
|
11
|
-
flex-grow: 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
when the invisible tab is selected (meaning no actual tab is selected)
|
|
16
|
-
show that the whole tab bar is focused
|
|
17
|
-
*/
|
|
18
|
-
.tab-bar--none-selected:focus-within {
|
|
19
|
-
background-color: rgba(0, 0, 0, 0.02);
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
22
|
-
function Tabs({ tabs, active, onActiveUpdate, isMinWidth, isMinWidthIndicator, isCompactHeight, className, ...props }) {
|
|
23
|
-
if (!active) {
|
|
24
|
-
// In the case that no tab is selected, an invisible tab will be added and be set to active
|
|
25
|
-
tabs = [
|
|
26
|
-
{
|
|
27
|
-
key: "",
|
|
28
|
-
label: null,
|
|
29
|
-
},
|
|
30
|
-
...tabs,
|
|
31
|
-
];
|
|
32
|
-
}
|
|
33
|
-
let activeIndex = active ? tabs.findIndex(tab => tab.key === active) : 0;
|
|
34
|
-
const handleActiveIndexUpdate = (i) => {
|
|
35
|
-
onActiveUpdate(tabs[i].key);
|
|
36
|
-
};
|
|
37
|
-
// When the component first mounts and active is set to null, the first
|
|
38
|
-
// (hidden) tab is selected. When this happens the tab bar gains focus
|
|
39
|
-
// and we can see the focus styling. The user didn't intend to focus the
|
|
40
|
-
// tab bar, so we unselect it by calling blur on the tab.
|
|
41
|
-
const ref = useRef(null);
|
|
42
|
-
const [mounted, setMounted] = useState(false);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (!mounted && !active && ref.current) {
|
|
45
|
-
let elem = ref.current;
|
|
46
|
-
let tab = elem.querySelector(".tab--noselect");
|
|
47
|
-
tab.blur();
|
|
48
|
-
}
|
|
49
|
-
setMounted(true);
|
|
50
|
-
}, [ref, active, mounted]);
|
|
51
|
-
return (<>
|
|
52
|
-
<TabBar key={(!!active).toString()} // TabBar crashes if the active index changes to -1 from non -1 or vice versa
|
|
53
|
-
activeIndex={activeIndex} handleActiveIndexUpdate={handleActiveIndexUpdate} className={classnames(scope.className, className, {
|
|
54
|
-
"tab-bar--none-selected": !active,
|
|
55
|
-
})} ref={ref} {...props}>
|
|
56
|
-
{tabs.map(({ key, label, className, ...tab }) => (<Tab key={key} isCompactHeight={isCompactHeight} isMinWidth={isMinWidth} isMinWidthIndicator={isMinWidthIndicator} className={classnames(scope.className, className, {
|
|
57
|
-
"tab--noselect": !key,
|
|
58
|
-
})} {...tab}>
|
|
59
|
-
<TabTextLabel>{label}</TabTextLabel>
|
|
60
|
-
</Tab>))}
|
|
61
|
-
</TabBar>
|
|
62
|
-
{scope.styles}
|
|
63
|
-
</>);
|
|
64
|
-
}
|
|
65
|
-
export default Tabs;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import CenterDecorator from "../../utils/center-decorator";
|
|
3
|
-
import Tabs from "./tabs";
|
|
4
|
-
import "./tabs.scss";
|
|
5
|
-
export default {
|
|
6
|
-
title: "Tabs",
|
|
7
|
-
decorators: [CenterDecorator],
|
|
8
|
-
};
|
|
9
|
-
export const tabs = function TabsDemo() {
|
|
10
|
-
const [active, setActive] = useState(null);
|
|
11
|
-
return (<div className="container">
|
|
12
|
-
<Tabs active={active} onActiveUpdate={setActive} tabs={[
|
|
13
|
-
{ key: "fundraise", label: "Fundraise" },
|
|
14
|
-
{ key: "donate", label: "Donate" },
|
|
15
|
-
{ key: "organisation", label: "Organisation" },
|
|
16
|
-
]}/>
|
|
17
|
-
<style jsx>{`
|
|
18
|
-
.container {
|
|
19
|
-
max-width: 680px;
|
|
20
|
-
width: 100%;
|
|
21
|
-
}
|
|
22
|
-
`}</style>
|
|
23
|
-
</div>);
|
|
24
|
-
};
|
|
25
|
-
tabs.story = {
|
|
26
|
-
name: "default",
|
|
27
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Text } from "./text";
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import classnames from "classnames";
|
|
3
|
-
import css from "styled-jsx/css";
|
|
4
|
-
import { useTheme, getColorToken, } from "../../theme/theme";
|
|
5
|
-
import { flags } from "../../utils/flags";
|
|
6
|
-
import { wrap } from "../../utils/wrap";
|
|
7
|
-
import Box from "../layout/box";
|
|
8
|
-
// Wrap the text in modifier elements like bold or italic
|
|
9
|
-
function addWrappers(node, { underline, strike, bold, italic }) {
|
|
10
|
-
let result = node;
|
|
11
|
-
result = wrap(result, "u", underline);
|
|
12
|
-
result = wrap(result, "s", strike);
|
|
13
|
-
result = wrap(result, "b", bold);
|
|
14
|
-
result = wrap(result, "i", italic);
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
const kinds = {
|
|
18
|
-
display1: `
|
|
19
|
-
font-size: 3rem;
|
|
20
|
-
line-height: 3.5rem;
|
|
21
|
-
`,
|
|
22
|
-
display2: `
|
|
23
|
-
font-size: 2.25rem;
|
|
24
|
-
line-height: 3rem;
|
|
25
|
-
`,
|
|
26
|
-
h1: `
|
|
27
|
-
font-size: 2.25rem;
|
|
28
|
-
line-height: 3rem;
|
|
29
|
-
font-weight: bold;
|
|
30
|
-
`,
|
|
31
|
-
h2: `
|
|
32
|
-
font-size: 1.75rem;
|
|
33
|
-
line-height: 2rem;
|
|
34
|
-
font-weight: bold;
|
|
35
|
-
`,
|
|
36
|
-
h3: `
|
|
37
|
-
font-size: 1.25rem;
|
|
38
|
-
line-height: 2rem;
|
|
39
|
-
font-weight: bold;
|
|
40
|
-
`,
|
|
41
|
-
h4: `
|
|
42
|
-
font-size: 1rem;
|
|
43
|
-
line-height: 1.5rem;
|
|
44
|
-
font-weight: bold;
|
|
45
|
-
`,
|
|
46
|
-
h5: `
|
|
47
|
-
font-size: 0.875rem;
|
|
48
|
-
line-height: 1.5rem;
|
|
49
|
-
font-weight: bold;
|
|
50
|
-
`,
|
|
51
|
-
h6: `
|
|
52
|
-
font-size: 0.875rem;
|
|
53
|
-
line-height: 1.5rem;
|
|
54
|
-
font-weight: bold;
|
|
55
|
-
`,
|
|
56
|
-
p: `
|
|
57
|
-
font-size: 1rem;
|
|
58
|
-
line-height: 1.5rem;
|
|
59
|
-
`,
|
|
60
|
-
sub: `
|
|
61
|
-
font-size: 0.875rem;
|
|
62
|
-
line-height: 1.25rem;
|
|
63
|
-
`,
|
|
64
|
-
small: `
|
|
65
|
-
font-size: 0.75rem;
|
|
66
|
-
line-height: 1.25rem;
|
|
67
|
-
`,
|
|
68
|
-
fine: `
|
|
69
|
-
font-size: 0.675rem;
|
|
70
|
-
line-height: 1rem;
|
|
71
|
-
`,
|
|
72
|
-
span: ``,
|
|
73
|
-
};
|
|
74
|
-
const Text = forwardRef(function Text({ elem: element, kind, font, align,
|
|
75
|
-
// component types
|
|
76
|
-
h1, h2, h3, h4, h5, h6, p, small, span,
|
|
77
|
-
// modifiers
|
|
78
|
-
underline, strike, bold, italic,
|
|
79
|
-
// color
|
|
80
|
-
color, invert,
|
|
81
|
-
//
|
|
82
|
-
children, className, ...rest }, ref) {
|
|
83
|
-
const theme = useTheme();
|
|
84
|
-
// Process component type flags, defaulting to span
|
|
85
|
-
element = flags({ h1, h2, h3, h4, h5, h6, p, small, span }, element || "span");
|
|
86
|
-
// If no kind is specified, just use the kind named after the element
|
|
87
|
-
kind = kind || element;
|
|
88
|
-
// Headings are already bold so prevent wrapping an extra <b> element
|
|
89
|
-
if (isHeading(element) && bold) {
|
|
90
|
-
bold = false;
|
|
91
|
-
}
|
|
92
|
-
// The h6 style has a different color by default
|
|
93
|
-
if (kind === "h6") {
|
|
94
|
-
color = color || "muted";
|
|
95
|
-
}
|
|
96
|
-
const foreground = color || invert
|
|
97
|
-
? getColorToken(theme, "foreground", color || "neutral", {
|
|
98
|
-
invert,
|
|
99
|
-
})
|
|
100
|
-
: "inherit";
|
|
101
|
-
const fontFamily = font
|
|
102
|
-
? theme.typography.fontFamily[font]
|
|
103
|
-
: "inherit";
|
|
104
|
-
const scope = css.resolve `
|
|
105
|
-
${element} {
|
|
106
|
-
font-weight: initial;
|
|
107
|
-
font-family: ${fontFamily};
|
|
108
|
-
color: ${foreground};
|
|
109
|
-
${kinds[kind]}
|
|
110
|
-
margin: 0;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.unbold {
|
|
114
|
-
font-weight: 400;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.align {
|
|
118
|
-
text-align: ${align};
|
|
119
|
-
}
|
|
120
|
-
`;
|
|
121
|
-
return (<Box as={element} {...rest} className={classnames(className, {
|
|
122
|
-
unbold: isHeading(element) && bold === false,
|
|
123
|
-
align: align,
|
|
124
|
-
}, scope.className)}
|
|
125
|
-
// The following error is caused by the fact that the element rendered
|
|
126
|
-
// could be either a HTMLElement or HTMLHeadingElement but it cannot know
|
|
127
|
-
// which at runtime. In practice the difference between the two elements
|
|
128
|
-
// never really arises as an issue.
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
ref={ref}>
|
|
131
|
-
{addWrappers(children, { underline, strike, bold, italic })}
|
|
132
|
-
{scope.styles}
|
|
133
|
-
</Box>);
|
|
134
|
-
});
|
|
135
|
-
function isHeading(kind) {
|
|
136
|
-
return kind.startsWith("h");
|
|
137
|
-
}
|
|
138
|
-
export default Text;
|