Skip to content

Commit

Permalink
[code-infra] Add alias for icon types (#41248)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Potoms <2109932+Janpot@users.noreply.github.com>
  • Loading branch information
Janpot committed Mar 7, 2024
1 parent 5fb8e19 commit 16e8ef7
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"packages/mui-base",
"packages/mui-codemod",
"packages/mui-core-downloads-tracker",
"packages/mui-docs",
"packages/mui-icons-material",
"packages/mui-joy",
"packages/mui-lab",
Expand All @@ -28,6 +29,7 @@
"@mui/base": "packages/mui-base/build",
"@mui/codemod": "packages/mui-codemod/build",
"@mui/core-downloads-tracker": "packages/mui-core-downloads-tracker/build",
"@mui/docs": "packages/mui-docs/build",
"@mui/icons-material": "packages/mui-icons-material/build",
"@mui/internal-babel-macros": "packages/mui-babel-macros",
"@mui/internal-markdown": "packages/markdown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function TransitionComponentSnackbar() {
const [exited, setExited] = React.useState(true);
const nodeRef = React.useRef(null);

const handleClose = (_: any, reason: SnackbarCloseReason) => {
const handleClose = (_: any, reason?: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function UnstyledSnackbarIntroduction() {
const [exited, setExited] = React.useState(true);
const nodeRef = React.useRef(null);

const handleClose = (_: any, reason: SnackbarCloseReason) => {
const handleClose = (_: any, reason?: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function UnstyledSnackbarIntroduction() {
const [exited, setExited] = React.useState(true);
const nodeRef = React.useRef(null);

const handleClose = (_: any, reason: SnackbarCloseReason) => {
const handleClose = (_: any, reason?: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function UnstyledSnackbarIntroduction() {
const [exited, setExited] = React.useState(true);
const nodeRef = React.useRef(null);

const handleClose = (_: any, reason: SnackbarCloseReason) => {
const handleClose = (_: any, reason?: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
Expand Down
13 changes: 8 additions & 5 deletions docs/data/joy/integrations/icon-libraries/IconFontSizes.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import * as React from 'react';
import { useTheme } from '@mui/joy/styles';
import Stack from '@mui/joy/Stack';
import Person from '@mui/icons-material/Person';

export default function IconFontSizes() {
const theme = useTheme();
return (
<Stack
spacing={2}
direction="row"
sx={{ gridColumn: '1 / -1', alignItems: 'center', justifyContent: 'center' }}
>
{Object.keys(theme.fontSize).map((size) => (
<Person key={size} fontSize={size} />
))}
<Person fontSize="xs" />
<Person fontSize="sm" />
<Person fontSize="md" />
<Person fontSize="lg" />
<Person fontSize="xl" />
<Person fontSize="xl2" />
<Person fontSize="xl3" />
<Person fontSize="xl4" />
</Stack>
);
}
13 changes: 8 additions & 5 deletions docs/data/joy/integrations/icon-libraries/IconFontSizes.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import * as React from 'react';
import { useTheme } from '@mui/joy/styles';
import Stack from '@mui/joy/Stack';
import Person from '@mui/icons-material/Person';

export default function IconFontSizes() {
const theme = useTheme();
return (
<Stack
spacing={2}
direction="row"
sx={{ gridColumn: '1 / -1', alignItems: 'center', justifyContent: 'center' }}
>
{Object.keys(theme.fontSize).map((size) => (
<Person key={size} fontSize={size} />
))}
<Person fontSize="xs" />
<Person fontSize="sm" />
<Person fontSize="md" />
<Person fontSize="lg" />
<Person fontSize="xl" />
<Person fontSize="xl2" />
<Person fontSize="xl3" />
<Person fontSize="xl4" />
</Stack>
);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{Object.keys(theme.fontSize).map((size) => (
<Person key={size} fontSize={size} />
))}
<Person fontSize="xs" />
<Person fontSize="sm" />
<Person fontSize="md" />
<Person fontSize="lg" />
<Person fontSize="xl" />
<Person fontSize="xl2" />
<Person fontSize="xl3" />
<Person fontSize="xl4" />
4 changes: 2 additions & 2 deletions docs/pages/experiments/base/components-gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default function ComponentsGallery() {
const [exited, setExited] = React.useState(true);
const nodeRef = React.useRef(null);

const handleClose = (_: any, reason: SnackbarCloseReason) => {
const handleClose = (_: any, reason?: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ export default function ComponentsGallery() {
setCopySnackbarOpen(true);
}

const handleCopyClose = (_: any, reason: SnackbarCloseReason) => {
const handleCopyClose = (_: any, reason?: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/productBaseUI/BaseUIThemesDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ export default function BaseUIThemesDemo() {
// Snackbar
const [openSnackbar, setOpenSnackbar] = React.useState(false);

const handleCloseSnackbar = (_: any, reason: SnackbarCloseReason) => {
const handleCloseSnackbar = (_: any, reason?: SnackbarCloseReason) => {
if (reason === 'clickaway') {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/showcase/TaskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function TaskCard() {
</Typography>
</Box>
<Box sx={{ my: 'auto' }}>
<CodeRounded color="white" />
<CodeRounded />
<Typography fontSize={18} component="div" fontWeight="semiBold" sx={{ lineHeight: 1.4 }}>
Customize every button and chip instance primary color
</Typography>
Expand Down
16 changes: 16 additions & 0 deletions docs/src/modules/brandingTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ declare module '@mui/material/Chip' {
}
}

declare module '@mui/material/SvgIcon' {
interface SvgIconPropsColorOverrides {
danger: true;
}
interface SvgIconPropsSizeOverrides {
xs: true;
sm: true;
md: true;
lg: true;
xl: true;
xl2: true;
xl3: true;
xl4: true;
}
}

// TODO: enable this once types conflict is fixed
// declare module '@mui/material/Button' {
// interface ButtonPropsVariantOverrides {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-icons-material/src/icon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@mui/material/SvgIcon';
7 changes: 1 addition & 6 deletions packages/mui-icons-material/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"paths": {
"@mui/material": ["../mui-material/src"],
"@mui/material/*": ["../mui-material/src/*"]
}
},
"compilerOptions": {},
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/mui-material/src/Alert/Alert.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CloseRounded } from '@mui/icons-material';
import CloseRounded from '@mui/icons-material/CloseRounded';
import { createTheme } from '@mui/material';

createTheme({
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"@mui/material-nextjs/*": ["./packages/mui-material-nextjs/src/*"],
"@mui/joy": ["./packages/mui-joy/src"],
"@mui/joy/*": ["./packages/mui-joy/src/*"],
"@mui/icons-material": ["./packages/mui-icons-material/lib"],
"@mui/icons-material/*": ["./packages/mui-icons-material/lib/*"],
"@mui/icons-material/*": ["./packages/mui-icons-material/src/icon.d.ts"],
"@pigment-css/nextjs-plugin": ["./packages/pigment-nextjs-plugin/src"],
"@pigment-css/nextjs-plugin/*": ["./packages/pigment-nextjs-plugin/src/*"],
"@pigment-css/react": ["./packages/pigment-react/src"],
Expand Down

0 comments on commit 16e8ef7

Please sign in to comment.