@nice-digital/nds-action-banner 4.0.8 → 4.0.9

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.
@@ -1,19 +1,11 @@
1
1
  import React, { ReactNode } from "react";
2
2
  import "../scss/action-banner.scss";
3
- interface ActionBannerProps {
3
+ export interface ActionBannerProps {
4
4
  title: string;
5
- variant?: "default" | "subtle";
5
+ variant?: "default" | "subtle" | "fullWidth" | "fullWidthSubtle";
6
6
  children: ReactNode[] | ReactNode;
7
- cta?: ReactNode;
8
- onClosing?: Function;
7
+ cta: ReactNode;
9
8
  className?: string;
9
+ image?: string;
10
10
  }
11
- interface ActionBannerState {
12
- isClosed: boolean;
13
- }
14
- export declare class ActionBanner extends React.Component<ActionBannerProps, ActionBannerState> {
15
- constructor(props: ActionBannerProps);
16
- closeClickHandler(): void;
17
- render(): JSX.Element | null;
18
- }
19
- export {};
11
+ export declare const ActionBanner: React.FC<ActionBannerProps>;
@@ -16,38 +16,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.ActionBanner = void 0;
18
18
  const jsx_runtime_1 = require("react/jsx-runtime");
19
- const react_1 = __importDefault(require("react"));
20
19
  const classnames_1 = __importDefault(require("classnames"));
21
- const Remove_1 = __importDefault(require("@nice-digital/icons/lib/Remove"));
22
20
  require("../scss/action-banner.scss");
23
- class ActionBanner extends react_1.default.Component {
24
- constructor(props) {
25
- super(props);
26
- this.state = {
27
- isClosed: false
28
- };
29
- this.closeClickHandler = this.closeClickHandler.bind(this);
30
- }
31
- closeClickHandler() {
32
- this.setState({
33
- isClosed: true
34
- });
35
- if (typeof this.props.onClosing === "function")
36
- this.props.onClosing(this);
37
- else
38
- throw new Error("The onClosing prop should be a function");
39
- }
40
- render() {
41
- if (this.state.isClosed)
42
- return null;
43
- const _a = this.props, { variant, onClosing, title, children, cta, className } = _a, rest = __rest(_a, ["variant", "onClosing", "title", "children", "cta", "className"]);
44
- const classes = {
45
- "action-banner": true,
46
- "action-banner--closeable": onClosing,
47
- [`action-banner--${variant}`]: variant,
48
- [`${className}`]: className
49
- };
50
- return ((0, jsx_runtime_1.jsx)("section", Object.assign({ className: (0, classnames_1.default)(classes), "data-component": `action-banner${variant ? `--${variant}` : ""}` }, rest, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "action-banner__container" }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "action-banner__inner" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "action-banner__text" }, { children: [(0, jsx_runtime_1.jsx)("h2", Object.assign({ className: "action-banner__title" }, { children: title })), children && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "action-banner__intro" }, { children: children })))] })), cta && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "action-banner__actions" }, { children: cta })), onClosing && ((0, jsx_runtime_1.jsxs)("button", Object.assign({ type: "button", className: "action-banner__close", onClick: this.closeClickHandler }, { children: [(0, jsx_runtime_1.jsx)(Remove_1.default, {}), (0, jsx_runtime_1.jsxs)("span", Object.assign({ className: "visually-hidden" }, { children: ["Close ", title] }))] })))] })) })) })));
51
- }
52
- }
21
+ const ActionBanner = (props) => {
22
+ const { variant, title, children, cta, className, image } = props, rest = __rest(props, ["variant", "title", "children", "cta", "className", "image"]);
23
+ const kebabCaseVariantClassName = variant
24
+ ? `${variant.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}`
25
+ : "";
26
+ const classes = {
27
+ "action-banner": true,
28
+ [`action-banner--${kebabCaseVariantClassName}`]: variant,
29
+ [`${className}`]: className
30
+ };
31
+ return ((0, jsx_runtime_1.jsxs)("section", Object.assign({ className: (0, classnames_1.default)(classes), "data-component": `action-banner${variant ? `--${variant}` : ""}` }, rest, { children: [image && variant === "fullWidth" ? ((0, jsx_runtime_1.jsx)("div", { className: "action-banner--full-width__image-container", style: { backgroundImage: `url(${image})` } })) : null, (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "action-banner__container" }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "action-banner__inner" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "action-banner__text" }, { children: [(0, jsx_runtime_1.jsx)("h2", Object.assign({ className: "action-banner__title" }, { children: title })), children && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "action-banner__intro" }, { children: children }))] })), cta && (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "action-banner__actions" }, { children: cta }))] })) }))] })));
32
+ };
53
33
  exports.ActionBanner = ActionBanner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-action-banner",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "description": "Action banner component for the NICE Design System",
5
5
  "keywords": [
6
6
  "banner"
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@nice-digital/icons": "^6.0.1",
35
- "@nice-digital/nds-core": "^4.0.8",
35
+ "@nice-digital/nds-core": "^4.0.9",
36
36
  "classnames": "^2.3.1"
37
37
  },
38
38
  "peerDependencies": {
@@ -47,5 +47,5 @@
47
47
  "@types/node": "^18.11.9",
48
48
  "typescript": "^4.8.4"
49
49
  },
50
- "gitHead": "3b51e48a6c3006fa350adf2b125d6cad9454d7c7"
50
+ "gitHead": "79b8403759d3b64619e04e9313f56594a79882fb"
51
51
  }
@@ -54,57 +54,144 @@
54
54
  }
55
55
  }
56
56
 
57
- &__close {
58
- @include focus.inverse-button-focus;
59
- appearance: none;
60
- background: 0;
61
- border: 0;
62
- color: colours.$text-inverse;
63
- cursor: pointer;
64
- line-height: 1;
65
- padding: utils.rem(spacing.$small);
66
- position: absolute;
67
- right: 0;
68
- top: 0;
69
- z-index: 1;
57
+ &--subtle {
58
+ @include typography.links-default;
59
+ background: colours.$action-banner-subtle-background;
60
+ border: 1px solid colours.$action-banner-subtle-border;
61
+ color: colours.$text;
70
62
 
71
- &:hover {
72
- background: rgb(0 0 0 / 20%);
63
+ .action-banner__title {
64
+ color: colours.$text;
73
65
  }
74
66
 
75
- &:focus {
76
- @include focus.inverse-focus-style;
67
+ .action-banner__actions {
68
+ @include focus.default-button-focus;
77
69
  }
78
70
  }
79
71
 
80
- &--subtle {
72
+ &--full-width {
73
+ @include layout.fullWidth();
81
74
  @include typography.links-default;
82
- background: colours.$action-banner-subtle-background;
83
- border: 1px solid colours.$action-banner-subtle-border;
84
- color: colours.$text;
75
+ background: colours.$action-banner-full-width-background;
76
+ border: 1px solid colours.$action-banner-full-width-border;
77
+ color: colours.$text-inverse;
78
+ padding: 0;
79
+
80
+ .action-banner__intro * {
81
+ @include typography.lead();
82
+ margin-top: utils.rem(spacing.$medium);
83
+ margin-bottom: utils.rem(spacing.$large);
84
+ }
85
+
86
+ .action-banner__container {
87
+ min-height: 300px;
88
+ padding-top: utils.rem(spacing.$x-large);
89
+ padding-bottom: utils.rem(spacing.$x-large);
90
+ }
85
91
 
86
92
  .action-banner__title {
87
- color: colours.$text;
93
+ @include typography.h2();
94
+ color: colours.$text-inverse;
95
+ margin: 0;
96
+ }
97
+
98
+ .action-banner__actions {
99
+ text-align: left;
100
+ position: relative;
101
+ top: 0;
102
+ left: 0;
103
+ transform: unset;
88
104
  }
89
105
 
90
- .action-banner__close {
106
+ .action-banner__actions > .btn.btn--inverse {
107
+ @include focus.default-button-focus;
108
+ }
109
+
110
+ &__image-container {
111
+ aspect-ratio: 16 / 9;
112
+ background-position: center center;
113
+ background-size: cover;
114
+ display: block;
115
+ height: 100%;
116
+ }
117
+
118
+ & a {
119
+ &:link,
120
+ &:visited,
121
+ &:hover,
122
+ &:active,
123
+ &:focus {
124
+ color: colours.$action-banner-full-width-dark-background-text-colour;
125
+ outline-color: colours.$focus-inverse;
126
+ }
127
+ }
128
+ }
129
+
130
+ &--full-width-subtle {
131
+ @extend .action-banner--full-width;
132
+
133
+ background: colours.$action-banner-full-width-subtle-background;
134
+ border: 1px solid colours.$action-banner-full-width-subtle-border;
135
+ color: colours.$text;
136
+
137
+ .action-banner__title {
91
138
  color: colours.$text;
92
139
  }
93
140
 
94
141
  .action-banner__actions {
95
142
  @include focus.default-button-focus;
96
143
  }
144
+
145
+ & a {
146
+ &:link,
147
+ &:visited,
148
+ &:hover,
149
+ &:active,
150
+ &:focus {
151
+ color: colours.$action-banner-full-width-light-background-text-colour;
152
+ outline-color: colours.$focus;
153
+ }
154
+ }
97
155
  }
98
156
 
99
- &--closeable {
100
- .action-banner__title {
101
- padding-right: utils.rem(spacing.$large); // Make room for close button
157
+ @include media-queries.mq($from: sm) {
158
+ &--full-width {
159
+ &__image-container {
160
+ aspect-ratio: 21 / 9;
161
+ }
102
162
  }
103
163
  }
104
164
 
105
165
  @include media-queries.mq($from: md) {
106
166
  @include layout.clearfix;
107
167
 
168
+ &--full-width {
169
+ &__image-container {
170
+ aspect-ratio: unset;
171
+ bottom: 0;
172
+ overflow: hidden;
173
+ position: absolute;
174
+ right: 0;
175
+ top: 0;
176
+ z-index: 0;
177
+
178
+ @include media-queries.mq($from: md) {
179
+ display: flex;
180
+ width: 34%;
181
+ }
182
+
183
+ &::before {
184
+ background: colours.$action-banner-full-width-background;
185
+ content: '';
186
+ flex: 0 0 200px;
187
+ pointer-events: none;
188
+ position: relative;
189
+ transform: rotate(-15deg) scale(1.2) translateX(-60%);
190
+ z-index: 1;
191
+ }
192
+ }
193
+ }
194
+
108
195
  &__text {
109
196
  margin-bottom: 0;
110
197
  width: math.percentage(3 * 0.25);
@@ -118,15 +205,5 @@
118
205
  transform: translateY(-50%);
119
206
  width: math.percentage(1 * 0.25);
120
207
  }
121
-
122
- &--closeable {
123
- .action-banner__title {
124
- padding-right: 0;
125
- }
126
-
127
- .action-banner__actions {
128
- right: utils.rem(spacing.$x-large);
129
- }
130
- }
131
208
  }
132
209
  }