@skyscanner/backpack-web 36.12.0 → 36.13.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.
|
@@ -40,6 +40,7 @@ const BpkPrice = props => {
|
|
|
40
40
|
const {
|
|
41
41
|
align,
|
|
42
42
|
className,
|
|
43
|
+
icon,
|
|
43
44
|
leadingClassName,
|
|
44
45
|
leadingText,
|
|
45
46
|
previousPrice,
|
|
@@ -51,6 +52,25 @@ const BpkPrice = props => {
|
|
|
51
52
|
const defaultTextStyle = getDefaultTextStyle(size);
|
|
52
53
|
const priceTextStyle = getPriceTextStyle(size);
|
|
53
54
|
const isAlignRight = align === ALIGNS.right;
|
|
55
|
+
const getTrailingTextNode = () => {
|
|
56
|
+
if (!trailingText) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const textNode = /*#__PURE__*/_jsx(BpkText, {
|
|
60
|
+
textStyle: defaultTextStyle,
|
|
61
|
+
tagName: "span",
|
|
62
|
+
children: trailingText
|
|
63
|
+
});
|
|
64
|
+
// When aligned right, use a <div> as the text appears on a separate line.
|
|
65
|
+
// When aligned left, use a <span> as the test is inline.
|
|
66
|
+
return isAlignRight ? /*#__PURE__*/_jsx("div", {
|
|
67
|
+
className: getClassName('bpk-price__trailing'),
|
|
68
|
+
children: textNode
|
|
69
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
70
|
+
className: getClassName('bpk-price__trailing'),
|
|
71
|
+
children: textNode
|
|
72
|
+
});
|
|
73
|
+
};
|
|
54
74
|
return /*#__PURE__*/_jsxs("div", {
|
|
55
75
|
className: getClassName('bpk-price', isAlignRight && 'bpk-price--right', className)
|
|
56
76
|
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
|
|
@@ -78,23 +98,22 @@ const BpkPrice = props => {
|
|
|
78
98
|
children: leadingText
|
|
79
99
|
})]
|
|
80
100
|
}), /*#__PURE__*/_jsxs("div", {
|
|
81
|
-
className: getClassName(isAlignRight && 'bpk-
|
|
101
|
+
className: getClassName(isAlignRight && 'bpk-price__main--right'),
|
|
82
102
|
children: [/*#__PURE__*/_jsx("span", {
|
|
83
|
-
className: getClassName('bpk-price__price',
|
|
103
|
+
className: getClassName('bpk-price__price',
|
|
104
|
+
// When aligning right, we use the gap property to add space between the price and the icon.
|
|
105
|
+
// When aligning left, we use the ::after pseudo-element instead to achieve the desired wrapping behaviour.
|
|
106
|
+
!isAlignRight && 'bpk-price__spacing'),
|
|
84
107
|
children: /*#__PURE__*/_jsx(BpkText, {
|
|
85
108
|
textStyle: priceTextStyle,
|
|
86
109
|
tagName: "span",
|
|
87
110
|
children: price
|
|
88
111
|
})
|
|
89
|
-
}),
|
|
90
|
-
className: getClassName('bpk-
|
|
91
|
-
children:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
children: trailingText
|
|
95
|
-
})
|
|
96
|
-
})]
|
|
97
|
-
})]
|
|
112
|
+
}), icon && /*#__PURE__*/_jsx("span", {
|
|
113
|
+
className: getClassName('bpk-price__icon', !isAlignRight && 'bpk-price__spacing'),
|
|
114
|
+
children: icon
|
|
115
|
+
}), !isAlignRight && getTrailingTextNode()]
|
|
116
|
+
}), isAlignRight && getTrailingTextNode()]
|
|
98
117
|
});
|
|
99
118
|
};
|
|
100
119
|
BpkPrice.propTypes = {
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-price{display:flex;flex-direction:column;color:#626971}.bpk-price--right{
|
|
18
|
+
.bpk-price{display:flex;flex-direction:column;color:#626971}.bpk-price--right{align-items:flex-end}.bpk-price__leading{display:flex;flex-direction:row}.bpk-price__leading--right{display:flex;justify-content:flex-end}.bpk-price__previous-price{display:flex;color:#e70866;text-decoration-line:line-through}.bpk-price__separator{display:flex;margin:0 .25rem}.bpk-price__main--right{display:flex;align-items:center;gap:.25rem}.bpk-price__price{display:contents;color:#161616;word-break:break-all}.bpk-price__spacing::after{content:"";margin-inline-end:.25rem}.bpk-price__icon{display:contents}.bpk-price__trailing{display:contents;white-space:nowrap}
|