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

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.10",
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.10",
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": "cd7581927d2863c8990b0f84afa46bf133c5945f"
51
51
  }
@@ -38,7 +38,6 @@
38
38
 
39
39
  &__title {
40
40
  @include typography.font-size(3);
41
- color: colours.$text-inverse;
42
41
  margin: utils.rem(0 0 spacing.$x-small);
43
42
  }
44
43
 
@@ -54,57 +53,133 @@
54
53
  }
55
54
  }
56
55
 
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;
70
-
71
- &:hover {
72
- background: rgb(0 0 0 / 20%);
73
- }
56
+ &--subtle {
57
+ @include typography.links-default;
58
+ background: colours.$action-banner-subtle-background;
59
+ color: colours.$text;
74
60
 
75
- &:focus {
76
- @include focus.inverse-focus-style;
61
+ .action-banner__actions {
62
+ @include focus.default-button-focus;
77
63
  }
78
64
  }
79
65
 
80
- &--subtle {
66
+ &--full-width {
67
+ @include layout.fullWidth();
81
68
  @include typography.links-default;
82
- background: colours.$action-banner-subtle-background;
83
- border: 1px solid colours.$action-banner-subtle-border;
84
- color: colours.$text;
69
+ background: colours.$action-banner-full-width-background;
70
+ border: 1px solid colours.$action-banner-full-width-border;
71
+ color: colours.$text-inverse;
72
+ padding: 0;
73
+
74
+ .action-banner__intro * {
75
+ @include typography.lead();
76
+ margin-top: utils.rem(spacing.$medium);
77
+ margin-bottom: utils.rem(spacing.$large);
78
+ }
79
+
80
+ .action-banner__container {
81
+ min-height: 300px;
82
+ padding-top: utils.rem(spacing.$x-large);
83
+ padding-bottom: utils.rem(spacing.$x-large);
84
+ }
85
85
 
86
86
  .action-banner__title {
87
- color: colours.$text;
87
+ @include typography.h2();
88
+ margin: 0;
88
89
  }
89
90
 
90
- .action-banner__close {
91
- color: colours.$text;
91
+ .action-banner__actions {
92
+ text-align: left;
93
+ position: relative;
94
+ top: 0;
95
+ left: 0;
96
+ transform: unset;
97
+ }
98
+
99
+ .action-banner__actions > .btn.btn--inverse {
100
+ @include focus.default-button-focus;
92
101
  }
93
102
 
103
+ &__image-container {
104
+ aspect-ratio: 16 / 9;
105
+ background-position: center center;
106
+ background-size: cover;
107
+ display: block;
108
+ height: 100%;
109
+ }
110
+
111
+ & a {
112
+ &:link,
113
+ &:visited,
114
+ &:hover,
115
+ &:active,
116
+ &:focus {
117
+ color: colours.$action-banner-full-width-dark-background-text-colour;
118
+ outline-color: colours.$focus-inverse;
119
+ }
120
+ }
121
+ }
122
+
123
+ &--full-width-subtle {
124
+ @extend .action-banner--full-width;
125
+
126
+ background: colours.$action-banner-full-width-subtle-background;
127
+ color: colours.$text;
128
+
94
129
  .action-banner__actions {
95
130
  @include focus.default-button-focus;
96
131
  }
132
+
133
+ & a {
134
+ &:link,
135
+ &:visited,
136
+ &:hover,
137
+ &:active,
138
+ &:focus {
139
+ color: colours.$action-banner-full-width-light-background-text-colour;
140
+ outline-color: colours.$focus;
141
+ }
142
+ }
97
143
  }
98
144
 
99
- &--closeable {
100
- .action-banner__title {
101
- padding-right: utils.rem(spacing.$large); // Make room for close button
145
+ @include media-queries.mq($from: sm) {
146
+ &--full-width {
147
+ &__image-container {
148
+ aspect-ratio: 21 / 9;
149
+ }
102
150
  }
103
151
  }
104
152
 
105
153
  @include media-queries.mq($from: md) {
106
154
  @include layout.clearfix;
107
155
 
156
+ &--full-width {
157
+ &__image-container {
158
+ aspect-ratio: unset;
159
+ bottom: 0;
160
+ overflow: hidden;
161
+ position: absolute;
162
+ right: 0;
163
+ top: 0;
164
+ z-index: 0;
165
+
166
+ @include media-queries.mq($from: md) {
167
+ display: flex;
168
+ width: 34%;
169
+ }
170
+
171
+ &::before {
172
+ background: colours.$action-banner-full-width-background;
173
+ content: '';
174
+ flex: 0 0 200px;
175
+ pointer-events: none;
176
+ position: relative;
177
+ transform: rotate(-15deg) scale(1.2) translateX(-60%);
178
+ z-index: 1;
179
+ }
180
+ }
181
+ }
182
+
108
183
  &__text {
109
184
  margin-bottom: 0;
110
185
  width: math.percentage(3 * 0.25);
@@ -118,15 +193,5 @@
118
193
  transform: translateY(-50%);
119
194
  width: math.percentage(1 * 0.25);
120
195
  }
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
196
  }
132
197
  }