-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[material-ui][docs] Add Connect-related content #40848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danilo-leal
merged 78 commits into
mui:next
from
danilo-leal:connect-documentation-content
Apr 12, 2024
Merged
Changes from 60 commits
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 8ab0f54
update content and image
danilo-leal 55d31ba
update border color on dark mode
danilo-leal 7e94a1a
iterate on the Design kits paragraph
danilo-leal 36db8ab
Merge branch 'master' into connect-documentation-content
danilo-leal 8e0ce99
add first skeleton of the documentation
danilo-leal fbffcd9
run pnpm docs:i18n
danilo-leal d2885a7
add image to the top of the page
danilo-leal 66ca88b
continue iterating on it
danilo-leal b902cc1
iterating on the existing tokens section
danilo-leal 119888c
trigger CI checks
danilo-leal 52fba0e
add the Material UI design kit docs
danilo-leal 28a3ff9
Merge branch 'master' into connect-documentation-content
danilo-leal 7c8f7f8
run docs:i18n
danilo-leal e9a8c44
reordering the pages
danilo-leal db30f41
run docs:i18n
danilo-leal 6ed171b
remove the MUI prefix from Connect
danilo-leal 7241d3b
remove markdown image element changes from this PR
danilo-leal 6073fb5
run docs:i18n
danilo-leal b8a9d49
Merge branch 'master' into connect-documentation-content
danilo-leal 917be65
Merge branch 'master' into connect-documentation-content
danilo-leal 0650865
update links to remove the "mui" prefix
danilo-leal 4422995
remove dash from "plugin"
danilo-leal 9d1ce9d
fix error regarding the muiMarkdown import
danilo-leal a0eaa96
add YouTube videos embeds for the design kits
danilo-leal bb0dcf0
update Connect images
danilo-leal b55e401
remove the new chip from the design kit page
danilo-leal 43c6070
iterating on the wording
danilo-leal c4d320d
Sam's first pass
danilo-leal 63d75a7
Merge branch 'next' into connect-documentation-content
danilo-leal 4821dd4
fix Vale brand name CI check
danilo-leal e5a6857
Merge branch 'next' into connect-documentation-content
danilo-leal 8000746
add beta chip on the nav drawer item
danilo-leal baf0238
update the Connect page description
danilo-leal 83ec809
lint: fix non-breaking space
danilo-leal 06f85dc
added getting started section
DavidCnoops cabb22d
Vale lint: non-breaking space
danilo-leal 8dbe6a2
formatting and adjustments
danilo-leal 5702773
edit the design resources page
danilo-leal 4179064
update to the design kits page
danilo-leal d22046d
Merge branch 'next' into connect-documentation-content
danilo-leal 0acbe09
Vale lint: fix non-breaking space
danilo-leal f1d2bce
iterate and fix things on the content + add images
danilo-leal 53b589c
add video about component customization
danilo-leal e0ea786
extra: fix Demo border styles
danilo-leal 7f6457a
add content about code customizations
danilo-leal 6ffb992
rerun CI checks again
danilo-leal 1199a00
rerun CI checks again
danilo-leal e549426
Sam's Connect page review
danilo-leal 3d28b19
Sam's review of the Material UI Design Kit page
danilo-leal bd6f6a6
Design Resources page review
danilo-leal 1891e88
ensure there's non-breaking space
danilo-leal 446741c
follow-up edits
danilo-leal 0198a40
update the Connect page
danilo-leal f54724a
update the Material UI for Figma page
danilo-leal 31e4bc5
update the Design resources page
danilo-leal 41a8875
slightly revise the Material UI for Figma page
danilo-leal 42f81a0
Vale lint: non-breakable space
danilo-leal 1dfc377
various changes and tweaks
DavidCnoops 53de30a
updated connect docs
DavidCnoops f2b83d9
updates to the Connect page
danilo-leal 77516db
updates to the Material UI page
danilo-leal 2bc570d
remove unused video
danilo-leal eee0ae0
compress all images
danilo-leal 33852e8
Vale lint: non-breaking space
danilo-leal e0f36ee
remove changes on the Demo component
danilo-leal 42050a3
rerun CI checks
danilo-leal ef9506f
small tweaks
DavidCnoops 27c7b4e
fix linting error
DavidCnoops dfbee60
has selector clarification + removal of last example
DavidCnoops 34b792a
fix linting error
DavidCnoops 6eac877
Connect page updates
danilo-leal c2819b5
Material UI for Figma updates
danilo-leal f891ea5
Design Resources updates
danilo-leal f41058a
additional edits
danilo-leal 6e53321
Vale lint: non-breakable space
danilo-leal b3df62e
fine-tune images
danilo-leal 7f47327
Vale lint: non-breakable space
danilo-leal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,298 @@ | ||
| # Connect plugin | ||
|
|
||
| <p class="description">Connect is a Figma plugin that generates Material UI themes directly from design to code.</p> | ||
|
|
||
| ## Introduction | ||
|
|
||
| [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/). | ||
| Customize the Design Kit's tokens and components, and run the Connect plugin to generate a theme ready for use in your Material UI based projects. | ||
|
|
||
| :::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 yet supported. | ||
| ::: | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect.png" style="width: 814px;" alt="Customizing the Material UI Switch component in Figma with the Connect plugin running." width="1628" height="400" /> | ||
|
|
||
| ## Running the plugin | ||
|
|
||
| If you don't have [the complete and latest](/store/items/figma-react/) Material UI Design Kit version installed, you can test the plugin by using [the Community version](https://www.figma.com/community/file/912837788133317724/material-ui-for-figma-and-mui-x/) instead. | ||
|
|
||
| After installing it, open the Design Kit file in Figma. | ||
| Then head over to [the Connect plugin page](https://www.figma.com/community/plugin/1336346114713490235/) on Figma's Community tab and click on **Open in...** and select the Material UI for Figma Design Kit. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-access.png" style="width: 814px;" alt="Accessing Connect via the Resources menu in Figma." width="1628" height="400" /> | ||
|
|
||
| ## Customizing design tokens | ||
|
|
||
| The Design Kit's design tokens are defined in the [local variable collections](https://help.figma.com/hc/en-us/articles/15145852043927-Create-and-manage-variables) for color palettes, breakpoints, shapes & spacing tokens, and in [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.) for shadow and typography tokens. You can freely alter or extend these tokens to customize the look and feel of your design system, and use Connect to generate a theme containing your customizations. | ||
|
|
||
| ### 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/). | ||
|
|
||
| To customize tokens defined by Figma variables, open the local variables modal by clicking on the filter icon as shown below. | ||
| Tweak any of the variables available in the various collections (palette, breakpoints, shapes & spacing) as you see fit. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-variables.png" style="width: 814px; margin-bottom: 8px;" alt="The Locals variables menu in Figma, where all design tokens are stored and new ones can be added." width="1628" height="400" /> | ||
danilo-leal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Then open the Connect plugin and click on **Generate theme**. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-generate.png" style="width: 814px" alt="The Generate theme button in the Connect plugin UI." width="1628" height="400" /> | ||
|
|
||
| A theme containing the altered tokens is generated and displayed in the plugin's **Theme** tab. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-code-editor.png" style="width: 814px" alt="The generated theme displayed in the Connect plugin UI." width="1628" height="400" /> | ||
|
|
||
| Preview the generated theme and your customized tokens by navigating to the **Storybook preview** tab. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-storybook.png" style="width: 814px" alt="The generated theme previewed in Storybook in the Connect plugin UI." width="1628" height="400" /> | ||
|
|
||
| ### Adding new tokens | ||
|
|
||
| You can also extend the existing tokens with your own by either adding new variables to the existing local variable collections, or by adding new elevation and typography styles. | ||
| After you've added your custom tokens, click on **Regenerate theme** to includes these tokens in your theme. | ||
danilo-leal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <img src="/static/material-ui/design-resources/connect-regenerate.png" style="width: 814px" alt="The 'Regenerate button' in the Connect plugin UI." width="1628" height="400" /> | ||
danilo-leal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Customizing components | ||
|
|
||
| Connect can also generate theme styles for customized components. This feature is currently limited to the **Button** and **Switch** components. Support for more components will follow soon. | ||
|
|
||
| :::warning | ||
| Please note that the Desing Kit's component layer hierarchy and layer names should remain unaltered in order for Connect to correctly extract the custom component styles and generate a theme for them. | ||
| ::: | ||
|
|
||
| <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> | ||
|
|
||
| You can customize components by changing the look and feel of component variants in the Desing Kit. | ||
|
|
||
| Each variant represents a specific version of a component defined by its variant properties (e.g. color, size, state, ...). These properties map to Material UI props and states. For example, the `Checked=True, Size=Medium, Color=Primary, State=Enabled` Switch variant in Figma maps to `<Switch color="primary" size="medium" checked={true} disabled={false} />` in Material UI. | ||
|
|
||
| ### Customizing component variants | ||
|
|
||
| In the example below we've customized the `Checked=True, Size=Medium, Color=Primary, State=Enabled` variant of the Switch component to look like an iOS switch. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-component-variant.png" style="width: 814px" alt="A specific variant of the Switch component selected in the Design Kit" width="1628" height="400" /> | ||
|
|
||
| Connect will generate the following theme: | ||
|
|
||
| ```js | ||
| { | ||
| 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(19px) translateY(2px)', | ||
| padding: '0', | ||
| '& .MuiSwitch-thumb': { | ||
| width: '17px', | ||
| height: '17px', | ||
| background: '#FAFAFA', | ||
| }, | ||
| '& + .MuiSwitch-track': { | ||
| width: '38px', | ||
| height: '21px', | ||
| background: 'var(--mui-palette-success-light)', | ||
| opacity: '1', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| ``` | ||
|
|
||
| As you can see, the generated theme targets the class names matching the specific variant we've altered in Figma. As we've only customized one variant in Figma the resulting theme will only apply our iOS style when the Switch component props and state exactly match those of the customized variant. | ||
|
|
||
| In order to deal with all the states the Switch can be in we have to alter the sibling variants in Figma as well. For example, let's say we fully want to customize Switch component of size `medium` and color `primary`. To do so we have to alter the style of the following variants in Figma: | ||
|
|
||
| - `Checked=True, Size=Medium, Color=Primary, State=Enabled` | ||
| - `Checked=False, Size=Medium, Color=Primary, State=Enabled` | ||
| - `Checked=True, Size=Medium, Color=Primary, State=Hovered` | ||
| - `Checked=False, Size=Medium, Color=Primary, State=Hovered` | ||
| - `Checked=True, Size=Medium, Color=Primary, State=Disabled` | ||
| - `Checked=False, Size=Medium, Color=Primary, State=Disabled` | ||
| - `Checked=True, Size=Medium, Color=Primary, State=Focused` | ||
| - `Checked=False, Size=Medium, Color=Primary, State=Focused` | ||
|
|
||
| To efficiently do this, you can: | ||
|
|
||
| 1. Start by customizing a single 'base' variant (e.g. `Checked=True, Size=Medium, Color=Primary, State=Enabled`). | ||
| 2. Clone this variant and rename it to target the next variant you'd like to customize (e.g. rename the cloned version of `Checked=True, Size=Medium, Color=Primary, State=Enabled` to `Checked=False, Size=Medium, Color=Primary, State=Enabled`) | ||
| 3. Delete the old, now duplicate version of this variant (e.g. delete the original `Checked=False, Size=Medium, Color=Primary, State=Enabled` variant). | ||
| 4. Move the new version of the variant to the correct square in the variant grid | ||
| 5. Make the necessary style adjustments to the variant's child layers. | ||
|
|
||
| Repeat this process for each variant you want to customize. Below you can see what the result can look like. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-switch-component-customized.png" style="width: 814px" alt="A fully customized Switch component in the Design Kit" width="1628" height="400" /> | ||
|
|
||
| Now you can go ahead and run Connect to generate a new theme. For the example shown above the theme will look like this: | ||
|
|
||
| ```js | ||
| { | ||
| components: { | ||
| MuiSwitch: { | ||
| styleOverrides: { | ||
| root: { | ||
| "&.MuiSwitch-sizeMedium:has(.MuiSwitch-colorPrimary)": { | ||
| width: "40px", | ||
| height: "21px", | ||
| padding: "0", | ||
| "& .MuiSwitch-switchBase": { | ||
| padding: "0", | ||
| "& .MuiSwitch-thumb": { | ||
| width: "17px", | ||
| height: "17px", | ||
| background: "#FAFAFA", | ||
| }, | ||
| "& + .MuiSwitch-track": { | ||
| width: "38px", | ||
| height: "21px", | ||
| }, | ||
| }, | ||
| "&:not(:has(.Mui-checked)):not(:has(.Mui-disabled)):not(:has(.Mui-focusVisible))": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(3px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| background: "#BDBDBD", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| "&:not(:has(.Mui-checked)):has(.Mui-disabled):not(:has(.Mui-focusVisible))": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(3px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| background: "rgba(229, 229, 229, 0.99)", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| "&:not(:has(.Mui-checked)):not(:has(.Mui-disabled)):has(.Mui-focusVisible)": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(3px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| border: "1px solid #000", | ||
| background: "#BDBDBD", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| "&:has(.Mui-checked):has(.Mui-disabled):not(:has(.Mui-focusVisible))": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(19px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| background: "rgba(187, 231, 188, 0.99)", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| "&:not(:has(.Mui-checked)):not(:has(.Mui-disabled)):not(:has(.Mui-focusVisible)):hover": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(3px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| background: "#616161", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| "&:has(.Mui-checked):not(:has(.Mui-disabled)):not(:has(.Mui-focusVisible))": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(19px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| background: "var(--mui-palette-success-light)", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| "&:has(.Mui-checked):not(:has(.Mui-disabled)):not(:has(.Mui-focusVisible)):hover": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(19px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| background: "var(--mui-palette-success-dark)", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| "&:has(.Mui-checked):not(:has(.Mui-disabled)):has(.Mui-focusVisible)": | ||
| { | ||
| "& .MuiSwitch-switchBase": { | ||
| transform: "translateX(19px) translateY(2px)", | ||
| "& + .MuiSwitch-track": { | ||
| border: "1px solid #000", | ||
| background: "var(--mui-palette-success-light)", | ||
| opacity: "1", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| ``` | ||
|
|
||
| Finally you can check out the Storybook preview to test the Material UI version of your component. | ||
|
|
||
| <img src="/static/material-ui/design-resources/connect-switch-component-customized-storybook.png" style="width: 814px" alt="A fully customized Switch component in Storybook" width="1628" height="400" /> | ||
danilo-leal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Using the generated theme | ||
|
|
||
| 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/). Material UI's default [`ThemeProvider`](/material-ui/customization/theming/#theme-provider) is currently not supported. | ||
|
|
||
| :::info | ||
| Use Material UI's [CssVarsProvider](/material-ui/experimental-api/css-theme-variables/migration/) to load a theme generated by Connect. | ||
| ::: | ||
|
|
||
| An example of using a theme generated theme by Connect in your frontend codebase: | ||
|
|
||
| ```ts | ||
| // Your app's root component | ||
| import { | ||
| experimental_extendTheme as extendTheme, | ||
| Experimental_CssVarsProvider as CssVarsProvider, | ||
| } from "@mui/material/styles"; | ||
|
|
||
| export default function MyApp({ Component, pageProps }) { | ||
| // the theme object generated by Connect | ||
| const copiedConnectTheme = { | ||
| shape: { | ||
| borderRadius: 12, | ||
| } | ||
| }; | ||
|
|
||
| const theme = extendTheme(copiedConnectTheme); | ||
|
|
||
| return ( | ||
| <CssVarsProvider theme={theme}> | ||
| <Component {...pageProps} /> | ||
| </CssVarsProvider> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Feedback and bug reports | ||
|
|
||
| Use [the dedicated Connect feedback board](https://mui-connect.canny.io/feedback) to share feedback, report bugs, or drop feature requests. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.