Add Stratakit MUI components (WIP)#204
Conversation
It is pinned to @typescript-eslint/parser 5.x and blocks us from upgrading Typescript. The whole CRA project is deprecated anyways https://github.com/react/create-react-app/blob/main/packages/eslint-config-react-app/package.json We also remove eslint-plugin-flowtype since we don't use Flow at all
|
@aruniverse since this PR adds new components without modifying existing, can we publish a new minor after merge? We need to consume this version in our July release (by next Friday) |
Sure, this repo auto publishes after merges into master based on the change files |
mayank99
left a comment
There was a problem hiding this comment.
There are way too many issues in this PR. I spent just a few minutes looking at it and already spotted over a dozen different problems. If I keep going, I'd find even more. I don't want to overwhelm you with even more comments though.
I'd suggest reading the StrataKit docs before you use anything from @stratakit/mui or @mui/material. If anything is unclear from our docs, please ask us questions by opening discussions. We're here to teach you how to use StrataKit (and MUI) correctly.
| "@itwin/itwinui-react": "~3.17.3", | ||
| "@mui/material": "~9.0.0", | ||
| "@mui/system": "~9.0.0", | ||
| "@mui/x-data-grid": "~9.3.0", | ||
| "@stratakit/icons": "~0.3.1", | ||
| "@stratakit/mui": "~0.4.1", |
There was a problem hiding this comment.
All of these (including iTwinUI) should use ^ instead of ~, otherwise you're blocking future updates to these packages for no good reason.
Also, I don't believe you need @mui/system.
|
|
||
| const icon = selected ? svgCheckmark : svgItwin; | ||
|
|
||
| return <Icon href={icon} size="regular" color={color} />; |
There was a problem hiding this comment.
The color SVG attribute does nothing here. You want to use the color CSS property, as documented.
|
|
||
| const icon = selected ? svgCheckmark : svgImodel; | ||
|
|
||
| return <Icon href={icon} size="regular" color={color} />; |
There was a problem hiding this comment.
Same comment about color.
| ); | ||
| return thumbnail ? ( | ||
| <CardMedia | ||
| component="img" |
There was a problem hiding this comment.
component prop should not to be used. Use render instead.
|
|
||
| return ( | ||
| <> | ||
| <IconButton |
| { | ||
| borderColor: | ||
| status === "positive" | ||
| ? "success.main" |
There was a problem hiding this comment.
This is accessing the MUI colors using the sx prop. You should instead be using the --stratakit-color variables in CSS.
| size="small" | ||
| sx={[ | ||
| (theme) => ({ | ||
| bgcolor: muted ? theme.palette.grey[300] : theme.palette.grey[400], |
There was a problem hiding this comment.
This is accessing the raw MUI palette using the theme.palette. This is no better than hardcoding hex codes. You should instead be using the semantic --stratakit-color tokens.
In this case though, I would argue all these overrides are unnecessary. This is diverging significantly from the design system. As I've said elsewhere, the Card doesn't currently support placing items in the corner. I'd recommend opening an issue with your use cases. Until then, there are other ways to show secondary actions, as documented.
There was a problem hiding this comment.
@kebbn see this note - not sure how to reconcile with the design
There was a problem hiding this comment.
- it makes sense to map everything to the semantic
--stratakit-colortokens, can add this to the next design QA pass. - in terms of placing items in the corner, does that refer to position:absolute ThumbnailIconButton containers on top of the thumbnail image? We currently have two of those in the existing iModelTile that I see used in current products, so would consider that the bare minimum for applications to accept migration
| title={ | ||
| <Skeleton variant="text"> | ||
| {/* TODO: i18n */} | ||
| <Typography variant="h5">Skeleton Name</Typography> |
There was a problem hiding this comment.
heading variant without render prop again.
| alignItems: "center", | ||
| position: "relative", | ||
| aspectRatio: "16 / 10", | ||
| backgroundColor: "var(--stratakit-mui-palette-action-hover)", |
There was a problem hiding this comment.
This is using (and misusing) the mui palette colors again, and I would again argue that most of these overrides are unnecessary and breaking away from the design system.
There was a problem hiding this comment.
As a general rule, you should not need a large amount of styles in most places. The design system should take care of 80% of styles. If you're overriding a lot of styles, it's a sign you're doing something wrong.
For the styles that are legitimately necessary, I would also recommend moving them into .css files so it's easy to keep track of them in one place. Inlining them in JS makes it harder to maintain and easier for mistakes to slip through. (this might be personal preference ultimately)
|
|
||
| if (actions?.length === 1) { | ||
| console.warn( | ||
| `Having a single 'actions' item is a design antipattern. Consider using the 'onClick' prop instead of 'actions' for a single action button.`, |
There was a problem hiding this comment.
This is not an anti-pattern. onClick is the anti-pattern.
Note this branch is based on #202
Posted here for previewing and early review. I can split out some other smaller PRs later.
I tried to strike a balance between keeping the existing API surface while also using MUI idioms.
All these components are exposed via
imodel-browser-react/muiwith aliases, so consumers can try them by swapping their import path (and then updating any necessary types).TODO
iTwinActionsandiModelActionstocontextMenuItemsisNewandfullWidth?more-horizontalicon when available