-
Notifications
You must be signed in to change notification settings - Fork 364
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
Refactor: [M3-6522] Chip: MUI refactor + v7 story #9310
Merged
abailly-akamai
merged 5 commits into
linode:develop
from
abailly-akamai:refactor-M3-6522
Jun 26, 2023
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
20dbf49
Refactor: [M3-6522] Chip: MUI refactor + story
abailly-akamai c951a2d
Refactor: [M3-6522] delete .mdx file
abailly-akamai 703b355
Added changeset: MUI v5 - Components > Chip
abailly-akamai 17c9084
Refactor: [M3-6522] delete .mdx file
abailly-akamai b0dd667
Refactor: [M3-6522] fix broken story
abailly-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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}; | ||
abailly-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
); | ||
}; | ||
|
||
return <ChipWrapper />; | ||
}, | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one shows how to use custom React state in our stories |
||
|
||
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
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
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
2 changes: 1 addition & 1 deletion
2
packages/manager/src/features/Linodes/LinodesCreate/SelectPlanPanel/PlanSelection.styles.ts
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/NodeBalancers/NodeBalancerConfigNode.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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty story i found. no need to keep this around