Skip to content

Add Stratakit MUI components (WIP)#204

Open
alexdunae wants to merge 78 commits into
mainfrom
alex/imodelgrid-mui
Open

Add Stratakit MUI components (WIP)#204
alexdunae wants to merge 78 commits into
mainfrom
alex/imodelgrid-mui

Conversation

@alexdunae
Copy link
Copy Markdown
Contributor

@alexdunae alexdunae commented May 20, 2026

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/mui with aliases, so consumers can try them by swapping their import path (and then updating any necessary types).

import { ITwinGrid, type ITwinGridProps } from "@itwin/imodel-browser-react/mui";

TODO

  • Improve I18n
  • Consistent thumbnail positioning
  • Fix fallback thumbnails - rendered differently currently
  • Maybe rename iTwinActions and iModelActions to contextMenuItems
  • Do we need a replacement for isNew and fullWidth?
  • Table views
  • Verify icons on top of different colour thumbnails / backgrounds
  • Switch to more-horizontal icon when available
  • Tests

Comment thread packages/modules/imodel-browser/src/components/baseCard/BaseCard.module.scss Outdated
@kckst8
Copy link
Copy Markdown
Collaborator

kckst8 commented Jun 1, 2026

@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)

@aruniverse
Copy link
Copy Markdown
Member

@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

@alexdunae alexdunae marked this pull request as ready for review June 4, 2026 18:35
@alexdunae alexdunae requested a review from mayank99 June 4, 2026 18:35
Copy link
Copy Markdown
Collaborator

@mayank99 mayank99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 103 to +108
"@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",
Copy link
Copy Markdown
Collaborator

@mayank99 mayank99 Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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} />;
Copy link
Copy Markdown
Collaborator

@mayank99 mayank99 Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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} />;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about color.

);
return thumbnail ? (
<CardMedia
component="img"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component prop should not to be used. Use render instead.


return (
<>
<IconButton
Copy link
Copy Markdown
Collaborator

@mayank99 mayank99 Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing label. See docs.

{
borderColor:
status === "positive"
? "success.main"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kebbn see this note - not sure how to reconcile with the design

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • it makes sense to map everything to the semantic --stratakit-color tokens, 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>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heading variant without render prop again.

alignItems: "center",
position: "relative",
aspectRatio: "16 / 10",
backgroundColor: "var(--stratakit-mui-palette-action-hover)",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

@mayank99 mayank99 Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.`,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an anti-pattern. onClick is the anti-pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants