Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DTO-5100] BpkChipGroup #3198

Open
wants to merge 83 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
74516e6
wip
Sep 21, 2023
47c712a
Merge branch 'main' of github.com:Skyscanner/backpack into DTO-4223
Jan 5, 2024
17d03c7
Create nudger for desktop
Jan 5, 2024
92ec095
Refactor chip groups to better match api
Jan 10, 2024
40480ef
More examples, support for dismissable chips, tests
Jan 12, 2024
50ffcb4
More WIP, Update docs, add tests, add a11y roles, add TODOs
Jan 25, 2024
b5690b3
Merge branch 'main' into DTO-4223
Iain530 Jan 25, 2024
2ba1a5a
Fix shadow clipping bug, remove scroll indicators
Feb 9, 2024
6e24bf2
Update prop names
Feb 16, 2024
73207a3
increase rail padding to 4px for focus indicator
Feb 16, 2024
f9c1d78
Nudger tests, fix single select prop
Feb 16, 2024
9273120
clean up imports
Mar 1, 2024
56a1e8b
Add tests for stateful chip groups
Mar 1, 2024
e92b9a1
Add sticky chip to a11y tests
Mar 1, 2024
fe8ef2d
Start readme
Mar 7, 2024
6327d6d
Merge branch 'main' of github.com:Skyscanner/backpack into DTO-4223
Mar 26, 2024
c89f975
Use BpkIconChip, @import -> @use
Mar 26, 2024
3b347f4
Fix nudgers jumpiness
Mar 27, 2024
9c90bd8
update todo comment
Apr 2, 2024
63063f7
Fix some type errors, write README
Apr 12, 2024
dcdbc32
a11y improvements
Apr 12, 2024
adea076
generate type declaration files
Apr 12, 2024
9f2fefb
Merge branch 'main' into DTO-4223
Iain530 Apr 12, 2024
b3452ff
build css
Apr 12, 2024
e3d05f1
remove custom classname support
Apr 12, 2024
708d7ef
remove classname from nudger
Apr 12, 2024
6b4a662
fix untyped imports
Apr 12, 2024
9c13146
update tests with a11y improvements
Apr 12, 2024
38e1791
add nudger labels
Apr 16, 2024
80db707
add nudger labels to tests, snaps, type declarations
Apr 16, 2024
79d0f47
Merge branch 'main' into DTO-4223
Iain530 Apr 16, 2024
8d7ea52
add missing license heading
Apr 16, 2024
e5c6cae
ChipGroup - Add support for visual label inc. examples (#3369)
steviehailey-skyscanner Apr 17, 2024
894a0a6
Update docs link
Iain530 Apr 23, 2024
58f20e2
Split definitions for group types (#3370)
steviehailey-skyscanner Apr 26, 2024
f49912b
remove generated css files
Apr 26, 2024
a34bf81
Merge branch 'main' of github.com:Skyscanner/backpack into DTO-4223
Apr 26, 2024
1896bb6
remove scroll indicator overrides
May 1, 2024
8cc0244
Merge branch 'main' of github.com:Skyscanner/backpack into DTO-4223
May 1, 2024
81a0f4e
refactor ChipGroup tests
May 1, 2024
48d5cb0
refactor SingleSelectChipGroup tests
May 1, 2024
c1b9601
refactor Nudger tests
May 1, 2024
3f3095e
fix type errors
May 1, 2024
1a814f0
remove snapshot
May 1, 2024
56bfd19
remove compiled css
May 2, 2024
834dfcc
ChipGroup - Remove label padding (#3407)
steviehailey-skyscanner May 2, 2024
5693e07
Set nudger labels as required in typedef (#3411)
steviehailey-skyscanner May 2, 2024
e6d5157
fix export style
May 2, 2024
822bdab
Merge branch 'main' into DTO-4223
Iain530 May 2, 2024
1c60641
Merge branch 'main' of github.com:Skyscanner/backpack into DTO-4223
May 23, 2024
4595b17
remove type declaration files
May 23, 2024
315042e
Rename chip groups
May 23, 2024
ea201b0
Rename chip groups
May 23, 2024
63f1092
fix zoom test
May 23, 2024
ab550bf
remove default nudger labels
May 23, 2024
2f0d314
refactor nudger positions
May 23, 2024
812451a
remove InternalProps classname
May 24, 2024
3410878
refactoring
May 24, 2024
1b072ce
styling/refactoring
May 24, 2024
f8729ea
Move stateful ChipGroups to storybook only
May 24, 2024
50785cb
fix type errors
May 24, 2024
2664de9
fix list keys
May 24, 2024
9affa37
Merge branch 'main' into DTO-4223
Iain530 May 28, 2024
0bec6e2
debug nudger test
May 28, 2024
366ff34
sync act
May 28, 2024
1bc4373
use waitFor
May 31, 2024
983840f
no waiting
May 31, 2024
15528f0
act only
May 31, 2024
625a588
no fake timers
May 31, 2024
dc23d8d
debug act
May 31, 2024
cdefa6b
no async
May 31, 2024
ec6a519
render in act
May 31, 2024
9817f8e
Increase rail padding for focus indicators
Jun 4, 2024
8782ed7
clear timers
Jun 4, 2024
a1365bc
dont clear timers
Jun 4, 2024
ffafa99
advanceTimers userEvent
Jun 4, 2024
c3f9a29
update mock values
Jun 4, 2024
a5baac3
no mock values
Jun 4, 2024
5ef8753
tweak mock values
Jun 4, 2024
46703b2
debug
Jun 4, 2024
bc96802
debug
Jun 4, 2024
9dbba83
use waitFor again
Jun 4, 2024
9db1c3a
less specific attribute testing
Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To contribute please see [contributing.md](CONTRIBUTING.md).
[`bpk-component-card`](/packages/bpk-component-card)
[`bpk-component-checkbox`](/packages/bpk-component-checkbox)
[`bpk-component-chip`](/packages/bpk-component-chip)
[`bpk-component-chip-group`](/packages/bpk-component-chip-group)
[`bpk-component-close-button`](/packages/bpk-component-close-button)
[`bpk-component-code`](/packages/bpk-component-code)
[`bpk-component-datatable`](/packages/bpk-component-datatable)
Expand Down
18 changes: 18 additions & 0 deletions examples/bpk-component-chip-group/examples.module.css
Iain530 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Backpack - Skyscanner's Design System
*
* Copyright 2016 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-chip-group-examples__fixed-width{width:18.75rem}.bpk-chip-group-examples__contrast{padding:1rem;background-color:#eff3f8}.bpk-chip-group-examples__dark{padding:1rem;background-color:#05203c}.bpk-chip-group-examples__image{padding:1rem;background-image:url("https://content.skyscnr.com/96508dbac15a2895b0147dc7e7f9ad30/canadian-rockies-canada.jpg")}.bpk-chip-group-examples__mixed-container h2{margin-top:2rem;margin-bottom:.5rem}
47 changes: 47 additions & 0 deletions examples/bpk-component-chip-group/examples.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Backpack - Skyscanner's Design System
*
* Copyright 2016 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@import '../../packages/bpk-mixins/index.scss';

.bpk-chip-group-examples {
&__fixed-width {
width: 300 * $bpk-one-pixel-rem;
}

&__contrast {
padding: bpk-spacing-base();
background-color: $bpk-canvas-contrast-day;
}

&__dark {
padding: bpk-spacing-base();
background-color: $bpk-surface-contrast-day;
}

&__image {
padding: bpk-spacing-base();
background-image: url('https://content.skyscnr.com/96508dbac15a2895b0147dc7e7f9ad30/canadian-rockies-canada.jpg');
}

&__mixed-container {
h2 {
margin-top: bpk-spacing-xl();
margin-bottom: bpk-spacing-md();
}
}
}
307 changes: 307 additions & 0 deletions examples/bpk-component-chip-group/examples.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
/*
* Backpack - Skyscanner's Design System
*
* Copyright 2016 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


import { useState } from 'react';

import { CHIP_TYPES } from '../../packages/bpk-component-chip';
import BpkChipGroup, {
BpkChipGroupState,
BpkChipGroupSingleSelectState,
CHIP_GROUP_TYPES,
CHIP_COMPONENT,
} from '../../packages/bpk-component-chip-group';
import BpkText, { TEXT_STYLES } from '../../packages/bpk-component-text/index';
import { cssModules } from '../../packages/bpk-react-utils/index';

import STYLES from './examples.module.scss';

const getClassName = cssModules(STYLES);

const chips = [
{
text: 'London',
},
{
text: 'Berlin',
selected: true,
},
{
text: 'Florence',
},
{
text: 'Stockholm',
},
{
text: 'Copenhagen',
},
{
text: 'Salzburg',
},
{
text: 'Graz',
},
{
text: 'Lanzarote',
},
{
text: 'Valencia',
},
{
text: 'Reykjavik',
},
{
text: 'Tallinn',
},
{
text: 'Sofia',
},
];


export const BpkChipGroupWrapping = () => (
<div className={getClassName('bpk-chip-group-examples__fixed-width')}>
<BpkChipGroupState
type={CHIP_GROUP_TYPES.wrap}
chips={chips}
ariaLabel="Select cities"
/>
</div>
);

export const BpkSingleChipGroupWrapping = () => (
<div>
<BpkChipGroupSingleSelectState
type={CHIP_GROUP_TYPES.wrap}
chips={chips}
initiallySelectedIndex={0}
ariaLabel="Select a city"
/>
</div>
);


export const BpkChipGroupRail = () => (
<div>
<BpkChipGroupState
type={CHIP_GROUP_TYPES.rail}
chips={chips}
ariaLabel="Select cities"
leadingNudgerLabel="Scroll back"
trailingNudgerLabel="Scroll forward"
/>
</div>
);


export const BpkChipGroupSticky = () => {
const stickyChip = {
text: 'Sort & Filter',
}

return (
<div>
<BpkChipGroupState
type={CHIP_GROUP_TYPES.rail}
chips={chips}
stickyChip={stickyChip}
ariaLabel="Select cities"
leadingNudgerLabel="Scroll back"
trailingNudgerLabel="Scroll forward"
/>
</div>
);
};

export const OnContrastChipGroup = () => {
const stickyChip = {
text: 'Sort & Filter',
}

return (
<div className={getClassName('bpk-chip-group-examples__contrast')}>
<BpkChipGroupState
type={CHIP_GROUP_TYPES.rail}
chips={chips}
stickyChip={stickyChip}
chipStyle={CHIP_TYPES.default}
ariaLabel="Select cities"
leadingNudgerLabel="Scroll back"
trailingNudgerLabel="Scroll forward"
/>
</div>
);
};


export const OnDarkChipGroup = () => {
const stickyChip = {
text: 'Sort & Filter',
}

return (
<div className={getClassName('bpk-chip-group-examples__dark')}>
<BpkChipGroupState
type={CHIP_GROUP_TYPES.rail}
chips={chips}
stickyChip={stickyChip}
chipStyle={CHIP_TYPES.onDark}
ariaLabel="Select cities"
leadingNudgerLabel="Scroll back"
trailingNudgerLabel="Scroll forward"
/>
</div>
);
};

export const OnImageChipGroup = () => {
const stickyChip = {
text: 'Sort & Filter',
}

return (
<div className={getClassName('bpk-chip-group-examples__image')}>
<BpkChipGroupState
type={CHIP_GROUP_TYPES.rail}
chips={chips}
stickyChip={stickyChip}
chipStyle={CHIP_TYPES.onImage}
ariaLabel="Select cities"
leadingNudgerLabel="Scroll back"
trailingNudgerLabel="Scroll forward"
/>
</div>
);
};


export const AllChipTypesGroup = () => {
const [dismissed, setDismissed] = useState(false);

const allChips = [
{
text: 'Disabled',
disabled: true,
},
{
text: 'Dismissible',
onClick: () => setDismissed(true),
component: CHIP_COMPONENT.dismissible,
hidden: dismissed,
},
{
text: 'Dropdown',
component: CHIP_COMPONENT.dropdown,
},
{
text: 'Selectable',
},
{
text: 'Initially selected',
selected: true,
},
];

return (
<BpkChipGroupState
chips={allChips}
type={CHIP_GROUP_TYPES.wrap}
ariaLabel="Select chips"
/>
);
};


export const StateManagement = () => {
const [route, setRoute] = useState('flights');

return (
<BpkChipGroup
type={CHIP_GROUP_TYPES.rail}
ariaLabel="Filter your search"
ariaMultiselectable={false}
leadingNudgerLabel="Scroll back"
trailingNudgerLabel="Scroll forward"
chips={[{
text: 'Flights',
selected: route === 'flights',
onClick: () => setRoute('flights'),
}, {
text: 'Car Hire',
selected: route === 'cars',
onClick: () => setRoute('cars'),
}, {
text: 'Hotels',
selected: route === 'hotels',
onClick: () => setRoute('hotels'),
}, {
text: 'Trains',
selected: route === 'trains',
onClick: () => setRoute('trains'),
}, {
component: CHIP_COMPONENT.dropdown,
text: 'More',
accessibilityLabel: 'Show more filter options',
// eslint-disable-next-line no-console
onClick: (selected) => console.log(`Open dropdown: ${selected}`),
}]}
/>
);
};

export const MixedExample = () => (
<div className={getClassName('bpk-chip-group-examples__mixed-container')}>
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
Rail
</BpkText>
<BpkChipGroupRail />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
Rail with sticky chip
</BpkText>
<BpkChipGroupSticky />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
On Contrast
</BpkText>
<OnContrastChipGroup />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
On Dark
</BpkText>
<OnDarkChipGroup />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
On Image
</BpkText>
<OnImageChipGroup />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
Wrapped
</BpkText>
<BpkChipGroupWrapping />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
All chip types
</BpkText>
<AllChipTypesGroup />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
Single Select Group
</BpkText>
<BpkSingleChipGroupWrapping />
<BpkText textStyle={TEXT_STYLES.heading3} tagName="h2">
State example
</BpkText>
<StateManagement />
<br />
</div>
)