baseui 11.0.1 → 11.1.0
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/a11y/index.d.ts +1 -1
- package/accordion/index.d.ts +25 -28
- package/app-nav-bar/app-nav-bar.js +33 -40
- package/app-nav-bar/app-nav-bar.js.flow +46 -62
- package/app-nav-bar/index.d.ts +9 -8
- package/app-nav-bar/styled-components.js +49 -29
- package/app-nav-bar/styled-components.js.flow +25 -8
- package/app-nav-bar/types.js.flow +2 -0
- package/aspect-ratio-box/index.d.ts +2 -4
- package/avatar/index.d.ts +6 -12
- package/badge/badge.js +109 -0
- package/badge/badge.js.flow +91 -0
- package/badge/constants.js +54 -0
- package/badge/constants.js.flow +52 -0
- package/badge/hint-dot.js +96 -0
- package/badge/hint-dot.js.flow +68 -0
- package/badge/index.d.ts +97 -0
- package/badge/index.js +80 -0
- package/badge/index.js.flow +20 -0
- package/badge/notification-circle.js +103 -0
- package/badge/notification-circle.js.flow +81 -0
- package/badge/package.json +4 -0
- package/badge/styled-components.js +242 -0
- package/badge/styled-components.js.flow +325 -0
- package/badge/types.js +11 -0
- package/badge/types.js.flow +59 -0
- package/badge/utils.js +33 -0
- package/badge/utils.js.flow +23 -0
- package/banner/banner.js +283 -0
- package/banner/banner.js.flow +253 -0
- package/banner/constants.js +35 -0
- package/banner/constants.js.flow +33 -0
- package/banner/index.d.ts +75 -0
- package/banner/index.js +44 -0
- package/banner/index.js.flow +16 -0
- package/banner/package.json +4 -0
- package/banner/styled-components.js +131 -0
- package/banner/styled-components.js.flow +119 -0
- package/banner/types.js +11 -0
- package/banner/types.js.flow +66 -0
- package/block/index.d.ts +4 -4
- package/breadcrumbs/breadcrumbs.js +5 -1
- package/breadcrumbs/breadcrumbs.js.flow +2 -2
- package/breadcrumbs/index.d.ts +5 -5
- package/button/button.js +2 -1
- package/button/button.js.flow +1 -0
- package/button/index.d.ts +19 -29
- package/button-group/index.d.ts +18 -24
- package/card/index.d.ts +16 -14
- package/checkbox/index.d.ts +17 -21
- package/combobox/index.d.ts +7 -11
- package/data-table/index.d.ts +7 -10
- package/datepicker/calendar.js +16 -11
- package/datepicker/calendar.js.flow +12 -9
- package/datepicker/datepicker.js +58 -58
- package/datepicker/datepicker.js.flow +51 -34
- package/datepicker/index.d.ts +42 -63
- package/datepicker/stateful-calendar.js +6 -1
- package/datepicker/stateful-calendar.js.flow +8 -1
- package/datepicker/stateful-container.js +23 -2
- package/datepicker/stateful-container.js.flow +17 -4
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/types.js.flow +21 -43
- package/datepicker/utils/date-helpers.js +1 -1
- package/datepicker/utils/date-helpers.js.flow +1 -1
- package/dnd-list/index.d.ts +22 -35
- package/drawer/index.d.ts +22 -27
- package/es/app-nav-bar/app-nav-bar.js +9 -19
- package/es/app-nav-bar/styled-components.js +32 -13
- package/es/badge/badge.js +70 -0
- package/es/badge/constants.js +42 -0
- package/es/badge/hint-dot.js +55 -0
- package/es/badge/index.js +11 -0
- package/es/badge/notification-circle.js +65 -0
- package/es/badge/styled-components.js +296 -0
- package/es/badge/types.js +8 -0
- package/es/badge/utils.js +17 -0
- package/es/banner/banner.js +213 -0
- package/es/banner/constants.js +24 -0
- package/es/banner/index.js +9 -0
- package/es/banner/styled-components.js +122 -0
- package/es/banner/types.js +8 -0
- package/es/breadcrumbs/breadcrumbs.js +5 -1
- package/es/button/button.js +1 -0
- package/es/datepicker/calendar.js +15 -10
- package/es/datepicker/datepicker.js +52 -52
- package/es/datepicker/stateful-calendar.js +6 -1
- package/es/datepicker/stateful-container.js +22 -2
- package/es/datepicker/stateful-datepicker.js +6 -1
- package/es/datepicker/utils/date-helpers.js +1 -1
- package/es/helper/helper-steps.js +3 -1
- package/es/input/base-input.js +18 -11
- package/es/input/input.js +15 -10
- package/es/input/masked-input.js +5 -2
- package/es/input/utils.js +4 -2
- package/es/locale/tr_TR.js +115 -0
- package/es/notification/notification.js +16 -1
- package/es/payment-card/custom-cards.config.js +22 -0
- package/es/payment-card/icons/uatp.js +52 -0
- package/es/payment-card/payment-card.js +8 -3
- package/es/popover/popover.js +2 -1
- package/es/popover/stateful-container.js +2 -0
- package/es/popover/styled-components.js +2 -1
- package/es/progress-steps/numbered-step.js +2 -2
- package/es/select/select-component.js +48 -23
- package/es/select/utils/default-filter-options.js +1 -1
- package/es/snackbar/snackbar-context.js +1 -1
- package/es/table-semantic/styled-components.js +14 -0
- package/es/table-semantic/table-builder.js +12 -5
- package/es/textarea/textarea.js +15 -9
- package/es/themes/dark-theme/color-component-tokens.js +8 -0
- package/es/themes/light-theme/color-component-tokens.js +8 -0
- package/es/tree-view/tree-label.js +9 -1
- package/esm/app-nav-bar/app-nav-bar.js +32 -38
- package/esm/app-nav-bar/styled-components.js +46 -28
- package/esm/badge/badge.js +97 -0
- package/esm/badge/constants.js +42 -0
- package/esm/badge/hint-dot.js +83 -0
- package/esm/badge/index.js +11 -0
- package/esm/badge/notification-circle.js +91 -0
- package/esm/badge/styled-components.js +235 -0
- package/esm/badge/types.js +8 -0
- package/esm/badge/utils.js +17 -0
- package/esm/banner/banner.js +271 -0
- package/esm/banner/constants.js +24 -0
- package/esm/banner/index.js +9 -0
- package/esm/banner/styled-components.js +113 -0
- package/esm/banner/types.js +8 -0
- package/esm/breadcrumbs/breadcrumbs.js +5 -1
- package/esm/button/button.js +2 -1
- package/esm/datepicker/calendar.js +16 -11
- package/esm/datepicker/datepicker.js +58 -58
- package/esm/datepicker/stateful-calendar.js +6 -1
- package/esm/datepicker/stateful-container.js +23 -2
- package/esm/datepicker/stateful-datepicker.js +6 -1
- package/esm/datepicker/utils/date-helpers.js +1 -1
- package/esm/helper/helper-steps.js +3 -1
- package/esm/input/base-input.js +18 -11
- package/esm/input/input.js +15 -10
- package/esm/input/masked-input.js +6 -3
- package/esm/input/utils.js +4 -2
- package/esm/locale/tr_TR.js +115 -0
- package/esm/notification/notification.js +17 -1
- package/esm/payment-card/custom-cards.config.js +22 -0
- package/esm/payment-card/icons/uatp.js +53 -0
- package/esm/payment-card/payment-card.js +9 -7
- package/esm/popover/popover.js +2 -1
- package/esm/popover/stateful-container.js +2 -0
- package/esm/popover/styled-components.js +3 -2
- package/esm/progress-steps/numbered-step.js +2 -2
- package/esm/select/select-component.js +85 -59
- package/esm/select/utils/default-filter-options.js +1 -1
- package/esm/snackbar/snackbar-context.js +1 -1
- package/esm/table-semantic/styled-components.js +31 -18
- package/esm/table-semantic/table-builder.js +34 -23
- package/esm/textarea/textarea.js +15 -9
- package/esm/themes/dark-theme/color-component-tokens.js +8 -0
- package/esm/themes/light-theme/color-component-tokens.js +8 -0
- package/esm/tree-view/tree-label.js +10 -2
- package/file-uploader/index.d.ts +11 -11
- package/flex-grid/index.d.ts +3 -3
- package/form-control/index.d.ts +7 -19
- package/header-navigation/index.d.ts +8 -9
- package/heading/index.d.ts +3 -4
- package/helper/helper-steps.js +19 -13
- package/helper/helper-steps.js.flow +3 -1
- package/helper/index.d.ts +7 -7
- package/helpers/base-provider.d.ts +16 -0
- package/helpers/overrides.d.ts +23 -0
- package/icon/index.d.ts +32 -32
- package/index.d.ts +34 -114
- package/input/base-input.js +18 -11
- package/input/base-input.js.flow +18 -6
- package/input/index.d.ts +29 -32
- package/input/input.js +15 -10
- package/input/input.js.flow +10 -5
- package/input/masked-input.js +6 -3
- package/input/masked-input.js.flow +3 -0
- package/input/types.js.flow +4 -0
- package/input/utils.js +4 -2
- package/input/utils.js.flow +2 -1
- package/layer/index.d.ts +6 -11
- package/layout-grid/index.d.ts +25 -7
- package/link/index.d.ts +2 -2
- package/list/index.d.ts +26 -31
- package/{locale.ts → locale/index.d.ts} +8 -0
- package/locale/tr_TR.js +123 -0
- package/locale/tr_TR.js.flow +124 -0
- package/map-marker/index.d.ts +41 -47
- package/menu/index.d.ts +27 -37
- package/modal/index.d.ts +28 -38
- package/notification/index.d.ts +2 -3
- package/notification/notification.js +18 -1
- package/notification/notification.js.flow +15 -1
- package/overrides.ts +2 -22
- package/package.json +26 -17
- package/pagination/index.d.ts +22 -26
- package/payment-card/custom-cards.config.js +30 -0
- package/payment-card/custom-cards.config.js.flow +29 -0
- package/payment-card/icons/uatp.js +67 -0
- package/payment-card/icons/uatp.js.flow +62 -0
- package/payment-card/index.d.ts +8 -8
- package/payment-card/payment-card.js +12 -7
- package/payment-card/payment-card.js.flow +12 -0
- package/phone-input/index.d.ts +261 -269
- package/pin-code/index.d.ts +11 -18
- package/popover/index.d.ts +39 -55
- package/popover/popover.js +2 -1
- package/popover/popover.js.flow +2 -1
- package/popover/stateful-container.js +2 -0
- package/popover/stateful-container.js.flow +2 -0
- package/popover/styled-components.js +3 -2
- package/popover/styled-components.js.flow +2 -1
- package/popover/types.js.flow +1 -0
- package/progress-bar/index.d.ts +11 -12
- package/progress-steps/index.d.ts +16 -16
- package/progress-steps/numbered-step.js.flow +2 -2
- package/radio/index.d.ts +12 -15
- package/rating/index.d.ts +9 -12
- package/select/index.d.ts +34 -36
- package/select/select-component.js +82 -56
- package/select/select-component.js.flow +46 -34
- package/select/types.js.flow +1 -0
- package/select/utils/default-filter-options.js +1 -1
- package/select/utils/default-filter-options.js.flow +1 -1
- package/side-navigation/index.d.ts +11 -13
- package/skeleton/index.d.ts +1 -1
- package/slider/index.d.ts +17 -26
- package/snackbar/index.d.ts +8 -8
- package/snackbar/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- package/spinner/index.d.ts +4 -3
- package/styles/index.d.ts +82 -2
- package/table/index.d.ts +16 -16
- package/table-grid/index.d.ts +6 -8
- package/table-semantic/index.d.ts +26 -32
- package/table-semantic/styled-components.js +33 -19
- package/table-semantic/styled-components.js.flow +12 -0
- package/table-semantic/table-builder.js +38 -22
- package/table-semantic/table-builder.js.flow +32 -17
- package/table-semantic/types.js.flow +1 -0
- package/tabs/index.d.ts +20 -23
- package/tabs-motion/index.d.ts +23 -23
- package/tag/index.d.ts +14 -18
- package/tag/types.js.flow +1 -1
- package/textarea/index.d.ts +11 -14
- package/textarea/textarea.js +15 -9
- package/textarea/textarea.js.flow +11 -5
- package/textarea/types.js.flow +1 -0
- package/theme.ts +36 -777
- package/themes/dark-theme/color-component-tokens.js +8 -0
- package/themes/dark-theme/color-component-tokens.js.flow +9 -0
- package/themes/index.d.ts +765 -0
- package/themes/light-theme/color-component-tokens.js +8 -0
- package/themes/light-theme/color-component-tokens.js.flow +9 -0
- package/themes/types.js.flow +9 -0
- package/timepicker/index.d.ts +5 -8
- package/timezonepicker/index.d.ts +5 -8
- package/toast/index.d.ts +26 -40
- package/tokens/index.d.ts +1 -1
- package/tooltip/index.d.ts +7 -9
- package/tree-view/index.d.ts +15 -19
- package/tree-view/tree-label.js +10 -2
- package/tree-view/tree-label.js.flow +4 -4
- package/typography/index.d.ts +37 -37
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useStyletron } from '../styles/index.js';
|
|
11
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
12
|
+
import { StyledHintDot, StyledRoot, StyledPositioner } from './styled-components.js';
|
|
13
|
+
import { PLACEMENT, ROLE } from './constants.js';
|
|
14
|
+
import { getAnchorFromChildren } from './utils.js';
|
|
15
|
+
|
|
16
|
+
const HintDot = ({
|
|
17
|
+
children,
|
|
18
|
+
color,
|
|
19
|
+
horizontalOffset: horizontalOffsetProp,
|
|
20
|
+
verticalOffset: verticalOffsetProp,
|
|
21
|
+
hidden,
|
|
22
|
+
overrides = {}
|
|
23
|
+
}) => {
|
|
24
|
+
const [HintDot, hintDotProps] = getOverrides(overrides.Badge, StyledHintDot);
|
|
25
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
26
|
+
const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
|
|
27
|
+
const [, theme] = useStyletron();
|
|
28
|
+
const anchor = getAnchorFromChildren(children); // if the anchor is a string, we supply default offsets
|
|
29
|
+
|
|
30
|
+
let horizontalOffset = horizontalOffsetProp;
|
|
31
|
+
let verticalOffset = verticalOffsetProp;
|
|
32
|
+
|
|
33
|
+
if (typeof anchor === 'string') {
|
|
34
|
+
if (!horizontalOffset) {
|
|
35
|
+
horizontalOffset = '-14px';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!verticalOffset) {
|
|
39
|
+
verticalOffset = '-4px';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement(Root, rootProps, anchor, /*#__PURE__*/React.createElement(Positioner, _extends({
|
|
44
|
+
$horizontalOffset: horizontalOffset,
|
|
45
|
+
$verticalOffset: verticalOffset,
|
|
46
|
+
$placement: theme.direction === 'rtl' ? PLACEMENT.topLeft : PLACEMENT.topRight,
|
|
47
|
+
$role: ROLE.hintDot
|
|
48
|
+
}, positionerProps), /*#__PURE__*/React.createElement(HintDot, _extends({}, hintDotProps, {
|
|
49
|
+
$color: color,
|
|
50
|
+
$horizontalOffset: horizontalOffset,
|
|
51
|
+
$hidden: hidden
|
|
52
|
+
}))));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default HintDot;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) Uber Technologies, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export { default as Badge } from './badge.js';
|
|
8
|
+
export { default as NotificationCircle } from './notification-circle.js';
|
|
9
|
+
export { default as HintDot } from './hint-dot.js';
|
|
10
|
+
export { HIERARCHY, SHAPE, COLOR, PLACEMENT } from './constants.js';
|
|
11
|
+
export * from './styled-components.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
11
|
+
import { StyledNotificationCircle, StyledRoot, StyledPositioner } from './styled-components.js';
|
|
12
|
+
import { PLACEMENT, ROLE } from './constants.js';
|
|
13
|
+
import { getAnchorFromChildren } from './utils.js';
|
|
14
|
+
|
|
15
|
+
const NotificationCircle = ({
|
|
16
|
+
children,
|
|
17
|
+
content: contentProp,
|
|
18
|
+
color,
|
|
19
|
+
placement = PLACEMENT.topRight,
|
|
20
|
+
horizontalOffset,
|
|
21
|
+
verticalOffset,
|
|
22
|
+
hidden,
|
|
23
|
+
overrides = {}
|
|
24
|
+
}) => {
|
|
25
|
+
const [NotificationCircle, NotificationCircleProps] = getOverrides(overrides.Badge, StyledNotificationCircle);
|
|
26
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
27
|
+
const [Positioner, positionerProps] = getOverrides(overrides.Positioner, StyledPositioner);
|
|
28
|
+
const anchor = getAnchorFromChildren(children);
|
|
29
|
+
|
|
30
|
+
if (process.env.NODE_ENV !== "production") {
|
|
31
|
+
if (typeof contentProp === 'string') {
|
|
32
|
+
console.error(`[baseui] NotificationCircle child must be number or icon, found string`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (placement && placement !== PLACEMENT.topLeft && placement !== PLACEMENT.topRight) {
|
|
36
|
+
console.error(`[baseui] NotificationCircle must be placed topLeft or topRight, found ${placement}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let content = contentProp;
|
|
41
|
+
|
|
42
|
+
if (typeof content === 'number' && content > 9) {
|
|
43
|
+
content = '9+';
|
|
44
|
+
} // If there's no anchor, render the badge inline
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if (!anchor) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(NotificationCircle, _extends({
|
|
49
|
+
$color: color,
|
|
50
|
+
$hidden: hidden
|
|
51
|
+
}, NotificationCircleProps), content);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return /*#__PURE__*/React.createElement(Root, rootProps, anchor, /*#__PURE__*/React.createElement(Positioner, _extends({
|
|
55
|
+
$horizontalOffset: horizontalOffset,
|
|
56
|
+
$verticalOffset: verticalOffset,
|
|
57
|
+
$placement: placement,
|
|
58
|
+
$role: ROLE.notificationCircle
|
|
59
|
+
}, positionerProps), /*#__PURE__*/React.createElement(NotificationCircle, _extends({}, NotificationCircleProps, {
|
|
60
|
+
$color: color,
|
|
61
|
+
$hidden: hidden
|
|
62
|
+
}), content)));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default NotificationCircle;
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) Uber Technologies, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { styled } from '../styles/index.js';
|
|
8
|
+
import { COLOR, SHAPE, ROLE, PLACEMENT, HIERARCHY } from './constants.js';
|
|
9
|
+
|
|
10
|
+
function getColorStyles({
|
|
11
|
+
$theme,
|
|
12
|
+
$hierarchy,
|
|
13
|
+
$color
|
|
14
|
+
}) {
|
|
15
|
+
const COLOR_STYLES = {
|
|
16
|
+
[HIERARCHY.primary]: {
|
|
17
|
+
[COLOR.accent]: {
|
|
18
|
+
color: $theme.colors.contentInversePrimary,
|
|
19
|
+
backgroundColor: $theme.colors.backgroundAccent
|
|
20
|
+
},
|
|
21
|
+
[COLOR.primary]: {
|
|
22
|
+
color: $theme.colors.contentInversePrimary,
|
|
23
|
+
backgroundColor: $theme.colors.backgroundInversePrimary
|
|
24
|
+
},
|
|
25
|
+
[COLOR.positive]: {
|
|
26
|
+
color: $theme.colors.contentInversePrimary,
|
|
27
|
+
backgroundColor: $theme.colors.backgroundPositive
|
|
28
|
+
},
|
|
29
|
+
[COLOR.negative]: {
|
|
30
|
+
color: $theme.colors.contentInversePrimary,
|
|
31
|
+
backgroundColor: $theme.colors.backgroundNegative
|
|
32
|
+
},
|
|
33
|
+
[COLOR.warning]: {
|
|
34
|
+
color: $theme.colors.primaryA,
|
|
35
|
+
backgroundColor: $theme.colors.backgroundWarning
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
[HIERARCHY.secondary]: {
|
|
39
|
+
[COLOR.accent]: {
|
|
40
|
+
color: $theme.colors.contentAccent,
|
|
41
|
+
backgroundColor: $theme.colors.backgroundLightAccent
|
|
42
|
+
},
|
|
43
|
+
[COLOR.primary]: {
|
|
44
|
+
color: $theme.colors.primaryA,
|
|
45
|
+
backgroundColor: $theme.colors.backgroundSecondary
|
|
46
|
+
},
|
|
47
|
+
[COLOR.positive]: {
|
|
48
|
+
color: $theme.colors.contentPositive,
|
|
49
|
+
backgroundColor: $theme.colors.backgroundLightPositive
|
|
50
|
+
},
|
|
51
|
+
[COLOR.negative]: {
|
|
52
|
+
color: $theme.colors.contentNegative,
|
|
53
|
+
backgroundColor: $theme.colors.backgroundLightNegative
|
|
54
|
+
},
|
|
55
|
+
[COLOR.warning]: {
|
|
56
|
+
color: $theme.colors.contentWarning,
|
|
57
|
+
backgroundColor: $theme.colors.backgroundLightWarning
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return COLOR_STYLES[$hierarchy][$color];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT = {
|
|
65
|
+
top: '-10px',
|
|
66
|
+
right: '-10px'
|
|
67
|
+
};
|
|
68
|
+
const DEFAULT_HINT_DOT_PLACEMENT = {
|
|
69
|
+
top: '-4px',
|
|
70
|
+
right: '-4px'
|
|
71
|
+
};
|
|
72
|
+
const POSITION_STYLES = Object.freeze({
|
|
73
|
+
[ROLE.badge]: {
|
|
74
|
+
[PLACEMENT.topEdge]: {
|
|
75
|
+
top: '-8px',
|
|
76
|
+
left: '50%',
|
|
77
|
+
transform: 'translateX(-50%)'
|
|
78
|
+
},
|
|
79
|
+
[PLACEMENT.bottomEdge]: {
|
|
80
|
+
bottom: '-8px',
|
|
81
|
+
left: '50%',
|
|
82
|
+
transform: 'translateX(-50%)'
|
|
83
|
+
},
|
|
84
|
+
[PLACEMENT.topLeft]: {
|
|
85
|
+
top: '16px',
|
|
86
|
+
left: '16px'
|
|
87
|
+
},
|
|
88
|
+
[PLACEMENT.topRight]: {
|
|
89
|
+
top: '16px',
|
|
90
|
+
right: '16px'
|
|
91
|
+
},
|
|
92
|
+
[PLACEMENT.bottomRight]: {
|
|
93
|
+
bottom: '16px',
|
|
94
|
+
right: '16px'
|
|
95
|
+
},
|
|
96
|
+
[PLACEMENT.bottomLeft]: {
|
|
97
|
+
bottom: '16px',
|
|
98
|
+
left: '16px'
|
|
99
|
+
},
|
|
100
|
+
[PLACEMENT.topLeftEdge]: {
|
|
101
|
+
top: '-8px',
|
|
102
|
+
left: '16px'
|
|
103
|
+
},
|
|
104
|
+
[PLACEMENT.topRightEdge]: {
|
|
105
|
+
top: '-8px',
|
|
106
|
+
right: '16px'
|
|
107
|
+
},
|
|
108
|
+
[PLACEMENT.bottomRightEdge]: {
|
|
109
|
+
bottom: '-8px',
|
|
110
|
+
right: '16px'
|
|
111
|
+
},
|
|
112
|
+
[PLACEMENT.bottomLeftEdge]: {
|
|
113
|
+
bottom: '-8px',
|
|
114
|
+
left: '16px'
|
|
115
|
+
},
|
|
116
|
+
[PLACEMENT.leftTopEdge]: {
|
|
117
|
+
top: '16px',
|
|
118
|
+
left: '-8px'
|
|
119
|
+
},
|
|
120
|
+
[PLACEMENT.rightTopEdge]: {
|
|
121
|
+
top: '16px',
|
|
122
|
+
right: '-8px'
|
|
123
|
+
},
|
|
124
|
+
[PLACEMENT.rightBottomEdge]: {
|
|
125
|
+
bottom: '16px',
|
|
126
|
+
right: '-8px'
|
|
127
|
+
},
|
|
128
|
+
[PLACEMENT.leftBottomEdge]: {
|
|
129
|
+
bottom: '16px',
|
|
130
|
+
left: '-8px'
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
[ROLE.notificationCircle]: {
|
|
134
|
+
[PLACEMENT.topLeft]: {
|
|
135
|
+
top: '-10px',
|
|
136
|
+
left: '-10px'
|
|
137
|
+
},
|
|
138
|
+
[PLACEMENT.topRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
139
|
+
// NotificationCircle can only be placed topLeft or topRight, other values fall back to topRight
|
|
140
|
+
[PLACEMENT.topEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
141
|
+
[PLACEMENT.bottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
142
|
+
[PLACEMENT.bottomRight]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
143
|
+
[PLACEMENT.bottomLeft]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
144
|
+
[PLACEMENT.topLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
145
|
+
[PLACEMENT.topRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
146
|
+
[PLACEMENT.bottomRightEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
147
|
+
[PLACEMENT.bottomLeftEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
148
|
+
[PLACEMENT.leftTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
149
|
+
[PLACEMENT.rightTopEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
150
|
+
[PLACEMENT.rightBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT,
|
|
151
|
+
[PLACEMENT.leftBottomEdge]: DEFAULT_NOTIFICATION_CIRCLE_PLACEMENT
|
|
152
|
+
},
|
|
153
|
+
[ROLE.hintDot]: {
|
|
154
|
+
[PLACEMENT.topLeft]: {
|
|
155
|
+
top: '-4px',
|
|
156
|
+
left: '-4px'
|
|
157
|
+
},
|
|
158
|
+
[PLACEMENT.topRight]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
159
|
+
// HintDot can only be placed topLeft or topRight, other values fall back to topRight
|
|
160
|
+
[PLACEMENT.topEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
161
|
+
[PLACEMENT.bottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
162
|
+
[PLACEMENT.bottomRight]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
163
|
+
[PLACEMENT.bottomLeft]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
164
|
+
[PLACEMENT.topLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
165
|
+
[PLACEMENT.topRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
166
|
+
[PLACEMENT.bottomRightEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
167
|
+
[PLACEMENT.bottomLeftEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
168
|
+
[PLACEMENT.leftTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
169
|
+
[PLACEMENT.rightTopEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
170
|
+
[PLACEMENT.rightBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT,
|
|
171
|
+
[PLACEMENT.leftBottomEdge]: DEFAULT_HINT_DOT_PLACEMENT
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
export const StyledRoot = styled('div', () => {
|
|
175
|
+
return {
|
|
176
|
+
position: 'relative',
|
|
177
|
+
display: 'inline-block',
|
|
178
|
+
lineHeight: 'initial'
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
StyledRoot.displayName = "StyledRoot";
|
|
182
|
+
const TOP_PLACEMENTS = [PLACEMENT.topLeft, PLACEMENT.topRight, PLACEMENT.topLeftEdge, PLACEMENT.topEdge, PLACEMENT.topRightEdge, PLACEMENT.leftTopEdge, PLACEMENT.rightTopEdge];
|
|
183
|
+
const BOTTOM_PLACEMENTS = [PLACEMENT.bottomLeft, PLACEMENT.bottomRight, PLACEMENT.bottomLeftEdge, PLACEMENT.bottomEdge, PLACEMENT.bottomRightEdge, PLACEMENT.leftBottomEdge, PLACEMENT.rightBottomEdge];
|
|
184
|
+
const LEFT_PLACEMENTS = [PLACEMENT.topLeft, PLACEMENT.topLeftEdge, PLACEMENT.topEdge, PLACEMENT.bottomLeft, PLACEMENT.bottomLeftEdge, PLACEMENT.bottomEdge, PLACEMENT.leftTopEdge, PLACEMENT.leftBottomEdge];
|
|
185
|
+
const RIGHT_PLACEMENTS = [PLACEMENT.topRight, PLACEMENT.topRightEdge, PLACEMENT.bottomRight, PLACEMENT.bottomRightEdge, PLACEMENT.rightTopEdge, PLACEMENT.rightBottomEdge];
|
|
186
|
+
export const StyledPositioner = styled('div', ({
|
|
187
|
+
$theme,
|
|
188
|
+
$role,
|
|
189
|
+
$placement,
|
|
190
|
+
$horizontalOffset,
|
|
191
|
+
$verticalOffset
|
|
192
|
+
}) => {
|
|
193
|
+
let positionStyle = POSITION_STYLES[$role][$placement];
|
|
194
|
+
|
|
195
|
+
if ($verticalOffset) {
|
|
196
|
+
if (TOP_PLACEMENTS.includes($placement)) {
|
|
197
|
+
positionStyle = { ...positionStyle,
|
|
198
|
+
top: $verticalOffset
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (BOTTOM_PLACEMENTS.includes($placement)) {
|
|
203
|
+
positionStyle = { ...positionStyle,
|
|
204
|
+
bottom: $verticalOffset
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if ($horizontalOffset) {
|
|
210
|
+
if (LEFT_PLACEMENTS.includes($placement)) {
|
|
211
|
+
positionStyle = { ...positionStyle,
|
|
212
|
+
left: $horizontalOffset
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (RIGHT_PLACEMENTS.includes($placement)) {
|
|
217
|
+
positionStyle = { ...positionStyle,
|
|
218
|
+
right: $horizontalOffset
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return { ...positionStyle,
|
|
224
|
+
position: 'absolute',
|
|
225
|
+
lineHeight: 'initial'
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
StyledPositioner.displayName = "StyledPositioner";
|
|
229
|
+
export const StyledBadge = styled('div', ({
|
|
230
|
+
$theme,
|
|
231
|
+
$shape = SHAPE.rectangle,
|
|
232
|
+
$color = COLOR.accent,
|
|
233
|
+
$hierarchy = HIERARCHY.primary,
|
|
234
|
+
$hidden
|
|
235
|
+
}) => {
|
|
236
|
+
return {
|
|
237
|
+
visibility: $hidden ? 'hidden' : 'inherit',
|
|
238
|
+
boxSizing: 'border-box',
|
|
239
|
+
height: $theme.sizing.scale700,
|
|
240
|
+
borderRadius: $shape === SHAPE.rectangle ? $theme.borders.radius200 : $theme.borders.radius500,
|
|
241
|
+
paddingRight: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
|
|
242
|
+
paddingLeft: $shape === SHAPE.rectangle ? $theme.sizing.scale100 : $theme.sizing.scale300,
|
|
243
|
+
display: 'inline-flex',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
...getColorStyles({
|
|
246
|
+
$theme,
|
|
247
|
+
$hierarchy,
|
|
248
|
+
$color
|
|
249
|
+
}),
|
|
250
|
+
...($hierarchy === HIERARCHY.primary ? $theme.typography.LabelSmall : $theme.typography.ParagraphSmall)
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
StyledBadge.displayName = "StyledBadge";
|
|
254
|
+
export const StyledNotificationCircle = styled('div', ({
|
|
255
|
+
$theme,
|
|
256
|
+
$color = COLOR.accent,
|
|
257
|
+
$hidden
|
|
258
|
+
}) => {
|
|
259
|
+
return {
|
|
260
|
+
visibility: $hidden ? 'hidden' : 'inherit',
|
|
261
|
+
height: $theme.sizing.scale700,
|
|
262
|
+
width: $theme.sizing.scale700,
|
|
263
|
+
borderRadius: '20px',
|
|
264
|
+
display: 'inline-flex',
|
|
265
|
+
alignItems: 'center',
|
|
266
|
+
justifyContent: 'center',
|
|
267
|
+
...getColorStyles({
|
|
268
|
+
$theme,
|
|
269
|
+
$hierarchy: HIERARCHY.primary,
|
|
270
|
+
$color
|
|
271
|
+
}),
|
|
272
|
+
...$theme.typography.LabelXSmall
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
StyledNotificationCircle.displayName = "StyledNotificationCircle";
|
|
276
|
+
export const StyledHintDot = styled('div', ({
|
|
277
|
+
$theme,
|
|
278
|
+
$color = COLOR.accent,
|
|
279
|
+
$hidden
|
|
280
|
+
}) => {
|
|
281
|
+
return {
|
|
282
|
+
visibility: $hidden ? 'hidden' : 'inherit',
|
|
283
|
+
backgroundColor: $theme.colors[$color],
|
|
284
|
+
boxSizing: 'content-box',
|
|
285
|
+
height: '8px',
|
|
286
|
+
width: '8px',
|
|
287
|
+
borderRadius: '50%',
|
|
288
|
+
border: `4px solid ${$theme.colors.backgroundPrimary}`,
|
|
289
|
+
...getColorStyles({
|
|
290
|
+
$theme,
|
|
291
|
+
$hierarchy: HIERARCHY.primary,
|
|
292
|
+
$color
|
|
293
|
+
})
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
StyledHintDot.displayName = "StyledHintDot";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) Uber Technologies, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { HIERARCHY, SHAPE, COLOR, PLACEMENT, ROLE } from './constants.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) Uber Technologies, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
export const getAnchorFromChildren = children => {
|
|
9
|
+
const childArray = React.Children.toArray(children);
|
|
10
|
+
|
|
11
|
+
if (childArray.length !== 1) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.error(`[baseui] No more than 1 child may be passed to Badge, found ${childArray.length} children`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return childArray[0];
|
|
17
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Copyright (c) Uber Technologies, Inc.
|
|
5
|
+
|
|
6
|
+
This source code is licensed under the MIT license found in the
|
|
7
|
+
LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { Button, SIZE as BUTTON_SIZE, SHAPE as BUTTON_SHAPE } from '../button/index.js';
|
|
11
|
+
import { getOverrides } from '../helpers/overrides.js';
|
|
12
|
+
import { useStyletron } from '../styles/index.js';
|
|
13
|
+
import { ACTION_POSITION, ARTWORK_TYPE, HIERARCHY, KIND } from './constants.js';
|
|
14
|
+
import { StyledRoot, StyledLeadingContent, StyledMessageContent, StyledTitle, StyledMessage, StyledBelowContent, StyledTrailingContent, StyledTrailingButtonContainer, StyledTrailingIconButton } from './styled-components.js';
|
|
15
|
+
|
|
16
|
+
function low(theme, kind) {
|
|
17
|
+
switch (kind) {
|
|
18
|
+
case KIND.negative:
|
|
19
|
+
return {
|
|
20
|
+
actionBackgroundColor: theme.colors.bannerActionLowNegative,
|
|
21
|
+
backgroundColor: theme.colors.backgroundLightNegative,
|
|
22
|
+
color: theme.colors.contentPrimary
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
case KIND.positive:
|
|
26
|
+
return {
|
|
27
|
+
actionBackgroundColor: theme.colors.bannerActionLowPositive,
|
|
28
|
+
backgroundColor: theme.colors.backgroundLightPositive,
|
|
29
|
+
color: theme.colors.contentPrimary
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
case KIND.warning:
|
|
33
|
+
return {
|
|
34
|
+
actionBackgroundColor: theme.colors.bannerActionLowWarning,
|
|
35
|
+
backgroundColor: theme.colors.backgroundLightWarning,
|
|
36
|
+
color: theme.colors.contentPrimary
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
case KIND.info:
|
|
40
|
+
default:
|
|
41
|
+
return {
|
|
42
|
+
actionBackgroundColor: theme.colors.bannerActionLowInfo,
|
|
43
|
+
backgroundColor: theme.colors.backgroundLightAccent,
|
|
44
|
+
color: theme.colors.contentPrimary
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function high(theme, kind) {
|
|
50
|
+
switch (kind) {
|
|
51
|
+
case KIND.negative:
|
|
52
|
+
return {
|
|
53
|
+
actionBackgroundColor: theme.colors.bannerActionHighNegative,
|
|
54
|
+
backgroundColor: theme.colors.backgroundNegative,
|
|
55
|
+
color: theme.colors.contentOnColor
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
case KIND.positive:
|
|
59
|
+
return {
|
|
60
|
+
actionBackgroundColor: theme.colors.bannerActionHighPositive,
|
|
61
|
+
backgroundColor: theme.colors.backgroundPositive,
|
|
62
|
+
color: theme.colors.contentOnColor
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
case KIND.warning:
|
|
66
|
+
return {
|
|
67
|
+
actionBackgroundColor: theme.colors.bannerActionHighWarning,
|
|
68
|
+
backgroundColor: theme.colors.backgroundWarning,
|
|
69
|
+
color: theme.colors.contentPrimary
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
case KIND.info:
|
|
73
|
+
default:
|
|
74
|
+
return {
|
|
75
|
+
actionBackgroundColor: theme.colors.bannerActionHighInfo,
|
|
76
|
+
backgroundColor: theme.colors.backgroundAccent,
|
|
77
|
+
color: theme.colors.contentOnColor
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function Leading({
|
|
83
|
+
artwork
|
|
84
|
+
}) {
|
|
85
|
+
const [, theme] = useStyletron();
|
|
86
|
+
|
|
87
|
+
if (!artwork) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const size = artwork.type === ARTWORK_TYPE.badge ? theme.sizing.scale1000 : theme.sizing.scale800;
|
|
92
|
+
return artwork.icon({
|
|
93
|
+
size
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function Below({
|
|
98
|
+
action,
|
|
99
|
+
backgroundColor,
|
|
100
|
+
color
|
|
101
|
+
}) {
|
|
102
|
+
if (!action || action.position !== ACTION_POSITION.below) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (process.env.NODE_ENV !== "production") {
|
|
107
|
+
if (action.icon) {
|
|
108
|
+
console.error('Banner ACTION_POSITION.below must not have an icon.');
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (action.label) {
|
|
114
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
115
|
+
colors: {
|
|
116
|
+
backgroundColor,
|
|
117
|
+
color
|
|
118
|
+
},
|
|
119
|
+
onClick: action.onClick,
|
|
120
|
+
size: BUTTON_SIZE.compact,
|
|
121
|
+
shape: BUTTON_SHAPE.pill
|
|
122
|
+
}, action.label);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function Trailing({
|
|
129
|
+
action,
|
|
130
|
+
backgroundColor,
|
|
131
|
+
color,
|
|
132
|
+
overrides,
|
|
133
|
+
nested
|
|
134
|
+
}) {
|
|
135
|
+
const [, theme] = useStyletron();
|
|
136
|
+
|
|
137
|
+
if (!action || action.position && action.position !== ACTION_POSITION.trailing) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const [TrailingIconButton, trailingIconButtonProps] = getOverrides(overrides.TrailingIconButton, StyledTrailingIconButton);
|
|
142
|
+
|
|
143
|
+
if (action.icon) {
|
|
144
|
+
return /*#__PURE__*/React.createElement(TrailingIconButton, _extends({
|
|
145
|
+
"aria-label": action.label,
|
|
146
|
+
onClick: action.onClick,
|
|
147
|
+
$nested: nested
|
|
148
|
+
}, trailingIconButtonProps), action.icon({
|
|
149
|
+
size: theme.sizing.scale650
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const [TrailingButtonContainer, trailingButtonContainerProps] = getOverrides(overrides.TrailingButtonContainer, StyledTrailingButtonContainer);
|
|
154
|
+
|
|
155
|
+
if (action.label) {
|
|
156
|
+
return /*#__PURE__*/React.createElement(TrailingButtonContainer, trailingButtonContainerProps, /*#__PURE__*/React.createElement(Button, {
|
|
157
|
+
colors: {
|
|
158
|
+
backgroundColor,
|
|
159
|
+
color
|
|
160
|
+
},
|
|
161
|
+
onClick: action.onClick,
|
|
162
|
+
size: BUTTON_SIZE.compact,
|
|
163
|
+
shape: BUTTON_SHAPE.pill
|
|
164
|
+
}, action.label));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function Banner({
|
|
171
|
+
action,
|
|
172
|
+
artwork,
|
|
173
|
+
children,
|
|
174
|
+
hierarchy = HIERARCHY.low,
|
|
175
|
+
kind = KIND.info,
|
|
176
|
+
overrides = {},
|
|
177
|
+
nested = false,
|
|
178
|
+
title
|
|
179
|
+
}) {
|
|
180
|
+
const [, theme] = useStyletron();
|
|
181
|
+
const styles = hierarchy === HIERARCHY.high ? high(theme, kind) : low(theme, kind);
|
|
182
|
+
const actionPosition = action && action.position ? action.position : ACTION_POSITION.trailing;
|
|
183
|
+
const [Root, rootProps] = getOverrides(overrides.Root, StyledRoot);
|
|
184
|
+
const [LeadingContent, leadingContentProps] = getOverrides(overrides.LeadingContent, StyledLeadingContent);
|
|
185
|
+
const [MessageContent, messageContentProps] = getOverrides(overrides.MessageContent, StyledMessageContent);
|
|
186
|
+
const [TrailingContent, trailingContentProps] = getOverrides(overrides.TrailingContent, StyledTrailingContent);
|
|
187
|
+
const [BelowContent, belowContentProps] = getOverrides(overrides.BelowContent, StyledBelowContent);
|
|
188
|
+
const [Title, titleProps] = getOverrides(overrides.Title, StyledTitle);
|
|
189
|
+
const [Message, messageProps] = getOverrides(overrides.Message, StyledMessage);
|
|
190
|
+
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
191
|
+
$backgroundColor: styles.backgroundColor,
|
|
192
|
+
$color: styles.color,
|
|
193
|
+
$nested: nested
|
|
194
|
+
}, rootProps), /*#__PURE__*/React.createElement(LeadingContent, _extends({
|
|
195
|
+
$includesArtwork: Boolean(artwork)
|
|
196
|
+
}, leadingContentProps), /*#__PURE__*/React.createElement(Leading, {
|
|
197
|
+
artwork: artwork
|
|
198
|
+
})), /*#__PURE__*/React.createElement(MessageContent, _extends({
|
|
199
|
+
$actionPosition: actionPosition
|
|
200
|
+
}, messageContentProps), Boolean(title) && /*#__PURE__*/React.createElement(Title, titleProps, title), Boolean(children) && /*#__PURE__*/React.createElement(Message, messageProps, children)), /*#__PURE__*/React.createElement(TrailingContent, trailingContentProps, /*#__PURE__*/React.createElement(Trailing, {
|
|
201
|
+
action: action,
|
|
202
|
+
backgroundColor: styles.actionBackgroundColor,
|
|
203
|
+
color: styles.color,
|
|
204
|
+
overrides: overrides,
|
|
205
|
+
nested: nested
|
|
206
|
+
})), /*#__PURE__*/React.createElement(BelowContent, _extends({
|
|
207
|
+
$actionPosition: actionPosition
|
|
208
|
+
}, belowContentProps), /*#__PURE__*/React.createElement(Below, {
|
|
209
|
+
action: action,
|
|
210
|
+
backgroundColor: styles.actionBackgroundColor,
|
|
211
|
+
color: styles.color
|
|
212
|
+
})));
|
|
213
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) Uber Technologies, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export const ACTION_POSITION = Object.freeze({
|
|
8
|
+
below: 'below',
|
|
9
|
+
trailing: 'trailing'
|
|
10
|
+
});
|
|
11
|
+
export const ARTWORK_TYPE = Object.freeze({
|
|
12
|
+
icon: 'icon',
|
|
13
|
+
badge: 'badge'
|
|
14
|
+
});
|
|
15
|
+
export const HIERARCHY = Object.freeze({
|
|
16
|
+
low: 'low',
|
|
17
|
+
high: 'high'
|
|
18
|
+
});
|
|
19
|
+
export const KIND = Object.freeze({
|
|
20
|
+
info: 'info',
|
|
21
|
+
negative: 'negative',
|
|
22
|
+
positive: 'positive',
|
|
23
|
+
warning: 'warning'
|
|
24
|
+
});
|