Skip to content
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

[Material You] Add theme structure & Button component #34650

Merged
merged 66 commits into from Nov 21, 2022

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Oct 7, 2022

What's the PR about

This is a proof of concept of how we can add support for Material You incrementally without introducing breaking changes (see #29345) and at the same time allow the new components to co-exist in an environment where @mui/material is used. This would mean that we would support both Material Design 2 and Material Design 3 in parallel. In a future major release, we can then drop the support for MD2.

👉 Playground link (inspired by #29345 (comment))
👉 Default theme showcase link - it should work without using CssVarsProvider
👉 Showcase of coexisting with @mui/material (Material Design 2) link

Implementation details

This POC uses a new factory for creating a Material Design 3 theme. It adds behind the scenes a new useMaterialYou flag, and adds the necessary design tokens for the new design systems (the palette values are added under under palette.md3, and all other tokens are under the md3 key so that we can avoid conflicts with the existing theme).

Usage

import * as React from 'react';
import { extendTheme, CssVarsProvider } from '@mui/material-next/styles';
import Button from '@mui/material-next/Button';

// Default MD3 theme
const theme= extendTheme();

// Or with custom palette
const theme= extendTheme({
    colorSchemes: {
      light: {
        ref: { 
          palette: { md3: palette }
        },
      },
      dark: {
        ref: { 
          palette: { md3: palette }
        },
      }
    }
  });

function App() {
  return (
    <CssVarsProvider  theme={theme}>
      <Button variant="filledTonal">MD 3 button</Button>
    </CssVarsProvider>
  );
}

@mnajdova mnajdova added design: material This is about Material Design, please involve a visual or UX designer in the process proof of concept Studying and/or experimenting with a to be validated approach labels Oct 7, 2022
@mui-bot
Copy link

mui-bot commented Oct 7, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-34650--material-ui.netlify.app/

@material-ui/core: parsed: +0.05% , gzip: +0.05%
@mui/material-next: parsed: -17.13% 😍, gzip: -14.97% 😍

Details of bundle changes

Generated by 🚫 dangerJS against b9dd876

@mnajdova mnajdova changed the title [POC] Add createMD3Theme creator v2 [POC] Add support for Material You (add new component) Oct 12, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 19, 2022
@@ -34,6 +34,8 @@ export type SupportedColorScheme = DefaultColorScheme | ExtendedColorScheme;
export interface Opacity {
inputPlaceholder: number;
inputUnderline: number;
switchTrackDisabled: number;
Copy link
Member Author

Choose a reason for hiding this comment

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

TypeScript found this missing keys.

import useThemeProps from '../styles/useThemeProps';
import useTheme from '../styles/useTheme';
import { getPaperUtilityClass } from './paperClasses';

// Inspired by https://github.com/material-components/material-components-ios/blob/bca36107405594d5b7b16265a5b0ed698f85a5ee/components/Elevation/src/UIColor%2BMaterialElevation.m#L61
export const getOverlayAlpha = (elevation) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed to be used in the extendTheme in @mui/material-next so it was extracted and exported.

@siriwatknp
Copy link
Member

siriwatknp commented Oct 25, 2022

how do we specify components css vars

I would not add all of the variables defined in the specs yet until we see them useful.

is the theme structured fine?

In long term, I'd say no. We should follow the m3 design specs to leverage their design tools, e.g. the Material Theme Builder (figma plugin) that generates tokens. If we have the theme structure close to their spec, I think we will have less unknown work from our side.

in general any other suggestions you may have

I am writing my thought in the discussion. I will post the link here when it is done.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

🤩 I'm pumped!

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

I don't have any remarks about Base usage. Just a tiny optimization/readability opportunity.

packages/mui-material-next/src/Button/Button.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Sweet, this is looking great⎯awesome work! Aside from the missing letter spacing declarations in a few of the text styles, there's nothing really standing out for me. I do wish though that the Playground demo would follow the same layout as in the Material 3 Figma file, just for the sake of ease of comparison as I think a bunch of folks will do the back & forth.

Screen Shot 2022-11-21 at 02 31 06

packages/mui-material-next/src/styles/typescale.ts Outdated Show resolved Hide resolved
packages/mui-material-next/src/styles/typescale.ts Outdated Show resolved Hide resolved
packages/mui-material-next/src/styles/typescale.ts Outdated Show resolved Hide resolved
Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Signed-off-by: Marija Najdova <mnajdova@gmail.com>
@mnajdova
Copy link
Member Author

Sweet, this is looking great⎯awesome work! Aside from the missing letter spacing declarations in a few of the text styles, there's nothing really standing out for me. I do wish though that the Playground demo would follow the same layout as in the Material 3 Figma file, just for the sake of ease of comparison as I think a bunch of folks will do the back & forth.

The main reason why I didn't structure it like this, is because most of the items in figma are dependent on some interactions, like hover, focused etc. I guess we can think a bit more about how we want to document these components in a follow-up PR. We need to somehow fit them with the rest of the docs.

@mnajdova mnajdova changed the title [POC] Add support for Material You (add new component) [Material You] Add theme structure & Button component Nov 21, 2022
@mnajdova mnajdova mentioned this pull request Nov 21, 2022
1 task
@mnajdova mnajdova merged commit fe3dc18 into mui:master Nov 21, 2022
alexfauquette pushed a commit to alexfauquette/material-ui that referenced this pull request Nov 22, 2022
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
@mnajdova mnajdova added design: material you and removed design: material This is about Material Design, please involve a visual or UX designer in the process labels Nov 30, 2022
feliperli pushed a commit to jesrodri/material-ui that referenced this pull request Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design: material you proof of concept Studying and/or experimenting with a to be validated approach
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants