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-ui] Export Pigment CSS layout components #42693

Merged
merged 28 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3a23222
export pigment layout components
siriwatknp Jun 20, 2024
2f14862
reexport layout components
siriwatknp Jun 20, 2024
24ed402
poc with latest pigment
siriwatknp Jun 20, 2024
088e088
restore
siriwatknp Jun 24, 2024
8ab5f8a
Merge branch 'next' of https://github.com/mui/material-ui into pigmen…
siriwatknp Jun 24, 2024
c8cb8fb
[docs-infra] support mulitple entrypoints
siriwatknp Jun 24, 2024
2bf53cf
run docs:api
siriwatknp Jun 24, 2024
79b5dd2
update pigment to latest
siriwatknp Jun 24, 2024
9a5882f
add PigmentGrid
siriwatknp Jun 24, 2024
fe622f5
add layout component demo pages
siriwatknp Jun 24, 2024
865e815
ignore PigmentContainer, PigmentGrid, and PigmentStack
siriwatknp Jun 24, 2024
646a3c3
test windows fix
siriwatknp Jun 25, 2024
9bc2fad
add classes
siriwatknp Jun 25, 2024
050ac80
add specs
siriwatknp Jun 25, 2024
7ef300d
run docs:api
siriwatknp Jun 25, 2024
9e75c6a
add 'grow' to grid size
siriwatknp Jun 25, 2024
f8d6b16
Merge branch 'next' of https://github.com/mui/material-ui into pigmen…
siriwatknp Jun 25, 2024
3d4a775
Revert "test windows fix"
siriwatknp Jun 25, 2024
2053947
update to latest pigment css
siriwatknp Jun 25, 2024
8b7be98
link PigmentGrid API to Grid2
siriwatknp Jun 25, 2024
661b5d4
Merge branch 'next' of https://github.com/mui/material-ui into pigmen…
siriwatknp Jun 26, 2024
ac919fa
add useDefaultProps
siriwatknp Jun 26, 2024
823aae0
remove use client from demo pages
siriwatknp Jun 26, 2024
5c828bc
fix
siriwatknp Jun 26, 2024
362e233
Revert "add useDefaultProps"
siriwatknp Jun 26, 2024
6cd978a
ignore Pigment layout components
siriwatknp Jun 26, 2024
146f943
remove useDefaultProps from PigmentGrid
siriwatknp Jun 26, 2024
e66f40d
run proptypes and docs:api
siriwatknp Jun 27, 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
2 changes: 1 addition & 1 deletion apps/local-ui-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "0.0.1",
"private": true,
"dependencies": {
"@pigment-css/react": "^0.0.13"
"@pigment-css/react": "https://pkg.csb.dev/mui/pigment-css/commit/59a9ad43/@pigment-css/react"
}
}
4 changes: 2 additions & 2 deletions apps/pigment-css-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"clean": "rimraf .next"
},
"dependencies": {
"@pigment-css/react": "^0.0.13",
"@pigment-css/react": "https://pkg.csb.dev/mui/pigment-css/commit/59a9ad43/@pigment-css/react",
"@mui/utils": "workspace:^",
"@mui/base": "workspace:^",
"@mui/lab": "workspace:^",
Expand All @@ -24,7 +24,7 @@
"next": "latest"
},
"devDependencies": {
"@pigment-css/nextjs-plugin": "^0.0.14",
"@pigment-css/nextjs-plugin": "https://pkg.csb.dev/mui/pigment-css/commit/59a9ad43/@pigment-css/nextjs-plugin",
"@types/node": "^20.5.7",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.3.0",
Expand Down
172 changes: 92 additions & 80 deletions apps/pigment-css-next-app/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Image from 'next/image';
import { styled, css } from '@pigment-css/react';
import PigmentStack from '@mui/material/PigmentStack';
import PigmentContainer from '@mui/material/PigmentContainer';
import PigmentHidden from '@mui/material/PigmentHidden';
import styles from './page.module.css';

const visuallyHidden = css({
Expand Down Expand Up @@ -91,92 +94,101 @@ const Description = styled.div({

export default function Home() {
return (
<Main>
<div className={visuallyHidden}>I am invisible</div>
<Description>
<p>
Get started by editing&nbsp;
<code className={styles.code}>src/app/page.tsx</code>
</p>
<div>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener"
>
By{' '}
<PigmentHidden implementation="css" only="xs">
<PigmentContainer maxWidth="md">
<Main>
<PigmentStack spacing={2}>
<div>Test</div>
<div>Test</div>
<div>Test</div>
</PigmentStack>
<div className={visuallyHidden}>I am invisible</div>
<Description>
<p>
Get started by editing&nbsp;
<code className={styles.code}>src/app/page.tsx</code>
</p>
<div>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className={styles.vercelLogo}
width={100}
height={24}
priority
/>
</a>
</div>
</Description>

<div className={styles.center}>
<Image
src="/vercel.svg"
alt="Vercel Logo"
className={styles.vercelLogo}
width={100}
height={24}
className={styles.logo}
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</a>
</div>
</Description>

<div className={styles.center}>
<Image
className={styles.logo}
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
</div>

<div className={styles.grid}>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener"
>
<h2>
Docs <span>-&gt;</span>
</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>
<div className={styles.grid}>
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener"
>
<h2>
Docs <span>-&gt;</span>
</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>

<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener"
>
<h2>
Learn <span>-&gt;</span>
</h2>
<p>Learn about Next.js in an interactive course with&nbsp;quizzes!</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener"
>
<h2>
Learn <span>-&gt;</span>
</h2>
<p>Learn about Next.js in an interactive course with&nbsp;quizzes!</p>
</a>

<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener"
>
<h2>
Templates <span>-&gt;</span>
</h2>
<p>Explore the Next.js 13 playground.</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener"
>
<h2>
Templates <span>-&gt;</span>
</h2>
<p>Explore the Next.js 13 playground.</p>
</a>

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Deploy <span>-&gt;</span>
</h2>
<p>Instantly deploy your Next.js site to a shareable URL with Vercel.</p>
</a>
</div>
</Main>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className={styles.card}
target="_blank"
rel="noopener noreferrer"
>
<h2>
Deploy <span>-&gt;</span>
</h2>
<p>Instantly deploy your Next.js site to a shareable URL with Vercel.</p>
</a>
</div>
</Main>
</PigmentContainer>
</PigmentHidden>
);
}
4 changes: 2 additions & 2 deletions apps/pigment-css-vite-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "vite build"
},
"dependencies": {
"@pigment-css/react": "^0.0.13",
"@pigment-css/react": "https://pkg.csb.dev/mui/pigment-css/commit/59a9ad43/@pigment-css/react",
"@mui/utils": "workspace:^",
"@mui/base": "workspace:^",
"@mui/lab": "workspace:^",
Expand All @@ -27,7 +27,7 @@
"devDependencies": {
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@pigment-css/vite-plugin": "^0.0.13",
"@pigment-css/vite-plugin": "https://pkg.csb.dev/mui/pigment-css/commit/59a9ad43/@pigment-css/vite-plugin",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"@mui/utils": "workspace:^",
"@next/eslint-plugin-next": "^14.2.4",
"@octokit/rest": "^20.1.1",
"@pigment-css/react": "^0.0.13",
"@pigment-css/react": "https://pkg.csb.dev/mui/pigment-css/commit/59a9ad43/@pigment-css/react",
"@playwright/test": "1.44.1",
"@types/enzyme": "^3.10.18",
"@types/fs-extra": "^11.0.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"peerDependencies": {
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@pigment-css/react": "https://pkg.csb.dev/mui/pigment-css/commit/59a9ad43/@pigment-css/react",
"@types/react": "^17.0.0 || ^18.0.0",
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
Expand All @@ -91,6 +92,9 @@
},
"@emotion/styled": {
"optional": true
},
"@pigment-css/react": {
"optional": true
}
},
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
import generateUtilityClass from '@mui/utils/generateUtilityClass';

export function getHiddenCssUtilityClass(slot) {
export function getHiddenCssUtilityClass(slot: string) {
return generateUtilityClass('PrivateHiddenCss', slot);
}

Expand Down
99 changes: 99 additions & 0 deletions packages/mui-material/src/PigmentContainer/PigmentContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import * as React from 'react';
import clsx from 'clsx';
// @ts-ignore
Copy link
Member Author

@siriwatknp siriwatknp Jun 25, 2024

Choose a reason for hiding this comment

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

Removing this @ts-ignore is far beyond this PR, it's related to the tsconfig setup with proper module resolution which I am not sure how to solve it.

import Container from '@pigment-css/react/Container';
import capitalize from '@mui/utils/capitalize';
import composeClasses from '@mui/utils/composeClasses';
import generateUtilityClass from '@mui/utils/generateUtilityClass';
import { SxProps, Breakpoint } from '@mui/system';
import { Theme } from '../styles';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { ContainerClasses } from '../Container/containerClasses';

export interface ContainerOwnProps {
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<ContainerClasses>;
/**
* If `true`, the left and right padding is removed.
* @default false
*/
disableGutters?: boolean;
/**
* Set the max-width to match the min-width of the current breakpoint.
* This is useful if you'd prefer to design for a fixed set of sizes
* instead of trying to accommodate a fully fluid viewport.
* It's fluid by default.
* @default false
*/
fixed?: boolean;
/**
* Determine the max-width of the container.
* The container width grows with the size of the screen.
* Set to `false` to disable `maxWidth`.
* @default 'lg'
*/
maxWidth?: Breakpoint | false;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
}

export interface ContainerTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'div',
> {
props: AdditionalProps & ContainerOwnProps;
defaultComponent: RootComponent;
}

export type ContainerProps<
RootComponent extends React.ElementType = ContainerTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<ContainerTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType;
};

const useUtilityClasses = (ownerState: ContainerOwnProps) => {
const { classes, fixed, disableGutters, maxWidth } = ownerState;

const slots = {
root: [
'root',
maxWidth && `maxWidth${capitalize(String(maxWidth))}`,
fixed && 'fixed',
disableGutters && 'disableGutters',
],
};

return composeClasses(slots, (slot) => generateUtilityClass('MuiContainer', slot), classes);
};

const PigmentContainer = React.forwardRef(function PigmentContainer(
{ className, disableGutters = false, fixed = false, maxWidth = 'lg', ...props },
ref,
) {
const ownerState = {
...props,
disableGutters,
fixed,
maxWidth,
};
const classes = useUtilityClasses(ownerState);
return (
<Container
className={clsx(classes.root, className)}
disableGutters={disableGutters}
fixed={fixed}
maxWidth={maxWidth}
{...props}
// @ts-ignore
ref={ref}
/>
);
}) as OverridableComponent<ContainerTypeMap>;

export default PigmentContainer;
3 changes: 3 additions & 0 deletions packages/mui-material/src/PigmentContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default } from './PigmentContainer';
export * from './PigmentContainer';
export { default as containerClasses } from '../Container/containerClasses';
Loading
Loading