-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: [M3-6522] Chip: MUI refactor + v7 story (#9310)
* Refactor: [M3-6522] Chip: MUI refactor + story * Refactor: [M3-6522] delete .mdx file * Added changeset: MUI v5 - Components > Chip * Refactor: [M3-6522] delete .mdx file * Refactor: [M3-6522] fix broken story
- Loading branch information
1 parent
e8b0246
commit cbd9db2
Showing
21 changed files
with
124 additions
and
201 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-9310-tech-stories-1687550766529.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tech Stories | ||
--- | ||
|
||
MUI v5 - Components > Chip ([#9310](https://github.com/linode/manager/pull/9310)) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from 'react'; | ||
import { Chip } from 'src/components/core/Chip'; | ||
import type { ChipProps } from './core/Chip'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
export const Default: StoryObj<ChipProps> = { | ||
render: (args) => <Chip {...args} />, | ||
}; | ||
|
||
/** | ||
* Actionable Chips indicate a state and allow users to take action.<br /> | ||
* **Example:** An ‘Upgrade’ chip on a Kubernetes cluster shows the software is not current and allows a user to upgrade to a new version.<br /> | ||
* **Visual style:** solid color background. | ||
*/ | ||
export const Clickable: StoryObj<ChipProps> = { | ||
render: (args) => <Chip {...args} label="Upgrade" clickable />, | ||
}; | ||
|
||
/** | ||
* Static Chips are an indication of status and are intended to be informational.<br /> | ||
* No action is required or enabled.<br /> | ||
* **Example:** ‘NVMe’ chip on a volume.<br /> | ||
* **Visual style:** outline. | ||
*/ | ||
export const Outlined: StoryObj<ChipProps> = { | ||
render: (args) => <Chip {...args} variant="outlined" />, | ||
}; | ||
|
||
export const Custom: StoryObj<ChipProps> = { | ||
render: (args) => ( | ||
<Chip | ||
{...args} | ||
label="NVMe" | ||
variant="outlined" | ||
outlineColor="green" | ||
size="small" | ||
/> | ||
), | ||
}; | ||
|
||
export const WithDeleteButton: StoryObj<ChipProps> = { | ||
render: (args) => { | ||
const ChipWrapper = () => { | ||
const [isDeleted, setIsDeleted] = React.useState(false); | ||
|
||
const handleDelete = () => { | ||
setIsDeleted(true); | ||
setTimeout(() => { | ||
setIsDeleted(false); | ||
}, 1000); | ||
}; | ||
|
||
return ( | ||
<div style={{ height: 20 }}> | ||
{!isDeleted ? <Chip {...args} onDelete={handleDelete} /> : null} | ||
</div> | ||
); | ||
}; | ||
|
||
return <ChipWrapper />; | ||
}, | ||
}; | ||
|
||
const meta: Meta<ChipProps> = { | ||
title: 'Components/Core/Chip', | ||
component: Chip, | ||
args: { label: 'Chip', onDelete: undefined }, | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,52 @@ | ||
import * as React from 'react'; | ||
import classNames from 'classnames'; | ||
import { makeStyles } from '@mui/styles'; | ||
import { Theme } from '@mui/material/styles'; | ||
import { default as _Chip, ChipProps as _ChipProps } from '@mui/material/Chip'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
inTable: { | ||
marginTop: 0, | ||
marginBottom: 0, | ||
marginLeft: theme.spacing(2), | ||
minHeight: theme.spacing(2), | ||
paddingLeft: theme.spacing(0.5), | ||
paddingRight: theme.spacing(0.5), | ||
}, | ||
['outline-gray']: { | ||
border: '1px solid #ccc', | ||
}, | ||
['outline-green']: { | ||
border: '1px solid #02B159', | ||
}, | ||
})); | ||
import { styled } from '@mui/material/styles'; | ||
|
||
export interface ChipProps extends _ChipProps { | ||
outlineColor?: 'green' | 'gray'; | ||
/** | ||
* Optional component to render instead of a span. | ||
*/ | ||
component?: string; | ||
/** | ||
* If true, the chip will inherit styles to allow for use in a table. | ||
* @default false | ||
*/ | ||
inTable?: boolean; | ||
/** | ||
* The color of the outline when the variant is outlined. | ||
* @default 'gray' | ||
*/ | ||
outlineColor?: 'green' | 'gray'; | ||
} | ||
|
||
const Chip: React.FC<ChipProps> = ({ | ||
export const Chip = ({ | ||
outlineColor = 'gray', | ||
className, | ||
inTable, | ||
...props | ||
}) => { | ||
const classes = useStyles(); | ||
|
||
}: ChipProps) => { | ||
return ( | ||
<_Chip | ||
className={classNames(className, { | ||
[classes.inTable]: inTable, | ||
[classes[`outline-${outlineColor}`]]: props.variant === 'outlined', | ||
})} | ||
<StyledChip | ||
inTable={inTable} | ||
outlineColor={outlineColor} | ||
className={className} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export default Chip; | ||
const StyledChip = styled(_Chip, { | ||
label: 'StyledChip', | ||
})<ChipProps>(({ theme, ...props }) => ({ | ||
...(props.inTable && { | ||
marginTop: 0, | ||
marginBottom: 0, | ||
marginLeft: theme.spacing(2), | ||
minHeight: theme.spacing(2), | ||
paddingLeft: theme.spacing(0.5), | ||
paddingRight: theme.spacing(0.5), | ||
}), | ||
...(props.variant === 'outlined' && { | ||
border: `1px solid ${props.outlineColor === 'green' ? '#02B159' : '#ccc'}`, | ||
}), | ||
})); |
2 changes: 1 addition & 1 deletion
2
...ger/src/features/Billing/BillingPanels/BillingSummary/PaymentDrawer/PaymentMethodCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/manager/src/features/Kubernetes/ClusterList/KubernetesClusterRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.