Repository navigation
Conversation
2c935fe to
c6ded63
Compare
Oli-Jones475
left a comment
There was a problem hiding this comment.
The component and tests look good! It will need to be rebased onto main though and the component should be moved (or copied) into the workflows-ui module since its for dashboard-2. Storybooks havent been set up in that moudle yet which is why copying it without the storybook might be a good idea
JamesDoingStuff
left a comment
There was a problem hiding this comment.
I haven't looked through the tests or tried using this yet, so I might have yet have more comments, but there's a few in the code to be getting on with
There was a problem hiding this comment.
Would this documentation be better in the storybook, so that it's accessible for users?
c6ded63 to
000e2c2
Compare
|
Oli, thanks! I've updated the branch with main and copied TemplateFilter and its tests into workflows-ui, leaving Storybook in workflows-lib-shared for now. |
Thank you! Sorry for the nit pick but could we have TemplateFilter.tsx in lib/components/templates instead of lib/components/common. Same thing applies to the test file (tests/components/templates instead of tests/components) Thank you! |
bf77e4a to
86510c5
Compare
86510c5 to
bfa9780
Compare
|
I am leaving until it's running fine in workflows-lib-share, then I will move to workflows-ui. |
JamesDoingStuff
left a comment
There was a problem hiding this comment.
Couple things to tidy up in the code, plus:
- I think it would be better to add this solely to
workflows-ui, which is where we want this component to live long-term. AddingTemplateFilter.stories.tsxtoworkflows-uibefore #1854 shouldn't cause any issues and theworkflows-lib-sharedstorybook isn't shown anywhere anyway, so it wouldn't be any better. If there's a reason it must be added to both, then theworkflows-uicopy also needs updating for everything I've reviewed thus far (I've only put comments on theworkflows-lib-sharedone to avoid repeating myself) - Commit messages need a bit of tidying:
- We should be consistent with commit scope, especially for
featorfix, as those show up in the changelog - I would suggest the component name in PascalCase e.g.feat(TemplateFilter) - Commits should only modify one package - split up changes to
workflows-uiandworkflows-lib-shared - Messages should be useful for people reading the changelog, so shouldn't reference things like review feedback
- It's a little bit fuzzier, but I think I like the idea of calling storybook commits
docs(RelevantComponent)to make it clear that it it's not actual component code. It means each new component should have afeat, atestand adocscommit. Open to pushback on this though.
- We should be consistent with commit scope, especially for
| label, | ||
| emptyLabel = "All ", | ||
| filterValues, | ||
| selectedTemplates, |
There was a problem hiding this comment.
Please can selectedTemplates be renamed too?
| {filterValues.map((template) => ( | ||
| <MenuItem key={template} value={template}> | ||
| <Checkbox | ||
| checked={selectedTemplates.includes(template)} | ||
| size="small" | ||
| /> | ||
| <ListItemText primary={template} /> |
There was a problem hiding this comment.
References to templates here should also be renamed
| const StoryTheme = ({ | ||
| children, | ||
| mode, | ||
| }: { | ||
| children: React.ReactNode; | ||
| mode: "light" | "dark"; | ||
| }) => { | ||
| return ( | ||
| <ThemeProvider theme={DiamondDSTheme}> | ||
| <ThemeMode mode={mode}>{children}</ThemeMode> | ||
| </ThemeProvider> | ||
| ); | ||
| }; | ||
|
|
||
| const ThemeMode = ({ | ||
| children, | ||
| mode, | ||
| }: { | ||
| children: React.ReactNode; | ||
| mode: "light" | "dark"; | ||
| }) => { | ||
| const { setMode } = useColorScheme(); | ||
|
|
||
| useEffect(() => { | ||
| setMode(mode); | ||
|
|
||
| // Synchronise Diamond Design System CSS variables. | ||
| document.documentElement.setAttribute("data-mode", mode); | ||
| }, [mode, setMode]); | ||
|
|
||
| return <>{children}</>; | ||
| }; | ||
|
|
||
| const meta: Meta<typeof TemplateFilter> = { | ||
| title: "TemplateFilter", | ||
| component: TemplateFilter, | ||
| decorators: [ | ||
| (Story, context) => { | ||
| console.log("Diamond mode:", context.globals.diamondMode); | ||
|
|
||
| return ( | ||
| <StoryTheme | ||
| mode={context.globals.diamondMode === "dark" ? "dark" : "light"} | ||
| > | ||
| <Story /> | ||
| </StoryTheme> | ||
| ); | ||
| }, | ||
| ], | ||
| }; |
There was a problem hiding this comment.
In #1854 I've included some code I pinched from SciReactUI that they use for dark/light mode switching in stories, so if that gets merged then this could be removed. The SRU version defines a decorator that gets used for all stories, rather than a component-specific one like this
| | `templates` | `string[]` | Available options displayed in the dropdown. | | ||
| | `selectedTemplates` | `string[]` | Currently selected values, controlled by the parent. | |
There was a problem hiding this comment.
Need to be updated to new names
| MenuProps={{ | ||
| PaperProps: { | ||
| sx: { | ||
| bgcolor: "background.paper", | ||
| color: "text.primary", | ||
| }, | ||
| }, | ||
| }} | ||
| sx={{ | ||
| bgcolor: "background.paper", | ||
| color: "text.primary", | ||
|
|
||
| "& .MuiSelect-select": { | ||
| color: "text.primary", | ||
| }, | ||
|
|
||
| "& .MuiSelect-icon": { | ||
| color: "text.primary", | ||
| }, | ||
| }} |
There was a problem hiding this comment.
I think Select, Paper and Menu should already be styled like this, so this shouldn't be necessary - perhaps it's just the storybook that lacks the Diamond theming? If so, that should be fixed by #1854
|
|
||
| ## Selection behaviour | ||
|
|
||
| The dropdown supports multiple selections without displaying checkboxes. |
There was a problem hiding this comment.
As discussed in https://diamondlightsource.slack.com/archives/C06N43M7JP3/p1795077722627219, please can we keep tests and stories with components? If you feel otherwise we can discuss
| component: TemplateFilter, | ||
| decorators: [ | ||
| (Story, context) => { | ||
| console.log("Diamond mode:", context.globals.diamondMode); |
There was a problem hiding this comment.
Debugging message?
| filterValues, | ||
| selectedTemplates, | ||
| onChange, | ||
| variant = "outlined", |
There was a problem hiding this comment.
What is the expected behaviour for the different variants? In my testing, standard makes the filter box shrink to the text height and filled/outlined just seem to affect the alignment of the text.
Also, it would also be good if the stories showed the variants
| } from "@diamondlightsource/sci-react-ui"; | ||
| import { TemplateFilter, type TemplateFilterProps } from "../lib/main"; | ||
|
|
||
| const templates = [ |
There was a problem hiding this comment.
Also needs renaming
Analysis PlatformAP-1408
Summary
Implemented a reusable multi-select filter component using MUI Select, following the Figma design.
Added configurable labels, compact selection counts, and Clear all functionality.
Implemented controlled state through props, keeping the component independent of GraphQL, Apollo, and Relay.
Added Storybook examples and component documentation.
Testing
Added unit tests covering selection, deselection, multiple selections, Clear all, and controlled state.
All 10 component tests passing.
Verified the shared library builds successfully.