@czi-sds/mcp 0.20.2 → 0.21.0
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/data/component-docs/Autocomplete.md +2 -14
- package/data/component-docs/Chip.md +160 -0
- package/data/component-docs/NavigationFooter.md +13 -13
- package/data/component-docs/NavigationHeader.md +26 -26
- package/data/component-docs/PreComposedTable.md +9 -27
- package/data/component-docs/ProteinStructureViewer.md +9 -0
- package/data/component-docs/Table.md +9 -31
- package/data/component-docs/Tabs.md +1 -6
- package/data/component-docs/Tag.md +357 -200
- package/data/component-docs/index.json +5 -5
- package/data/component-list.json +1 -0
- package/data/component-props/Button.json +6 -6
- package/data/component-props/Chip.json +30 -0
- package/data/component-props/Dropdown.json +6 -6
- package/data/component-props/InputSlider.json +5 -5
- package/data/component-props/LoadingIndicator.json +6 -6
- package/data/component-props/Menu.json +74 -0
- package/data/component-props/NavigationFooter.json +2 -2
- package/data/component-props/NavigationHeader.json +2 -2
- package/data/component-props/Notification.json +5 -5
- package/data/component-props/PreComposedTable.json +9 -9
- package/data/component-props/ProteinStructureViewer.json +21 -16
- package/data/component-props/Tag.json +41 -20
- package/data/component-props/TagFilter.json +0 -2
- package/data/component-props/TagLegacy.json +40 -0
- package/data/component-props/Tooltip.json +5 -5
- package/data/component-props/TooltipTable.json +5 -5
- package/package.json +2 -2
- package/data/component-docs/TagFilter.md +0 -131
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# TagFilter
|
|
2
|
-
|
|
3
|
-
## Source Code
|
|
4
|
-
|
|
5
|
-
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/TagFilter/index.tsx).
|
|
6
|
-
|
|
7
|
-
## Import
|
|
8
|
-
|
|
9
|
-
**React TypeScript**
|
|
10
|
-
|
|
11
|
-
```tsx
|
|
12
|
-
import { TagFilter } from "@czi-sds/components";
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Code examples
|
|
16
|
-
|
|
17
|
-
### Default TagFilter
|
|
18
|
-
|
|
19
|
-
A row of applied filters, each removing itself from the page's state through `onDelete`. The row is a named group, which gives the identical "Delete Tag" buttons some context.
|
|
20
|
-
|
|
21
|
-
**Example: DefaultTagFilter**
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
// TagFilter is the tag that comes off: onDelete is required, and removing the tag
|
|
25
|
-
// from your own state is what makes it disappear. Everything about how it looks is
|
|
26
|
-
// fixed (the accent fill, the square shape, and the small X), so there are no
|
|
27
|
-
// style props to pass.
|
|
28
|
-
//
|
|
29
|
-
// Both the tag and its X are focusable, so each filter is two tab stops: Backspace
|
|
30
|
-
// or Delete on the tag removes it, and so does Enter on the X.
|
|
31
|
-
|
|
32
|
-
import {
|
|
33
|
-
TagFilter,
|
|
34
|
-
fontBodyXs,
|
|
35
|
-
getSemanticColors,
|
|
36
|
-
getSpaces,
|
|
37
|
-
type CommonThemeProps,
|
|
38
|
-
} from "@czi-sds/components";
|
|
39
|
-
import styled from "@emotion/styled";
|
|
40
|
-
import { useState } from "react";
|
|
41
|
-
|
|
42
|
-
const FILTERS = ["Homo sapiens", "Lung", "10x 3' v3", "Healthy"];
|
|
43
|
-
|
|
44
|
-
const Row = styled.div<CommonThemeProps>`
|
|
45
|
-
${(props) => {
|
|
46
|
-
const spaces = getSpaces(props);
|
|
47
|
-
|
|
48
|
-
return `
|
|
49
|
-
display: flex;
|
|
50
|
-
flex-wrap: wrap;
|
|
51
|
-
gap: ${spaces?.s}px;
|
|
52
|
-
margin-bottom: ${spaces?.m}px;
|
|
53
|
-
min-height: 28px;
|
|
54
|
-
`;
|
|
55
|
-
}}
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
const Readout = styled.p<CommonThemeProps>`
|
|
59
|
-
${fontBodyXs}
|
|
60
|
-
|
|
61
|
-
${(props) => {
|
|
62
|
-
const semanticColors = getSemanticColors(props);
|
|
63
|
-
|
|
64
|
-
return `
|
|
65
|
-
color: ${semanticColors?.base?.textSecondary};
|
|
66
|
-
margin: 0;
|
|
67
|
-
`;
|
|
68
|
-
}}
|
|
69
|
-
`;
|
|
70
|
-
|
|
71
|
-
function App() {
|
|
72
|
-
const [filters, setFilters] = useState(FILTERS);
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<div className="app">
|
|
76
|
-
<Row aria-label="Applied filters" role="group">
|
|
77
|
-
{filters.map((filter) => (
|
|
78
|
-
<TagFilter
|
|
79
|
-
key={filter}
|
|
80
|
-
label={filter}
|
|
81
|
-
onDelete={() =>
|
|
82
|
-
setFilters((current) => current.filter((item) => item !== filter))
|
|
83
|
-
}
|
|
84
|
-
/>
|
|
85
|
-
))}
|
|
86
|
-
</Row>
|
|
87
|
-
|
|
88
|
-
<Readout>
|
|
89
|
-
{filters.length > 0
|
|
90
|
-
? `${filters.length} of ${FILTERS.length} filters applied`
|
|
91
|
-
: "No filters applied"}
|
|
92
|
-
</Readout>
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export default App;
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## SDS vs MUI
|
|
101
|
-
|
|
102
|
-
TagFilter is built on the SDS Tag, and so on MUI's Chip, but it exists for one job: showing which Filters are applied and letting them be taken off again. It has one appearance and no style props:
|
|
103
|
-
|
|
104
|
-
- **onDelete is required.** MUI treats it as the switch that decides whether a chip can be deleted; here the delete control is always there, so the handler has to be. Removing the tag from your own state is what makes it disappear.
|
|
105
|
-
|
|
106
|
-
- **The look is fixed:** the accent fill, the square shape, the small semibold label and the 12px X. Tag's `sdsStyle`, `sdsType`, `sdsSize` and `color` are not part of the type, and MUI's `variant` is not either.
|
|
107
|
-
|
|
108
|
-
- **The X cannot be swapped:** SDS applies its own `deleteIcon` (an SDS Button holding the XMark icon) after your props, so a `deleteIcon` of your own is ignored without a warning.
|
|
109
|
-
|
|
110
|
-
## MUI Documentation
|
|
111
|
-
|
|
112
|
-
Documentation for the underlying MUI component can be found [here](https://mui.com/material-ui/react-chip/).
|
|
113
|
-
|
|
114
|
-
## Behavior and accessibility
|
|
115
|
-
|
|
116
|
-
- There are two ways to remove a filter, and both are reachable from the keyboard: the X is a button that answers Enter, and the tag itself answers Backspace and Delete. That also means each filter tag is two tab stops.
|
|
117
|
-
|
|
118
|
-
- The X button is named "Delete Tag" on every filter tag, and the name cannot be changed. The label beside it is read as plain text rather than as part of the button, so a row of filters is worth wrapping in a group with a name of its own, to say what the buttons are removing. The example below uses `role="group"` with an `aria-label`.
|
|
119
|
-
|
|
120
|
-
- The tag carries `role="none presentation"`, so it contributes no semantics of its own. Adding an `onClick` does not change that: the tag becomes clickable to the pointer while still announcing nothing, so leave the clicking to the X.
|
|
121
|
-
|
|
122
|
-
- Like a Tag, a filter tag does not wrap: a long filter value is cut off with an ellipsis. Keep the values short, or shorten them yourself so the part that survives is the part that matters.
|
|
123
|
-
|
|
124
|
-
## Props
|
|
125
|
-
|
|
126
|
-
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
127
|
-
|
|
128
|
-
| Name | Type | Default | Description |
|
|
129
|
-
| ---------- | ---------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
130
|
-
| `label` | `string` | - (required) | The filter's text. Cut off with an ellipsis when there is not room for it. |
|
|
131
|
-
| `onDelete` | `function` | - (required) | Runs when the X is clicked or activated, and when Backspace or Delete is pressed on the tag. Drop the filter from your state here; the component does not remove itself. **Signature:** `function(event: SyntheticEvent) => void` |
|