@team-monolith/cds 1.23.0 → 1.24.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/dist/components/Banner.d.ts +3 -1
- package/dist/components/Banner.js +40 -35
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export type BannerColor = "red" | "blue" | "green" | "yellow";
|
|
2
|
+
export type BannerColor = "red" | "blue" | "green" | "yellow" | "white";
|
|
3
3
|
export interface BannerProps {
|
|
4
4
|
className?: string;
|
|
5
5
|
component?: React.ElementType;
|
|
@@ -15,6 +15,8 @@ export interface BannerProps {
|
|
|
15
15
|
buttonLabel?: string;
|
|
16
16
|
/** 컴포넌트 우측 버튼 클릭 시 호출될 콜백 함수 */
|
|
17
17
|
onButtonClick?: () => void;
|
|
18
|
+
/** 버튼 컴포넌트에 삽입될 ClassName */
|
|
19
|
+
buttonClassName?: string;
|
|
18
20
|
/** 컴포넌트 우측에 표기될 닫기 버튼 유무 */
|
|
19
21
|
close?: boolean;
|
|
20
22
|
/** 닫기 버튼 클릭 시 호출될 콜백 함수 */
|
|
@@ -14,43 +14,50 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
14
14
|
import { css, useTheme } from "@emotion/react";
|
|
15
15
|
import styled from "@emotion/styled";
|
|
16
16
|
import React from "react";
|
|
17
|
-
import COLOR from "../foundation/color";
|
|
18
17
|
import { CloseFillIcon } from "../icons";
|
|
19
|
-
import { RESET_BUTTON } from "../utils/reset";
|
|
20
18
|
import SquareButton from "./SquareButton";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
import Button from "./Button";
|
|
20
|
+
const COLOR_PALETTE = (theme, color) => ({
|
|
21
|
+
red: {
|
|
22
|
+
background: theme.color.container.dangerContainer,
|
|
23
|
+
headline: theme.color.container.dangerOnContainer,
|
|
24
|
+
content: theme.color.container.dangerOnContainer,
|
|
25
|
+
},
|
|
26
|
+
blue: {
|
|
27
|
+
background: theme.color.container.primaryContainer,
|
|
28
|
+
headline: theme.color.container.primaryOnContainer,
|
|
29
|
+
content: theme.color.container.primaryOnContainer,
|
|
30
|
+
},
|
|
31
|
+
green: {
|
|
32
|
+
background: theme.color.container.successContainer,
|
|
33
|
+
headline: theme.color.container.successOnContainer,
|
|
34
|
+
content: theme.color.container.successOnContainer,
|
|
35
|
+
},
|
|
36
|
+
yellow: {
|
|
37
|
+
background: theme.color.container.warningContainer,
|
|
38
|
+
headline: theme.color.container.warningOnContainer,
|
|
39
|
+
content: theme.color.container.warningOnContainer,
|
|
40
|
+
},
|
|
41
|
+
white: {
|
|
42
|
+
background: theme.color.background.neutralBase,
|
|
43
|
+
headline: theme.color.foreground.neutralBaseDisabled,
|
|
44
|
+
content: theme.color.foreground.neutralBase,
|
|
45
|
+
},
|
|
38
46
|
})[color];
|
|
39
47
|
/**
|
|
40
48
|
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=44-2847&t=bhnL1ombbddld3RQ-0)
|
|
41
49
|
*/
|
|
42
50
|
const Banner = React.forwardRef((props, ref) => {
|
|
43
|
-
const { className, component: Component = "div", headline, content, icon, color, buttonLabel, onButtonClick, close, onClose, fullWidth } = props, other = __rest(props, ["className", "component", "headline", "content", "icon", "color", "buttonLabel", "onButtonClick", "close", "onClose", "fullWidth"]);
|
|
51
|
+
const { className, component: Component = "div", headline, content, icon, color, buttonLabel, buttonClassName, onButtonClick, close, onClose, fullWidth } = props, other = __rest(props, ["className", "component", "headline", "content", "icon", "color", "buttonLabel", "buttonClassName", "onButtonClick", "close", "onClose", "fullWidth"]);
|
|
44
52
|
const theme = useTheme();
|
|
45
53
|
return (_jsxs(Component, Object.assign({}, other, { ref: ref, className: className, css: [
|
|
46
54
|
css `
|
|
47
55
|
box-sizing: border-box;
|
|
48
56
|
display: flex;
|
|
49
57
|
align-items: center;
|
|
50
|
-
color: ${COLOR.white};
|
|
51
58
|
line-height: 125%;
|
|
59
|
+
background: ${COLOR_PALETTE(theme, color).background};
|
|
52
60
|
`,
|
|
53
|
-
COLOR_TO_STYLE(theme, color),
|
|
54
61
|
fullWidth
|
|
55
62
|
? css `
|
|
56
63
|
width: 100%;
|
|
@@ -59,10 +66,17 @@ const Banner = React.forwardRef((props, ref) => {
|
|
|
59
66
|
border-radius: 12px;
|
|
60
67
|
width: fit-content;
|
|
61
68
|
`,
|
|
62
|
-
] }, { children: [icon && _jsx(IconDiv,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
color:
|
|
69
|
+
] }, { children: [icon && (_jsx(IconDiv, Object.assign({ css: css `
|
|
70
|
+
color: ${COLOR_PALETTE(theme, color).headline};
|
|
71
|
+
` }, { children: icon }))), _jsxs(TextContainer, { children: [headline && (_jsx(HeadlineDiv, Object.assign({ css: css `
|
|
72
|
+
color: ${COLOR_PALETTE(theme, color).headline};
|
|
73
|
+
` }, { children: headline }))), content && (_jsx(ContentDiv, Object.assign({ css: css `
|
|
74
|
+
color: ${COLOR_PALETTE(theme, color).content};
|
|
75
|
+
` }, { children: content })))] }), buttonLabel && (_jsx(Button, { className: buttonClassName, css: css `
|
|
76
|
+
color: ${COLOR_PALETTE(theme, color).content};
|
|
77
|
+
`, color: "textNeutral", size: "small", label: buttonLabel, onClick: onButtonClick })), close && (_jsx(SquareButton, { css: css `
|
|
78
|
+
> button {
|
|
79
|
+
color: ${COLOR_PALETTE(theme, color).content};
|
|
66
80
|
}
|
|
67
81
|
`, color: "icon", size: "medium", icon: _jsx(CloseFillIcon, {}), onClick: onClose }))] })));
|
|
68
82
|
});
|
|
@@ -94,13 +108,4 @@ const TextContainer = styled.div `
|
|
|
94
108
|
padding: 16px;
|
|
95
109
|
gap: 4px;
|
|
96
110
|
`;
|
|
97
|
-
const BannerButton = styled.button `
|
|
98
|
-
${RESET_BUTTON}
|
|
99
|
-
display: flex;
|
|
100
|
-
justify-content: center;
|
|
101
|
-
align-items: center;
|
|
102
|
-
padding: 10px 12px;
|
|
103
|
-
cursor: pointer;
|
|
104
|
-
color: currentColor;
|
|
105
|
-
`;
|
|
106
111
|
export default Banner;
|