New ChipTabGroup component should be implemented, to support the selection panel layout updates. Said component should handle group switching, and styles, but it will not contain the implementation of full metrics selection and lists. That will be handled in separate issue.
As part of this issue assets/js/components/SelectionPanel/SelectionPanelItems.js should be used as a starting point for creating a key metrics specific SelectionPanelItems which will be rendering the ChipTabGroup component instead of the current markdown. A new story for the said SelectionPanelItems should be added, to visually test and develop new component. It shouldn't replace the usage of generic SelectionPanelItems in this issue.
Basic group filtering should be implemented as part of this issue
As part of this issue only ChipTabGroup component within new key metrics specific selection panel items is added, together with the stories, excluding "new" badge implementation. It should support group chip switching only (filtering all KMW items by the active group), rest of the functionality, and implementation of new panel will come in later issue
Implementation Brief
Follow the figma design while implementing the following components
metricItems - an array of metric item objects to render. This component is not concerned with filtering, and active group selection logic, it will only receive final list that should be output.
Wrap the markup with main div.googlesitekit-chip-tab-group__tab-item for example
Iterate over metricItems and render MetricItem component for each item, passing the needed props
It should accept following prop for now (rest of the logic will be implemented in 9385):
allMetricItems - will hold the array of metric objects retrieved from KEY_METRICS_WIDGETS list
Define a new group variable for Current selection, following the same structure how other existing groups are defined, for example {SLUG: 'currentSelection', LABEL: 'Current selection'}
Define a local state that will be used to update active group, and active value will be passed to the Chip component. By default Current selection slug should be used as initial value.
Define a callback which will be passed to the Chip component as onClick prop. It should accept a group slug as argument and update the local active state
Filter the allMetricItems prop by the group property, only the items which fulfil this criteria item.group === active should be returned, and assigned to a new variable, say activeMetricItems
The resulting activeMetricItems will be passed to the TabGroup component as the metricItems prop
Define selectedCount variable, for now assign it value 0 - this functionality will be implemented as part of the 9385
Wrap the markup in main div with class googlesitekit-chip-tab-group for example
Collect all ACR groups added in 9376, with Current selection being the first item in the array, and other groups should follow the order from the design.
Iterate over this list of groups, and render Chip component for each item, using the current group as group prop, and other props previously defined above
Feature Description
New
ChipTabGroup
component should be implemented, to support the selection panel layout updates. Said component should handle group switching, and styles, but it will not contain the implementation of full metrics selection and lists. That will be handled in separate issue.As part of this issue
assets/js/components/SelectionPanel/SelectionPanelItems.js
should be used as a starting point for creating a key metrics specificSelectionPanelItems
which will be rendering theChipTabGroup
component instead of the current markdown. A new story for the saidSelectionPanelItems
should be added, to visually test and develop new component. It shouldn't replace the usage of genericSelectionPanelItems
in this issue.Basic group filtering should be implemented as part of this issue
Check New Metric Grouping Logic Within Sidebar/Selection Panel - Tabbed Functionality section and more particularly
Implementation of tabbed containers and tab functionality
sub-section of the design docDo not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
ChipTabGroup
component is createdCurrent selection
group chip will be listing the selected items, functionality will be expanded on in 9385 , so for now it can display an empty list.SelectionPanelItems
component is also added to render theChipTabGroup
componentImplementation of tabbed containers and tab functionality
sub-section of the design docChipTabGroup
component within new key metrics specific selection panel items is added, together with the stories, excluding "new" badge implementation. It should support group chip switching only (filtering all KMW items by the active group), rest of the functionality, and implementation of new panel will come in later issueImplementation Brief
Add
assets/js/components/KeyMetrics/ChipTabGroup/Chip.js
group
, which will hold the group object -{SLUG: '...', LABEL: '...'}
active
, a boolean valueselectedCount
, number of selected metric items from the current group, if any.onClick
, a callback function. It should accept group slug as an argument, so it can switch the active group in the parent's component stateButton
component with classgooglesitekit-chip-tab-group__chip-item
for examplegroup.LABEL
for label.selectedCount
value astrailingIcon
prop. You can wrap it inspan
and pass the value within parentheses()
onClick
prop, pass theonClick
callback prop, including thegroup.SLUG
as an argumentactive
prop matches the currentgroup.SLUG
, render an extra class in the button, for examplegooglesitekit-chip-tab-group__chip-item--active
assets/sass/components/key-metrics/_googlesitekit-chip-tab-group.scss
to include needed styling for bothChip
andTabGroup
componentsAdd
assets/js/components/KeyMetrics/ChipTabGroup/TabGroup.js
metricItems
- an array of metric item objects to render. This component is not concerned with filtering, and active group selection logic, it will only receive final list that should be output.div.googlesitekit-chip-tab-group__tab-item
for examplemetricItems
and renderMetricItem
component for each item, passing the needed propsAdd
assets/js/components/KeyMetrics/ChipTabGroup/index.js
allMetricItems
- will hold the array of metric objects retrieved fromKEY_METRICS_WIDGETS
listCurrent selection
, following the same structure how other existing groups are defined, for example{SLUG: 'currentSelection', LABEL: 'Current selection'}
active
value will be passed to theChip
component. By defaultCurrent selection
slug should be used as initial value.Chip
component asonClick
prop. It should accept a group slug as argument and update the localactive
stateallMetricItems
prop by thegroup
property, only the items which fulfil this criteriaitem.group === active
should be returned, and assigned to a new variable, sayactiveMetricItems
activeMetricItems
will be passed to theTabGroup
component as themetricItems
propselectedCount
variable, for now assign it value0
- this functionality will be implemented as part of the 9385div
with classgooglesitekit-chip-tab-group
for exampleCurrent selection
being the first item in the array, and other groups should follow the order from the design.Chip
component for each item, using the current group asgroup
prop, and other props previously defined aboveAdd
assets/js/components/KeyMetrics/SelectionPanelItems.js
assets/js/components/SelectionPanel/SelectionPanelItems.js
as a starting pointChipTabGroup
component instead of the current markup.KEY_METRICS_WIDGETS
for theallMetricItems
propTest Coverage
assets/js/components/SelectionPanel/SelectionPanelItems.js
component, which should render the new selection panel layoutQA Brief
Changelog entry