@skyscanner/backpack-web 2.0.1 → 3.1.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.
Files changed (90) hide show
  1. package/bpk-animate-height/package.json +26 -0
  2. package/bpk-component-accordion/package.json +31 -0
  3. package/bpk-component-aria-live/package.json +31 -0
  4. package/bpk-component-autosuggest/package.json +29 -0
  5. package/bpk-component-badge/package.json +29 -0
  6. package/bpk-component-banner-alert/package.json +34 -0
  7. package/bpk-component-barchart/package.json +35 -0
  8. package/bpk-component-barchart/src/BpkBarchartBar.js +3 -2
  9. package/bpk-component-blockquote/package.json +24 -0
  10. package/bpk-component-breadcrumb/package.json +27 -0
  11. package/bpk-component-breakpoint/package.json +28 -0
  12. package/bpk-component-button/package.json +26 -0
  13. package/bpk-component-calendar/package.json +34 -0
  14. package/bpk-component-calendar/src/BpkCalendarGridTransition.js +4 -2
  15. package/bpk-component-calendar/src/Week.js +3 -1
  16. package/bpk-component-card/package.json +28 -0
  17. package/bpk-component-checkbox/package.json +29 -0
  18. package/bpk-component-chip/package.json +29 -0
  19. package/bpk-component-close-button/package.json +28 -0
  20. package/bpk-component-code/package.json +24 -0
  21. package/bpk-component-content-container/package.json +24 -0
  22. package/bpk-component-datatable/package.json +30 -0
  23. package/bpk-component-datepicker/package.json +33 -0
  24. package/bpk-component-description-list/package.json +24 -0
  25. package/bpk-component-dialog/package.json +32 -0
  26. package/bpk-component-drawer/package.json +34 -0
  27. package/bpk-component-fieldset/package.json +36 -0
  28. package/bpk-component-flare/package.json +29 -0
  29. package/bpk-component-form-validation/package.json +34 -0
  30. package/bpk-component-graphic-promotion/package.json +26 -0
  31. package/bpk-component-grid/package.json +24 -0
  32. package/bpk-component-grid-toggle/package.json +25 -0
  33. package/bpk-component-horizontal-nav/package.json +30 -0
  34. package/bpk-component-icon/package.json +34 -0
  35. package/bpk-component-image/package.json +31 -0
  36. package/bpk-component-infinite-scroll/package.json +31 -0
  37. package/bpk-component-input/package.json +30 -0
  38. package/bpk-component-label/package.json +24 -0
  39. package/bpk-component-link/package.json +28 -0
  40. package/bpk-component-list/package.json +24 -0
  41. package/bpk-component-loading-button/package.json +30 -0
  42. package/bpk-component-map/package.json +32 -0
  43. package/bpk-component-mobile-scroll-container/package.json +28 -0
  44. package/bpk-component-modal/package.json +33 -0
  45. package/bpk-component-navigation-bar/package.json +32 -0
  46. package/bpk-component-navigation-stack/package.json +32 -0
  47. package/bpk-component-nudger/package.json +32 -0
  48. package/bpk-component-overlay/package.json +28 -0
  49. package/bpk-component-pagination/package.json +28 -0
  50. package/bpk-component-panel/package.json +24 -0
  51. package/bpk-component-phone-input/package.json +33 -0
  52. package/bpk-component-popover/README.md +2 -2
  53. package/bpk-component-popover/package.json +35 -0
  54. package/bpk-component-popover/src/BpkPopover.js +1 -0
  55. package/bpk-component-popover/src/BpkPopover.module.scss +28 -26
  56. package/bpk-component-popover/src/BpkPopoverPortal.js +43 -17
  57. package/bpk-component-price/README.md +35 -0
  58. package/bpk-component-price/index.js +23 -0
  59. package/bpk-component-price/package.json +24 -0
  60. package/bpk-component-price/src/BpkPrice.js +106 -0
  61. package/bpk-component-price/src/BpkPrice.module.scss +55 -0
  62. package/bpk-component-progress/package.json +30 -0
  63. package/bpk-component-radio/package.json +28 -0
  64. package/bpk-component-rating/package.json +29 -0
  65. package/bpk-component-rating/src/BpkRating.js +6 -1
  66. package/bpk-component-rtl-toggle/package.json +24 -0
  67. package/bpk-component-scrollable-calendar/package.json +32 -0
  68. package/bpk-component-section-list/package.json +30 -0
  69. package/bpk-component-select/package.json +27 -0
  70. package/bpk-component-skip-link/package.json +24 -0
  71. package/bpk-component-slider/package.json +29 -0
  72. package/bpk-component-spinner/package.json +25 -0
  73. package/bpk-component-star-rating/package.json +29 -0
  74. package/bpk-component-star-rating/src/BpkStarRating.js +6 -1
  75. package/bpk-component-switch/package.json +24 -0
  76. package/bpk-component-table/package.json +24 -0
  77. package/bpk-component-text/package.json +24 -0
  78. package/bpk-component-textarea/package.json +28 -0
  79. package/bpk-component-theme-toggle/package.json +27 -0
  80. package/bpk-component-theme-toggle/src/BpkThemeToggle.js +0 -8
  81. package/bpk-component-ticket/package.json +28 -0
  82. package/bpk-component-tooltip/README.md +2 -2
  83. package/bpk-component-tooltip/package.json +29 -0
  84. package/bpk-component-tooltip/src/BpkTooltip.js +6 -1
  85. package/bpk-component-tooltip/src/BpkTooltip.module.scss +46 -55
  86. package/bpk-component-tooltip/src/BpkTooltipPortal.js +21 -12
  87. package/bpk-react-utils/package.json +25 -0
  88. package/bpk-scrim-utils/package.json +25 -0
  89. package/bpk-theming/package.json +23 -0
  90. package/package.json +5 -3
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "bpk-component-navigation-bar",
3
+ "version": "3.1.12",
4
+ "description": "Backpack nativation bar component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
+ "dependencies": {
17
+ "bpk-component-close-button": "^3.1.11",
18
+ "bpk-component-link": "^3.1.10",
19
+ "bpk-component-text": "^7.0.4",
20
+ "bpk-mixins": "^31.1.1",
21
+ "bpk-react-utils": "^4.1.2",
22
+ "prop-types": "^15.7.2"
23
+ },
24
+ "peerDependencies": {
25
+ "react": "^16.3.0 || ^17.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "@skyscanner/bpk-foundations-web": "^8.0.0",
29
+ "bpk-component-icon": "^9.2.11",
30
+ "bpk-storybook-utils": "^1.1.9"
31
+ }
32
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "bpk-component-navigation-stack",
3
+ "version": "3.1.12",
4
+ "description": "Backpack navigation stack component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
+ "dependencies": {
17
+ "@skyscanner/bpk-foundations-web": "^8.0.0",
18
+ "bpk-mixins": "^31.1.1",
19
+ "bpk-react-utils": "^4.1.2",
20
+ "prop-types": "^15.7.2",
21
+ "react-transition-group": "^2.5.3"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^16.3.0 || ^17.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "bpk-component-button": "^6.2.5",
28
+ "bpk-component-icon": "^9.2.11",
29
+ "bpk-component-navigation-bar": "^3.1.12",
30
+ "bpk-component-rtl-toggle": "^3.1.10"
31
+ }
32
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "bpk-component-nudger",
3
+ "version": "7.0.4",
4
+ "description": "Backpack nudger component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
+ "dependencies": {
17
+ "@skyscanner/bpk-foundations-web": "^8.0.0",
18
+ "bpk-component-button": "^6.2.5",
19
+ "bpk-component-icon": "^9.2.11",
20
+ "bpk-mixins": "^31.1.1",
21
+ "bpk-react-utils": "^4.1.2",
22
+ "lodash.clamp": "^4.0.3",
23
+ "prop-types": "^15.7.2"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "^16.3.0 || ^17.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "bpk-component-label": "^5.1.10",
30
+ "bpk-storybook-utils": "^1.1.9"
31
+ }
32
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "bpk-component-overlay",
3
+ "version": "2.1.11",
4
+ "description": "Backpack overlay component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "dependencies": {
16
+ "bpk-mixins": "^31.1.1",
17
+ "bpk-react-utils": "^4.1.2",
18
+ "prop-types": "^15.5.8"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^16.3.0 || ^17.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "bpk-component-image": "^5.1.11",
25
+ "bpk-component-text": "^7.0.4"
26
+ },
27
+ "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8"
28
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "bpk-component-pagination",
3
+ "version": "4.0.9",
4
+ "description": "Backpack pagination component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
+ "dependencies": {
17
+ "bpk-component-button": "^6.2.5",
18
+ "bpk-mixins": "^31.1.1",
19
+ "bpk-react-utils": "^4.1.2",
20
+ "prop-types": "^15.7.2"
21
+ },
22
+ "peerDependencies": {
23
+ "react": "^16.3.0 || ^17.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "bpk-component-icon": "^9.2.11"
27
+ }
28
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "bpk-component-panel",
3
+ "version": "3.1.10",
4
+ "description": "Backpack panel component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
16
+ "dependencies": {
17
+ "bpk-mixins": "^31.1.1",
18
+ "bpk-react-utils": "^4.1.2",
19
+ "prop-types": "^15.7.2"
20
+ },
21
+ "peerDependencies": {
22
+ "react": "^16.3.0 || ^17.0.0"
23
+ }
24
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "bpk-component-phone-input",
3
+ "version": "7.1.15",
4
+ "description": "Backpack phone input component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
+ "dependencies": {
17
+ "@skyscanner/bpk-foundations-web": "^8.0.0",
18
+ "bpk-component-input": "^6.1.13",
19
+ "bpk-component-label": "^5.1.10",
20
+ "bpk-component-select": "^5.1.10",
21
+ "bpk-component-text": "^7.0.4",
22
+ "bpk-mixins": "^31.1.1",
23
+ "bpk-react-utils": "^4.1.2",
24
+ "prop-types": "^15.7.2"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "^16.3.0 || ^17.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "bpk-component-fieldset": "^4.1.15",
31
+ "bpk-component-image": "^5.1.11"
32
+ }
33
+ }
@@ -84,7 +84,7 @@ class App extends Component {
84
84
  | labelAsTitle | bool | false | false |
85
85
  | padded | bool | false | true |
86
86
  | placement | oneOf(['top', 'right', 'bottom', 'left']) | false | 'bottom' |
87
- | popperModifiers | object | false | null |
87
+ | popperModifiers | arrayOf(object) | false | null |
88
88
  | portalClassName | string | false | null |
89
89
  | portalStyle | object | false | null |
90
90
  | renderTarget | func | false | null |
@@ -118,7 +118,7 @@ const onClose = (event, {
118
118
 
119
119
  #### popperModifiers
120
120
 
121
- Please refer to the [documentation](https://github.com/FezVrasta/popper.js/blob/v1.12.9/docs/_includes/popper-documentation.md#modifiers) for the underlying positioning library "Popper.js". You can achieve various behaviours such as allowing the popover to overflow the viewport etc.
121
+ Please refer to the [documentation](https://popper.js.org/docs/v2/modifiers/) for the underlying positioning library "Popper.js". You can achieve various behaviours such as allowing the popover to overflow the viewport etc.
122
122
 
123
123
  ## Theme Props
124
124
 
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "bpk-component-popover",
3
+ "version": "5.0.0",
4
+ "description": "Backpack popover component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
+ "dependencies": {
17
+ "@popperjs/core": "^2.11.5",
18
+ "a11y-focus-scope": "^1.1.3",
19
+ "a11y-focus-store": "^1.0.0",
20
+ "bpk-component-close-button": "^3.1.11",
21
+ "bpk-component-link": "^3.1.10",
22
+ "bpk-component-text": "^7.0.4",
23
+ "bpk-mixins": "^31.1.1",
24
+ "bpk-react-utils": "^4.1.2",
25
+ "prop-types": "^15.7.2"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^16.3.0 || ^17.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "bpk-component-button": "^6.2.5",
32
+ "bpk-component-content-container": "^5.0.4",
33
+ "bpk-component-input": "^6.1.13"
34
+ }
35
+ }
@@ -109,6 +109,7 @@ const BpkPopover = (props: Props) => {
109
109
  id={ARROW_ID}
110
110
  className={getClassName('bpk-popover__arrow')}
111
111
  role="presentation"
112
+ data-popper-arrow
112
113
  />
113
114
  {labelAsTitle ? (
114
115
  <header className={getClassName('bpk-popover__header')}>
@@ -20,7 +20,8 @@
20
20
 
21
21
  $bpk-spacing-v2: true;
22
22
 
23
- $arrow-size: bpk-spacing-sm() * 3;
23
+ $arrow-size: bpk-spacing-lg();
24
+ $arrow-inset-margin: -($bpk-one-pixel-rem * 11);
24
25
 
25
26
  .bpk-popover-portal {
26
27
  z-index: $bpk-zindex-popover;
@@ -29,22 +30,6 @@ $arrow-size: bpk-spacing-sm() * 3;
29
30
  margin-right: bpk-spacing-base();
30
31
  margin-left: bpk-spacing-base();
31
32
  }
32
-
33
- &[x-placement='top'] {
34
- margin-bottom: $arrow-size;
35
- }
36
-
37
- &[x-placement='right'] {
38
- margin-left: $arrow-size;
39
- }
40
-
41
- &[x-placement='bottom'] {
42
- margin-top: $arrow-size;
43
- }
44
-
45
- &[x-placement='left'] {
46
- margin-right: $arrow-size;
47
- }
48
33
  }
49
34
 
50
35
  .bpk-popover {
@@ -68,22 +53,39 @@ $arrow-size: bpk-spacing-sm() * 3;
68
53
  }
69
54
 
70
55
  &__arrow {
71
- @include bpk-layer-arrow($arrow-size);
56
+ position: aboslute;
57
+ width: $arrow-size;
58
+ height: $arrow-size;
59
+ transform: rotate(45deg);
60
+ border: $bpk-one-pixel-rem solid transparent;
61
+ background: inherit;
62
+
63
+ .bpk-popover-portal[data-popper-placement='top'] & {
64
+ bottom: $arrow-inset-margin;
65
+ border-right-color: $bpk-color-sky-gray-tint-06;
66
+ border-bottom-color: $bpk-color-sky-gray-tint-06;
67
+ }
72
68
 
73
- .bpk-popover-portal[x-placement='top'] & {
74
- @include bpk-layer-arrow-bottom($arrow-size);
69
+ .bpk-popover-portal[data-popper-placement='right'] & {
70
+ left: $arrow-inset-margin;
71
+ border-bottom-color: $bpk-color-sky-gray-tint-06;
72
+ border-left-color: $bpk-color-sky-gray-tint-06;
75
73
  }
76
74
 
77
- .bpk-popover-portal[x-placement='right'] & {
78
- @include bpk-layer-arrow-left($arrow-size);
75
+ .bpk-popover-portal[data-popper-placement='bottom'] & {
76
+ top: $arrow-inset-margin;
77
+ border-top-color: $bpk-color-sky-gray-tint-06;
78
+ border-left-color: $bpk-color-sky-gray-tint-06;
79
79
  }
80
80
 
81
- .bpk-popover-portal[x-placement='bottom'] & {
82
- @include bpk-layer-arrow-top($arrow-size);
81
+ .bpk-popover-portal[data-popper-placement='left'] & {
82
+ right: $arrow-inset-margin;
83
+ border-top-color: $bpk-color-sky-gray-tint-06;
84
+ border-right-color: $bpk-color-sky-gray-tint-06;
83
85
  }
84
86
 
85
- .bpk-popover-portal[x-placement='left'] & {
86
- @include bpk-layer-arrow-right($arrow-size);
87
+ &[data-hide] {
88
+ visibility: hidden;
87
89
  }
88
90
  }
89
91
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  /* @flow strict */
20
20
 
21
- import Popper from '@skyscanner/popper.js';
21
+ import { createPopper, basePlacements } from '@popperjs/core';
22
22
  import PropTypes from 'prop-types';
23
23
  import React, { Component, type Node } from 'react';
24
24
  import focusStore from 'a11y-focus-store';
@@ -32,7 +32,6 @@ import BpkPopover, {
32
32
  defaultProps as popoverDefaultProps,
33
33
  type Props as PopoverProps,
34
34
  } from './BpkPopover';
35
- import { ARROW_ID } from './constants';
36
35
 
37
36
  const getClassName = cssModules(STYLES);
38
37
 
@@ -52,7 +51,7 @@ export const propTypes = {
52
51
  target: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
53
52
  isOpen: PropTypes.bool.isRequired,
54
53
  onClose: PropTypes.func.isRequired,
55
- placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
54
+ placement: PropTypes.oneOf(basePlacements),
56
55
  portalStyle: PropTypes.object, // eslint-disable-line react/forbid-prop-types
57
56
  portalClassName: PropTypes.string,
58
57
  renderTarget: PropTypes.func,
@@ -69,7 +68,7 @@ export const defaultProps = {
69
68
  };
70
69
 
71
70
  class BpkPopoverPortal extends Component<Props> {
72
- popper: ?typeof Popper;
71
+ popper: ?typeof createPopper;
73
72
 
74
73
  suppressRestoreFocus: boolean;
75
74
 
@@ -140,34 +139,61 @@ class BpkPopoverPortal extends Component<Props> {
140
139
  this.popper = null;
141
140
  }
142
141
 
142
+ // Custom modifier that makes the arrow display at the edge of the target.
143
+ const applyArrowHide = {
144
+ name: 'applyArrowHide',
145
+ enabled: true,
146
+ phase: 'write',
147
+ fn({ state }) {
148
+ const { arrow } = state.elements;
149
+ if (arrow) {
150
+ if (state.modifiersData.arrow.centerOffset !== 0) {
151
+ arrow.setAttribute('data-hide', '');
152
+ } else {
153
+ arrow.removeAttribute('data-hide');
154
+ }
155
+ }
156
+ },
157
+ };
158
+
159
+ // The default modifiers for the popper
143
160
  // Note that GPU acceleration should be disabled otherwise Popper will use `translate3d`
144
161
  // which can cause blurriness in Safari and Chrome.
162
+ const stdModifiers = [
163
+ {
164
+ name: 'computeStyles',
165
+ options: {
166
+ gpuAcceleration: false,
167
+ },
168
+ },
169
+ {
170
+ name: 'offset',
171
+ options: {
172
+ offset: [0, 17],
173
+ },
174
+ },
175
+ applyArrowHide,
176
+ ];
177
+
145
178
  if (!this.popper) {
146
- this.popper = new Popper(targetElement, popoverElement, {
179
+ this.popper = createPopper(targetElement, popoverElement, {
147
180
  placement: this.props.placement,
148
- onCreate: () => {
181
+ onFirstUpdate: () => {
149
182
  if (targetElement) {
150
183
  targetElement.focus();
151
184
  }
152
185
  focusStore.storeFocus();
153
186
  keyboardFocusScope.scopeFocus(popoverElement);
154
187
  },
155
- modifiers: {
156
- ...this.props.popperModifiers,
157
- computeStyle: {
158
- gpuAcceleration: false,
159
- },
160
- arrow: {
161
- element: `#${ARROW_ID}`,
162
- },
163
- },
188
+ modifiers: this.props.popperModifiers
189
+ ? [...this.props.popperModifiers, ...stdModifiers]
190
+ : stdModifiers,
164
191
  });
165
192
  }
166
193
 
167
194
  this.previousTargetElement = targetElement;
168
-
169
195
  if (this.popper) {
170
- this.popper.scheduleUpdate();
196
+ this.popper.update();
171
197
  }
172
198
  }
173
199
 
@@ -0,0 +1,35 @@
1
+ # bpk-component-price
2
+
3
+ > Backpack example component.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install bpk-component-price --save-dev
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import React from 'react';
15
+ import BpkPrice, { SIZES } from 'bpk-component-price';
16
+
17
+ export default () => (
18
+ <BpkPrice
19
+ size={SIZES.large}
20
+ subtitle="£209"
21
+ title="£1,830"
22
+ description="/ night"
23
+ />
24
+ );
25
+ ```
26
+
27
+ ## Props
28
+
29
+ | Property | PropType | Required | Default Value |
30
+ | --------- | -------- | -------- | ------------- |
31
+ | title | string | true | - |
32
+ | size | oneOf(SIZES) | false | SIZES.small |
33
+ | subtitle | string | false | null |
34
+ | description | string | false | null |
35
+ | className | string | false | null |
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /* @flow strict */
19
+
20
+ import BpkPrice, { SIZES } from './src/BpkPrice';
21
+
22
+ export default BpkPrice;
23
+ export { SIZES };
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "bpk-component-price",
3
+ "version": "1.0.0",
4
+ "description": "Backpack price component.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@github.com:Skyscanner/backpack.git"
9
+ },
10
+ "author": "Backpack Design System <backpack@skyscanner.net>",
11
+ "main": "index.js",
12
+ "publishConfig": {
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "dependencies": {
16
+ "bpk-component-text": "^7.0.4",
17
+ "bpk-mixins": "^31.1.1",
18
+ "bpk-react-utils": "^4.1.2",
19
+ "prop-types": "^15.5.8"
20
+ },
21
+ "peerDependencies": {
22
+ "react": "^16.3.0 || ^17.0.0"
23
+ }
24
+ }
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /* @flow strict */
19
+
20
+ import PropTypes from 'prop-types';
21
+ import React from 'react';
22
+
23
+ import { cssModules } from '../../bpk-react-utils';
24
+ import BpkText, { TEXT_STYLES } from '../../bpk-component-text';
25
+
26
+ import STYLES from './BpkPrice.module.scss';
27
+
28
+ export const SIZES = {
29
+ small: 'small',
30
+ large: 'large',
31
+ };
32
+
33
+ type Props = {
34
+ title: string,
35
+ size: $Values<typeof SIZES>,
36
+ className: ?string,
37
+ subtitle: ?string,
38
+ description: ?string,
39
+ };
40
+
41
+ const getClassName = cssModules(STYLES);
42
+
43
+ const BpkPrice = (props: Props) => {
44
+ const { className, description, size, subtitle, title, ...rest } = props;
45
+
46
+ const isSmall = size === SIZES.small;
47
+
48
+ return (
49
+ <div
50
+ className={getClassName(
51
+ 'bpk-price',
52
+ isSmall && 'bpk-price--small',
53
+ className,
54
+ )}
55
+ // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
56
+ {...rest}
57
+ >
58
+ {subtitle && (
59
+ <BpkText
60
+ className={getClassName('bpk-price__subtitle')}
61
+ textStyle={isSmall ? TEXT_STYLES.xs : TEXT_STYLES.sm}
62
+ tagName="span"
63
+ >
64
+ {subtitle}
65
+ </BpkText>
66
+ )}
67
+ <div className={isSmall && getClassName('bpk-price__titleColumn')}>
68
+ <BpkText
69
+ textStyle={isSmall ? TEXT_STYLES.heading4 : TEXT_STYLES.xxl}
70
+ tagName="span"
71
+ >
72
+ {title}
73
+ </BpkText>
74
+ {description && (
75
+ <BpkText
76
+ textStyle={isSmall ? TEXT_STYLES.xs : TEXT_STYLES.sm}
77
+ tagName="span"
78
+ className={getClassName(
79
+ 'bpk-price__description',
80
+ !isSmall && 'bpk-price__descriptionSpacing',
81
+ )}
82
+ >
83
+ {description}
84
+ </BpkText>
85
+ )}
86
+ </div>
87
+ </div>
88
+ );
89
+ };
90
+
91
+ BpkPrice.propTypes = {
92
+ title: PropTypes.string.isRequired,
93
+ size: PropTypes.oneOf(Object.keys(SIZES)),
94
+ className: PropTypes.string,
95
+ subtitle: PropTypes.string,
96
+ description: PropTypes.string,
97
+ };
98
+
99
+ BpkPrice.defaultProps = {
100
+ size: SIZES.small,
101
+ className: null,
102
+ subtitle: null,
103
+ description: null,
104
+ };
105
+
106
+ export default BpkPrice;