@telus-uds/components-web 1.1.0 → 1.3.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 +23 -2
- package/lib/OrderedList/Item.js +162 -0
- package/lib/OrderedList/ItemBase.js +42 -0
- package/lib/OrderedList/OrderedList.js +94 -0
- package/lib/OrderedList/OrderedListBase.js +68 -0
- package/lib/OrderedList/constants.js +9 -0
- package/lib/OrderedList/index.js +16 -0
- package/lib/Ribbon/Ribbon.js +209 -0
- package/lib/Ribbon/index.js +13 -0
- package/lib/index.js +18 -0
- package/lib-module/OrderedList/Item.js +139 -0
- package/lib-module/OrderedList/ItemBase.js +28 -0
- package/lib-module/OrderedList/OrderedList.js +71 -0
- package/lib-module/OrderedList/OrderedListBase.js +48 -0
- package/lib-module/OrderedList/constants.js +2 -0
- package/lib-module/OrderedList/index.js +4 -0
- package/lib-module/Ribbon/Ribbon.js +191 -0
- package/lib-module/Ribbon/index.js +2 -0
- package/lib-module/index.js +2 -0
- package/package.json +4 -3
- package/src/OrderedList/Item.jsx +121 -0
- package/src/OrderedList/ItemBase.jsx +18 -0
- package/src/OrderedList/OrderedList.jsx +61 -0
- package/src/OrderedList/OrderedListBase.jsx +38 -0
- package/src/OrderedList/constants.js +2 -0
- package/src/OrderedList/index.js +6 -0
- package/src/Ribbon/Ribbon.jsx +126 -0
- package/src/Ribbon/index.js +3 -0
- package/src/index.js +2 -0
- package/types/Ribbon.d.ts +14 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { applyTextStyles, getTokensPropType, selectSystemProps, StackView, Typography, useTheme, useThemeTokens, wrapStringsInText } from '@telus-uds/components-base';
|
|
5
|
+
import ItemBase from './ItemBase';
|
|
6
|
+
import { htmlAttrs } from '../utils';
|
|
7
|
+
import { OL_COUNTER_NAME } from './constants';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
11
|
+
|
|
12
|
+
const selectItemTextStyles = (_ref, themeOptions) => {
|
|
13
|
+
let {
|
|
14
|
+
itemFontWeight,
|
|
15
|
+
itemFontSize,
|
|
16
|
+
itemLineHeight,
|
|
17
|
+
itemFontName,
|
|
18
|
+
itemColor
|
|
19
|
+
} = _ref;
|
|
20
|
+
return applyTextStyles({
|
|
21
|
+
fontWeight: itemFontWeight,
|
|
22
|
+
fontSize: itemFontSize,
|
|
23
|
+
fontName: itemFontName,
|
|
24
|
+
color: itemColor,
|
|
25
|
+
themeOptions,
|
|
26
|
+
lineHeight: itemLineHeight
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const StyledItemBase = /*#__PURE__*/styled(ItemBase).withConfig({
|
|
31
|
+
displayName: "Item__StyledItemBase",
|
|
32
|
+
componentId: "components-web__sc-7jzwcq-0"
|
|
33
|
+
})(_ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
interItemMargin,
|
|
36
|
+
itemBulletContainerWidth,
|
|
37
|
+
itemBulletContainerAlign,
|
|
38
|
+
itemFontWeight,
|
|
39
|
+
itemFontSize,
|
|
40
|
+
itemFontName,
|
|
41
|
+
itemLineHeight,
|
|
42
|
+
themeOptions,
|
|
43
|
+
listGutter,
|
|
44
|
+
itemColor
|
|
45
|
+
} = _ref2;
|
|
46
|
+
return {
|
|
47
|
+
counterIncrement: OL_COUNTER_NAME,
|
|
48
|
+
'::before': {
|
|
49
|
+
content: `counter(${OL_COUNTER_NAME})'.'`,
|
|
50
|
+
display: 'inline-flex',
|
|
51
|
+
color: itemColor,
|
|
52
|
+
width: itemBulletContainerWidth,
|
|
53
|
+
paddingRight: listGutter,
|
|
54
|
+
textAlign: itemBulletContainerAlign,
|
|
55
|
+
...applyTextStyles({
|
|
56
|
+
fontWeight: itemFontWeight,
|
|
57
|
+
fontSize: itemFontSize,
|
|
58
|
+
fontName: itemFontName,
|
|
59
|
+
themeOptions
|
|
60
|
+
}),
|
|
61
|
+
lineHeight: `${itemLineHeight * itemFontSize}px`
|
|
62
|
+
},
|
|
63
|
+
':not(:last-child)': {
|
|
64
|
+
marginBottom: interItemMargin
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const ItemContent = /*#__PURE__*/styled.div.withConfig({
|
|
69
|
+
displayName: "Item__ItemContent",
|
|
70
|
+
componentId: "components-web__sc-7jzwcq-1"
|
|
71
|
+
})({
|
|
72
|
+
flex: 1
|
|
73
|
+
});
|
|
74
|
+
const Item = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
75
|
+
let {
|
|
76
|
+
children,
|
|
77
|
+
counterName,
|
|
78
|
+
title,
|
|
79
|
+
tokens,
|
|
80
|
+
variant,
|
|
81
|
+
...rest
|
|
82
|
+
} = _ref3;
|
|
83
|
+
// We are reusing some tokens from the list component here in order to provide a unified
|
|
84
|
+
// experience
|
|
85
|
+
const themeTokens = useThemeTokens('OrderedList', tokens, variant);
|
|
86
|
+
const headingTokens = title && {
|
|
87
|
+
lineHeight: themeTokens.itemLineHeight,
|
|
88
|
+
fontSize: themeTokens.itemFontSize,
|
|
89
|
+
color: themeTokens.itemColor,
|
|
90
|
+
fontName: themeTokens.headerFontName,
|
|
91
|
+
fontWeight: themeTokens.headerFontWeight
|
|
92
|
+
};
|
|
93
|
+
const {
|
|
94
|
+
themeOptions
|
|
95
|
+
} = useTheme();
|
|
96
|
+
const itemContent = wrapStringsInText(children, {
|
|
97
|
+
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
98
|
+
});
|
|
99
|
+
return /*#__PURE__*/_jsx(StyledItemBase, {
|
|
100
|
+
ref: ref,
|
|
101
|
+
themeOptions: themeOptions,
|
|
102
|
+
...themeTokens,
|
|
103
|
+
...selectProps(rest),
|
|
104
|
+
children: title ? /*#__PURE__*/_jsxs(StackView, {
|
|
105
|
+
tokens: {
|
|
106
|
+
flexShrink: 1
|
|
107
|
+
},
|
|
108
|
+
space: 0,
|
|
109
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
110
|
+
variant: {
|
|
111
|
+
size: 'h4'
|
|
112
|
+
},
|
|
113
|
+
tokens: headingTokens,
|
|
114
|
+
children: title
|
|
115
|
+
}), /*#__PURE__*/_jsx(ItemContent, { ...themeTokens,
|
|
116
|
+
children: itemContent
|
|
117
|
+
})]
|
|
118
|
+
}) : itemContent
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
Item.displayName = 'OrderedListItem';
|
|
122
|
+
Item.propTypes = { ...selectedSystemPropTypes,
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Item content
|
|
126
|
+
*/
|
|
127
|
+
children: PropTypes.node.isRequired,
|
|
128
|
+
title: PropTypes.string,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Item tokens
|
|
132
|
+
*/
|
|
133
|
+
tokens: getTokensPropType('List')
|
|
134
|
+
};
|
|
135
|
+
Item.defaultProps = {
|
|
136
|
+
title: undefined,
|
|
137
|
+
tokens: {}
|
|
138
|
+
};
|
|
139
|
+
export default Item;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const StyledItem = /*#__PURE__*/styled.li.withConfig({
|
|
6
|
+
displayName: "ItemBase__StyledItem",
|
|
7
|
+
componentId: "components-web__sc-o0oiv5-0"
|
|
8
|
+
})({
|
|
9
|
+
display: 'flex'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const Item = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
...rest
|
|
16
|
+
} = _ref;
|
|
17
|
+
return /*#__PURE__*/_jsx(StyledItem, { ...rest,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Item.propTypes = {
|
|
23
|
+
/**
|
|
24
|
+
* Item content
|
|
25
|
+
*/
|
|
26
|
+
children: PropTypes.node.isRequired
|
|
27
|
+
};
|
|
28
|
+
export default Item;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { selectSystemProps } from '@telus-uds/components-base';
|
|
5
|
+
import { htmlAttrs } from '../utils';
|
|
6
|
+
import OrderedListBase from './OrderedListBase';
|
|
7
|
+
import Item from './Item';
|
|
8
|
+
import { OL_COUNTER_NAME } from './constants';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
11
|
+
const StyledOrderedListBase = /*#__PURE__*/styled(OrderedListBase).withConfig({
|
|
12
|
+
displayName: "OrderedList__StyledOrderedListBase",
|
|
13
|
+
componentId: "components-web__sc-t5az8z-0"
|
|
14
|
+
})(_ref => {
|
|
15
|
+
let {
|
|
16
|
+
start
|
|
17
|
+
} = _ref;
|
|
18
|
+
return {
|
|
19
|
+
// Using CSS counters here to have better control over the number styling
|
|
20
|
+
listStyle: 'none',
|
|
21
|
+
counterReset: `${OL_COUNTER_NAME} ${start - 1}`
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Themed semantic ordered list.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const OrderedList = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
29
|
+
let {
|
|
30
|
+
children,
|
|
31
|
+
start,
|
|
32
|
+
variant,
|
|
33
|
+
...rest
|
|
34
|
+
} = _ref2;
|
|
35
|
+
// Pass any variants "OrderedList" receives down to the individual list items.
|
|
36
|
+
const childrenWithParentVariants = variant ? children.map(child => {
|
|
37
|
+
var _child$props;
|
|
38
|
+
|
|
39
|
+
const existingChildVariants = ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.variant) ?? {};
|
|
40
|
+
return { ...child,
|
|
41
|
+
props: { ...child.props,
|
|
42
|
+
variant: { ...existingChildVariants,
|
|
43
|
+
...variant
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}) : children;
|
|
48
|
+
return /*#__PURE__*/_jsx(StyledOrderedListBase, { ...selectProps(rest),
|
|
49
|
+
ref: ref,
|
|
50
|
+
start: start,
|
|
51
|
+
children: childrenWithParentVariants
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
OrderedList.displayName = 'OrderedList';
|
|
55
|
+
OrderedList.propTypes = { ...selectedSystemPropTypes,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A list of ordered items wrapped in `OrderedList.Item`.
|
|
59
|
+
*/
|
|
60
|
+
children: PropTypes.node.isRequired,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The position to start the list with.
|
|
64
|
+
*/
|
|
65
|
+
start: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
66
|
+
};
|
|
67
|
+
OrderedList.defaultProps = {
|
|
68
|
+
start: 1
|
|
69
|
+
};
|
|
70
|
+
OrderedList.Item = Item;
|
|
71
|
+
export default OrderedList;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import ItemBase from './ItemBase';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const StyledList = /*#__PURE__*/styled.ol.withConfig({
|
|
7
|
+
displayName: "OrderedListBase__StyledList",
|
|
8
|
+
componentId: "components-web__sc-4m9lgj-0"
|
|
9
|
+
})({
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
listStylePosition: 'inside',
|
|
13
|
+
margin: 0,
|
|
14
|
+
padding: 0
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Semantic ordered list.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const OrderedListBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
start,
|
|
24
|
+
...rest
|
|
25
|
+
} = _ref;
|
|
26
|
+
return /*#__PURE__*/_jsx(StyledList, { ...rest,
|
|
27
|
+
ref: ref,
|
|
28
|
+
start: start,
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
OrderedListBase.displayName = 'OrderedList';
|
|
33
|
+
OrderedListBase.propTypes = {
|
|
34
|
+
/**
|
|
35
|
+
* A list of ordered items wrapped in `OrderedListBase.Item`.
|
|
36
|
+
*/
|
|
37
|
+
children: PropTypes.node.isRequired,
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The position to start the list with.
|
|
41
|
+
*/
|
|
42
|
+
start: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
43
|
+
};
|
|
44
|
+
OrderedListBase.defaultProps = {
|
|
45
|
+
start: 1
|
|
46
|
+
};
|
|
47
|
+
OrderedListBase.Item = ItemBase;
|
|
48
|
+
export default OrderedListBase;
|
|
@@ -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,13 +4,14 @@
|
|
|
4
4
|
"extends @telus-uds/browserslist-config"
|
|
5
5
|
],
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@telus-uds/components-base": "1.
|
|
7
|
+
"@telus-uds/components-base": "1.33.0",
|
|
8
8
|
"@telus-uds/system-constants": "^1.2.0",
|
|
9
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
9
|
+
"@telus-uds/system-theme-tokens": "^2.17.0",
|
|
10
10
|
"prop-types": "^15.7.2"
|
|
11
11
|
},
|
|
12
12
|
"description": "UDS mult-brand web components",
|
|
13
13
|
"devDependencies": {
|
|
14
|
+
"@telus-uds/palette-allium": "^2.12.3",
|
|
14
15
|
"@telus-uds/browserslist-config": "^1.0.4",
|
|
15
16
|
"@testing-library/jest-dom": "^5.16.1",
|
|
16
17
|
"@testing-library/react": "^13.3.0",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"skip": true
|
|
54
55
|
},
|
|
55
56
|
"types": "types/index.d.ts",
|
|
56
|
-
"version": "1.
|
|
57
|
+
"version": "1.3.0"
|
|
57
58
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
import {
|
|
5
|
+
applyTextStyles,
|
|
6
|
+
getTokensPropType,
|
|
7
|
+
selectSystemProps,
|
|
8
|
+
StackView,
|
|
9
|
+
Typography,
|
|
10
|
+
useTheme,
|
|
11
|
+
useThemeTokens,
|
|
12
|
+
wrapStringsInText
|
|
13
|
+
} from '@telus-uds/components-base'
|
|
14
|
+
import ItemBase from './ItemBase'
|
|
15
|
+
import { htmlAttrs } from '../utils'
|
|
16
|
+
import { OL_COUNTER_NAME } from './constants'
|
|
17
|
+
|
|
18
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
19
|
+
|
|
20
|
+
const selectItemTextStyles = (
|
|
21
|
+
{ itemFontWeight, itemFontSize, itemLineHeight, itemFontName, itemColor },
|
|
22
|
+
themeOptions
|
|
23
|
+
) =>
|
|
24
|
+
applyTextStyles({
|
|
25
|
+
fontWeight: itemFontWeight,
|
|
26
|
+
fontSize: itemFontSize,
|
|
27
|
+
fontName: itemFontName,
|
|
28
|
+
color: itemColor,
|
|
29
|
+
themeOptions,
|
|
30
|
+
lineHeight: itemLineHeight
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const StyledItemBase = styled(ItemBase)(
|
|
34
|
+
({
|
|
35
|
+
interItemMargin,
|
|
36
|
+
itemBulletContainerWidth,
|
|
37
|
+
itemBulletContainerAlign,
|
|
38
|
+
itemFontWeight,
|
|
39
|
+
itemFontSize,
|
|
40
|
+
itemFontName,
|
|
41
|
+
itemLineHeight,
|
|
42
|
+
themeOptions,
|
|
43
|
+
listGutter,
|
|
44
|
+
itemColor
|
|
45
|
+
}) => ({
|
|
46
|
+
counterIncrement: OL_COUNTER_NAME,
|
|
47
|
+
'::before': {
|
|
48
|
+
content: `counter(${OL_COUNTER_NAME})'.'`,
|
|
49
|
+
display: 'inline-flex',
|
|
50
|
+
color: itemColor,
|
|
51
|
+
width: itemBulletContainerWidth,
|
|
52
|
+
paddingRight: listGutter,
|
|
53
|
+
textAlign: itemBulletContainerAlign,
|
|
54
|
+
...applyTextStyles({
|
|
55
|
+
fontWeight: itemFontWeight,
|
|
56
|
+
fontSize: itemFontSize,
|
|
57
|
+
fontName: itemFontName,
|
|
58
|
+
themeOptions
|
|
59
|
+
}),
|
|
60
|
+
lineHeight: `${itemLineHeight * itemFontSize}px`
|
|
61
|
+
},
|
|
62
|
+
':not(:last-child)': { marginBottom: interItemMargin }
|
|
63
|
+
})
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const ItemContent = styled.div({
|
|
67
|
+
flex: 1
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const Item = forwardRef(({ children, counterName, title, tokens, variant, ...rest }, ref) => {
|
|
71
|
+
// We are reusing some tokens from the list component here in order to provide a unified
|
|
72
|
+
// experience
|
|
73
|
+
const themeTokens = useThemeTokens('OrderedList', tokens, variant)
|
|
74
|
+
const headingTokens = title && {
|
|
75
|
+
lineHeight: themeTokens.itemLineHeight,
|
|
76
|
+
fontSize: themeTokens.itemFontSize,
|
|
77
|
+
color: themeTokens.itemColor,
|
|
78
|
+
fontName: themeTokens.headerFontName,
|
|
79
|
+
fontWeight: themeTokens.headerFontWeight
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const { themeOptions } = useTheme()
|
|
83
|
+
const itemContent = wrapStringsInText(children, {
|
|
84
|
+
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<StyledItemBase ref={ref} themeOptions={themeOptions} {...themeTokens} {...selectProps(rest)}>
|
|
89
|
+
{title ? (
|
|
90
|
+
<StackView tokens={{ flexShrink: 1 }} space={0}>
|
|
91
|
+
<Typography variant={{ size: 'h4' }} tokens={headingTokens}>
|
|
92
|
+
{title}
|
|
93
|
+
</Typography>
|
|
94
|
+
<ItemContent {...themeTokens}>{itemContent}</ItemContent>
|
|
95
|
+
</StackView>
|
|
96
|
+
) : (
|
|
97
|
+
itemContent
|
|
98
|
+
)}
|
|
99
|
+
</StyledItemBase>
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
Item.displayName = 'OrderedListItem'
|
|
103
|
+
|
|
104
|
+
Item.propTypes = {
|
|
105
|
+
...selectedSystemPropTypes,
|
|
106
|
+
/**
|
|
107
|
+
* Item content
|
|
108
|
+
*/
|
|
109
|
+
children: PropTypes.node.isRequired,
|
|
110
|
+
title: PropTypes.string,
|
|
111
|
+
/**
|
|
112
|
+
* Item tokens
|
|
113
|
+
*/
|
|
114
|
+
tokens: getTokensPropType('List')
|
|
115
|
+
}
|
|
116
|
+
Item.defaultProps = {
|
|
117
|
+
title: undefined,
|
|
118
|
+
tokens: {}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default Item
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
const StyledItem = styled.li({
|
|
6
|
+
display: 'flex'
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const Item = ({ children, ...rest }) => <StyledItem {...rest}>{children}</StyledItem>
|
|
10
|
+
|
|
11
|
+
Item.propTypes = {
|
|
12
|
+
/**
|
|
13
|
+
* Item content
|
|
14
|
+
*/
|
|
15
|
+
children: PropTypes.node.isRequired
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default Item
|