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

[Chip] adding 'rounded' property to chip component #37576

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 37 additions & 9 deletions docs/data/material/components/chips/ColorChips.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
import * as React from 'react';
import Chip from '@mui/material/Chip';
import Stack from '@mui/material/Stack';
import { pink, common } from '@mui/material/colors';
import { ThemeProvider, createTheme } from '@mui/material/styles';

const theme = createTheme({
palette: {
violet: {
main: '#8F00FF',
contrastText: '#FFFFFF',
},
},
});

export default function ColorChips() {
return (
<Stack spacing={1} alignItems="center">
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" />
<Chip label="success" color="success" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" variant="outlined" />
<Chip label="success" color="success" variant="outlined" />
<ThemeProvider theme={theme}>
<Stack spacing={1} alignItems="center">
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" />
<Chip label="success" color="success" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" variant="outlined" />
<Chip label="success" color="success" variant="outlined" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip label="violet" color="violet" />
<Chip label="violet" color="violet" variant="outlined" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip
label="pink"
sx={{ backgroundColor: pink[500], color: common.white }}
/>
<Chip
label="pink"
sx={{ borderColor: pink[500], color: pink[500] }}
variant="outlined"
/>
</Stack>
</Stack>
</Stack>
</ThemeProvider>
);
}
46 changes: 37 additions & 9 deletions docs/data/material/components/chips/ColorChips.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
import * as React from 'react';
import Chip from '@mui/material/Chip';
import Stack from '@mui/material/Stack';
import { pink, common } from '@mui/material/colors';
import { ThemeProvider, createTheme } from '@mui/material/styles';

const theme = createTheme({
palette: {
violet: {
main: '#8F00FF',
contrastText: '#FFFFFF',
},
},
});

export default function ColorChips() {
return (
<Stack spacing={1} alignItems="center">
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" />
<Chip label="success" color="success" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" variant="outlined" />
<Chip label="success" color="success" variant="outlined" />
<ThemeProvider theme={theme}>
<Stack spacing={1} alignItems="center">
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" />
<Chip label="success" color="success" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip label="primary" color="primary" variant="outlined" />
<Chip label="success" color="success" variant="outlined" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip label="violet" color="violet" />
<Chip label="violet" color="violet" variant="outlined" />
</Stack>
<Stack direction="row" spacing={1}>
<Chip
label="pink"
sx={{ backgroundColor: pink[500], color: common.white }}
/>
<Chip
label="pink"
sx={{ borderColor: pink[500], color: pink[500] }}
variant="outlined"
/>
</Stack>
</Stack>
</Stack>
</ThemeProvider>
);
}
12 changes: 12 additions & 0 deletions docs/data/material/components/chips/RoundedChips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react';
import Chip from '@mui/material/Chip';
import Stack from '@mui/material/Stack';

export default function RoundedChips() {
return (
<Stack direction="row" spacing={1}>
<Chip label="Rounded" rounded />
<Chip label="Rounded" rounded variant="outlined" />
</Stack>
);
}
12 changes: 12 additions & 0 deletions docs/data/material/components/chips/RoundedChips.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react';
import Chip from '@mui/material/Chip';
import Stack from '@mui/material/Stack';

export default function RoundedChips() {
return (
<Stack direction="row" spacing={1}>
<Chip label="Rounded" rounded />
<Chip label="Rounded" rounded variant="outlined" />
</Stack>
);
}
2 changes: 2 additions & 0 deletions docs/data/material/components/chips/RoundedChips.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Chip label="Rounded" rounded />
<Chip label="Rounded" rounded variant="outlined" />
8 changes: 7 additions & 1 deletion docs/data/material/components/chips/chips.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Use the `avatar` prop to add an avatar or use the `icon` prop to add an icon.

## Color chip

You can use the `color` prop to define a color from theme palette.
You can use the `color` prop to define a color from theme palette. Addtionally, you can use either the theme extension or the `sx` prop to create chips with other colors.

{{"demo": "ColorChips.js"}}

Expand All @@ -77,6 +77,12 @@ You can use the `size` prop to define a small Chip.

{{"demo": "SizesChips.js"}}

## Rounded chip

You can use the `rounded` prop to create a rounded Chip.

{{"demo": "RoundedChips.js"}}

## Multiline chip

By default, Chips displays labels only in a single line.
Expand Down
28 changes: 4 additions & 24 deletions docs/pages/base-ui/api/popup.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,10 @@
"container": { "type": { "name": "union", "description": "HTML element<br>&#124;&nbsp;func" } },
"disablePortal": { "type": { "name": "bool" }, "default": "false" },
"keepMounted": { "type": { "name": "bool" }, "default": "false" },
"middleware": {
"type": {
"name": "arrayOf",
"description": "Array&lt;false<br>&#124;&nbsp;{ fn: func, name: string, options?: any }&gt;"
}
},
"offset": {
"type": {
"name": "union",
"description": "func<br>&#124;&nbsp;number<br>&#124;&nbsp;{ alignmentAxis?: number, crossAxis?: number, mainAxis?: number }"
},
"default": "0"
},
"middleware": { "type": { "name": "array" } },
"offset": { "type": { "name": "any" }, "default": "0" },
"open": { "type": { "name": "bool" }, "default": "false" },
"placement": {
"type": {
"name": "enum",
"description": "'bottom-end'<br>&#124;&nbsp;'bottom-start'<br>&#124;&nbsp;'bottom'<br>&#124;&nbsp;'left-end'<br>&#124;&nbsp;'left-start'<br>&#124;&nbsp;'left'<br>&#124;&nbsp;'right-end'<br>&#124;&nbsp;'right-start'<br>&#124;&nbsp;'right'<br>&#124;&nbsp;'top-end'<br>&#124;&nbsp;'top-start'<br>&#124;&nbsp;'top'"
},
"default": "'bottom'"
},
"placement": { "type": { "name": "any" }, "default": "'bottom'" },
"slotProps": {
"type": { "name": "shape", "description": "{ root?: func<br>&#124;&nbsp;object }" },
"default": "{}"
Expand All @@ -39,10 +22,7 @@
"default": "{}",
"additionalInfo": { "slotsApi": true }
},
"strategy": {
"type": { "name": "enum", "description": "'absolute'<br>&#124;&nbsp;'fixed'" },
"default": "'absolute'"
},
"strategy": { "type": { "name": "any" }, "default": "'absolute'" },
"withTransition": { "type": { "name": "bool" }, "default": "false" }
},
"name": "Popup",
Expand Down
4 changes: 3 additions & 1 deletion docs/pages/material-ui/api/chip.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"icon": { "type": { "name": "element" } },
"label": { "type": { "name": "node" } },
"onDelete": { "type": { "name": "func" } },
"rounded": { "type": { "name": "bool" }, "default": "false" },
"size": {
"type": {
"name": "union",
Expand Down Expand Up @@ -88,7 +89,8 @@
"deleteIconOutlinedColorSecondary",
"deleteIconFilledColorPrimary",
"deleteIconFilledColorSecondary",
"focusVisible"
"focusVisible",
"rounded"
],
"globalClasses": { "disabled": "Mui-disabled", "focusVisible": "Mui-focusVisible" },
"name": "MuiChip"
Expand Down
4 changes: 3 additions & 1 deletion docs/translations/api-docs/chip/chip.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"onDelete": {
"description": "Callback fired when the delete icon is clicked. If set, the delete icon will be shown."
},
"rounded": { "description": "If <code>true</code>, allows the chip to be rounded" },
"size": { "description": "The size of the component." },
"skipFocusWhenDisabled": {
"description": "If <code>true</code>, allows the disabled chip to escape focus. If <code>false</code>, allows the disabled chip to receive focus."
Expand Down Expand Up @@ -247,6 +248,7 @@
"description": "State class applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "keyboard focused"
}
},
"rounded": { "description": "Styles applied to chip if &#39;rounded=true&#39;" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ const TextareaAutosize = React.forwardRef(function TextareaAutosize(
resizeObserver = new ResizeObserver(
process.env.NODE_ENV === 'test' ? rAFHandleResize : handleResize,
);

resizeObserver.observe(input);
}

Expand Down
38 changes: 4 additions & 34 deletions packages/mui-base/src/Unstable_Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,32 +204,15 @@ Popup.propTypes /* remove-proptypes */ = {
*
* @see https://floating-ui.com/docs/computePosition#middleware
*/
middleware: PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.oneOf([false]),
PropTypes.shape({
fn: PropTypes.func.isRequired,
name: PropTypes.string.isRequired,
options: PropTypes.any,
}),
]),
),
middleware: PropTypes.array,
/**
* Distance between a popup and the trigger element.
* This prop is ignored when custom `middleware` is provided.
*
* @default 0
* @see https://floating-ui.com/docs/offset
*/
offset: PropTypes.oneOfType([
PropTypes.func,
PropTypes.number,
PropTypes.shape({
alignmentAxis: PropTypes.number,
crossAxis: PropTypes.number,
mainAxis: PropTypes.number,
}),
]),
offset: PropTypes.any,
/**
* If `true`, the popup is visible.
*
Expand All @@ -242,20 +225,7 @@ Popup.propTypes /* remove-proptypes */ = {
* @default 'bottom'
* @see https://floating-ui.com/docs/computePosition#placement
*/
placement: PropTypes.oneOf([
'bottom-end',
'bottom-start',
'bottom',
'left-end',
'left-start',
'left',
'right-end',
'right-start',
'right',
'top-end',
'top-start',
'top',
]),
placement: PropTypes.any,
/**
* The props used for each slot inside the Popup.
*
Expand All @@ -279,7 +249,7 @@ Popup.propTypes /* remove-proptypes */ = {
* @default 'absolute'
* @see https://floating-ui.com/docs/computePosition#strategy
*/
strategy: PropTypes.oneOf(['absolute', 'fixed']),
strategy: PropTypes.any,
/**
* If `true`, the popup will not disappear immediately when it needs to be closed
* but wait until the exit transition has finished.
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/AccordionDetails/AccordionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const AccordionDetails = React.forwardRef(function AccordionDetails(inProps, ref
const elements = rootRef.current.querySelectorAll(
'a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])',
);

elements.forEach((elm) => {
if (expanded) {
const prevTabIndex = elm.getAttribute('data-prev-tabindex');
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const AlertRoot = styled('div', {
'padding',
'borderRadius',
]);

return [
{
'--Alert-radius': theme.vars.radius.sm,
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const StyledButtonGroup = styled('div')<{ ownerState: ButtonGroupOwnerSta
}
},
);

const outlinedStyle = theme.variants.outlined?.[ownerState.color!];
const outlinedDisabledStyle = theme.variants.outlinedDisabled?.[ownerState.color!];
const outlinedHoverStyle = theme.variants.outlinedHover?.[ownerState.color!];
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const StyledCardRoot = styled('div')<{ ownerState: CardOwnerState }>(
'padding',
'borderRadius',
]);

return [
{
'--Icon-color':
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/ChipDelete/ChipDelete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const ChipDelete = React.forwardRef(function ChipDelete(inProps, ref) {
inProps.color,
true,
);

const color = inProps.color || inheritedColor;
const disabled = disabledProp ?? chipContext.disabled;

Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/LinearProgress/LinearProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const LinearProgressRoot = styled('div', {
'borderRadius',
'height',
]);

return {
...(borderRadius !== undefined && { '--LinearProgress-radius': borderRadius }),
...(height !== undefined && { '--LinearProgress-thickness': height }),
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const StyledList = styled('ul')<{ ownerState: ListOwnerState }>(({ theme,
'padding',
'borderRadius',
]);

function applySizeVars(size: ListProps['size']) {
if (size === 'sm') {
return {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Option/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Option = React.forwardRef(function Option(inProps, ref: React.ForwardedRef
inProps.variant,
inProps.color,
);

const optionRef = React.useRef<HTMLLIElement>(null);
const combinedRef = useForkRef(optionRef, ref);

Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Sheet/Sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const SheetRoot = styled('div', {
'backgroundColor',
'background',
]);

const resolvedBg =
(getPath(theme, `palette.${bgcolor}`) as string) ||
bgcolor ||
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Skeleton/Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ const SkeletonRoot = styled('span', {
];
},
);

/**
*
* Demos:
Expand Down
Loading