@pushwoosh/dumb-components 0.0.19 → 1.0.1
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/ActionsGroup/ActionsGroup.d.ts +3 -0
- package/ActionsGroup/ActionsGroup.js +18 -0
- package/ActionsGroup/ActionsGroupItem.d.ts +3 -0
- package/ActionsGroup/ActionsGroupItem.js +12 -0
- package/ActionsGroup/index.d.ts +3 -0
- package/ActionsGroup/index.js +2 -0
- package/ActionsGroup/styles.d.ts +7 -0
- package/ActionsGroup/styles.js +22 -0
- package/ActionsGroup/types.d.ts +12 -0
- package/Badge/Badge.d.ts +3 -0
- package/Badge/Badge.js +16 -0
- package/Badge/index.d.ts +2 -0
- package/Badge/index.js +1 -0
- package/Badge/maps.d.ts +19 -0
- package/Badge/maps.js +19 -0
- package/Badge/styles.d.ts +5 -0
- package/Badge/styles.js +14 -0
- package/Badge/types.d.ts +8 -0
- package/Banner/Banner.d.ts +3 -0
- package/Banner/Banner.js +82 -0
- package/Banner/colors.d.ts +12 -0
- package/Banner/colors.js +115 -0
- package/Banner/index.d.ts +2 -0
- package/Banner/index.js +1 -0
- package/Banner/maps.d.ts +27 -0
- package/Banner/maps.js +19 -0
- package/Banner/styles.d.ts +29 -0
- package/Banner/styles.js +45 -0
- package/Banner/types.d.ts +20 -0
- package/Button/Button.d.ts +5 -0
- package/Button/Button.js +48 -0
- package/Button/GhostButton.d.ts +1 -0
- package/Button/GhostButton.js +5 -0
- package/Button/colors.d.ts +16 -0
- package/Button/colors.js +130 -0
- package/Button/index.d.ts +3 -0
- package/Button/index.js +2 -0
- package/Button/maps.d.ts +132 -0
- package/Button/maps.js +37 -0
- package/Button/styles.d.ts +120 -0
- package/Button/styles.js +103 -0
- package/Button/types.d.ts +26 -0
- package/CardMetric/CardChildren.d.ts +3 -0
- package/CardMetric/CardChildren.js +25 -0
- package/CardMetric/CardCollapse.d.ts +3 -0
- package/CardMetric/CardCollapse.js +13 -0
- package/CardMetric/CardMetric.d.ts +3 -0
- package/CardMetric/CardMetric.js +62 -0
- package/CardMetric/index.d.ts +2 -0
- package/CardMetric/index.js +1 -0
- package/CardMetric/styles.d.ts +13 -0
- package/CardMetric/styles.js +74 -0
- package/CardMetric/types.d.ts +34 -0
- package/Checkbox/Checkbox.d.ts +3 -0
- package/Checkbox/Checkbox.js +47 -0
- package/Checkbox/index.d.ts +2 -0
- package/Checkbox/index.js +1 -0
- package/Checkbox/maps.d.ts +3 -0
- package/Checkbox/maps.js +7 -0
- package/Checkbox/styles.d.ts +9 -0
- package/Checkbox/styles.js +17 -0
- package/Checkbox/types.d.ts +15 -0
- package/Drawer/Drawer.d.ts +3 -0
- package/Drawer/Drawer.js +62 -0
- package/Drawer/index.d.ts +1 -0
- package/Drawer/index.js +1 -0
- package/Drawer/maps.d.ts +6 -0
- package/Drawer/maps.js +6 -0
- package/Drawer/styles.d.ts +11 -0
- package/Drawer/styles.js +57 -0
- package/Drawer/types.d.ts +18 -0
- package/EditableField/EditableField.d.ts +3 -0
- package/EditableField/EditableField.js +61 -0
- package/EditableField/index.d.ts +2 -0
- package/EditableField/index.js +1 -0
- package/EditableField/styles.d.ts +8 -0
- package/EditableField/styles.js +25 -0
- package/EditableField/types.d.ts +15 -0
- package/EmailTemplatePreview/EmailTemplatePreview.d.ts +3 -11
- package/EmailTemplatePreview/EmailTemplatePreview.js +11 -10
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/NoEmailTemplatePreview.d.ts +2 -2
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/NoEmailTemplatePreview.js +3 -3
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/assets/PW_logo.svg +1 -5
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/{styled.js → styles.js} +2 -2
- package/EmailTemplatePreview/{styled.js → styles.js} +1 -1
- package/EmailTemplatePreview/types.d.ts +8 -0
- package/ExportResult/ExportResult.d.ts +2 -2
- package/ExportResult/ExportResult.js +10 -9
- package/ExportResult/{styled.js → styles.js} +5 -5
- package/FieldBox/FieldBox.d.ts +3 -3
- package/FieldBox/FieldBox.js +8 -7
- package/FieldBox/index.d.ts +1 -1
- package/FieldBox/types.js +1 -0
- package/NumberPicker/NumberPicker.js +2 -2
- package/NumberPicker/{AutosizeInput.d.ts → components/AutosizeInput/AutosizeInput.d.ts} +1 -1
- package/NumberPicker/{AutosizeInput.js → components/AutosizeInput/AutosizeInput.js} +3 -3
- package/NumberPicker/components/AutosizeInput/index.d.ts +1 -0
- package/NumberPicker/components/AutosizeInput/index.js +1 -0
- package/NumberPicker/{AutosizeInput.styled.js → components/AutosizeInput/styles.js} +1 -1
- package/NumberPicker/components/AutosizeInput/types.js +1 -0
- package/NumberPicker/{styled.js → styles.js} +3 -3
- package/Popover/Popover.d.ts +3 -0
- package/Popover/Popover.js +44 -0
- package/Popover/index.d.ts +4 -0
- package/Popover/index.js +2 -0
- package/Popover/styles.d.ts +6 -0
- package/Popover/styles.js +19 -0
- package/Popover/types.d.ts +12 -0
- package/Popover/types.js +1 -0
- package/ProgressBar/ProgressBar.d.ts +2 -2
- package/ProgressBar/ProgressBar.js +19 -16
- package/ProgressBar/{styled.js → styles.js} +10 -10
- package/PushPreview/PushPreview.js +3 -3
- package/PushPreview/{styled.js → styles.js} +8 -8
- package/Radio/Radio.d.ts +3 -0
- package/Radio/Radio.js +37 -0
- package/Radio/index.d.ts +2 -0
- package/Radio/index.js +1 -0
- package/Radio/maps.d.ts +3 -0
- package/Radio/maps.js +8 -0
- package/Radio/styled.d.ts +5 -0
- package/Radio/styled.js +13 -0
- package/Radio/types.d.ts +12 -0
- package/Radio/types.js +1 -0
- package/Spinner/Spinner.d.ts +3 -0
- package/Spinner/Spinner.js +20 -0
- package/Spinner/assets/index.d.ts +4 -0
- package/Spinner/assets/index.js +6 -0
- package/Spinner/assets/spinner.medium.svg +1 -0
- package/Spinner/assets/spinner.small.svg +1 -0
- package/Spinner/index.d.ts +2 -0
- package/Spinner/index.js +1 -0
- package/Spinner/maps.d.ts +5 -0
- package/Spinner/maps.js +5 -0
- package/Spinner/styles.d.ts +5 -0
- package/Spinner/styles.js +20 -0
- package/Spinner/types.d.ts +6 -0
- package/Spinner/types.js +1 -0
- package/StatisticCard/StatisticCard.d.ts +2 -2
- package/StatisticCard/StatisticCard.js +15 -14
- package/Tabs/{tab/tab.d.ts → components/Tab/Tab.d.ts} +2 -2
- package/Tabs/{tab/tab.js → components/Tab/Tab.js} +2 -2
- package/Tabs/components/Tab/index.d.ts +1 -0
- package/Tabs/components/Tab/index.js +1 -0
- package/Tabs/{tab/tab.types.d.ts → components/Tab/types.d.ts} +1 -1
- package/Tabs/components/Tab/types.js +1 -0
- package/Tabs/{tab-bar/tab-bar.js → components/TabBar/TabBar.js} +2 -2
- package/Tabs/components/TabBar/index.d.ts +1 -0
- package/Tabs/components/TabBar/index.js +1 -0
- package/Tabs/{tab-bar/tab-bar.styles.js → components/TabBar/styles.js} +2 -2
- package/Tabs/components/TabBar/types.js +1 -0
- package/Tabs/{tabs-list-slide-frame/tabs-list-slide-frame.d.ts → components/TabBarScrollableFrame/TabBarScrollableFrame.d.ts} +1 -1
- package/Tabs/{tabs-list-slide-frame/tabs-list-slide-frame.js → components/TabBarScrollableFrame/TabBarScrollableFrame.js} +2 -2
- package/Tabs/components/TabBarScrollableFrame/index.d.ts +1 -0
- package/Tabs/components/TabBarScrollableFrame/index.js +1 -0
- package/Tabs/{tabs-list-slide-frame/tabs-list-slide-frame.styles.js → components/TabBarScrollableFrame/styles.js} +5 -5
- package/Tabs/components/TabBarScrollableFrame/types.js +1 -0
- package/Tabs/{tab-base/tab-base.js → components/TabBase/TabBase.js} +1 -1
- package/Tabs/components/TabBase/index.d.ts +1 -0
- package/Tabs/components/TabBase/index.js +1 -0
- package/Tabs/{tab-base/tab-base.styles.js → components/TabBase/styles.js} +4 -4
- package/Tabs/components/TabBase/types.js +1 -0
- package/Tabs/{tab-panel/tab-panel.d.ts → components/TabPanel/TabPanel.d.ts} +1 -1
- package/Tabs/{tab-panel/tab-panel.js → components/TabPanel/TabPanel.js} +1 -1
- package/Tabs/components/TabPanel/index.d.ts +1 -0
- package/Tabs/components/TabPanel/index.js +1 -0
- package/Tabs/{tab-panel → components/TabPanel}/styles.js +1 -1
- package/Tabs/{tab-panel/tab-panel.types.d.ts → components/TabPanel/types.d.ts} +1 -1
- package/Tabs/components/TabPanel/types.js +1 -0
- package/Tabs/{tabs/tabs.d.ts → components/Tabs/Tabs.d.ts} +1 -1
- package/Tabs/{tabs/tabs.js → components/Tabs/Tabs.js} +1 -1
- package/Tabs/components/Tabs/index.d.ts +1 -0
- package/Tabs/components/Tabs/index.js +1 -0
- package/Tabs/{tabs → components/Tabs}/styles.js +1 -1
- package/Tabs/{tabs/tabs.types.d.ts → components/Tabs/types.d.ts} +1 -1
- package/Tabs/components/Tabs/types.js +1 -0
- package/Tabs/{tabs.context.d.ts → context.d.ts} +1 -1
- package/Tabs/index.d.ts +5 -5
- package/Tabs/index.js +4 -5
- package/Tabs/types.js +1 -0
- package/Tooltip/Tooltip.d.ts +3 -0
- package/Tooltip/Tooltip.js +47 -0
- package/Tooltip/index.d.ts +2 -0
- package/Tooltip/index.js +1 -0
- package/Tooltip/maps.d.ts +48 -0
- package/Tooltip/maps.js +161 -0
- package/Tooltip/styles.d.ts +5 -0
- package/Tooltip/styles.js +22 -0
- package/Tooltip/types.d.ts +14 -0
- package/Tooltip/types.js +1 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useElementWidth.d.ts +11 -0
- package/hooks/useElementWidth.js +27 -0
- package/hooks/useOnClickOutside.d.ts +4 -0
- package/hooks/useOnClickOutside.js +23 -0
- package/index.d.ts +14 -3
- package/index.js +12 -1
- package/package.json +7 -4
- package/Tabs/tab/index.d.ts +0 -2
- package/Tabs/tab/index.js +0 -2
- package/Tabs/tab-bar/index.d.ts +0 -2
- package/Tabs/tab-bar/index.js +0 -2
- package/Tabs/tab-base/index.d.ts +0 -3
- package/Tabs/tab-base/index.js +0 -3
- package/Tabs/tab-panel/index.d.ts +0 -2
- package/Tabs/tab-panel/index.js +0 -2
- package/Tabs/tabs/index.d.ts +0 -2
- package/Tabs/tabs/index.js +0 -2
- package/Tabs/tabs-list-slide-frame/index.d.ts +0 -3
- package/Tabs/tabs-list-slide-frame/index.js +0 -3
- package/{FieldBox/FieldBox.types.js → ActionsGroup/types.js} +0 -0
- package/{NumberPicker/AutosizeInput.types.js → Badge/types.js} +0 -0
- package/{Tabs/tab-bar/tab-bar.types.js → Banner/types.js} +0 -0
- package/{Tabs/tab-base/tab-base.types.js → Button/types.js} +0 -0
- package/{Tabs/tab-panel/tab-panel.types.js → CardMetric/types.js} +0 -0
- package/{Tabs/tab/tab.types.js → Checkbox/types.js} +0 -0
- package/{Tabs/tabs-list-slide-frame/tabs-list-slide-frame.types.js → Drawer/types.js} +0 -0
- package/{Tabs/tabs.types.js → EditableField/types.js} +0 -0
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/{styled.d.ts → styles.d.ts} +0 -0
- package/EmailTemplatePreview/{styled.d.ts → styles.d.ts} +0 -0
- package/{Tabs/tabs/tabs.types.js → EmailTemplatePreview/types.js} +0 -0
- package/ExportResult/{styled.d.ts → styles.d.ts} +0 -0
- package/FieldBox/{FieldBox.types.d.ts → types.d.ts} +0 -0
- package/NumberPicker/{AutosizeInput.constants.d.ts → components/AutosizeInput/constants.d.ts} +0 -0
- package/NumberPicker/{AutosizeInput.constants.js → components/AutosizeInput/constants.js} +0 -0
- package/NumberPicker/{AutosizeInput.styled.d.ts → components/AutosizeInput/styles.d.ts} +0 -0
- package/NumberPicker/{AutosizeInput.types.d.ts → components/AutosizeInput/types.d.ts} +0 -0
- package/NumberPicker/{styled.d.ts → styles.d.ts} +0 -0
- package/ProgressBar/{styled.d.ts → styles.d.ts} +0 -0
- package/PushPreview/{constants/urls.d.ts → constants.d.ts} +0 -0
- package/PushPreview/{constants/urls.js → constants.js} +0 -0
- package/PushPreview/{helpers/helpers.d.ts → helpers.d.ts} +0 -0
- package/PushPreview/{helpers/helpers.js → helpers.js} +0 -0
- package/PushPreview/{styled.d.ts → styles.d.ts} +0 -0
- package/Tabs/{tab-bar/tab-bar.d.ts → components/TabBar/TabBar.d.ts} +0 -0
- package/Tabs/{tab-bar/tab-bar.styles.d.ts → components/TabBar/styles.d.ts} +0 -0
- package/Tabs/{tab-bar/tab-bar.types.d.ts → components/TabBar/types.d.ts} +0 -0
- package/Tabs/{tabs-list-slide-frame/tabs-list-slide-frame.styles.d.ts → components/TabBarScrollableFrame/styles.d.ts} +0 -0
- package/Tabs/{tabs-list-slide-frame/tabs-list-slide-frame.types.d.ts → components/TabBarScrollableFrame/types.d.ts} +0 -0
- package/Tabs/{tab-base/tab-base.d.ts → components/TabBase/TabBase.d.ts} +1 -1
- package/Tabs/{tab-base/tab-base.styles.d.ts → components/TabBase/styles.d.ts} +0 -0
- package/Tabs/{tab-base/tab-base.types.d.ts → components/TabBase/types.d.ts} +1 -1
- /package/Tabs/{tab-panel → components/TabPanel}/styles.d.ts +0 -0
- /package/Tabs/{tabs → components/Tabs}/styles.d.ts +0 -0
- /package/Tabs/{tabs.context.js → context.js} +0 -0
- /package/Tabs/{tabs.helpers.d.ts → helpers.d.ts} +0 -0
- /package/Tabs/{tabs.helpers.js → helpers.js} +0 -0
- /package/Tabs/{tabs.types.d.ts → types.d.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionsGroupBox, ActionsGroupInner } from './styles';
|
|
3
|
+
export function ActionsGroup(props) {
|
|
4
|
+
const {
|
|
5
|
+
boxRef,
|
|
6
|
+
align,
|
|
7
|
+
gap,
|
|
8
|
+
children,
|
|
9
|
+
...rest
|
|
10
|
+
} = props;
|
|
11
|
+
return React.createElement(ActionsGroupBox, {
|
|
12
|
+
...rest,
|
|
13
|
+
ref: boxRef
|
|
14
|
+
}, React.createElement(ActionsGroupInner, {
|
|
15
|
+
"$align": align,
|
|
16
|
+
"$gap": gap
|
|
17
|
+
}, children));
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ActionsGroupProps } from './types';
|
|
2
|
+
export declare const ActionsGroupBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const ActionsGroupItemBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const ActionsGroupInner: import("styled-components").StyledComponent<"div", any, {
|
|
5
|
+
$align: ActionsGroupProps["align"];
|
|
6
|
+
$gap: ActionsGroupProps["gap"];
|
|
7
|
+
}, never>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const ActionsGroupBox = styled.div.withConfig({
|
|
3
|
+
displayName: "ActionsGroupBox",
|
|
4
|
+
componentId: "sc-eb6b51-0"
|
|
5
|
+
})([""]);
|
|
6
|
+
export const ActionsGroupItemBox = styled.div.withConfig({
|
|
7
|
+
displayName: "ActionsGroupItemBox",
|
|
8
|
+
componentId: "sc-eb6b51-1"
|
|
9
|
+
})([""]);
|
|
10
|
+
export const ActionsGroupInner = styled.div.withConfig({
|
|
11
|
+
displayName: "ActionsGroupInner",
|
|
12
|
+
componentId: "sc-eb6b51-2"
|
|
13
|
+
})(["display:flex;flex-wrap:nowrap;align-items:center;justify-content:", ";margin:0 ", ";", "{padding:0 ", ";}"], ({
|
|
14
|
+
$align
|
|
15
|
+
}) => $align === 'end' ? 'flex-end' : 'flex-start', ({
|
|
16
|
+
$gap
|
|
17
|
+
}) => `calc(-${$gap}/2)`, ActionsGroupItemBox, ({
|
|
18
|
+
$gap
|
|
19
|
+
}) => `calc(${$gap}/2)`);
|
|
20
|
+
ActionsGroupBox.displayName = 'ActionsGroupBox';
|
|
21
|
+
ActionsGroupInner.displayName = 'ActionsGroupInner';
|
|
22
|
+
ActionsGroupItemBox.displayName = 'ActionsGroupBox';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Ref, ReactNode } from 'react';
|
|
2
|
+
import type { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
export type ActionsGroupProps = Omit<JSX.IntrinsicElements['div'], 'ref'> & {
|
|
4
|
+
readonly boxRef?: Ref<HTMLDivElement>;
|
|
5
|
+
readonly align: 'start' | 'end';
|
|
6
|
+
readonly gap: Spacing;
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export type ActionsGroupItemProps = Omit<JSX.IntrinsicElements['div'], 'ref'> & {
|
|
10
|
+
readonly boxRef?: Ref<HTMLDivElement>;
|
|
11
|
+
readonly children: ReactNode;
|
|
12
|
+
};
|
package/Badge/Badge.d.ts
ADDED
package/Badge/Badge.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BadgeBox } from './styles';
|
|
3
|
+
export function Badge(props) {
|
|
4
|
+
const {
|
|
5
|
+
boxRef,
|
|
6
|
+
color,
|
|
7
|
+
isSaturated,
|
|
8
|
+
...rest
|
|
9
|
+
} = props;
|
|
10
|
+
return React.createElement(BadgeBox, {
|
|
11
|
+
...rest,
|
|
12
|
+
ref: boxRef,
|
|
13
|
+
"$color": color,
|
|
14
|
+
"$isSaturated": isSaturated
|
|
15
|
+
});
|
|
16
|
+
}
|
package/Badge/index.d.ts
ADDED
package/Badge/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge } from './Badge';
|
package/Badge/maps.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
2
|
+
export declare const BadgeColorToColorMap: {
|
|
3
|
+
gray: Color;
|
|
4
|
+
green: Color;
|
|
5
|
+
orange: Color;
|
|
6
|
+
red: Color;
|
|
7
|
+
purple: Color;
|
|
8
|
+
sky: Color;
|
|
9
|
+
locked: Color;
|
|
10
|
+
};
|
|
11
|
+
export declare const BadgeColorToLightColorMap: {
|
|
12
|
+
gray: Color;
|
|
13
|
+
green: Color;
|
|
14
|
+
orange: Color;
|
|
15
|
+
red: Color;
|
|
16
|
+
purple: Color;
|
|
17
|
+
sky: Color;
|
|
18
|
+
locked: Color;
|
|
19
|
+
};
|
package/Badge/maps.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
2
|
+
export const BadgeColorToColorMap = {
|
|
3
|
+
gray: Color.SOFT,
|
|
4
|
+
green: Color.SUCCESS,
|
|
5
|
+
orange: Color.WARNING,
|
|
6
|
+
red: Color.DANGER,
|
|
7
|
+
purple: Color.EXCEPTIONAL,
|
|
8
|
+
sky: Color.BRIGHT,
|
|
9
|
+
locked: Color.LOCKED
|
|
10
|
+
};
|
|
11
|
+
export const BadgeColorToLightColorMap = {
|
|
12
|
+
gray: Color.SOFT_LIGHT,
|
|
13
|
+
green: Color.SUCCESS_LIGHT,
|
|
14
|
+
orange: Color.WARNING_LIGHT,
|
|
15
|
+
red: Color.DANGER_LIGHT,
|
|
16
|
+
purple: Color.EXCEPTIONAL_LIGHT,
|
|
17
|
+
sky: Color.BRIGHT_LIGHT,
|
|
18
|
+
locked: Color.FROZEN
|
|
19
|
+
};
|
package/Badge/styles.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, FontSize, FontWeight, FontFamily, LineHeight, ShapeRadius, Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { BadgeColorToColorMap, BadgeColorToLightColorMap } from './maps';
|
|
4
|
+
export const BadgeBox = styled.div.withConfig({
|
|
5
|
+
displayName: "BadgeBox",
|
|
6
|
+
componentId: "sc-6ptm8-0"
|
|
7
|
+
})(["display:inline-block;width:fit-content;padding:", " ", ";border-radius:", ";color:", ";background-color:", ";font-size:", ";font-family:", ";font-weight:", ";line-height:", ";text-transform:uppercase;user-select:none;"], Spacing.S0, Spacing.S2, ShapeRadius.SECTION, ({
|
|
8
|
+
$isSaturated,
|
|
9
|
+
$color
|
|
10
|
+
}) => $isSaturated ? Color.CLEAR : BadgeColorToColorMap[$color], ({
|
|
11
|
+
$isSaturated,
|
|
12
|
+
$color
|
|
13
|
+
}) => $isSaturated ? BadgeColorToColorMap[$color] : BadgeColorToLightColorMap[$color], FontSize.HEADING5, FontFamily.MAIN, FontWeight.MEDIUM, LineHeight.SMALL);
|
|
14
|
+
BadgeBox.displayName = 'BadgeBox';
|
package/Badge/types.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ref, ReactNode } from 'react';
|
|
2
|
+
export type BadgeColor = 'gray' | 'green' | 'orange' | 'red' | 'purple' | 'sky' | 'locked';
|
|
3
|
+
export type BadgeProps = Omit<JSX.IntrinsicElements['div'], 'ref'> & {
|
|
4
|
+
readonly boxRef?: Ref<HTMLDivElement>;
|
|
5
|
+
readonly color: BadgeColor;
|
|
6
|
+
readonly isSaturated?: boolean;
|
|
7
|
+
readonly children: ReactNode;
|
|
8
|
+
};
|
package/Banner/Banner.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { CloseIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { H4 } from '@pushwoosh/kit-typography';
|
|
6
|
+
import { Spinner } from '../Spinner';
|
|
7
|
+
import { BannerPropsToBannerBoxMap, BannerPropsToIconContainerMap, BannerTypeToSpinnerColorMap } from './maps';
|
|
8
|
+
import { ActionButton, BannerContent, BannerSpinner, CloseButton, IconContainer } from './styles';
|
|
9
|
+
export function Banner(props) {
|
|
10
|
+
const [isOpen, setIsOpen] = useState(true);
|
|
11
|
+
const [isActionPressed, setIsActionPressed] = useState(false);
|
|
12
|
+
const [isClosePressed, setIsClosePressed] = useState(false);
|
|
13
|
+
const {
|
|
14
|
+
boxRef,
|
|
15
|
+
type,
|
|
16
|
+
title,
|
|
17
|
+
icon,
|
|
18
|
+
view = 'shape',
|
|
19
|
+
canBeClosed,
|
|
20
|
+
isLoading = false,
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
onClose,
|
|
24
|
+
...rest
|
|
25
|
+
} = props;
|
|
26
|
+
const {
|
|
27
|
+
action
|
|
28
|
+
} = props;
|
|
29
|
+
const handleClose = useCallback(() => {
|
|
30
|
+
setIsOpen(false);
|
|
31
|
+
setIsClosePressed(true);
|
|
32
|
+
if (onClose) {
|
|
33
|
+
onClose();
|
|
34
|
+
}
|
|
35
|
+
}, [onClose]);
|
|
36
|
+
const handleAction = useCallback(() => {
|
|
37
|
+
setIsActionPressed(true);
|
|
38
|
+
action === null || action === void 0 || action.onClick();
|
|
39
|
+
}, [action]);
|
|
40
|
+
if (!type) {
|
|
41
|
+
console.error(`[Banner]: required prop type "${type}" is not set`);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const BannerBox = BannerPropsToBannerBoxMap[view];
|
|
45
|
+
if (!BannerBox) {
|
|
46
|
+
console.error(`[Banner]: cannot render with type "${type}" and view "${view}"`);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const DefaultIcon = BannerPropsToIconContainerMap[type] ?? null;
|
|
50
|
+
const SpinnerColor = BannerTypeToSpinnerColorMap[type];
|
|
51
|
+
if (!isOpen) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return React.createElement(BannerBox, {
|
|
55
|
+
...rest,
|
|
56
|
+
"$isOpen": isOpen,
|
|
57
|
+
"$isLoading": isLoading,
|
|
58
|
+
ref: boxRef,
|
|
59
|
+
"$type": type,
|
|
60
|
+
className: className
|
|
61
|
+
}, React.createElement(IconContainer, null, icon || React.createElement(DefaultIcon, {
|
|
62
|
+
size: "small",
|
|
63
|
+
view: "filled"
|
|
64
|
+
})), React.createElement(BannerContent, {
|
|
65
|
+
"$hasChildren": !!children
|
|
66
|
+
}, React.createElement(H4, null, title), children && React.createElement("div", null, children)), action && React.createElement(Vertical, {
|
|
67
|
+
"$padding": `0 ${Spacing.S3} 0 0`,
|
|
68
|
+
"$alignContent": "center"
|
|
69
|
+
}, React.createElement(ActionButton, {
|
|
70
|
+
onClick: handleAction,
|
|
71
|
+
"$isPressed": isActionPressed,
|
|
72
|
+
"$isLoading": isLoading
|
|
73
|
+
}, React.createElement("span", null, action.buttonText), isLoading && React.createElement(BannerSpinner, null, React.createElement(Spinner, {
|
|
74
|
+
size: "small",
|
|
75
|
+
color: SpinnerColor
|
|
76
|
+
})))), canBeClosed && React.createElement(CloseButton, {
|
|
77
|
+
onClick: handleClose,
|
|
78
|
+
"$isPressed": isClosePressed
|
|
79
|
+
}, React.createElement(CloseIcon, {
|
|
80
|
+
size: "small"
|
|
81
|
+
})));
|
|
82
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BannerType } from './types';
|
|
2
|
+
type Colors = {
|
|
3
|
+
color: string;
|
|
4
|
+
bgColor: string;
|
|
5
|
+
};
|
|
6
|
+
type BannerColors = {
|
|
7
|
+
base: Colors;
|
|
8
|
+
iconArea: Colors;
|
|
9
|
+
hover: Partial<Colors>;
|
|
10
|
+
};
|
|
11
|
+
export declare const colors: Record<BannerType, Record<'shape' | 'ghost', BannerColors>>;
|
|
12
|
+
export {};
|
package/Banner/colors.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
2
|
+
export const colors = {
|
|
3
|
+
error: {
|
|
4
|
+
shape: {
|
|
5
|
+
base: {
|
|
6
|
+
color: Color.MAIN,
|
|
7
|
+
bgColor: Color.DANGER_LIGHT
|
|
8
|
+
},
|
|
9
|
+
iconArea: {
|
|
10
|
+
color: Color.CLEAR,
|
|
11
|
+
bgColor: Color.DANGER
|
|
12
|
+
},
|
|
13
|
+
hover: {
|
|
14
|
+
bgColor: Color.DANGER_LIGHT
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
ghost: {
|
|
18
|
+
base: {
|
|
19
|
+
color: Color.MAIN,
|
|
20
|
+
bgColor: Color.DANGER_LIGHT
|
|
21
|
+
},
|
|
22
|
+
iconArea: {
|
|
23
|
+
color: Color.DANGER,
|
|
24
|
+
bgColor: Color.DANGER_LIGHT
|
|
25
|
+
},
|
|
26
|
+
hover: {
|
|
27
|
+
bgColor: Color.DANGER_LIGHT
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
warning: {
|
|
32
|
+
shape: {
|
|
33
|
+
base: {
|
|
34
|
+
color: Color.MAIN,
|
|
35
|
+
bgColor: Color.WARNING_LIGHT
|
|
36
|
+
},
|
|
37
|
+
iconArea: {
|
|
38
|
+
color: Color.CLEAR,
|
|
39
|
+
bgColor: Color.WARNING
|
|
40
|
+
},
|
|
41
|
+
hover: {
|
|
42
|
+
bgColor: Color.WARNING_LIGHT
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
ghost: {
|
|
46
|
+
base: {
|
|
47
|
+
color: Color.MAIN,
|
|
48
|
+
bgColor: Color.WARNING_LIGHT
|
|
49
|
+
},
|
|
50
|
+
iconArea: {
|
|
51
|
+
color: Color.WARNING,
|
|
52
|
+
bgColor: Color.WARNING_LIGHT
|
|
53
|
+
},
|
|
54
|
+
hover: {
|
|
55
|
+
bgColor: Color.WARNING_LIGHT
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
info: {
|
|
60
|
+
shape: {
|
|
61
|
+
base: {
|
|
62
|
+
color: Color.MAIN,
|
|
63
|
+
bgColor: Color.BRIGHT_LIGHT
|
|
64
|
+
},
|
|
65
|
+
iconArea: {
|
|
66
|
+
color: Color.CLEAR,
|
|
67
|
+
bgColor: Color.BRIGHT
|
|
68
|
+
},
|
|
69
|
+
hover: {
|
|
70
|
+
bgColor: Color.BRIGHT_LIGHT
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
ghost: {
|
|
74
|
+
base: {
|
|
75
|
+
color: Color.MAIN,
|
|
76
|
+
bgColor: Color.BRIGHT_LIGHT
|
|
77
|
+
},
|
|
78
|
+
iconArea: {
|
|
79
|
+
color: Color.BRIGHT,
|
|
80
|
+
bgColor: Color.BRIGHT_LIGHT
|
|
81
|
+
},
|
|
82
|
+
hover: {
|
|
83
|
+
bgColor: Color.BRIGHT_LIGHT
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
success: {
|
|
88
|
+
shape: {
|
|
89
|
+
base: {
|
|
90
|
+
color: Color.MAIN,
|
|
91
|
+
bgColor: Color.SUCCESS_LIGHT
|
|
92
|
+
},
|
|
93
|
+
iconArea: {
|
|
94
|
+
color: Color.CLEAR,
|
|
95
|
+
bgColor: Color.SUCCESS
|
|
96
|
+
},
|
|
97
|
+
hover: {
|
|
98
|
+
bgColor: Color.SUCCESS_LIGHT
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
ghost: {
|
|
102
|
+
base: {
|
|
103
|
+
color: Color.MAIN,
|
|
104
|
+
bgColor: Color.SUCCESS_LIGHT
|
|
105
|
+
},
|
|
106
|
+
iconArea: {
|
|
107
|
+
color: Color.SUCCESS,
|
|
108
|
+
bgColor: Color.SUCCESS_LIGHT
|
|
109
|
+
},
|
|
110
|
+
hover: {
|
|
111
|
+
bgColor: Color.SUCCESS_LIGHT
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
package/Banner/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Banner } from './Banner';
|
package/Banner/maps.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
2
|
+
export declare const BannerPropsToIconContainerMap: {
|
|
3
|
+
error: import("react").FC<import("@pushwoosh/kit-icons").DangerTriangleIconProps>;
|
|
4
|
+
warning: import("react").FC<import("@pushwoosh/kit-icons").WarningRoundIconProps>;
|
|
5
|
+
info: import("react").FC<import("@pushwoosh/kit-icons").WarningRoundIconProps>;
|
|
6
|
+
success: import("react").FC<import("@pushwoosh/kit-icons").WarningRoundIconProps>;
|
|
7
|
+
};
|
|
8
|
+
export declare const BannerTypeToSpinnerColorMap: {
|
|
9
|
+
error: Color;
|
|
10
|
+
warning: Color;
|
|
11
|
+
info: Color;
|
|
12
|
+
success: Color;
|
|
13
|
+
};
|
|
14
|
+
export declare const BannerPropsToBannerBoxMap: {
|
|
15
|
+
readonly shape: import("styled-components").StyledComponent<"div", any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
16
|
+
$isOpen?: boolean;
|
|
17
|
+
$isLoading: boolean;
|
|
18
|
+
} & {
|
|
19
|
+
$type: import("./types").BannerType;
|
|
20
|
+
}, never>;
|
|
21
|
+
readonly ghost: import("styled-components").StyledComponent<"div", any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
22
|
+
$isOpen?: boolean;
|
|
23
|
+
$isLoading: boolean;
|
|
24
|
+
} & {
|
|
25
|
+
$type: import("./types").BannerType;
|
|
26
|
+
}, never>;
|
|
27
|
+
};
|
package/Banner/maps.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
2
|
+
import { DangerTriangleIcon, WarningRoundIcon } from '@pushwoosh/kit-icons';
|
|
3
|
+
import { BannerShape, BannerGhost } from './styles';
|
|
4
|
+
export const BannerPropsToIconContainerMap = {
|
|
5
|
+
error: DangerTriangleIcon,
|
|
6
|
+
warning: WarningRoundIcon,
|
|
7
|
+
info: WarningRoundIcon,
|
|
8
|
+
success: WarningRoundIcon
|
|
9
|
+
};
|
|
10
|
+
export const BannerTypeToSpinnerColorMap = {
|
|
11
|
+
error: Color.DANGER,
|
|
12
|
+
warning: Color.WARNING,
|
|
13
|
+
info: Color.BRIGHT,
|
|
14
|
+
success: Color.SUCCESS
|
|
15
|
+
};
|
|
16
|
+
export const BannerPropsToBannerBoxMap = {
|
|
17
|
+
shape: BannerShape,
|
|
18
|
+
ghost: BannerGhost
|
|
19
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BannerType } from './types';
|
|
2
|
+
export declare const BannerSpinner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const ActionButton: import("styled-components").StyledComponent<"button", any, import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
4
|
+
$isPressed: boolean;
|
|
5
|
+
$isLoading?: boolean;
|
|
6
|
+
}, never>;
|
|
7
|
+
export declare const CloseButton: import("styled-components").StyledComponent<"button", any, import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
8
|
+
$isPressed: boolean;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const BannerBox: import("styled-components").StyledComponent<"div", any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
11
|
+
$isOpen?: boolean;
|
|
12
|
+
$isLoading: boolean;
|
|
13
|
+
}, never>;
|
|
14
|
+
export declare const BannerContent: import("styled-components").StyledComponent<"div", any, {
|
|
15
|
+
$hasChildren?: boolean;
|
|
16
|
+
}, never>;
|
|
17
|
+
export declare const IconContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
18
|
+
export declare const BannerShape: import("styled-components").StyledComponent<"div", any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
19
|
+
$isOpen?: boolean;
|
|
20
|
+
$isLoading: boolean;
|
|
21
|
+
} & {
|
|
22
|
+
$type: BannerType;
|
|
23
|
+
}, never>;
|
|
24
|
+
export declare const BannerGhost: import("styled-components").StyledComponent<"div", any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
25
|
+
$isOpen?: boolean;
|
|
26
|
+
$isLoading: boolean;
|
|
27
|
+
} & {
|
|
28
|
+
$type: BannerType;
|
|
29
|
+
}, never>;
|
package/Banner/styles.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { rgba } from 'polished';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Spacing, ShapeRadius, FontWeight } from '@pushwoosh/kit-constants';
|
|
4
|
+
import { colors } from './colors';
|
|
5
|
+
export const BannerSpinner = styled.div.withConfig({
|
|
6
|
+
displayName: "BannerSpinner",
|
|
7
|
+
componentId: "sc-9uu4ap-0"
|
|
8
|
+
})(["position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-wrap:nowrap;align-items:center;justify-content:center;"]);
|
|
9
|
+
export const ActionButton = styled.button.withConfig({
|
|
10
|
+
displayName: "ActionButton",
|
|
11
|
+
componentId: "sc-9uu4ap-1"
|
|
12
|
+
})(["appearance:none !important;border:none;background:initial;cursor:pointer;padding:", ";position:relative;font-weight:", ";white-space:nowrap;height:fit-content;> span{visibility:", ";}opacity:", ";"], Spacing.S2, FontWeight.BOLD, ({
|
|
13
|
+
$isLoading
|
|
14
|
+
}) => $isLoading ? 'hidden' : 'visible', ({
|
|
15
|
+
$isPressed,
|
|
16
|
+
$isLoading
|
|
17
|
+
}) => $isPressed && !$isLoading ? 0.5 : 1);
|
|
18
|
+
export const CloseButton = styled.button.withConfig({
|
|
19
|
+
displayName: "CloseButton",
|
|
20
|
+
componentId: "sc-9uu4ap-2"
|
|
21
|
+
})(["appearance:none !important;border:none;background:initial;cursor:pointer;padding:0 ", " 0 0;height:fit-content;align-self:center;opacity:", ";"], Spacing.S3, props => props.$isPressed ? 0.5 : 1);
|
|
22
|
+
export const BannerBox = styled.div.withConfig({
|
|
23
|
+
displayName: "BannerBox",
|
|
24
|
+
componentId: "sc-9uu4ap-3"
|
|
25
|
+
})(["display:flex;border-radius:", ";pointer-events:", ";"], ShapeRadius.SECTION, ({
|
|
26
|
+
$isLoading
|
|
27
|
+
}) => $isLoading ? 'none' : 'auto');
|
|
28
|
+
export const BannerContent = styled.div.withConfig({
|
|
29
|
+
displayName: "BannerContent",
|
|
30
|
+
componentId: "sc-9uu4ap-4"
|
|
31
|
+
})(["flex-grow:1;padding:", ";color:", ";"], ({
|
|
32
|
+
$hasChildren
|
|
33
|
+
}) => $hasChildren ? Spacing.S5 : `${Spacing.S3} ${Spacing.S5}`, colors.error.shape.base.color);
|
|
34
|
+
export const IconContainer = styled.div.withConfig({
|
|
35
|
+
displayName: "IconContainer",
|
|
36
|
+
componentId: "sc-9uu4ap-5"
|
|
37
|
+
})(["display:flex;align-items:center;justify-content:center;padding:0 ", ";border-radius:", " 0 0 ", ";"], Spacing.S3, ShapeRadius.SECTION, ShapeRadius.SECTION);
|
|
38
|
+
export const BannerShape = styled(BannerBox).withConfig({
|
|
39
|
+
displayName: "BannerShape",
|
|
40
|
+
componentId: "sc-9uu4ap-6"
|
|
41
|
+
})(["background:", ";", "{color:", ";background:", ";}", "{color:", ";background:", ";;border-radius:", ";&:hover{text-decoration:none;background:", ";border-radius:", ";}}", "{color:", ";> *{&:hover{text-decoration:none;background:", ";border-radius:", ";}}}"], props => colors[props.$type].shape.base.bgColor, IconContainer, props => colors[props.$type].shape.iconArea.color, props => colors[props.$type].shape.iconArea.bgColor, ActionButton, props => colors[props.$type].shape.iconArea.bgColor, props => props.$isLoading ? colors[props.$type].shape.base.bgColor : 'initial', props => props.$isLoading ? ShapeRadius.CONTROL : 'initial', props => colors[props.$type].shape.hover.bgColor, ShapeRadius.CONTROL, CloseButton, props => colors[props.$type].shape.iconArea.bgColor, props => colors[props.$type].shape.hover.bgColor, Spacing.S5);
|
|
42
|
+
export const BannerGhost = styled(BannerBox).withConfig({
|
|
43
|
+
displayName: "BannerGhost",
|
|
44
|
+
componentId: "sc-9uu4ap-7"
|
|
45
|
+
})(["background:", ";", "{color:", ";background:", ";}", "{color:", ";background:", ";;border-radius:", ";&:hover{text-decoration:none;background:", ";border-radius:", ";}}", "{color:", ";> *{&:hover{text-decoration:none;background:", ";border-radius:", ";}}}"], props => colors[props.$type].ghost.base.bgColor, IconContainer, props => colors[props.$type].ghost.iconArea.color, props => rgba(colors[props.$type].ghost.iconArea.bgColor, 0.14), ActionButton, props => colors[props.$type].ghost.iconArea.color, props => props.$isLoading ? colors[props.$type].ghost.base.bgColor : 'initial', props => props.$isLoading ? ShapeRadius.CONTROL : 'initial', props => colors[props.$type].ghost.hover.bgColor, ShapeRadius.CONTROL, CloseButton, props => colors[props.$type].ghost.iconArea.color, props => colors[props.$type].ghost.hover.bgColor, Spacing.S5);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type BannerType = 'error' | 'warning' | 'info' | 'success';
|
|
3
|
+
export type RequiredBannerProps = {
|
|
4
|
+
readonly boxRef?: any;
|
|
5
|
+
readonly type: BannerType;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly view?: 'shape' | 'ghost';
|
|
8
|
+
readonly icon?: ReactElement;
|
|
9
|
+
readonly className?: string;
|
|
10
|
+
readonly isLoading?: boolean;
|
|
11
|
+
readonly canBeClosed?: boolean;
|
|
12
|
+
readonly onClose?: () => void;
|
|
13
|
+
readonly children?: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export type BannerPropsWithButton = RequiredBannerProps & {
|
|
16
|
+
readonly action?: {
|
|
17
|
+
readonly onClick: () => void;
|
|
18
|
+
readonly buttonText: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { ButtonPropsWithoutAs, ButtonPropsWithAsTag, ButtonPropsWithAsComponent } from './types';
|
|
3
|
+
export declare function Button(props: ButtonPropsWithoutAs): ReactElement | null;
|
|
4
|
+
export declare function Button<AS extends keyof HTMLElementTagNameMap>(props: ButtonPropsWithAsTag<AS>): ReactElement | null;
|
|
5
|
+
export declare function Button<OuterProps extends object>(props: ButtonPropsWithAsComponent<OuterProps>): ReactElement | null;
|
package/Button/Button.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Spinner } from '../Spinner';
|
|
3
|
+
import { ButtonPropsToButtonBoxMap, SpinnerSizeByButtonSizeMap } from './maps';
|
|
4
|
+
import { ButtonIcon, ButtonSpinner, ButtonContent } from './styles';
|
|
5
|
+
export function Button(props) {
|
|
6
|
+
const {
|
|
7
|
+
type = 'button',
|
|
8
|
+
boxRef,
|
|
9
|
+
color,
|
|
10
|
+
view = 'shape',
|
|
11
|
+
size = 'field',
|
|
12
|
+
isDisabled,
|
|
13
|
+
isLoading,
|
|
14
|
+
isOpen,
|
|
15
|
+
icon,
|
|
16
|
+
rightIcon,
|
|
17
|
+
children,
|
|
18
|
+
...rest
|
|
19
|
+
} = props;
|
|
20
|
+
if (!color) {
|
|
21
|
+
console.error(`[Button]: required prop color "${color}" is not set`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const ButtonBox = ButtonPropsToButtonBoxMap[color][view][size];
|
|
25
|
+
if (!ButtonBox) {
|
|
26
|
+
console.error(`[Button]: cannot render with color "${color}" and size "${size}" and view "${view}"`);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const isShowOverlaySpinner = !!children && !icon && view !== 'ghost' && isLoading;
|
|
30
|
+
return React.createElement(ButtonBox, {
|
|
31
|
+
...rest,
|
|
32
|
+
type: type,
|
|
33
|
+
disabled: isDisabled,
|
|
34
|
+
"$isDisabled": isDisabled,
|
|
35
|
+
"$isLoading": isLoading,
|
|
36
|
+
"$isOpen": isOpen,
|
|
37
|
+
"$hideContent": isShowOverlaySpinner,
|
|
38
|
+
"$hasLeftIcon": !!icon,
|
|
39
|
+
"$hasRightIcon": !!rightIcon,
|
|
40
|
+
"$hasContent": !!children,
|
|
41
|
+
ref: boxRef
|
|
42
|
+
}, icon && React.createElement(ButtonIcon, null, isLoading ? React.createElement(Spinner, {
|
|
43
|
+
size: SpinnerSizeByButtonSizeMap[size]
|
|
44
|
+
}) : icon), children && React.createElement(ButtonContent, null, React.createElement("div", null, children)), rightIcon && React.createElement(ButtonIcon, null, rightIcon), isShowOverlaySpinner && React.createElement(ButtonSpinner, null, React.createElement(Spinner, {
|
|
45
|
+
color: "danger",
|
|
46
|
+
size: SpinnerSizeByButtonSizeMap[size]
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GhostButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const GhostButton = styled.button.withConfig({
|
|
3
|
+
displayName: "GhostButton",
|
|
4
|
+
componentId: "sc-11te6l1-0"
|
|
5
|
+
})(["padding:0;appearance:none;border:none;background-color:transparent;user-select:none;&:focus{outline:none;}"]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Colors = {
|
|
2
|
+
color: string;
|
|
3
|
+
bgColor: string;
|
|
4
|
+
borderColor?: string;
|
|
5
|
+
};
|
|
6
|
+
type ButtonColors = {
|
|
7
|
+
base: Colors;
|
|
8
|
+
disabled: Partial<Colors>;
|
|
9
|
+
hover: Partial<Colors>;
|
|
10
|
+
};
|
|
11
|
+
export declare const colors: Record<string, Record<string, ButtonColors>>;
|
|
12
|
+
export declare function createColors(buttonColors: ButtonColors): import("styled-components").FlattenInterpolation<import("styled-components").ThemedStyledProps<{
|
|
13
|
+
$isOpen?: boolean;
|
|
14
|
+
$isDisabled?: boolean;
|
|
15
|
+
}, any>>;
|
|
16
|
+
export {};
|