diff --git a/benchmark/browser/README.md b/benchmark/browser/README.md
index 97b3e69eccdf33..9b73c532d8a380 100644
--- a/benchmark/browser/README.md
+++ b/benchmark/browser/README.md
@@ -16,163 +16,45 @@ You should use these numbers exclusively for comparing performance between diffe
yarn benchmark:browser
noop (baseline):
-
-20.10ms
-20.05ms
-19.28ms
-19.64ms
-20.96ms
-18.80ms
-18.39ms
-20.38ms
-18.85ms
-18.99ms
+mean: 4.70ms, median: 4.72ms
-------------
-Avg: 19.55ms
-Median: 19.46ms
-
-styled-components Box + @material-ui/system:
-
-184.17ms
-161.51ms
-168.84ms
-165.21ms
-163.43ms
-158.10ms
-158.81ms
-297.91ms
-161.25ms
-158.87ms
+React primitives:
+mean: 68.89ms, median: 64.02ms
-------------
-Avg: 177.81ms
-Median: 162.47ms
-
-styled-components Box + styled-system:
-
-142.66ms
-146.55ms
-141.12ms
-141.04ms
-139.45ms
-145.63ms
-141.36ms
-134.98ms
-123.98ms
-146.09ms
+React components:
+mean: 74.38ms, median: 74.46ms
-------------
-Avg: 140.29ms
-Median: 141.24ms
-
-Box emotion:
-
-143.21ms
-135.28ms
-122.53ms
-124.80ms
-143.69ms
-147.81ms
-138.16ms
-124.55ms
-140.32ms
-157.74ms
+Styled Material-UI:
+mean: 109.73ms, median: 109.46ms
-------------
-Avg: 137.81ms
-Median: 139.24ms
-
-Box @material-ui/styles:
-
-146.16ms
-131.37ms
-139.43ms
-158.55ms
-149.54ms
-131.81ms
-134.84ms
-151.08ms
-152.30ms
-130.69ms
+Styled emotion:
+mean: 102.59ms, median: 104.28ms
-------------
-Avg: 142.58ms
-Median: 142.79ms
-
-Box styled-components:
-
-145.59ms
-150.12ms
-179.04ms
-169.63ms
-148.21ms
-155.55ms
-182.55ms
-170.04ms
-153.14ms
-148.92ms
+Styled SC:
+mean: 104.06ms, median: 102.67ms
-------------
-Avg: 160.28ms
-Median: 154.35ms
-
-Basic styled-components box:
-
-141.73ms
-139.71ms
-121.01ms
-120.02ms
-121.81ms
-143.22ms
-135.67ms
-120.85ms
-121.08ms
-120.59ms
+makeStyles:
+mean: 93.81ms, median: 92.90ms
-------------
-Avg: 128.57ms
-Median: 121.44ms
-
-Chakra-UI box component:
-
-147.42ms
-128.51ms
-118.74ms
-110.01ms
-133.05ms
-130.20ms
-121.57ms
-119.11ms
-108.57ms
-134.90ms
+sx Material-UI box:
+mean: 187.98ms, median: 188.77ms
-------------
-Avg: 125.21ms
-Median: 125.04ms
-
-Theme-UI box sx prop:
-
-165.02ms
-141.07ms
-139.19ms
-185.45ms
-166.16ms
-138.83ms
-140.56ms
-139.02ms
-179.26ms
-165.58ms
+Box Material-UI:
+mean: 159.24ms, median: 157.90ms
-------------
-Avg: 156.01ms
-Median: 153.05ms
-
-Theme-UI div sx prop:
-
-131.07ms
-130.84ms
-130.99ms
-132.66ms
-132.24ms
-130.89ms
-131.11ms
-167.10ms
-154.42ms
-131.48ms
+sx Theme-UI box:
+mean: 164.22ms, median: 164.16ms
+-------------
+sx Theme-UI div:
+mean: 153.10ms, median: 152.77ms
+-------------
+Box Chakra-UI:
+mean: 154.95ms, median: 153.89ms
+-------------
+styled-components Box + @material-ui/system:
+mean: 176.82ms, median: 176.60ms
+-------------
+styled-components Box + styled-system:
+mean: 155.18ms, median: 154.63ms
-------------
-Avg: 137.28ms
-Median: 131.30ms
-Done in 31.83s.
```
diff --git a/benchmark/browser/index.js b/benchmark/browser/index.js
index 4bd1f0b727d96c..f997ff05f770e8 100644
--- a/benchmark/browser/index.js
+++ b/benchmark/browser/index.js
@@ -15,7 +15,7 @@ const Component = requirePerfScenarios(scenarioSuitePath).default;
const start = performance.now();
let end;
-function TestCase(props) {
+function Measure(props) {
const ref = React.useRef(null);
React.useLayoutEffect(() => {
@@ -28,20 +28,18 @@ function TestCase(props) {
};
});
- return (
-
Styled system & style functions for building powerful design systems.
+CSS utilities for rapidly creating custom design.
-## Getting Started +Material-UI comes with dozens or **ready-to-use** components in the core. +These components are an incredible starting point but when it comes to making your site stand out with a custom design, it can be simpler to start from an unstyled state. Introducing the system: -`@material-ui/system` provides low-level utility functions called "_style functions_" for building powerful design systems. Some of the key features: +The **system** lets you quickly build custom UI components leveraging the values defined in your theme. -- ⚛️ Access the theme values directly from the component props. -- 🦋 Encourage UI consistency. -- 🌈 Write responsive style effortlessly. -- 🦎 Work with any theme object. -- 💅 Work with the most popular CSS-in-JS solutions. -- 📦 Less than [4 KB gzipped](https://bundlephobia.com/result?p=@material-ui/system). -- 🚀 [Fast enough](https://github.com/mui-org/material-ui/blob/next/packages/material-ui-benchmark/README.md#material-uisystem) not to be a bottleneck at runtime. +## Demo -It's important to understand that this package exposes pure (side-effect free) style functions with this signature: `({ theme, ...style }) => style`, **that's it**. +_(Resize the window to see the responsive breakpoints)_ -### Demo +{{"demo": "pages/system/basics/Demo.js", "bg": true, "defaultCodeOpen": true}} -In the rest of this _Getting Started_ section we are using **styled-components** as the reference example (to emphasize the universality of this package). Alternatively, you can [emotion](#interoperability) or any other CSS-in-JS styling solution. -The demos are also based on the **default** Material-UI [theme object](/customization/default-theme/). - -{{"demo": "pages/system/basics/Demo.js", "defaultCodeOpen": true}} - -### Installation +## Installation ```jsx // with npm @@ -33,311 +23,372 @@ npm install @material-ui/system yarn add @material-ui/system ``` -### Create a component +## Why use the system? + +Compare how the same stat component can be built with two different APIs. + +{{"demo": "pages/system/basics/Why.js", "bg": true, "defaultCodeOpen": false}} -In order to use the `Box` component, you first need to create it. -To start with, add a `spacing` and `palette` function to the style argument. +1. ❌ using the styled-components's API: ```jsx -import styled from 'styled-components'; -import { spacing, palette } from '@material-ui/system'; +const StatWrapper = styled('div')( + ({ theme }) => ` + background-color: ${theme.palette.background.paper}; + box-shadow: ${theme.shadows[1]}; + border-radius: ${theme.shape.borderRadius}px; + padding: ${theme.spacing(2)}; + min-width: 300px; +`, +); + +const StatHeader = styled('div')( + ({ theme }) => ` + color: ${theme.palette.text.secondary}; +`, +); -const Box = styled.div` - ${spacing}${palette} -`; +const StyledTrend = styled(TrendingUpIcon)( + ({ theme }) => ` + color: ${theme.palette.success.dark}; + font-size: 16px; + vertical-alignment: sub; +`, +); + +const StatValue = styled('div')( + ({ theme }) => ` + color: ${theme.palette.text.primary}; + font-size: 34px; + font-weight: ${theme.typography.fontWeightMedium}; +`, +); + +const StatDiff = styled('div')( + ({ theme }) => ` + color: ${theme.palette.success.dark}; + display: inline; + font-weight: ${theme.typography.fontWeightMedium}; + margin-left: ${theme.spacing(0.5)}; + margin-right: ${theme.spacing(0.5)}; +`, +); + +const StatPrevious = styled('div')( + ({ theme }) => ` + color: ${theme.palette.text.secondary}; + display: inline; + font-size: 12px; +`, +); -export default Box; +return ( +The API reference of the @material-ui/system package.
+The properties reference of the @material-ui/system package.
| Group | Import name | Prop | CSS property | Theme key | | :-------------------------------- | :--------------- | :----------------- | :------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------- | diff --git a/docs/translations/translations.json b/docs/translations/translations.json index 5d55c45c7f0107..71abc9e73a3e58 100644 --- a/docs/translations/translations.json +++ b/docs/translations/translations.json @@ -212,9 +212,6 @@ "/components/trap-focus": "Trap Focus", "/components/tree-view": "Tree View", "/api-docs": "Component API", - "/styles": "Styles", - "/styles/basics": "Basics", - "/styles/advanced": "Advanced", "/system": "System", "/system/basics": "Basics", "/system/borders": "Borders", @@ -227,6 +224,10 @@ "/system/spacing": "Spacing", "/system/screen-readers": "Screen Readers", "/system/typography": "Typography", + "/system/properties": "Properties", + "/styles": "Styles", + "/styles/basics": "Basics", + "/styles/advanced": "Advanced", "/customization": "Customization", "/customization/theme": "Theme", "/customization/theming": "Theming", diff --git a/test/regressions/index.js b/test/regressions/index.js index 6e74c96d78175b..a768232f7b89f6 100644 --- a/test/regressions/index.js +++ b/test/regressions/index.js @@ -144,6 +144,9 @@ const blacklist = [ 'docs-production-error', // No components, page for DX 'docs-styles-advanced', // Redudant 'docs-styles-basics/StressTest.png', // Need interaction + 'docs-system-basics/BreakpointsAsArray.png', // Unit tests are enough + 'docs-system-basics/BreakpointsAsObject.png', // Unit tests are enough + 'docs-system-basics/ValueAsFunction.png', // Unit tests are enough 'docs-system-borders', // Unit tests are enough 'docs-system-display', // Unit tests are enough 'docs-system-flexbox', // Unit tests are enough