@skyscanner/backpack-web 0.0.1 → 0.0.2
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/README.md +100 -0
- package/bpk-component-accordion/package.json +4 -4
- package/bpk-component-accordion/src/BpkAccordionItem.js +1 -1
- package/bpk-component-aria-live/package.json +3 -3
- package/bpk-component-autosuggest/package.json +3 -3
- package/bpk-component-badge/package.json +2 -2
- package/bpk-component-banner-alert/package.json +4 -4
- package/bpk-component-barchart/examples.js +2 -2
- package/bpk-component-barchart/package.json +2 -2
- package/bpk-component-breadcrumb/package.json +3 -3
- package/bpk-component-calendar/package.json +4 -4
- package/bpk-component-card/examples.js +1 -1
- package/bpk-component-card/package.json +2 -2
- package/bpk-component-checkbox/package.json +2 -2
- package/bpk-component-chip/examples.js +4 -5
- package/bpk-component-chip/package.json +4 -4
- package/bpk-component-chip/src/BpkSelectableChip.js +1 -1
- package/bpk-component-close-button/package.json +2 -2
- package/bpk-component-datatable/package.json +2 -2
- package/bpk-component-datepicker/package.json +5 -5
- package/bpk-component-dialog/examples.js +2 -2
- package/bpk-component-dialog/package.json +5 -5
- package/bpk-component-drawer/examples.js +2 -2
- package/bpk-component-drawer/package.json +4 -4
- package/bpk-component-fieldset/package.json +7 -7
- package/bpk-component-flare/examples.js +3 -3
- package/bpk-component-flare/package.json +2 -2
- package/bpk-component-form-validation/package.json +4 -4
- package/bpk-component-horizontal-nav/package.json +2 -2
- package/bpk-component-icon/examples.js +5 -5
- package/bpk-component-icon/package.json +2 -2
- package/bpk-component-image/examples.js +4 -4
- package/bpk-component-image/package.json +2 -2
- package/bpk-component-input/package.json +3 -3
- package/bpk-component-loading-button/package.json +2 -2
- package/bpk-component-map/package.json +3 -3
- package/bpk-component-map/src/BpkPriceMarker.js +3 -7
- package/bpk-component-modal/examples.js +2 -2
- package/bpk-component-modal/package.json +5 -5
- package/bpk-component-navigation-bar/package.json +4 -4
- package/bpk-component-navigation-bar/src/BpkNavigationBar.js +2 -2
- package/bpk-component-navigation-stack/package.json +3 -3
- package/bpk-component-nudger/package.json +2 -2
- package/bpk-component-overlay/package.json +3 -3
- package/bpk-component-pagination/package.json +2 -2
- package/bpk-component-phone-input/package.json +5 -5
- package/bpk-component-popover/examples.js +2 -2
- package/bpk-component-popover/package.json +4 -4
- package/bpk-component-popover/src/BpkPopover.js +2 -2
- package/bpk-component-rating/package.json +2 -2
- package/bpk-component-rating/src/BpkRating.js +14 -8
- package/bpk-component-scrollable-calendar/package.json +3 -3
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.js +2 -3
- package/bpk-component-section-list/package.json +3 -3
- package/bpk-component-section-list/src/BpkSectionListSection.js +2 -4
- package/bpk-component-star-rating/package.json +2 -2
- package/bpk-component-text/examples.js +17 -17
- package/bpk-component-text/package.json +1 -1
- package/bpk-component-text/src/BpkText.js +1 -1
- package/bpk-component-ticket/package.json +2 -2
- package/bpk-component-tooltip/examples.js +2 -2
- package/bpk-component-tooltip/package.json +2 -2
- package/package.json +2 -2
- package/bpk-component-heading/README.md +0 -31
- package/bpk-component-heading/examples.js +0 -36
- package/bpk-component-heading/index.js +0 -23
- package/bpk-component-heading/package.json +0 -25
- package/bpk-component-heading/src/BpkHeading.js +0 -70
- package/bpk-component-heading/src/BpkHeading.module.css +0 -18
- package/bpk-component-heading/src/BpkHeading.module.scss +0 -49
- package/bpk-component-paragraph/README.md +0 -28
- package/bpk-component-paragraph/examples.js +0 -46
- package/bpk-component-paragraph/index.js +0 -23
- package/bpk-component-paragraph/package.json +0 -25
- package/bpk-component-paragraph/src/BpkParagraph.js +0 -55
- package/bpk-component-paragraph/src/BpkParagraph.module.css +0 -18
- package/bpk-component-paragraph/src/BpkParagraph.module.scss +0 -25
- package/bpk-tether/.eslintrc +0 -6
- package/bpk-tether/README.md +0 -52
- package/bpk-tether/index.js +0 -24
- package/bpk-tether/package.json +0 -19
- package/bpk-tether/src/TetherWrapper.js +0 -30
- package/bpk-tether/src/applyRTLTransforms.js +0 -49
- package/bpk-tether/src/getArrowPositionCallback.js +0 -65
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
/* @flow strict */
|
|
20
|
-
|
|
21
|
-
import PropTypes from 'prop-types';
|
|
22
|
-
import React, { type Node } from 'react';
|
|
23
|
-
import { cssModules } from 'bpk-react-utils';
|
|
24
|
-
|
|
25
|
-
import STYLES from './BpkParagraph.module.scss';
|
|
26
|
-
|
|
27
|
-
const getClassName = cssModules(STYLES);
|
|
28
|
-
|
|
29
|
-
type Props = {
|
|
30
|
-
children: Node,
|
|
31
|
-
className: ?string,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const BpkParagraph = (props: Props) => {
|
|
35
|
-
const classNames = [getClassName('bpk-paragraph')];
|
|
36
|
-
const { className, ...rest } = props;
|
|
37
|
-
|
|
38
|
-
if (className) {
|
|
39
|
-
classNames.push(className);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See decisions/flowfixme.md
|
|
43
|
-
return <p className={classNames.join(' ')} {...rest} />;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
BpkParagraph.propTypes = {
|
|
47
|
-
children: PropTypes.node.isRequired,
|
|
48
|
-
className: PropTypes.string,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
BpkParagraph.defaultProps = {
|
|
52
|
-
className: null,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default BpkParagraph;
|
|
@@ -1,18 +0,0 @@
|
|
|
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-paragraph{margin-top:0;margin-bottom:1rem}
|
|
@@ -1,25 +0,0 @@
|
|
|
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';
|
|
20
|
-
|
|
21
|
-
$bpk-spacing-v2: true;
|
|
22
|
-
|
|
23
|
-
.bpk-paragraph {
|
|
24
|
-
@include bpk-paragraph;
|
|
25
|
-
}
|
package/bpk-tether/.eslintrc
DELETED
package/bpk-tether/README.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# bpk-tether
|
|
2
|
-
|
|
3
|
-
> Wrapper around the Tether library, along with related utilities
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
npm install bpk-tether --save-dev
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Tether Wrapper
|
|
12
|
-
|
|
13
|
-
A wrapper around the [Tether](http://tether.io/) library which extends the `Tether` object to emit a `position` event.
|
|
14
|
-
|
|
15
|
-
### Usage
|
|
16
|
-
|
|
17
|
-
```js
|
|
18
|
-
import { Tether } from 'bpk-tether';
|
|
19
|
-
|
|
20
|
-
this.tether = new Tether({
|
|
21
|
-
classPrefix: 'bpk-popover-tether',
|
|
22
|
-
element: popoverElement,
|
|
23
|
-
target: targetElement,
|
|
24
|
-
tetherOptions: tetherOptions,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
this.tether.on('position', position => console.log('Tether was repositioned', position));
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## getArrowPositionCallback
|
|
31
|
-
|
|
32
|
-
When using Tether to create a popover or tooltip with an arrow pointing towards the target element, we want to have
|
|
33
|
-
this arrow point to the target element at all times. To achieve this, the `getArrowPositionCallback` function returns
|
|
34
|
-
a callback to be used on the `position` event. When invoked, it repositions the arrow element to stick to the target
|
|
35
|
-
element.
|
|
36
|
-
|
|
37
|
-
### Usage
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
import { Tether } from 'bpk-tether';
|
|
41
|
-
|
|
42
|
-
const classPrefix = 'bpk-popover-tether';
|
|
43
|
-
|
|
44
|
-
this.tether = new Tether({
|
|
45
|
-
classPrefix,
|
|
46
|
-
element: tetherElement,
|
|
47
|
-
target: targetElement,
|
|
48
|
-
tetherOptions: tetherOptions,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
this.tether.on('position', getArrowPositionCallback(tetherElement, 'arrow-id', classPrefix));
|
|
52
|
-
```
|
package/bpk-tether/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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 TetherWrapper from './src/TetherWrapper';
|
|
20
|
-
import getArrowPositionCallback from './src/getArrowPositionCallback';
|
|
21
|
-
import applyRTLTransforms from './src/applyRTLTransforms';
|
|
22
|
-
|
|
23
|
-
export default TetherWrapper;
|
|
24
|
-
export { getArrowPositionCallback, applyRTLTransforms };
|
package/bpk-tether/package.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "bpk-tether",
|
|
3
|
-
"version": "1.1.2",
|
|
4
|
-
"description": "Wrapper and utils for Tether.",
|
|
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": "09fc99e4e67a5b71dc15f41a5409ad412bc139d4",
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"tether": "^2.0.0"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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 Tether from 'tether';
|
|
20
|
-
|
|
21
|
-
// We extend tether to hook into the position function in order to expose
|
|
22
|
-
// a `position` event on the tether object. Useful for repositioning arrows
|
|
23
|
-
// etc. See http://tether.io/advanced/extending_tether/.
|
|
24
|
-
Tether.modules.push({
|
|
25
|
-
position(props) {
|
|
26
|
-
this.trigger('position', props);
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export default Tether;
|
|
@@ -1,49 +0,0 @@
|
|
|
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 { isRTL } from 'bpk-react-utils';
|
|
20
|
-
|
|
21
|
-
const tryFlipAttachmentString = (value) => {
|
|
22
|
-
if (value.indexOf('right') !== -1) {
|
|
23
|
-
return value.replace('right', 'left');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return value.replace('left', 'right');
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const transform = (tetherOptions) => {
|
|
30
|
-
const { attachment, targetAttachment, ...rest } = tetherOptions;
|
|
31
|
-
|
|
32
|
-
const options = {};
|
|
33
|
-
|
|
34
|
-
if (attachment) {
|
|
35
|
-
options.attachment = isRTL()
|
|
36
|
-
? tryFlipAttachmentString(attachment)
|
|
37
|
-
: attachment;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (targetAttachment) {
|
|
41
|
-
options.targetAttachment = isRTL()
|
|
42
|
-
? tryFlipAttachmentString(targetAttachment)
|
|
43
|
-
: targetAttachment;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return { ...options, ...rest };
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default transform;
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
// For compat with various IE browsers who haven't implemented classList yet.
|
|
20
|
-
// See http://youmightnotneedjquery.com/#has_class.
|
|
21
|
-
const hasClass = (el, className) => {
|
|
22
|
-
if (el.classList) {
|
|
23
|
-
return el.classList.contains(className);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return new RegExp(`(^| )${className}( |$)`, 'gi').test(el.className);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const getArrowPositionCallback = (
|
|
30
|
-
popoverElement = {},
|
|
31
|
-
arrowId,
|
|
32
|
-
classNamePrefix = 'bpk-popover-tether',
|
|
33
|
-
) => {
|
|
34
|
-
let arrowElement = null;
|
|
35
|
-
|
|
36
|
-
if (popoverElement.querySelector) {
|
|
37
|
-
arrowElement = popoverElement.querySelector(`#${arrowId}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (arrowElement === null) {
|
|
41
|
-
return () => null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (props) => {
|
|
45
|
-
const { left, targetPos, top } = props;
|
|
46
|
-
|
|
47
|
-
const shouldApplyLeftOffset =
|
|
48
|
-
hasClass(popoverElement, `${classNamePrefix}-element-attached-top`) ||
|
|
49
|
-
hasClass(popoverElement, `${classNamePrefix}-element-attached-bottom`);
|
|
50
|
-
|
|
51
|
-
if (shouldApplyLeftOffset) {
|
|
52
|
-
const leftOffset = targetPos.left + targetPos.width / 2 - left;
|
|
53
|
-
|
|
54
|
-
arrowElement.style.top = '';
|
|
55
|
-
arrowElement.style.left = `${leftOffset}px`;
|
|
56
|
-
} else {
|
|
57
|
-
const topOffset = targetPos.top + targetPos.height / 2 - top;
|
|
58
|
-
|
|
59
|
-
arrowElement.style.top = `${topOffset}px`;
|
|
60
|
-
arrowElement.style.left = '';
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default getArrowPositionCallback;
|