-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/python-3-12
- Loading branch information
Showing
58 changed files
with
2,166 additions
and
2,092 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
import FiltersRow from '../filters-row/filters-row'; | ||
import { nodeListRowHeight } from '../../../config'; | ||
import LazyList from '../../lazy-list'; | ||
import { getDataTestAttribute } from '../../../utils/get-data-test-attribute'; | ||
|
||
import './filters-group.scss'; | ||
|
||
/** A group collection of FiltersRow */ | ||
const FiltersGroup = ({ items = [], group, collapsed, onItemChange }) => ( | ||
<LazyList | ||
height={(start, end) => (end - start) * nodeListRowHeight} | ||
total={items.length} | ||
> | ||
{({ start, end, listRef, listStyle }) => ( | ||
<ul | ||
ref={listRef} | ||
style={listStyle} | ||
className={classnames('filters-group', { | ||
'filters-group--closed': collapsed, | ||
})} | ||
> | ||
{items.slice(start, end).map((item) => ( | ||
<FiltersRow | ||
allUnchecked={group.allUnchecked} | ||
checked={item.checked} | ||
container={'li'} | ||
count={item.count} | ||
dataTest={getDataTestAttribute('node-list-row', 'filter-row')} | ||
id={item.id} | ||
offIndicatorIcon={item.invisibleIcon} | ||
key={item.id} | ||
kind={group.kind} | ||
label={item.highlightedLabel} | ||
name={item.name} | ||
onChange={(e) => onItemChange(e, item)} | ||
onClick={(e) => onItemChange(e, item)} | ||
parentClassName={'node-list-filter-row'} | ||
visible={item.visible} | ||
indicatorIcon={item.visibleIcon} | ||
/> | ||
))} | ||
</ul> | ||
)} | ||
</LazyList> | ||
); | ||
|
||
export default FiltersGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@use '../../../styles/variables' as var; | ||
@use '../../node-list-tree/styles/variables'; | ||
|
||
.filters-group { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0 0 1.2em; | ||
|
||
// Avoid placeholder fade leaking out for small lists | ||
overflow: hidden; | ||
|
||
&--closed { | ||
display: none; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/components/filters/filters-group/filters-group.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import FiltersGroup from './filters-group'; | ||
import { mockState, setup } from '../../../utils/state.mock'; | ||
import { getNodeTypes } from '../../../selectors/node-types'; | ||
import { getGroupedNodes } from '../../../selectors/nodes'; | ||
import { getGroups } from '../../../selectors/filtered-node-list-items'; | ||
|
||
describe('FiltersGroup Component', () => { | ||
const mockProps = () => { | ||
const items = getGroupedNodes(mockState.spaceflights); | ||
const nodeTypes = getNodeTypes(mockState.spaceflights); | ||
const groups = getGroups({ nodeTypes, items }); | ||
return { group: groups['tags'], items: [] }; | ||
}; | ||
|
||
it('renders without throwing', () => { | ||
expect(() => setup.mount(<FiltersGroup {...mockProps()} />)).not.toThrow(); | ||
}); | ||
it('adds class when collapsed prop true', () => { | ||
const wrapper = setup.mount( | ||
<FiltersGroup {...mockProps()} collapsed={true} /> | ||
); | ||
const children = wrapper.find('.filters-group'); | ||
expect(children.hasClass('filters-group--closed')).toBe(true); | ||
}); | ||
|
||
it('removes class when collapsed prop false', () => { | ||
const wrapper = setup.mount( | ||
<FiltersGroup {...mockProps()} collapsed={false} /> | ||
); | ||
const children = wrapper.find('.filters-group'); | ||
expect(children.hasClass('filters-group--closed')).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
import IndicatorIcon from '../../icons/indicator'; | ||
import OffIndicatorIcon from '../../icons/indicator-off'; | ||
import { ToggleControl } from '../../ui/toggle-control/toggle-control'; | ||
import { RowText } from '../../ui/row-text/row-text'; | ||
|
||
import './filters-row.scss'; | ||
|
||
const FiltersRow = ({ | ||
allUnchecked, | ||
checked, | ||
children, | ||
container: ContainerWrapper, | ||
count, | ||
dataTest, | ||
id, | ||
indicatorIcon = IndicatorIcon, | ||
kind, | ||
label, | ||
name, | ||
offIndicatorIcon = OffIndicatorIcon, | ||
onChange, | ||
onClick, | ||
parentClassName, | ||
visible, | ||
}) => { | ||
const Icon = checked ? indicatorIcon : offIndicatorIcon; | ||
|
||
return ( | ||
<ContainerWrapper | ||
className={classnames( | ||
'filter-row kedro', | ||
`filter-row--kind-${kind}`, | ||
parentClassName, | ||
{ | ||
'filter-row--visible': visible, | ||
'filter-row--unchecked': !checked, | ||
} | ||
)} | ||
title={name} | ||
> | ||
<RowText | ||
kind={kind} | ||
dataTest={dataTest} | ||
onClick={onClick} | ||
name={children ? null : name} | ||
label={label} | ||
/> | ||
<span onClick={onClick} className={'filter-row__count'}> | ||
{count} | ||
</span> | ||
<ToggleControl | ||
allUnchecked={allUnchecked} | ||
className={'filter-row__icon'} | ||
IconComponent={Icon} | ||
id={id} | ||
isChecked={checked} | ||
kind={kind} | ||
name={name} | ||
onChange={onChange} | ||
/> | ||
{children} | ||
</ContainerWrapper> | ||
); | ||
}; | ||
|
||
export default FiltersRow; |
Oops, something went wrong.