@telus-uds/components-web 1.1.0 → 1.2.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/CHANGELOG.md +12 -2
- package/lib/Ribbon/Ribbon.js +209 -0
- package/lib/Ribbon/index.js +13 -0
- package/lib/index.js +9 -0
- package/lib-module/Ribbon/Ribbon.js +191 -0
- package/lib-module/Ribbon/index.js +2 -0
- package/lib-module/index.js +1 -0
- package/package.json +3 -3
- package/src/Ribbon/Ribbon.jsx +126 -0
- package/src/Ribbon/index.js +3 -0
- package/src/index.js +1 -0
- package/types/Ribbon.d.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-web
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 04 Apr 2023 14:45:59 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.2.0
|
|
8
|
+
|
|
9
|
+
Tue, 04 Apr 2023 14:45:59 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Add Ribbon component (wlsdud194@hotmail.com)
|
|
14
|
+
- Bump @telus-uds/components-base to v1.32.0
|
|
15
|
+
- Bump @telus-uds/system-theme-tokens to v2.16.0
|
|
16
|
+
|
|
7
17
|
## 1.1.0
|
|
8
18
|
|
|
9
|
-
Mon, 03 Apr 2023 20:
|
|
19
|
+
Mon, 03 Apr 2023 20:41:50 GMT
|
|
10
20
|
|
|
11
21
|
### Minor changes
|
|
12
22
|
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
// import palette from '@telus-uds/palette-allium/build/web/palette'
|
|
23
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
24
|
+
|
|
25
|
+
const RibbonWrapper = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
26
|
+
displayName: "Ribbon__RibbonWrapper",
|
|
27
|
+
componentId: "components-web__sc-186270k-0"
|
|
28
|
+
})(["width:fit-content;position:", ";z-index:1;left:", ";top:", ";"], _ref => {
|
|
29
|
+
let {
|
|
30
|
+
left,
|
|
31
|
+
top
|
|
32
|
+
} = _ref;
|
|
33
|
+
return left ?? top ? 'absolute' : 'relative';
|
|
34
|
+
}, _ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
left
|
|
37
|
+
} = _ref2;
|
|
38
|
+
return left && `${left}px`;
|
|
39
|
+
}, _ref3 => {
|
|
40
|
+
let {
|
|
41
|
+
top
|
|
42
|
+
} = _ref3;
|
|
43
|
+
return top && `${top}px`;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const RibbonContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
47
|
+
displayName: "Ribbon__RibbonContainer",
|
|
48
|
+
componentId: "components-web__sc-186270k-1"
|
|
49
|
+
})(["display:flex;justify-content:center;background:", ";padding:", ";border-radius:", ";width:fit-content;box-shadow:", ";"], _ref4 => {
|
|
50
|
+
let {
|
|
51
|
+
backgroundColor
|
|
52
|
+
} = _ref4;
|
|
53
|
+
return backgroundColor;
|
|
54
|
+
}, _ref5 => {
|
|
55
|
+
let {
|
|
56
|
+
padding
|
|
57
|
+
} = _ref5;
|
|
58
|
+
return `${padding}`;
|
|
59
|
+
}, _ref6 => {
|
|
60
|
+
let {
|
|
61
|
+
borderRadius
|
|
62
|
+
} = _ref6;
|
|
63
|
+
return borderRadius;
|
|
64
|
+
}, _ref7 => {
|
|
65
|
+
let {
|
|
66
|
+
boxShadow,
|
|
67
|
+
shouldWrap
|
|
68
|
+
} = _ref7;
|
|
69
|
+
return shouldWrap && boxShadow;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const RibbonCurve = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
73
|
+
displayName: "Ribbon__RibbonCurve",
|
|
74
|
+
componentId: "components-web__sc-186270k-2"
|
|
75
|
+
})(["background:", ";width:", ";height:", ";margin-top:-", ";border-radius:0 0 0 100%;position:relative;z-index:-1;&::after{content:'';border-bottom-left-radius:", ";position:absolute;height:", ";background:", ";width:", ";}"], _ref8 => {
|
|
76
|
+
let {
|
|
77
|
+
curveBackgroundColor
|
|
78
|
+
} = _ref8;
|
|
79
|
+
return curveBackgroundColor;
|
|
80
|
+
}, _ref9 => {
|
|
81
|
+
let {
|
|
82
|
+
curveWidth
|
|
83
|
+
} = _ref9;
|
|
84
|
+
return curveWidth;
|
|
85
|
+
}, _ref10 => {
|
|
86
|
+
let {
|
|
87
|
+
curveHeight
|
|
88
|
+
} = _ref10;
|
|
89
|
+
return curveHeight;
|
|
90
|
+
}, _ref11 => {
|
|
91
|
+
let {
|
|
92
|
+
curveMarginTop
|
|
93
|
+
} = _ref11;
|
|
94
|
+
return curveMarginTop;
|
|
95
|
+
}, _ref12 => {
|
|
96
|
+
let {
|
|
97
|
+
curveAfterRadius
|
|
98
|
+
} = _ref12;
|
|
99
|
+
return curveAfterRadius;
|
|
100
|
+
}, _ref13 => {
|
|
101
|
+
let {
|
|
102
|
+
curveAfterHeight
|
|
103
|
+
} = _ref13;
|
|
104
|
+
return curveAfterHeight;
|
|
105
|
+
}, _ref14 => {
|
|
106
|
+
let {
|
|
107
|
+
curveAfterBackgroundColor
|
|
108
|
+
} = _ref14;
|
|
109
|
+
return curveAfterBackgroundColor;
|
|
110
|
+
}, _ref15 => {
|
|
111
|
+
let {
|
|
112
|
+
curveAfterWidth
|
|
113
|
+
} = _ref15;
|
|
114
|
+
return curveAfterWidth;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const Ribbon = _ref16 => {
|
|
118
|
+
let {
|
|
119
|
+
children,
|
|
120
|
+
tokens,
|
|
121
|
+
wrap: shouldWrap = false,
|
|
122
|
+
left,
|
|
123
|
+
top,
|
|
124
|
+
variant = {},
|
|
125
|
+
...rest
|
|
126
|
+
} = _ref16;
|
|
127
|
+
const {
|
|
128
|
+
backgroundColor,
|
|
129
|
+
borderRadius,
|
|
130
|
+
boxShadowPaddingBottom,
|
|
131
|
+
boxShadowPaddingLeft,
|
|
132
|
+
boxShadowPaddingRight,
|
|
133
|
+
boxShadowPaddingTop,
|
|
134
|
+
boxShadowColor,
|
|
135
|
+
curveAfterBackgroundColor,
|
|
136
|
+
curveAfterHeight,
|
|
137
|
+
curveAfterWidth,
|
|
138
|
+
curveBackgroundColor,
|
|
139
|
+
curveHeight,
|
|
140
|
+
curveAfterRadius,
|
|
141
|
+
curveWidth,
|
|
142
|
+
curveMarginTop,
|
|
143
|
+
paddingBottom,
|
|
144
|
+
paddingLeft,
|
|
145
|
+
paddingRight,
|
|
146
|
+
paddingTop,
|
|
147
|
+
gradient
|
|
148
|
+
} = (0, _componentsBase.useThemeTokens)('Ribbon', tokens, variant);
|
|
149
|
+
const {
|
|
150
|
+
purpose
|
|
151
|
+
} = variant;
|
|
152
|
+
const {
|
|
153
|
+
type: gradientType,
|
|
154
|
+
angle: gradientAngle,
|
|
155
|
+
stops: gradientColors
|
|
156
|
+
} = gradient;
|
|
157
|
+
const isOfferPurpose = purpose === 'offer';
|
|
158
|
+
const gradientBackground = `${gradientType}-gradient(${gradientAngle}deg, ${gradientColors[0].color}, ${gradientColors[1].color})`;
|
|
159
|
+
const background = isOfferPurpose ? gradientBackground : backgroundColor;
|
|
160
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(RibbonWrapper, {
|
|
161
|
+
left: left,
|
|
162
|
+
top: top,
|
|
163
|
+
"data-testid": "ribbon-wrapper",
|
|
164
|
+
...selectProps(rest),
|
|
165
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(RibbonContainer, {
|
|
166
|
+
shouldWrap: shouldWrap,
|
|
167
|
+
backgroundColor: background,
|
|
168
|
+
padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
|
|
169
|
+
borderRadius: `${borderRadius}px`,
|
|
170
|
+
boxShadow: `${boxShadowPaddingTop}px ${boxShadowPaddingRight}px ${boxShadowPaddingBottom}px ${boxShadowPaddingLeft}px ${boxShadowColor}`,
|
|
171
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
172
|
+
variant: {
|
|
173
|
+
size: 'micro',
|
|
174
|
+
bold: true,
|
|
175
|
+
inverse: true
|
|
176
|
+
},
|
|
177
|
+
children: children
|
|
178
|
+
})
|
|
179
|
+
}), shouldWrap && /*#__PURE__*/(0, _jsxRuntime.jsx)(RibbonCurve, {
|
|
180
|
+
"data-testid": "ribbon-curve",
|
|
181
|
+
backgroundColor: backgroundColor,
|
|
182
|
+
curveMarginTop: `${curveMarginTop}px`,
|
|
183
|
+
curveWidth: `${curveWidth}px`,
|
|
184
|
+
curveHeight: `${curveHeight}px`,
|
|
185
|
+
curveBackgroundColor: curveBackgroundColor,
|
|
186
|
+
curveAfterRadius: `${curveAfterRadius}px`,
|
|
187
|
+
curveAfterWidth: `${curveAfterWidth}px`,
|
|
188
|
+
curveAfterHeight: `${curveAfterHeight}px`,
|
|
189
|
+
curveAfterBackgroundColor: curveAfterBackgroundColor
|
|
190
|
+
})]
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
Ribbon.propTypes = { ...selectedSystemPropTypes,
|
|
195
|
+
children: _propTypes.default.node,
|
|
196
|
+
|
|
197
|
+
/** show/hide the ribbon fold
|
|
198
|
+
* @deprecated please don't rely on `wrap` to turn off the wrapping (use `Badge` instead) as it will be removed in the future
|
|
199
|
+
*/
|
|
200
|
+
wrap: _propTypes.default.bool,
|
|
201
|
+
|
|
202
|
+
/** sets the left offset (triggers absolute positioning) */
|
|
203
|
+
left: _propTypes.default.number,
|
|
204
|
+
|
|
205
|
+
/** sets the top offset (triggers absolute positioning) */
|
|
206
|
+
top: _propTypes.default.number
|
|
207
|
+
};
|
|
208
|
+
var _default = Ribbon;
|
|
209
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _Ribbon = _interopRequireDefault(require("./Ribbon"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _Ribbon.default;
|
|
13
|
+
exports.default = _default;
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
Badge: true,
|
|
8
|
+
Ribbon: true,
|
|
8
9
|
transformGradient: true
|
|
9
10
|
};
|
|
10
11
|
Object.defineProperty(exports, "Badge", {
|
|
@@ -13,6 +14,12 @@ Object.defineProperty(exports, "Badge", {
|
|
|
13
14
|
return _Badge.default;
|
|
14
15
|
}
|
|
15
16
|
});
|
|
17
|
+
Object.defineProperty(exports, "Ribbon", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _Ribbon.default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
16
23
|
Object.defineProperty(exports, "transformGradient", {
|
|
17
24
|
enumerable: true,
|
|
18
25
|
get: function () {
|
|
@@ -22,6 +29,8 @@ Object.defineProperty(exports, "transformGradient", {
|
|
|
22
29
|
|
|
23
30
|
var _Badge = _interopRequireDefault(require("./Badge"));
|
|
24
31
|
|
|
32
|
+
var _Ribbon = _interopRequireDefault(require("./Ribbon"));
|
|
33
|
+
|
|
25
34
|
var _utils = require("./utils");
|
|
26
35
|
|
|
27
36
|
var _baseExports = require("./baseExports");
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { selectSystemProps, Typography, useThemeTokens } from '@telus-uds/components-base'; // import palette from '@telus-uds/palette-allium/build/web/palette'
|
|
4
|
+
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { htmlAttrs } from '../utils';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
10
|
+
const RibbonWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
11
|
+
displayName: "Ribbon__RibbonWrapper",
|
|
12
|
+
componentId: "components-web__sc-186270k-0"
|
|
13
|
+
})(["width:fit-content;position:", ";z-index:1;left:", ";top:", ";"], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
left,
|
|
16
|
+
top
|
|
17
|
+
} = _ref;
|
|
18
|
+
return left ?? top ? 'absolute' : 'relative';
|
|
19
|
+
}, _ref2 => {
|
|
20
|
+
let {
|
|
21
|
+
left
|
|
22
|
+
} = _ref2;
|
|
23
|
+
return left && `${left}px`;
|
|
24
|
+
}, _ref3 => {
|
|
25
|
+
let {
|
|
26
|
+
top
|
|
27
|
+
} = _ref3;
|
|
28
|
+
return top && `${top}px`;
|
|
29
|
+
});
|
|
30
|
+
const RibbonContainer = /*#__PURE__*/styled.div.withConfig({
|
|
31
|
+
displayName: "Ribbon__RibbonContainer",
|
|
32
|
+
componentId: "components-web__sc-186270k-1"
|
|
33
|
+
})(["display:flex;justify-content:center;background:", ";padding:", ";border-radius:", ";width:fit-content;box-shadow:", ";"], _ref4 => {
|
|
34
|
+
let {
|
|
35
|
+
backgroundColor
|
|
36
|
+
} = _ref4;
|
|
37
|
+
return backgroundColor;
|
|
38
|
+
}, _ref5 => {
|
|
39
|
+
let {
|
|
40
|
+
padding
|
|
41
|
+
} = _ref5;
|
|
42
|
+
return `${padding}`;
|
|
43
|
+
}, _ref6 => {
|
|
44
|
+
let {
|
|
45
|
+
borderRadius
|
|
46
|
+
} = _ref6;
|
|
47
|
+
return borderRadius;
|
|
48
|
+
}, _ref7 => {
|
|
49
|
+
let {
|
|
50
|
+
boxShadow,
|
|
51
|
+
shouldWrap
|
|
52
|
+
} = _ref7;
|
|
53
|
+
return shouldWrap && boxShadow;
|
|
54
|
+
});
|
|
55
|
+
const RibbonCurve = /*#__PURE__*/styled.div.withConfig({
|
|
56
|
+
displayName: "Ribbon__RibbonCurve",
|
|
57
|
+
componentId: "components-web__sc-186270k-2"
|
|
58
|
+
})(["background:", ";width:", ";height:", ";margin-top:-", ";border-radius:0 0 0 100%;position:relative;z-index:-1;&::after{content:'';border-bottom-left-radius:", ";position:absolute;height:", ";background:", ";width:", ";}"], _ref8 => {
|
|
59
|
+
let {
|
|
60
|
+
curveBackgroundColor
|
|
61
|
+
} = _ref8;
|
|
62
|
+
return curveBackgroundColor;
|
|
63
|
+
}, _ref9 => {
|
|
64
|
+
let {
|
|
65
|
+
curveWidth
|
|
66
|
+
} = _ref9;
|
|
67
|
+
return curveWidth;
|
|
68
|
+
}, _ref10 => {
|
|
69
|
+
let {
|
|
70
|
+
curveHeight
|
|
71
|
+
} = _ref10;
|
|
72
|
+
return curveHeight;
|
|
73
|
+
}, _ref11 => {
|
|
74
|
+
let {
|
|
75
|
+
curveMarginTop
|
|
76
|
+
} = _ref11;
|
|
77
|
+
return curveMarginTop;
|
|
78
|
+
}, _ref12 => {
|
|
79
|
+
let {
|
|
80
|
+
curveAfterRadius
|
|
81
|
+
} = _ref12;
|
|
82
|
+
return curveAfterRadius;
|
|
83
|
+
}, _ref13 => {
|
|
84
|
+
let {
|
|
85
|
+
curveAfterHeight
|
|
86
|
+
} = _ref13;
|
|
87
|
+
return curveAfterHeight;
|
|
88
|
+
}, _ref14 => {
|
|
89
|
+
let {
|
|
90
|
+
curveAfterBackgroundColor
|
|
91
|
+
} = _ref14;
|
|
92
|
+
return curveAfterBackgroundColor;
|
|
93
|
+
}, _ref15 => {
|
|
94
|
+
let {
|
|
95
|
+
curveAfterWidth
|
|
96
|
+
} = _ref15;
|
|
97
|
+
return curveAfterWidth;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const Ribbon = _ref16 => {
|
|
101
|
+
let {
|
|
102
|
+
children,
|
|
103
|
+
tokens,
|
|
104
|
+
wrap: shouldWrap = false,
|
|
105
|
+
left,
|
|
106
|
+
top,
|
|
107
|
+
variant = {},
|
|
108
|
+
...rest
|
|
109
|
+
} = _ref16;
|
|
110
|
+
const {
|
|
111
|
+
backgroundColor,
|
|
112
|
+
borderRadius,
|
|
113
|
+
boxShadowPaddingBottom,
|
|
114
|
+
boxShadowPaddingLeft,
|
|
115
|
+
boxShadowPaddingRight,
|
|
116
|
+
boxShadowPaddingTop,
|
|
117
|
+
boxShadowColor,
|
|
118
|
+
curveAfterBackgroundColor,
|
|
119
|
+
curveAfterHeight,
|
|
120
|
+
curveAfterWidth,
|
|
121
|
+
curveBackgroundColor,
|
|
122
|
+
curveHeight,
|
|
123
|
+
curveAfterRadius,
|
|
124
|
+
curveWidth,
|
|
125
|
+
curveMarginTop,
|
|
126
|
+
paddingBottom,
|
|
127
|
+
paddingLeft,
|
|
128
|
+
paddingRight,
|
|
129
|
+
paddingTop,
|
|
130
|
+
gradient
|
|
131
|
+
} = useThemeTokens('Ribbon', tokens, variant);
|
|
132
|
+
const {
|
|
133
|
+
purpose
|
|
134
|
+
} = variant;
|
|
135
|
+
const {
|
|
136
|
+
type: gradientType,
|
|
137
|
+
angle: gradientAngle,
|
|
138
|
+
stops: gradientColors
|
|
139
|
+
} = gradient;
|
|
140
|
+
const isOfferPurpose = purpose === 'offer';
|
|
141
|
+
const gradientBackground = `${gradientType}-gradient(${gradientAngle}deg, ${gradientColors[0].color}, ${gradientColors[1].color})`;
|
|
142
|
+
const background = isOfferPurpose ? gradientBackground : backgroundColor;
|
|
143
|
+
return /*#__PURE__*/_jsxs(RibbonWrapper, {
|
|
144
|
+
left: left,
|
|
145
|
+
top: top,
|
|
146
|
+
"data-testid": "ribbon-wrapper",
|
|
147
|
+
...selectProps(rest),
|
|
148
|
+
children: [/*#__PURE__*/_jsx(RibbonContainer, {
|
|
149
|
+
shouldWrap: shouldWrap,
|
|
150
|
+
backgroundColor: background,
|
|
151
|
+
padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
|
|
152
|
+
borderRadius: `${borderRadius}px`,
|
|
153
|
+
boxShadow: `${boxShadowPaddingTop}px ${boxShadowPaddingRight}px ${boxShadowPaddingBottom}px ${boxShadowPaddingLeft}px ${boxShadowColor}`,
|
|
154
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
155
|
+
variant: {
|
|
156
|
+
size: 'micro',
|
|
157
|
+
bold: true,
|
|
158
|
+
inverse: true
|
|
159
|
+
},
|
|
160
|
+
children: children
|
|
161
|
+
})
|
|
162
|
+
}), shouldWrap && /*#__PURE__*/_jsx(RibbonCurve, {
|
|
163
|
+
"data-testid": "ribbon-curve",
|
|
164
|
+
backgroundColor: backgroundColor,
|
|
165
|
+
curveMarginTop: `${curveMarginTop}px`,
|
|
166
|
+
curveWidth: `${curveWidth}px`,
|
|
167
|
+
curveHeight: `${curveHeight}px`,
|
|
168
|
+
curveBackgroundColor: curveBackgroundColor,
|
|
169
|
+
curveAfterRadius: `${curveAfterRadius}px`,
|
|
170
|
+
curveAfterWidth: `${curveAfterWidth}px`,
|
|
171
|
+
curveAfterHeight: `${curveAfterHeight}px`,
|
|
172
|
+
curveAfterBackgroundColor: curveAfterBackgroundColor
|
|
173
|
+
})]
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
Ribbon.propTypes = { ...selectedSystemPropTypes,
|
|
178
|
+
children: PropTypes.node,
|
|
179
|
+
|
|
180
|
+
/** show/hide the ribbon fold
|
|
181
|
+
* @deprecated please don't rely on `wrap` to turn off the wrapping (use `Badge` instead) as it will be removed in the future
|
|
182
|
+
*/
|
|
183
|
+
wrap: PropTypes.bool,
|
|
184
|
+
|
|
185
|
+
/** sets the left offset (triggers absolute positioning) */
|
|
186
|
+
left: PropTypes.number,
|
|
187
|
+
|
|
188
|
+
/** sets the top offset (triggers absolute positioning) */
|
|
189
|
+
top: PropTypes.number
|
|
190
|
+
};
|
|
191
|
+
export default Ribbon;
|
package/lib-module/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"extends @telus-uds/browserslist-config"
|
|
5
5
|
],
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@telus-uds/components-base": "1.
|
|
7
|
+
"@telus-uds/components-base": "1.32.0",
|
|
8
8
|
"@telus-uds/system-constants": "^1.2.0",
|
|
9
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
9
|
+
"@telus-uds/system-theme-tokens": "^2.16.0",
|
|
10
10
|
"prop-types": "^15.7.2"
|
|
11
11
|
},
|
|
12
12
|
"description": "UDS mult-brand web components",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"skip": true
|
|
54
54
|
},
|
|
55
55
|
"types": "types/index.d.ts",
|
|
56
|
-
"version": "1.
|
|
56
|
+
"version": "1.2.0"
|
|
57
57
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { selectSystemProps, Typography, useThemeTokens } from '@telus-uds/components-base'
|
|
4
|
+
// import palette from '@telus-uds/palette-allium/build/web/palette'
|
|
5
|
+
import styled from 'styled-components'
|
|
6
|
+
import { htmlAttrs } from '../utils'
|
|
7
|
+
|
|
8
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
9
|
+
|
|
10
|
+
const RibbonWrapper = styled.div`
|
|
11
|
+
width: fit-content;
|
|
12
|
+
position: ${({ left, top }) => (left ?? top ? 'absolute' : 'relative')};
|
|
13
|
+
z-index: 1;
|
|
14
|
+
left: ${({ left }) => left && `${left}px`};
|
|
15
|
+
top: ${({ top }) => top && `${top}px`};
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
const RibbonContainer = styled.div`
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
background: ${({ backgroundColor }) => backgroundColor};
|
|
22
|
+
padding: ${({ padding }) => `${padding}`};
|
|
23
|
+
border-radius: ${({ borderRadius }) => borderRadius};
|
|
24
|
+
width: fit-content;
|
|
25
|
+
box-shadow: ${({ boxShadow, shouldWrap }) => shouldWrap && boxShadow};
|
|
26
|
+
`
|
|
27
|
+
|
|
28
|
+
const RibbonCurve = styled.div`
|
|
29
|
+
background: ${({ curveBackgroundColor }) => curveBackgroundColor};
|
|
30
|
+
width: ${({ curveWidth }) => curveWidth};
|
|
31
|
+
height: ${({ curveHeight }) => curveHeight};
|
|
32
|
+
margin-top: -${({ curveMarginTop }) => curveMarginTop};
|
|
33
|
+
border-radius: 0 0 0 100%;
|
|
34
|
+
position: relative;
|
|
35
|
+
z-index: -1;
|
|
36
|
+
&::after {
|
|
37
|
+
content: '';
|
|
38
|
+
border-bottom-left-radius: ${({ curveAfterRadius }) => curveAfterRadius};
|
|
39
|
+
position: absolute;
|
|
40
|
+
height: ${({ curveAfterHeight }) => curveAfterHeight};
|
|
41
|
+
background: ${({ curveAfterBackgroundColor }) => curveAfterBackgroundColor};
|
|
42
|
+
width: ${({ curveAfterWidth }) => curveAfterWidth};
|
|
43
|
+
}
|
|
44
|
+
`
|
|
45
|
+
|
|
46
|
+
const Ribbon = ({
|
|
47
|
+
children,
|
|
48
|
+
tokens,
|
|
49
|
+
wrap: shouldWrap = false,
|
|
50
|
+
left,
|
|
51
|
+
top,
|
|
52
|
+
variant = {},
|
|
53
|
+
...rest
|
|
54
|
+
}) => {
|
|
55
|
+
const {
|
|
56
|
+
backgroundColor,
|
|
57
|
+
borderRadius,
|
|
58
|
+
boxShadowPaddingBottom,
|
|
59
|
+
boxShadowPaddingLeft,
|
|
60
|
+
boxShadowPaddingRight,
|
|
61
|
+
boxShadowPaddingTop,
|
|
62
|
+
boxShadowColor,
|
|
63
|
+
curveAfterBackgroundColor,
|
|
64
|
+
curveAfterHeight,
|
|
65
|
+
curveAfterWidth,
|
|
66
|
+
curveBackgroundColor,
|
|
67
|
+
curveHeight,
|
|
68
|
+
curveAfterRadius,
|
|
69
|
+
curveWidth,
|
|
70
|
+
curveMarginTop,
|
|
71
|
+
paddingBottom,
|
|
72
|
+
paddingLeft,
|
|
73
|
+
paddingRight,
|
|
74
|
+
paddingTop,
|
|
75
|
+
gradient
|
|
76
|
+
} = useThemeTokens('Ribbon', tokens, variant)
|
|
77
|
+
|
|
78
|
+
const { purpose } = variant
|
|
79
|
+
const { type: gradientType, angle: gradientAngle, stops: gradientColors } = gradient
|
|
80
|
+
const isOfferPurpose = purpose === 'offer'
|
|
81
|
+
const gradientBackground = `${gradientType}-gradient(${gradientAngle}deg, ${gradientColors[0].color}, ${gradientColors[1].color})`
|
|
82
|
+
const background = isOfferPurpose ? gradientBackground : backgroundColor
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<RibbonWrapper left={left} top={top} data-testid="ribbon-wrapper" {...selectProps(rest)}>
|
|
86
|
+
<RibbonContainer
|
|
87
|
+
shouldWrap={shouldWrap}
|
|
88
|
+
backgroundColor={background}
|
|
89
|
+
padding={`${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`}
|
|
90
|
+
borderRadius={`${borderRadius}px`}
|
|
91
|
+
boxShadow={`${boxShadowPaddingTop}px ${boxShadowPaddingRight}px ${boxShadowPaddingBottom}px ${boxShadowPaddingLeft}px ${boxShadowColor}`}
|
|
92
|
+
>
|
|
93
|
+
<Typography variant={{ size: 'micro', bold: true, inverse: true }}>{children}</Typography>
|
|
94
|
+
</RibbonContainer>
|
|
95
|
+
{shouldWrap && (
|
|
96
|
+
<RibbonCurve
|
|
97
|
+
data-testid="ribbon-curve"
|
|
98
|
+
backgroundColor={backgroundColor}
|
|
99
|
+
curveMarginTop={`${curveMarginTop}px`}
|
|
100
|
+
curveWidth={`${curveWidth}px`}
|
|
101
|
+
curveHeight={`${curveHeight}px`}
|
|
102
|
+
curveBackgroundColor={curveBackgroundColor}
|
|
103
|
+
curveAfterRadius={`${curveAfterRadius}px`}
|
|
104
|
+
curveAfterWidth={`${curveAfterWidth}px`}
|
|
105
|
+
curveAfterHeight={`${curveAfterHeight}px`}
|
|
106
|
+
curveAfterBackgroundColor={curveAfterBackgroundColor}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
</RibbonWrapper>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Ribbon.propTypes = {
|
|
114
|
+
...selectedSystemPropTypes,
|
|
115
|
+
children: PropTypes.node,
|
|
116
|
+
/** show/hide the ribbon fold
|
|
117
|
+
* @deprecated please don't rely on `wrap` to turn off the wrapping (use `Badge` instead) as it will be removed in the future
|
|
118
|
+
*/
|
|
119
|
+
wrap: PropTypes.bool,
|
|
120
|
+
/** sets the left offset (triggers absolute positioning) */
|
|
121
|
+
left: PropTypes.number,
|
|
122
|
+
/** sets the top offset (triggers absolute positioning) */
|
|
123
|
+
top: PropTypes.number
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export default Ribbon
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
export interface RibbonProps extends HTMLAttrs {
|
|
5
|
+
children?: ReactNode
|
|
6
|
+
variant?: Variant
|
|
7
|
+
left: Boolean
|
|
8
|
+
top: Boolean
|
|
9
|
+
wrap: Boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const Ribbon: ComponentType<RibbonProps>
|
|
13
|
+
|
|
14
|
+
export default Ribbon
|