@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-price__column-container'),
101
+ className: getClassName(isAlignRight && 'bpk-price__main--right'),
82
102
  children: [/*#__PURE__*/_jsx("span", {
83
- className: getClassName('bpk-price__price', !isAlignRight && 'bpk-price__spacing'),
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
- }), trailingText && /*#__PURE__*/_jsx("span", {
90
- className: getClassName('bpk-price__trailing'),
91
- children: /*#__PURE__*/_jsx(BpkText, {
92
- textStyle: defaultTextStyle,
93
- tagName: "span",
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{text-align:right}html[dir=rtl] .bpk-price--right{text-align:left}.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__column-container{display:flex;flex-direction:column}.bpk-price__price{display:contents;color:#161616;word-break:break-all}.bpk-price__spacing::after{content:"";margin-right:.25rem}html[dir=rtl] .bpk-price__spacing::after{margin-right:unset;margin-left:.25rem}.bpk-price__trailing{display:contents;white-space:nowrap}
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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "36.12.0",
3
+ "version": "36.13.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",