Skip to content

Commit

Permalink
Refactor row toggle/label CSS, and fix row hover icon bug (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwestenra authored Jan 27, 2021
1 parent fb9b791 commit 6d5b64b
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 305 deletions.
66 changes: 38 additions & 28 deletions src/components/node-list/node-list-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,43 @@ export const getSections = createSelector(() =>
}))
);

/**
* Create a new group of items. This can be one of two kinds:
* 'filter': Categories, e.g. tags
* 'element': Graph elements, e.g. nodes, datasets, or parameters
* An item is a node-list row, e.g. a node or a tag.
* @param {object} itemType Meta information about the group's items
* @param {array} itemsOfType List of items in the group
*/
export const createGroup = (itemType, itemsOfType = []) => {
const group = {
type: itemType,
id: itemType.id,
count: itemsOfType.length,
allUnset: itemsOfType.every(item => item.unset),
allChecked: itemsOfType.every(item => item.checked)
};

if (itemType.id === 'tag') {
Object.assign(group, {
name: 'Tags',
kind: 'filter',
checked: !group.allUnset,
visibleIcon: group.allChecked ? IndicatorIcon : IndicatorPartialIcon,
invisibleIcon: IndicatorOffIcon
});
} else {
Object.assign(group, {
name: itemType.name,
kind: 'element',
checked: !itemType.disabled,
visibleIcon: VisibleIcon,
invisibleIcon: InvisibleIcon
});
}
return group;
};

/**
* Returns groups of items per type
* @param {array} types List of node types
Expand All @@ -196,36 +233,9 @@ export const getGroups = createSelector(
(nodeTypes, items) => {
const groups = {};
const itemTypes = [...nodeTypes, { id: 'tag' }];

for (const itemType of itemTypes) {
const itemsOfType = items[itemType.id] || [];

groups[itemType.id] = {
type: itemType,
id: itemType.id,
name: itemType.name,
kind: 'toggle',
visibleIcon: VisibleIcon,
invisibleIcon: InvisibleIcon,
checked: !itemType.disabled,
count: itemsOfType.length,
allUnset: itemsOfType.every(item => item.unset),
allChecked: itemsOfType.every(item => item.checked)
};

if (itemType.id === 'tag') {
const group = groups[itemType.id];

Object.assign(group, {
name: 'Tags',
kind: 'filter',
checked: !group.allUnset,
visibleIcon: group.allChecked ? IndicatorIcon : IndicatorPartialIcon,
invisibleIcon: IndicatorOffIcon
});
}
groups[itemType.id] = createGroup(itemType, items[itemType.id]);
}

return groups;
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/node-list/node-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('NodeList', () => {
const rows = () =>
wrapper
.find(
'.pipeline-nodelist__group--kind-toggle .pipeline-nodelist__list--nested'
'.pipeline-nodelist__group--kind-element .pipeline-nodelist__list--nested'
)
.find('.pipeline-nodelist__row');
const rowName = row =>
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('NodeList', () => {
const elements = wrapper =>
wrapper
.find(
'.pipeline-nodelist__group--kind-toggle .pipeline-nodelist__list--nested'
'.pipeline-nodelist__group--kind-element .pipeline-nodelist__list--nested'
)
.find('.pipeline-nodelist__row')
.map(row => [
Expand Down
127 changes: 0 additions & 127 deletions src/components/node-list/styles/_filter.scss

This file was deleted.

79 changes: 79 additions & 0 deletions src/components/node-list/styles/_row-label.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@import '../../../styles/extends';
@import '../../../styles/mixins';
@import '../../../styles/variables';
@import './variables';

.pipeline-nodelist__row__text {
display: flex;
align-items: center;
width: 100%;
padding: $row-padding-y $row-offset-right $row-padding-y $row-offset-left;
color: inherit;
font-size: inherit;
font-family: inherit;
letter-spacing: inherit;
text-align: inherit;
background: none;
border: none;
border-radius: 0;
box-shadow: none;
cursor: default;
user-select: none;

&:focus {
outline: none;
box-shadow: 0 0 0 4px $color-link inset;

[data-whatintent='mouse'] & {
box-shadow: none;
}
}
}

.pipeline-nodelist__row__label {
overflow: hidden;
font-size: 1.48em;
white-space: nowrap;
text-overflow: ellipsis;

&--faded {
opacity: 0.65;
}

&--disabled {
opacity: 0.3;
}

b {
color: var(--color-nodelist-highlight);
font-weight: normal;
}

i {
display: inline-block;
margin-left: 0.45em;
font-weight: normal;
font-style: normal;
}
}

.pipeline-nodelist__row--unchecked {
// Fade row text when unchecked
.pipeline-nodelist__row__label--kind-filter {
opacity: 0.55;
}

// Brighter row text when unchecked and hovered
&:hover {
.pipeline-nodelist__row__label--kind-filter {
opacity: 0.8;
}
}

// Bright row text when all unset
.pipeline-nodelist__group--all-unset & {
.pipeline-nodelist__row__label--kind-filter {
opacity: 1;
}
}
}
Loading

0 comments on commit 6d5b64b

Please sign in to comment.