Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/next' into package-test-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed May 28, 2024
2 parents 118e5f8 + da22b89 commit 21c6da3
Show file tree
Hide file tree
Showing 108 changed files with 2,679 additions and 1,549 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5
uses: github/codeql-action/init@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
with:
languages: typescript
config-file: ./.github/codeql/codeql-config.yml
Expand All @@ -30,4 +30,4 @@ jobs:
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5
uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3.25.5
uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6
with:
sarif_file: results.sarif
9 changes: 4 additions & 5 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ module.exports = {
// TypeScript declaration files contain no styles.
// Stylelint is also reporting parseError on `docs/types/react-docgen.d.ts`.
'**/*.d.ts',
'docs/.next/**/*',
'docs/export/**/*',
'**/node_modules/**/*',
],
rules: {
'alpha-value-notation': null,
'custom-property-pattern': null,
'declaration-colon-newline-after': null,
'function-parentheses-newline-inside': null, // not compatible with prettier
'media-feature-range-notation': null,
'no-empty-source': null,
'no-missing-end-of-source-newline': null,
'selector-class-pattern': null,
'string-no-newline': null, // not compatible with prettier
'value-keyword-case': null,
'value-list-comma-newline-after': null, // not compatible with prettier
},
overrides: [
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.tsx'],
files: ['**/*.js', '**/*.cjs', '**/*.mjs', '**/*.ts', '**/*.tsx'],
customSyntax: 'postcss-styled-syntax',
},
],
Expand Down
2 changes: 1 addition & 1 deletion apps/pigment-css-next-app/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env node */
// eslint-ignore-next-line import/no-unresolved
const { withPigment } = require('@pigment-css/nextjs-plugin');
const { experimental_extendTheme: extendTheme } = require('@mui/material/styles');
const { extendTheme } = require('@mui/material/styles');

/**
* @typedef {import('@pigment-css/nextjs-plugin').PigmentOptions} PigmentOptions
Expand Down
4 changes: 2 additions & 2 deletions apps/pigment-css-vite-app/src/augment.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { experimental_extendTheme } from '@mui/material/styles';
import type { extendTheme } from '@mui/material/styles';
import '@pigment-css/react/theme';

declare module '@pigment-css/react/theme' {
export interface ThemeArgs {
theme: ReturnType<typeof experimental_extendTheme> & {
theme: ReturnType<typeof extendTheme> & {
applyDarkStyles<T>(obj: T): Record<string, T>;
};
}
Expand Down
4 changes: 2 additions & 2 deletions apps/pigment-css-vite-app/src/extend-zero.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { experimental_extendTheme } from '@mui/material/styles';
import type { extendTheme } from '@mui/material/styles';

declare module '@pigment-css/react/theme' {
interface ThemeArgs {
theme: ReturnType<typeof experimental_extendTheme> & {
theme: ReturnType<typeof extendTheme> & {
applyDarkStyles<T>(obj: T): Record<string, T>;
};
}
Expand Down
2 changes: 1 addition & 1 deletion apps/pigment-css-vite-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig, splitVendorChunkPlugin } from 'vite';
import reactPlugin from '@vitejs/plugin-react';
import Pages from 'vite-plugin-pages';
import { pigment } from '@pigment-css/vite-plugin';
import { experimental_extendTheme as extendTheme } from '@mui/material/styles';
import { extendTheme } from '@mui/material/styles';

const theme = extendTheme({
getSelector: function getSelector(colorScheme, css) {
Expand Down
8 changes: 8 additions & 0 deletions docs/data/about/teamMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,13 @@
"about": "Amateur cook, DIYer, and film photographer",
"github": "KenanYusuf",
"twitter": "KebabYusuf"
},
{
"name": "Nikita Ossei",
"title": "Customer Support",
"location": "London, United Kingdom",
"locationCountry": "uk",
"about": "Astrology ♊️, learning 📚 and designing stuff 🎨",
"github": "nikitaa24"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ChatsPane(props: ChatsPaneProps) {
sx={{
borderRight: '1px solid',
borderColor: 'divider',
height: 'calc(100dvh - var(--Header-height))',
height: { sm: 'calc(100dvh - var(--Header-height))', md: '100dvh' },
overflowY: 'auto',
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Header() {
return (
<Sheet
sx={{
display: { xs: 'flex', sm: 'none' },
display: { sm: 'flex', md: 'none' },
alignItems: 'center',
justifyContent: 'space-between',
position: 'fixed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function MessagesPane(props: MessagesPaneProps) {
return (
<Sheet
sx={{
height: { xs: 'calc(100dvh - var(--Header-height))', lg: '100dvh' },
height: { xs: 'calc(100dvh - var(--Header-height))', md: '100dvh' },
display: 'flex',
flexDirection: 'column',
backgroundColor: 'background.level1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function MyProfile() {
flex: 1,
width: '100%',
mx: 'auto',
pt: { xs: 'var(--Header-height)', sm: 0 },
pt: { xs: 'var(--Header-height)', md: 0 },
display: 'grid',
gridTemplateColumns: {
xs: '1fr',
Expand Down
4 changes: 2 additions & 2 deletions docs/data/joy/integrations/material-ui/material-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Render Joy UI's `CssVarsProvider` inside Material UI's provider and use `THEME

```js
import {
experimental_extendTheme as materialExtendTheme,
Experimental_CssVarsProvider as MaterialCssVarsProvider,
extendTheme as materialExtendTheme,
CssVarsProvider as MaterialCssVarsProvider,
THEME_ID as MATERIAL_THEME_ID,
} from '@mui/material/styles';
import { CssVarsProvider as JoyCssVarsProvider } from '@mui/joy/styles';
Expand Down
7 changes: 1 addition & 6 deletions docs/data/material/components/tabs/BasicTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';

function CustomTabPanel(props) {
Expand All @@ -16,11 +15,7 @@ function CustomTabPanel(props) {
aria-labelledby={`simple-tab-${index}`}
{...other}
>
{value === index && (
<Box sx={{ p: 3 }}>
<Typography>{children}</Typography>
</Box>
)}
{value === index && <Box sx={{ p: 3 }}>{children}</Box>}
</div>
);
}
Expand Down
7 changes: 1 addition & 6 deletions docs/data/material/components/tabs/BasicTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';

interface TabPanelProps {
Expand All @@ -21,11 +20,7 @@ function CustomTabPanel(props: TabPanelProps) {
aria-labelledby={`simple-tab-${index}`}
{...other}
>
{value === index && (
<Box sx={{ p: 3 }}>
<Typography>{children}</Typography>
</Box>
)}
{value === index && <Box sx={{ p: 3 }}>{children}</Box>}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# CSS theme variables - Customization
# CSS theme variables - Configuration

<p class="description">A guide for customizing CSS theme variables in Material UI.</p>
<p class="description">A guide for configuring CSS theme variables in Material UI.</p>

## Theming

`experimental_extendTheme` is an API that extends the default theme. It returns a theme that can only be used by the `Experimental_CssVarsProvider`.
`extendTheme` is an API that extends the default theme. It returns a theme that can only be used by the `CssVarsProvider`.

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

const theme = extendTheme();
// ...custom theme
Expand Down Expand Up @@ -181,7 +178,7 @@ Or use `var()` to refer to the CSS variable directly:
```

:::warning
If you're using a [custom prefix](/material-ui/experimental-api/css-theme-variables/customization/#changing-variable-prefixes), make sure to replace the default `--mui`.
If you're using a [custom prefix](/material-ui/customization/css-theme-variables/configuration/#changing-variable-prefixes), make sure to replace the default `--mui`.
:::

### TypeScript
Expand Down Expand Up @@ -289,7 +286,7 @@ function App() {
}
```

For a server-side application, provide the same value to [`getInitColorSchemeScript()`](/material-ui/experimental-api/css-theme-variables/usage/#server-side-rendering):
For a server-side application, provide the same value to [`getInitColorSchemeScript()`](/material-ui/customization/css-theme-variables/usage/#server-side-rendering):

```js
getInitColorSchemeScript({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ If this is your first time encountering CSS variables, you should check out [the

## Introduction

CSS theme variable support is a new feature in Material UI added in [`v5.6.0`](https://github.com/mui/material-ui/releases/tag/v5.6.0) (but not enabled by default). It tells Material UI components to use the generated CSS theme variables instead of raw values. This provides significant improvements in developer experience related to theming and customization.
With these variables, you can inject a theme into your app's stylesheet _at build time_ to apply the user's selected settings before the whole app is rendered.
CSS theme variables replace raw values in Material UI components for a better developer experience because, in the browser dev tool, you will see which theme token is used as a value.

In addition with these variables, you can inject a theme into your app's stylesheet _at build time_ to apply the user's selected settings before the whole app is rendered.

:::info
The `CssVarsProvider` is built on top of the [`ThemeProvider`](/material-ui/customization/theming/#themeprovider) with extra features like CSS variable generation, storage synchronization, unlimited color schemes, and more.

If you have an existing theme, you can migrate to CSS theme variables by following the [migration guide](/material-ui/migration/migration-css-theme-variables/).
:::

## Advantages

Expand Down Expand Up @@ -60,7 +67,7 @@ const darkTheme = createTheme({
**CSS theme variables**: Light and dark colors are consolidated into a theme.

```js
import { experimental_extendTheme as extendTheme } from '@mui/material/styles';
import { extendTheme } from '@mui/material/styles';

// `extendTheme` is a new API
const theme = extendTheme({
Expand Down Expand Up @@ -117,6 +124,6 @@ extendTheme({

## What's next

- To start a new project with CSS theme variables, check out the [basic usage guide](/material-ui/experimental-api/css-theme-variables/usage/).
- For an existing Material UI project, check out the [migration guide](/material-ui/experimental-api/css-theme-variables/migration/).
- For theming and customization, check out the [how-to guide](/material-ui/experimental-api/css-theme-variables/customization/).
- To start a new project with CSS theme variables, check out the [basic usage guide](/material-ui/customization/css-theme-variables/usage/).
- For an existing Material UI project, check out the [migration guide](/material-ui/migration/migration-css-theme-variables/).
- For theming and customization, check out the [how-to guide](/material-ui/customization/css-theme-variables/configuration/).
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as React from 'react';
import {
experimental_extendTheme as extendTheme,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material/styles';
import { extendTheme, CssVarsProvider } from '@mui/material/styles';
import Button from '@mui/material/Button';

const theme = extendTheme({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as React from 'react';
import {
experimental_extendTheme as extendTheme,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material/styles';
import { extendTheme, CssVarsProvider } from '@mui/material/styles';
import Button from '@mui/material/Button';

const theme = extendTheme({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# CSS theme variables - Usage

<p class="description">Learn how to use the experimental APIs to adopt CSS theme variables.</p>
<p class="description">Learn how to adopt CSS theme variables.</p>

## Getting started

The CSS variables API relies on a new experimental provider for the theme called `Experimental_CssVarsProvider` to inject styles into Material UI components.
In addition to providing the theme in the inner React context, this new provider also generates CSS variables out of all tokens in the theme that are not functions, and makes them available in the context as well.
The CSS variables API relies on a provider called `CssVarsProvider` to inject styles into Material UI components.
`CssVarsProvider` generates CSS variables out of all tokens in the theme that are serializable, and makes them available in the React context along with the theme itself via [`ThemeProvider`](/material-ui/customization/theming/#theme-provider).

Once the `App` renders on the screen, you will see the CSS theme variables in the HTML `:root` stylesheet.
The variables are flattened and prefixed with `--mui` by default:
Expand All @@ -27,17 +27,16 @@ The following demo uses `--md-demo` as a prefix for the variables:

:::info
The `CssVarsProvider` is built on top of the [`ThemeProvider`](/material-ui/customization/theming/#themeprovider) with extra features like CSS variable generation, storage synchronization, unlimited color schemes, and more.

If you have an existing theme, you can migrate to CSS theme variables by following the [migration guide](/material-ui/migration/migration-css-theme-variables/).
:::

## Toggle between light and dark mode

The `useColorScheme` hook lets you read and update the user-selected mode:

```jsx
import {
Experimental_CssVarsProvider as CssVarsProvider,
useColorScheme,
} from '@mui/material/styles';
import { CssVarsProvider, useColorScheme } from '@mui/material/styles';

// ModeSwitcher is an example interface for toggling between modes.
// Material UI does not provide the toggle interface—you have to build it yourself.
Expand Down Expand Up @@ -111,7 +110,7 @@ The structure of this object is nearly identical to the theme structure, the onl
```

:::warning
If you have set up a [custom prefix](/material-ui/experimental-api/css-theme-variables/customization/#changing-variable-prefixes), make sure to replace the default `--mui`.
If you have set up a [custom prefix](/material-ui/customization/css-theme-variables/configuration/#changing-variable-prefixes), make sure to replace the default `--mui`.
:::

## Server-side rendering
Expand Down
12 changes: 10 additions & 2 deletions docs/data/material/customization/theming/theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To promote greater consistency between apps, light and dark theme types are avai

## Theme provider

If you wish to customize the theme, you need to use the `ThemeProvider` component in order to inject a theme into your application.
Use `ThemeProvider` or [`CssVarsProvider`](#css-variables-provider) to inject a custom theme into your application.
However, this is optional; Material UI components come with a default theme.

`ThemeProvider` relies on the [context feature of React](https://react.dev/learn/passing-data-deeply-with-context) to pass the theme down to the components, so you need to make sure that `ThemeProvider` is a parent of the components you are trying to customize.
Expand Down Expand Up @@ -45,7 +45,8 @@ const theme = createTheme({
```

:::warning
`vars` is a private field for [CSS theme variables](/material-ui/experimental-api/css-theme-variables/overview/). It will throw an error if you try to pass a value to it:
`vars` is an autogenerated field for [CSS theme variables](/material-ui/customization/css-theme-variables/overview/).
It will throw an error if you try to pass a value to it:

```jsx
createTheme({
Expand Down Expand Up @@ -114,6 +115,13 @@ You can extend the outer theme by providing a function:

{{"demo": "ThemeNestingExtend.js"}}

## CSS variables provider

The `CssVarsProvider` is built on top of the `ThemeProvider` with extra features like theme CSS variables generation, built-in color scheme synchronization with the user's system preference, and more.
The `CssVarsProvider` is built on top of the `ThemeProvider` with extra features like theme CSS variables generation, built-in color scheme synchronization, user's system preference, and more.

To start using the `CssVarsProvider`, check out the [basic usage guide](/material-ui/customization/css-theme-variables/usage/). If you are using the `ThemeProvider`, read the [migration guide](/material-ui/migration/migration-css-theme-variables/).

## API

### `createTheme(options, ...args) => theme`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,13 @@ You can also check out the Storybook preview to test the Material UI version of
## Using the generated theme

:::warning
Themes generated by Sync must be used with Material UI's [`CssVarsProvider`](/material-ui/experimental-api/css-theme-variables/migration/)—the default [`ThemeProvider`](/material-ui/customization/theming/#theme-provider) is not supported.
Themes generated by Sync must be used with Material UI's [`CssVarsProvider`](/material-ui/migration/migration-css-theme-variables/)—the [`ThemeProvider`](/material-ui/customization/theming/#theme-provider) is not supported.
:::

Here's an example of how to add a Sync-generated theme to your codebase:

```tsx title="_app.tsx"
import {
experimental_extendTheme as extendTheme,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material/styles';
import { extendTheme, CssVarsProvider } from '@mui/material/styles';

export default function MyApp({ Component, pageProps }) {
const theme = extendTheme({
Expand Down
Loading

0 comments on commit 21c6da3

Please sign in to comment.