@skyscanner/backpack-web 14.0.0 → 14.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 (106) hide show
  1. package/README.md +67 -64
  2. package/bpk-animate-height/README.md +2 -4
  3. package/bpk-component-accordion/README.md +6 -8
  4. package/bpk-component-aria-live/README.md +2 -4
  5. package/bpk-component-autosuggest/README.md +5 -7
  6. package/bpk-component-badge/README.md +2 -4
  7. package/bpk-component-banner-alert/README.md +4 -6
  8. package/bpk-component-barchart/README.md +2 -4
  9. package/bpk-component-blockquote/README.md +2 -4
  10. package/bpk-component-breadcrumb/README.md +2 -4
  11. package/bpk-component-breakpoint/README.md +2 -4
  12. package/bpk-component-button/README.md +4 -6
  13. package/bpk-component-calendar/README.md +3 -5
  14. package/bpk-component-card/README.md +2 -4
  15. package/bpk-component-checkbox/README.md +2 -4
  16. package/bpk-component-checkbox/src/BpkCheckbox.js +1 -0
  17. package/bpk-component-checkbox/src/BpkCheckbox.module.scss +4 -0
  18. package/bpk-component-chip/README.md +3 -5
  19. package/bpk-component-close-button/README.md +2 -4
  20. package/bpk-component-code/README.md +3 -5
  21. package/bpk-component-content-cards/README.md +1 -3
  22. package/bpk-component-content-container/README.md +2 -4
  23. package/bpk-component-datatable/README.md +3 -5
  24. package/bpk-component-datepicker/README.md +4 -6
  25. package/bpk-component-description-list/README.md +2 -4
  26. package/bpk-component-dialog/README.md +3 -5
  27. package/bpk-component-drawer/README.md +3 -5
  28. package/bpk-component-fieldset/README.md +3 -5
  29. package/bpk-component-flare/README.md +2 -4
  30. package/bpk-component-floating-notification/README.md +2 -4
  31. package/bpk-component-form-validation/README.md +2 -4
  32. package/bpk-component-graphic-promotion/README.md +2 -4
  33. package/bpk-component-grid/README.md +2 -4
  34. package/bpk-component-grid-toggle/README.md +2 -4
  35. package/bpk-component-grid-toggle/src/BpkGridToggle.module.scss +1 -1
  36. package/bpk-component-horizontal-nav/README.md +2 -4
  37. package/bpk-component-icon/README.md +9 -11
  38. package/bpk-component-icon/lg/baggage-cabin-add.js +8 -0
  39. package/bpk-component-icon/lg/baggage-cabin-not-included.js +8 -0
  40. package/bpk-component-icon/lg/baggage-cabin.js +8 -0
  41. package/bpk-component-icon/lg/baggage-checked-add.js +8 -0
  42. package/bpk-component-icon/lg/baggage-checked-not-included.js +8 -0
  43. package/bpk-component-icon/lg/baggage-checked.js +8 -0
  44. package/bpk-component-icon/lg/baggage-generic.js +8 -0
  45. package/bpk-component-icon/sm/baggage-cabin-add.js +8 -0
  46. package/bpk-component-icon/sm/baggage-cabin-not-included.js +8 -0
  47. package/bpk-component-icon/sm/baggage-cabin.js +8 -0
  48. package/bpk-component-icon/sm/baggage-checked-add.js +8 -0
  49. package/bpk-component-icon/sm/baggage-checked-not-included.js +8 -0
  50. package/bpk-component-icon/sm/baggage-checked.js +8 -0
  51. package/bpk-component-icon/sm/baggage-generic.js +8 -0
  52. package/bpk-component-image/README.md +5 -7
  53. package/bpk-component-infinite-scroll/README.md +5 -7
  54. package/bpk-component-input/README.md +4 -6
  55. package/bpk-component-label/README.md +2 -4
  56. package/bpk-component-label/src/BpkLabel.js +9 -14
  57. package/bpk-component-label/src/BpkLabel.module.scss +4 -0
  58. package/bpk-component-link/README.md +2 -4
  59. package/bpk-component-list/README.md +2 -4
  60. package/bpk-component-loading-button/README.md +4 -6
  61. package/bpk-component-map/README.md +7 -9
  62. package/bpk-component-mobile-scroll-container/README.md +3 -5
  63. package/bpk-component-modal/README.md +4 -6
  64. package/bpk-component-navigation-bar/README.md +7 -9
  65. package/bpk-component-nudger/README.md +5 -7
  66. package/bpk-component-nudger/src/BpkNudger.module.scss +2 -1
  67. package/bpk-component-overlay/README.md +3 -5
  68. package/bpk-component-page-indicator/README.md +42 -0
  69. package/bpk-component-page-indicator/index.js +28 -0
  70. package/bpk-component-page-indicator/src/BpkPageIndicator.js +147 -0
  71. package/bpk-component-page-indicator/src/BpkPageIndicator.module.css +18 -0
  72. package/bpk-component-page-indicator/src/BpkPageIndicator.module.scss +91 -0
  73. package/bpk-component-page-indicator/src/NavButton.js +85 -0
  74. package/bpk-component-pagination/README.md +2 -4
  75. package/bpk-component-pagination/src/BpkPaginationNudger.module.scss +1 -22
  76. package/bpk-component-pagination/src/BpkPaginationPage.js +2 -1
  77. package/bpk-component-pagination/src/BpkPaginationPage.module.scss +5 -57
  78. package/bpk-component-panel/README.md +2 -4
  79. package/bpk-component-phone-input/README.md +3 -5
  80. package/bpk-component-popover/README.md +4 -6
  81. package/bpk-component-price/README.md +2 -4
  82. package/bpk-component-progress/README.md +2 -4
  83. package/bpk-component-radio/README.md +2 -4
  84. package/bpk-component-radio/src/BpkRadio.js +9 -10
  85. package/bpk-component-radio/src/BpkRadio.module.scss +4 -0
  86. package/bpk-component-rating/README.md +2 -4
  87. package/bpk-component-rtl-toggle/README.md +2 -4
  88. package/bpk-component-scrollable-calendar/README.md +3 -5
  89. package/bpk-component-section-list/README.md +2 -4
  90. package/bpk-component-select/README.md +2 -4
  91. package/bpk-component-skip-link/README.md +2 -4
  92. package/bpk-component-slider/README.md +2 -4
  93. package/bpk-component-spinner/README.md +2 -4
  94. package/bpk-component-split-input/README.md +2 -4
  95. package/bpk-component-star-rating/README.md +2 -4
  96. package/bpk-component-switch/README.md +2 -4
  97. package/bpk-component-table/README.md +2 -4
  98. package/bpk-component-text/README.md +5 -7
  99. package/bpk-component-textarea/README.md +2 -4
  100. package/bpk-component-theme-toggle/README.md +4 -6
  101. package/bpk-component-ticket/README.md +2 -4
  102. package/bpk-component-tooltip/README.md +3 -5
  103. package/bpk-react-utils/README.md +11 -13
  104. package/bpk-scrim-utils/README.md +2 -4
  105. package/bpk-theming/README.md +3 -5
  106. package/package.json +4 -4
@@ -31,6 +31,10 @@
31
31
 
32
32
  &--disabled {
33
33
  @include bpk-label--disabled;
34
+
35
+ &--white {
36
+ color: $bpk-text-disabled-on-dark-day;
37
+ }
34
38
  }
35
39
 
36
40
  &__asterisk {
@@ -4,15 +4,13 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-link --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
13
11
  ```js
14
12
  import React from 'react';
15
- import BpkLink, { BpkButtonLink } from 'bpk-component-link';
13
+ import BpkLink, { BpkButtonLink } from '@skyscanner/backpack-web/bpk-component-link';
16
14
 
17
15
  export default () => (
18
16
  <div>
@@ -4,15 +4,13 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-list --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
13
11
  ```js
14
12
  import React from 'react';
15
- import { BpkList, BpkListItem } from 'bpk-component-list';
13
+ import { BpkList, BpkListItem } from '@skyscanner/backpack-web/bpk-component-list';
16
14
 
17
15
  export default () => (
18
16
  <BpkList>
@@ -4,17 +4,15 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-loading-button --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
13
11
  ```js
14
12
  import React from 'react';
15
- import BpkLoadingButton from 'bpk-component-loading-button';
16
- import BaggageIcon from 'bpk-component-icon/sm/baggage';
17
- import { withButtonAlignment, withRtlSupport } from 'bpk-component-icon';
13
+ import BpkLoadingButton from '@skyscanner/backpack-web/bpk-component-loading-button';
14
+ import BaggageIcon from '@skyscanner/backpack-web/bpk-component-icon/sm/baggage';
15
+ import { withButtonAlignment, withRtlSupport } from '@skyscanner/backpack-web/bpk-component-icon';
18
16
 
19
17
  const AlignedBaggageIcon = withButtonAlignment(withRtlSupport(BaggageIcon));
20
18
  const icon = <AlignedBaggageIcon />;
@@ -6,21 +6,19 @@ Requires **React 16.8+**
6
6
 
7
7
  ## Installation
8
8
 
9
- ```sh
10
- npm install bpk-component-map --save-dev
11
- ```
9
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
12
10
 
13
11
  ## Usage
14
12
 
15
13
  ```js
16
14
  import React from 'react';
17
- import BpkText from 'bpk-component-text';
18
- import { withRtlSupport } from 'bpk-component-icon';
19
- import LandmarkIconSm from 'bpk-component-icon/sm/landmark';
15
+ import BpkText from '@skyscanner/backpack-web/bpk-component-text';
16
+ import { withRtlSupport } from '@skyscanner/backpack-web/bpk-component-icon';
17
+ import LandmarkIconSm from '@skyscanner/backpack-web/bpk-component-icon/sm/landmark';
20
18
  import BpkMap, {
21
19
  BpkIconMarker,
22
20
  BpkOverlayView,
23
- } from 'bpk-component-map';
21
+ } from '@skyscanner/backpack-web/bpk-component-map';
24
22
 
25
23
  const AlignedLandmarkIconSm = withRtlSupport(LandmarkIconSm);
26
24
 
@@ -64,7 +62,7 @@ Price markers are used to display clickable prices on a map.
64
62
 
65
63
  ```js
66
64
  import React from 'react';
67
- import BpkMap, { BpkPriceMarker, PRICE_MARKER_STATUSES } from 'bpk-component-map';
65
+ import BpkMap, { BpkPriceMarker, PRICE_MARKER_STATUSES } from '@skyscanner/backpack-web/bpk-component-map';
68
66
 
69
67
  export default () => (
70
68
  <BpkMap
@@ -106,7 +104,7 @@ If you intend to include multiple maps on one page, it's better to load the Goog
106
104
 
107
105
  ```js
108
106
  import React from 'react';
109
- import BpkMap, { withGoogleMapsScript } from 'bpk-component-map';
107
+ import BpkMap, { withGoogleMapsScript } from '@skyscanner/backpack-web/bpk-component-map';
110
108
 
111
109
  const BpkMapWithScript = withGoogleMapsScript(BpkMap);
112
110
 
@@ -4,16 +4,14 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-mobile-scroll-container --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
13
11
  ```js
14
12
  import React from 'react';
15
- import { cssModules } from 'bpk-react-utils';
16
- import BpkMobileScrollContainer from 'bpk-component-mobile-scroll-container';
13
+ import { cssModules } from '@skyscanner/backpack-web/bpk-react-utils';
14
+ import BpkMobileScrollContainer from '@skyscanner/backpack-web/bpk-component-mobile-scroll-container';
17
15
 
18
16
  import STYLES from './MyComponent.scss';
19
17
 
@@ -4,17 +4,15 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-modal --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
13
11
  ```js
14
12
  import React, { Component } from 'react';
15
- import BpkModal from 'bpk-component-modal';
16
- import BpkButton from 'bpk-component-button';
17
- import { BpkNavigationBarButtonLink } from 'bpk-component-navigation-bar';
13
+ import BpkModal from '@skyscanner/backpack-web/bpk-component-modal';
14
+ import BpkButton from '@skyscanner/backpack-web/bpk-component-button';
15
+ import { BpkNavigationBarButtonLink } from '@skyscanner/backpack-web/bpk-component-navigation-bar';
18
16
 
19
17
  class App extends Component {
20
18
  constructor() {
@@ -4,9 +4,7 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-navigation-bar --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
@@ -14,10 +12,10 @@ npm install bpk-component-navigation-bar --save-dev
14
12
 
15
13
  ```js
16
14
  import React from 'react';
17
- import ArrowIcon from 'bpk-component-icon/sm/long-arrow-left';
18
- import { withRtlSupport } from 'bpk-component-icon';
15
+ import ArrowIcon from '@skyscanner/backpack-web/bpk-component-icon/sm/long-arrow-left';
16
+ import { withRtlSupport } from '@skyscanner/backpack-web/bpk-component-icon';
19
17
 
20
- import BpkNavigationBar, { BpkNavigationBarIconButton, BpkNavigationBarButtonLink } from 'bpk-component-navigation-bar';
18
+ import BpkNavigationBar, { BpkNavigationBarIconButton, BpkNavigationBarButtonLink } from '@skyscanner/backpack-web/bpk-component-navigation-bar';
21
19
 
22
20
  const ArrowIconWithRtl = withRtlSupport(ArrowIcon);
23
21
 
@@ -58,8 +56,8 @@ export default () => (
58
56
 
59
57
  ```js
60
58
  import React from 'react';
61
- import ArrowIcon from 'bpk-component-icon/sm/long-arrow-left';
62
- import { BpkNavigationBarIconButton } from 'bpk-component-navigation-bar';
59
+ import ArrowIcon from '@skyscanner/backpack-web/bpk-component-icon/sm/long-arrow-left';
60
+ import { BpkNavigationBarIconButton } from '@skyscanner/backpack-web/bpk-component-navigation-bar';
63
61
 
64
62
  export default () => (
65
63
  <BpkNavigationBarIconButton
@@ -89,7 +87,7 @@ export default () => (
89
87
 
90
88
  ```js
91
89
  import React from 'react';
92
- import { BpkNavigationBarButtonLink } from 'bpk-component-navigation-bar';
90
+ import { BpkNavigationBarButtonLink } from '@skyscanner/backpack-web/bpk-component-navigation-bar';
93
91
 
94
92
  export default () => (
95
93
  <BpkNavigationBarButtonLink onClick={() => {}}>
@@ -4,9 +4,7 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-nudger --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
@@ -14,8 +12,8 @@ npm install bpk-component-nudger --save-dev
14
12
 
15
13
  ```js
16
14
  import React, { Component } from 'react';
17
- import BpkLabel from 'bpk-component-label';
18
- import BpkNudger from 'bpk-component-nudger';
15
+ import BpkLabel from '@skyscanner/backpack-web/bpk-component-label';
16
+ import BpkNudger from '@skyscanner/backpack-web/bpk-component-nudger';
19
17
 
20
18
  class App extends Component {
21
19
  constructor() {
@@ -53,8 +51,8 @@ class App extends Component {
53
51
 
54
52
  ```js
55
53
  import React, { Component } from 'react';
56
- import BpkLabel from 'bpk-component-label';
57
- import { BpkConfigurableNudger } from 'bpk-component-nudger';
54
+ import BpkLabel from '@skyscanner/backpack-web/bpk-component-label';
55
+ import { BpkConfigurableNudger } from '@skyscanner/backpack-web/bpk-component-nudger';
58
56
 
59
57
  const options = ['economy', 'premium', 'business', 'first'];
60
58
 
@@ -29,6 +29,7 @@ $bpk-spacing-v2: true;
29
29
  display: inline-block;
30
30
  padding: bpk-spacing-md() 0;
31
31
  border: none;
32
+ color: $bpk-text-primary-day;
32
33
  text-align: center;
33
34
  vertical-align: middle;
34
35
 
@@ -37,7 +38,7 @@ $bpk-spacing-v2: true;
37
38
 
38
39
  &--secondary-on-dark {
39
40
  background-color: transparent;
40
- color: $bpk-text-primary-night;
41
+ color: $bpk-text-on-dark-day;
41
42
  }
42
43
 
43
44
  &--numeric {
@@ -4,16 +4,14 @@
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
8
- npm install bpk-component-overlay --save-dev
9
- ```
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
10
8
 
11
9
  ## Usage
12
10
 
13
11
  ```js
14
12
  import React from 'react';
15
- import BpkText from 'bpk-component-text';
16
- import BpkOverlay, { BORDER_RADIUS_STYLES, OVERLAY_TYPES } from 'bpk-component-overlay';
13
+ import BpkText from '@skyscanner/backpack-web/bpk-component-text';
14
+ import BpkOverlay, { BORDER_RADIUS_STYLES, OVERLAY_TYPES } from '@skyscanner/backpack-web/bpk-component-overlay';
17
15
 
18
16
  export default () => (
19
17
  <div>
@@ -0,0 +1,42 @@
1
+ # bpk-component-page-indicator
2
+
3
+ > Backpack page indicator component.
4
+
5
+ ## Installation
6
+
7
+ Check the main [Readme](https://github.com/skyscanner/backpack#usage) for a complete installation guide.
8
+
9
+ ## Usage
10
+
11
+ ```js
12
+ import React from 'react';
13
+ import BpkPageIndicator from '@skyscanner/backpack-web/bpk-component-page-indicator';
14
+
15
+ export default () =>
16
+ <BpkPageIndicator
17
+ currentIndex={0}
18
+ totalIndicators={7}
19
+ onClick={(e, newIndex, direction) => {
20
+ console.log('Slide to new index:', newIndex);
21
+ console.log('Slide direction:', direction);
22
+ }}
23
+ indicatorLabel='Go to slide'
24
+ prevNavLabel='Previous slide'
25
+ nextNavLabel='Next slide'
26
+ />;
27
+ ```
28
+
29
+ ## Props
30
+
31
+ | Property | PropType | Required | Default Value |
32
+ |-----------------|----------------|----------|-----------------|
33
+ | currentIndex | number | true | - |
34
+ | totalIndicators | number | true | - |
35
+ | indicatorLabel | string | true | - |
36
+ | prevNavLabel | string | true | - |
37
+ | nextNavLabel | string | true | - |
38
+ | className | string | false | null |
39
+ | showNav | bool | false | false |
40
+ | variant | oneOf(VARIANT) | false | VARIANT.default |
41
+ | onClick | func | false | null |
42
+
@@ -0,0 +1,28 @@
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 BpkPageIndicator, {
21
+ type Props as BpkPageIndicatorProps,
22
+ VARIANT,
23
+ } from './src/BpkPageIndicator';
24
+ import { DIRECTIONS } from './src/NavButton';
25
+
26
+ export type { BpkPageIndicatorProps };
27
+ export { DIRECTIONS, VARIANT };
28
+ export default BpkPageIndicator;
@@ -0,0 +1,147 @@
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 React from 'react';
21
+ import PropTypes from 'prop-types';
22
+
23
+ import { cssModules } from '../../bpk-react-utils';
24
+
25
+ import NavButton, { DIRECTIONS } from './NavButton';
26
+ import STYLES from './BpkPageIndicator.module.scss';
27
+
28
+ const getClassName = cssModules(STYLES);
29
+
30
+ const DISPLAYED_TOTAL = 5;
31
+ const START_SCROLL_INDEX = Math.floor(DISPLAYED_TOTAL / 2);
32
+
33
+ export const VARIANT = {
34
+ default: 'default',
35
+ overImage: 'overImage',
36
+ };
37
+
38
+ export type Props = {
39
+ className: ?string,
40
+ showNav: ?boolean,
41
+ currentIndex: number,
42
+ totalIndicators: number,
43
+ onClick: ?() => void,
44
+ indicatorLabel: string,
45
+ prevNavLabel: string,
46
+ nextNavLabel: string,
47
+ variant: ?$Keys<typeof VARIANT>,
48
+ };
49
+
50
+ const BpkPageIndicator = ({
51
+ className,
52
+ currentIndex,
53
+ indicatorLabel,
54
+ nextNavLabel,
55
+ onClick,
56
+ prevNavLabel,
57
+ showNav,
58
+ totalIndicators,
59
+ variant,
60
+ }: Props) => (
61
+ // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
62
+ <div className={className}>
63
+ <div
64
+ className={getClassName(
65
+ 'bpk-page-indicator',
66
+ showNav && 'bpk-page-indicator__showNav',
67
+ )}
68
+ >
69
+ {showNav && (
70
+ <NavButton
71
+ currentIndex={currentIndex}
72
+ onClick={onClick}
73
+ disabled={currentIndex === 0}
74
+ direction={DIRECTIONS.PREV}
75
+ ariaLabel={prevNavLabel}
76
+ />
77
+ )}
78
+ <div className={getClassName('bpk-page-indicator__container')}>
79
+ <div
80
+ className={getClassName('bpk-page-indicator__indicators-container')}
81
+ style={
82
+ currentIndex > START_SCROLL_INDEX
83
+ ? {
84
+ '--scroll-index':
85
+ totalIndicators > DISPLAYED_TOTAL
86
+ ? Math.min(
87
+ currentIndex - START_SCROLL_INDEX,
88
+ totalIndicators - DISPLAYED_TOTAL,
89
+ )
90
+ : 0,
91
+ }
92
+ : undefined
93
+ }
94
+ >
95
+ {[...Array(totalIndicators)].map((val, index) => (
96
+ <button
97
+ type="button"
98
+ onClick={(e) => {
99
+ onClick(e, index, DIRECTIONS.INDICATORS);
100
+ }}
101
+ className={getClassName(
102
+ 'bpk-page-indicator__indicator',
103
+ `bpk-page-indicator__indicator--${variant}`,
104
+ index === currentIndex &&
105
+ `bpk-page-indicator__indicator--active-${variant}`,
106
+ )}
107
+ aria-label={`${indicatorLabel} ${index + 1}`}
108
+ aria-current={currentIndex === index ? 'true' : 'false'}
109
+ // eslint-disable-next-line react/no-array-index-key
110
+ key={`indicator-${index}`}
111
+ />
112
+ ))}
113
+ </div>
114
+ </div>
115
+ {showNav && (
116
+ <NavButton
117
+ currentIndex={currentIndex}
118
+ onClick={onClick}
119
+ disabled={currentIndex === totalIndicators - 1}
120
+ ariaLabel={nextNavLabel}
121
+ direction={DIRECTIONS.NEXT}
122
+ />
123
+ )}
124
+ </div>
125
+ </div>
126
+ );
127
+
128
+ BpkPageIndicator.propTypes = {
129
+ indicatorLabel: PropTypes.string.isRequired,
130
+ prevNavLabel: PropTypes.string.isRequired,
131
+ nextNavLabel: PropTypes.string.isRequired,
132
+ currentIndex: PropTypes.number.isRequired,
133
+ totalIndicators: PropTypes.number.isRequired,
134
+ variant: PropTypes.oneOf(Object.keys(VARIANT)),
135
+ onClick: PropTypes.func,
136
+ className: PropTypes.string,
137
+ showNav: PropTypes.bool,
138
+ };
139
+
140
+ BpkPageIndicator.defaultProps = {
141
+ onClick: null,
142
+ className: null,
143
+ showNav: false,
144
+ variant: VARIANT.default,
145
+ };
146
+
147
+ export default BpkPageIndicator;
@@ -0,0 +1,18 @@
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
+ @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-page-indicator{display:flex}
@@ -0,0 +1,91 @@
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
+
19
+ @import '~bpk-mixins/index.scss';
20
+
21
+ $bpk-spacing-v2: true;
22
+ $dot-size: bpk-spacing-md();
23
+ $dot-margin: bpk-spacing-sm();
24
+ $displayed-total: 5;
25
+ /* stylelint-disable-next-line scss/operator-no-newline-after */
26
+ $container-width: $dot-size * $displayed-total + $dot-margin * $displayed-total *
27
+ 2;
28
+
29
+ .bpk-page-indicator {
30
+ display: flex;
31
+ width: 100%;
32
+ justify-content: center;
33
+ align-items: center;
34
+
35
+ &__showNav {
36
+ justify-content: space-between;
37
+ }
38
+
39
+ &__container {
40
+ max-width: $container-width;
41
+ min-height: $dot-size;
42
+ overflow: hidden;
43
+ }
44
+
45
+ &__indicators-container {
46
+ --direction: -1;
47
+
48
+ /* stylelint-disable scss/operator-no-newline-after */
49
+ transform: translateX(
50
+ calc(
51
+ var(--direction) * var(--scroll-index, 0) * #{$dot-size + $dot-margin *
52
+ 2}
53
+ )
54
+ );
55
+ /* stylelint-enable scss/operator-no-newline-after */
56
+ transition: transform $bpk-duration-sm ease-in-out;
57
+ white-space: nowrap;
58
+
59
+ @include bpk-rtl {
60
+ --direction: 1;
61
+ }
62
+ }
63
+
64
+ &__indicator {
65
+ display: inline-block;
66
+ width: $dot-size;
67
+ height: $dot-size;
68
+ padding: 0;
69
+ border: none;
70
+ border-radius: 50%;
71
+ margin-inline: $dot-margin;
72
+
73
+ &--default {
74
+ background-color: $bpk-line-day;
75
+ }
76
+
77
+ &--overImage {
78
+ background-color: $bpk-line-on-dark-day;
79
+ }
80
+
81
+ &--active {
82
+ &-default {
83
+ background-color: $bpk-text-secondary-day;
84
+ }
85
+
86
+ &-overImage {
87
+ background-color: $bpk-text-on-dark-day;
88
+ }
89
+ }
90
+ }
91
+ }