Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
8b7db60
add Connect-related content on the documentation
danilo-leal Jan 29, 2024
8ab0f54
update content and image
danilo-leal Feb 13, 2024
55d31ba
update border color on dark mode
danilo-leal Feb 13, 2024
7e94a1a
iterate on the Design kits paragraph
danilo-leal Feb 13, 2024
36db8ab
Merge branch 'master' into connect-documentation-content
danilo-leal Feb 13, 2024
8e0ce99
add first skeleton of the documentation
danilo-leal Feb 15, 2024
fbffcd9
run pnpm docs:i18n
danilo-leal Feb 15, 2024
d2885a7
add image to the top of the page
danilo-leal Feb 15, 2024
66ca88b
continue iterating on it
danilo-leal Feb 15, 2024
b902cc1
iterating on the existing tokens section
danilo-leal Feb 16, 2024
119888c
trigger CI checks
danilo-leal Feb 19, 2024
52fba0e
add the Material UI design kit docs
danilo-leal Feb 21, 2024
28a3ff9
Merge branch 'master' into connect-documentation-content
danilo-leal Feb 21, 2024
7c8f7f8
run docs:i18n
danilo-leal Feb 21, 2024
e9a8c44
reordering the pages
danilo-leal Feb 21, 2024
db30f41
run docs:i18n
danilo-leal Feb 21, 2024
6ed171b
remove the MUI prefix from Connect
danilo-leal Feb 28, 2024
7241d3b
remove markdown image element changes from this PR
danilo-leal Feb 28, 2024
6073fb5
run docs:i18n
danilo-leal Feb 28, 2024
b8a9d49
Merge branch 'master' into connect-documentation-content
danilo-leal Feb 28, 2024
917be65
Merge branch 'master' into connect-documentation-content
danilo-leal Mar 1, 2024
0650865
update links to remove the "mui" prefix
danilo-leal Mar 1, 2024
4422995
remove dash from "plugin"
danilo-leal Mar 1, 2024
9d1ce9d
fix error regarding the muiMarkdown import
danilo-leal Mar 4, 2024
a0eaa96
add YouTube videos embeds for the design kits
danilo-leal Mar 4, 2024
bb0dcf0
update Connect images
danilo-leal Mar 4, 2024
b55e401
remove the new chip from the design kit page
danilo-leal Mar 4, 2024
43c6070
iterating on the wording
danilo-leal Mar 8, 2024
c4d320d
Sam's first pass
danilo-leal Mar 25, 2024
63d75a7
Merge branch 'next' into connect-documentation-content
danilo-leal Mar 25, 2024
4821dd4
fix Vale brand name CI check
danilo-leal Mar 25, 2024
e5a6857
Merge branch 'next' into connect-documentation-content
danilo-leal Mar 27, 2024
8000746
add beta chip on the nav drawer item
danilo-leal Mar 28, 2024
baf0238
update the Connect page description
danilo-leal Mar 29, 2024
83ec809
lint: fix non-breaking space
danilo-leal Mar 29, 2024
06f85dc
added getting started section
DavidCnoops Apr 4, 2024
cabb22d
Vale lint: non-breaking space
danilo-leal Apr 4, 2024
8dbe6a2
formatting and adjustments
danilo-leal Apr 4, 2024
5702773
edit the design resources page
danilo-leal Apr 4, 2024
4179064
update to the design kits page
danilo-leal Apr 4, 2024
d22046d
Merge branch 'next' into connect-documentation-content
danilo-leal Apr 4, 2024
0acbe09
Vale lint: fix non-breaking space
danilo-leal Apr 4, 2024
f1d2bce
iterate and fix things on the content + add images
danilo-leal Apr 5, 2024
53b589c
add video about component customization
danilo-leal Apr 5, 2024
e0ea786
extra: fix Demo border styles
danilo-leal Apr 5, 2024
7f6457a
add content about code customizations
danilo-leal Apr 5, 2024
6ffb992
rerun CI checks again
danilo-leal Apr 5, 2024
1199a00
rerun CI checks again
danilo-leal Apr 5, 2024
e549426
Sam's Connect page review
danilo-leal Apr 5, 2024
3d28b19
Sam's review of the Material UI Design Kit page
danilo-leal Apr 5, 2024
bd6f6a6
Design Resources page review
danilo-leal Apr 5, 2024
1891e88
ensure there's non-breaking space
danilo-leal Apr 5, 2024
446741c
follow-up edits
danilo-leal Apr 5, 2024
0198a40
update the Connect page
danilo-leal Apr 8, 2024
f54724a
update the Material UI for Figma page
danilo-leal Apr 9, 2024
31e4bc5
update the Design resources page
danilo-leal Apr 9, 2024
41a8875
slightly revise the Material UI for Figma page
danilo-leal Apr 9, 2024
42f81a0
Vale lint: non-breakable space
danilo-leal Apr 9, 2024
1dfc377
various changes and tweaks
DavidCnoops Apr 9, 2024
53de30a
updated connect docs
DavidCnoops Apr 10, 2024
f2b83d9
updates to the Connect page
danilo-leal Apr 10, 2024
77516db
updates to the Material UI page
danilo-leal Apr 10, 2024
2bc570d
remove unused video
danilo-leal Apr 10, 2024
eee0ae0
compress all images
danilo-leal Apr 10, 2024
33852e8
Vale lint: non-breaking space
danilo-leal Apr 10, 2024
e0f36ee
remove changes on the Demo component
danilo-leal Apr 10, 2024
42050a3
rerun CI checks
danilo-leal Apr 10, 2024
ef9506f
small tweaks
DavidCnoops Apr 11, 2024
27c7b4e
fix linting error
DavidCnoops Apr 11, 2024
dfbee60
has selector clarification + removal of last example
DavidCnoops Apr 11, 2024
34b792a
fix linting error
DavidCnoops Apr 11, 2024
6eac877
Connect page updates
danilo-leal Apr 11, 2024
c2819b5
Material UI for Figma updates
danilo-leal Apr 11, 2024
f891ea5
Design Resources updates
danilo-leal Apr 11, 2024
f41058a
additional edits
danilo-leal Apr 11, 2024
6e53321
Vale lint: non-breakable space
danilo-leal Apr 11, 2024
b3df62e
fine-tune images
danilo-leal Apr 11, 2024
7f47327
Vale lint: non-breakable space
danilo-leal Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
various changes and tweaks
  • Loading branch information
DavidCnoops committed Apr 9, 2024
commit 1dfc37714d37764edf06ddf09a58e8f07b3df55b
115 changes: 70 additions & 45 deletions docs/data/material/design-resources/connect/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
[Connect](https://www.figma.com/community/plugin/1336346114713490235/) is a Figma plugin that lets you generate a theme from the [Material UI for Figma Design Kit](https://www.figma.com/community/file/912837788133317724/material-ui-for-figma-and-mui-x/).
You can customize design tokens and components, export the generated theme as a JSON file, and visualize your customizations through an embedded Storybook instance.

:::info
This plugin is in beta.
Component customization support is currently limited to the Button, Switch, and Typography components.
More components will follow soon!
:::

:::warning
Connect works in combination with the Material UI for Figma Design Kit [v5.16.0 and later](https://github.com/mui/mui-design-kits/releases).
Other kits, such as the Joy UI Design Kit, are not supported yet.
Expand All @@ -32,12 +26,12 @@ Select the Design Kit file.

## Customizing design tokens

Design tokens consist of the styles that are defined through Figma's [local variables](https://help.figma.com/hc/en-us/articles/15145852043927-Create-and-manage-variables) and [local styles](https://help.figma.com/hc/en-us/articles/360039820134-Manage-and-share-styles#:~:text=Local%20styles%20are%20styles%20that,or%20from%20the%20style%20picker.).
Design tokens consist of the reusable styles that are defined through the design kit's [local variable collections](https://help.figma.com/hc/en-us/articles/15145852043927-Create-and-manage-variables) (i.e. palette, breakpoints, shapes & spacing) and [local effect and text styles](https://help.figma.com/hc/en-us/articles/360039820134-Manage-and-share-styles#:~:text=Local%20styles%20are%20styles%20that,or%20from%20the%20style%20picker.) (i.e. elevations and typography).

### Existing tokens
### Altering existing tokens

The Material UI Design Kit comes fully loaded with design tokens that map out to [the default theme of the Material UI React library](/material-ui/customization/default-theme/).
Connect can read all of the existing tokens in the theme.
Connect can read all of the existing tokens present in the design kit, and generate a theme containing all customizations made to these tokens.

To customize them using local variables, open the modal by clicking on the filter icon as shown below.
Tweak any of the variables available there as you see fit.
Expand All @@ -51,73 +45,104 @@ The theme will then be updated in the code editor with your customizations.

### Adding new tokens

You can add custom tokens such as new colors or shadows to the existing list.
After adding them, click on **Regenerate theme** again to see them in the code editor tab.
Next to altering the existing tokens that come out of the box, you can also create your own custom tokens either by creating new variables in the existing local variable collections (i.e. palette, shape, breakpoints, spacing) or by creating new elevation or typography styles.
After you've added your custom tokens, click on **Regenerate theme** again to includes these tokens in your theme.

## Customizing the components
## Customizing components

You can customize how a component looks in all of its variants and states and generate its theme using Connect.
You can customize how a component looks in all of its variants, and generate its theme using Connect. Connect will generate the appropriate theme styles for the customized variants.

:::info
This feature is currently limited to the **Button** and **Switch** components.
:::

:::warning
The default component layer names and hierarchy should not be changed in order for Connect to generate the correct theme output. You can however freely alter all style properties of each layer.
:::

<video controls muted loop width="1584" height="1080" style="border-radius: 12px; border: 1px solid; border-color: hsla(0, 0%, 0%, .1);">
  <source src="/static/material-ui/design-resources/custom-component.mp4" type="video/mp4">
</video>

## Using the generated theme

The code generated by Connect uses [the `CssVarsProvider` API](/material-ui/experimental-api/css-theme-variables/migration/) under the hood.
This primarily impacts you if your project supports both light and dark modes, whereas component customization code should work on your theme regardless of which API you're using because Connect utilizes CSS classes to target component slots.
The theme generated by Connect is meant to be used in combination with Material UI's [`CssVarsProvider`](/material-ui/experimental-api/css-theme-variables/migration/). While using the generated theme together with the default [`ThemeProvider`](/material-ui/customization/theming/#theme-provider) might work in some cases it is not recommended.

### Theme tokens

For example, say you've changed the primary main color in light mode as well as the border-radius value.
This is how your code should be inserted into your theme:
For example, say you've changed the border-radius token by in the design kit altering the `local variable > shape > borderRadius` variable value from 4 to 12.

<img src="/static/material-ui/design-resources/connect-border-radius.png" style="width: 814px" alt="A screenshot of the Connect plugin UI highlighting the Generate theme button." width="1628" height="400" />

This is what the theme generated by Connect will look like:

```js
const theme = extendTheme({
colorSchemes: {
light: {
palette: {
primary: {
main: '#BBDEFB', // example color
},
},
},
},
{
shape: {
borderRadius: 12,
},
});
}
}
```

:::info
The `colorSchemes` node and `extendTheme` function are the only elements particular to the `CssVarsProvider` API.
Remove the former and change the latter to `createTheme` if you're using [the standard `ThemeProvider` API](/material-ui/customization/theming/) instead.
:::
You can then copy this object and paste it into Material UI's [`extendTheme`](https://mui.com/material-ui/experimental-api/css-theme-variables/customization/) function and use the function's output in the `CssVarsProvider` in your app's root component:

```ts
import {
experimental_extendTheme as extendTheme,
Experimental_CssVarsProvider as CssVarsProvider,
} from "@mui/material/styles";

export default function App({ Component, pageProps }) {
const theme = extendTheme({
shape: {
borderRadius: 12,
}
});

return (
<CssVarsProvider theme={theme}>
<Component {...pageProps} />
</CssVarsProvider>
);
}
```

### Component customizations

Next to theme tokens Connect also generates custom component styles (currently limited to the **Button** and **Switch** components).

## Component customizations
For example, imagine you've customized a variant of the Switch component to resemble an iOS switch instead of the default Material Design style.

The code Connect generates for component customizations can be copied and pasted into your theme's `component` node.
For example, imagine you've customized the Switch's track and thumb size.
Here's how you'd add the code to your theme:
<img src="/static/material-ui/design-resources/connect-switch.png" style="width: 814px" alt="A screenshot of a customized Switch component" width="1628" height="400" />

Here's how the theme generated by Connect would look:

```js
const theme = createTheme({
{
components: {
MuiSwitch: {
styleOverrides: {
root: {
'&.MuiSwitch-sizeMedium:has(.MuiSwitch-colorPrimary)': {
'&:has(.Mui-checked):not(:has(.Mui-disabled)):not(:has(.Mui-focusVisible))':
{
width: '40px',
height: '21px',
padding: '0',
'& .MuiSwitch-switchBase': {
transform: 'translateX(20px) translateY(5px)',
transform: 'translateX(19px) translateY(2px)',
padding: '0',
'& .MuiSwitch-thumb': {
width: '15px',
height: '15px',
boxShadow: 'none',
width: '17px',
height: '17px',
background: '#FAFAFA',
},
'& + .MuiSwitch-track': {
height: '20px',
width: '38px',
height: '21px',
borderRadius: '999px',
background: 'var(--mui-palette-success-light)',
opacity: '1',
},
},
},
Expand All @@ -126,15 +151,15 @@ const theme = createTheme({
},
},
},
});
}
```

You can clean it up further by removing all of the `has()` pseudo-classes.
Connect needs those to be able to isolate changes made through Figma, but you might not need it on your code.
Here's the updated code:

```js
const theme = createTheme({
const theme = extendTheme({
components: {
MuiSwitch: {
styleOverrides: {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.