-
Notifications
You must be signed in to change notification settings - Fork 367
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-selection-card] Selection Card: named exports and v7 story #9327
Merged
abailly-akamai
merged 4 commits into
linode:develop
from
abailly-akamai:refactor-M3-6522-selection-card
Jun 28, 2023
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4c3081c
Refactor: [M3-6522-selection-card] Initial commit: exports
abailly-akamai 26e0a95
Refactor: [M3-6522-selection-card] New v7 story
abailly-akamai 37bbd2c
Added changeset: MUI v5 Migration - Components > SelectionCard
abailly-akamai 9eaca12
Refactor: [M3-6522-selection-card] Add some interactivity
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
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-9327-tech-stories-1687891798862.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 Migration - Components > SelectionCard ([#9327](https://github.com/linode/manager/pull/9327)) |
85 changes: 85 additions & 0 deletions
85
packages/manager/src/components/SelectionCard/CardBase.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import { styled } from '@mui/material/styles'; | ||
import type { CardBaseProps } from './CardBase'; | ||
|
||
export const CardBaseGrid = styled(Grid, { | ||
label: 'CardBaseGrid', | ||
})<Partial<CardBaseProps>>(({ theme, ...props }) => ({ | ||
alignItems: 'center', | ||
backgroundColor: props.checked ? theme.bg.lightBlue2 : theme.bg.offWhite, | ||
border: `1px solid ${theme.bg.main}`, | ||
borderColor: props.checked ? theme.palette.primary.main : undefined, | ||
height: '100%', | ||
margin: 0, | ||
minHeight: 60, | ||
padding: `0 ${theme.spacing(1)} !important`, | ||
position: 'relative', | ||
transition: | ||
'background-color 225ms ease-in-out, border-color 225ms ease-in-out', | ||
width: '100%', | ||
|
||
'&:hover': { | ||
backgroundColor: props.checked ? theme.bg.lightBlue2 : theme.bg.main, | ||
borderColor: props.checked | ||
? theme.palette.primary.main | ||
: theme.color.border2, | ||
}, | ||
|
||
'&:before': { | ||
content: '""', | ||
display: 'block', | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: 5, | ||
height: '100%', | ||
backgroundColor: 'transparent', | ||
transition: theme.transitions.create('backgroundColor'), | ||
}, | ||
})); | ||
|
||
export const CardBaseIcon = styled(Grid, { | ||
label: 'CardBaseIcon', | ||
})(() => ({ | ||
display: 'flex', | ||
alignItems: 'flex-end', | ||
justifyContent: 'flex-end', | ||
'& svg, & span': { | ||
fontSize: 32, | ||
color: '#939598', | ||
}, | ||
'& img': { | ||
maxHeight: 32, | ||
maxWidth: 32, | ||
}, | ||
})); | ||
|
||
export const CardBaseHeadings = styled(Grid, { | ||
label: 'CardBaseHeadings', | ||
})(() => ({ | ||
flex: 1, | ||
flexDirection: 'column', | ||
justifyContent: 'space-around', | ||
'& > div': { | ||
lineHeight: 1.3, | ||
}, | ||
})); | ||
|
||
export const CardBaseHeading = styled('div', { | ||
label: 'CardBaseHeading', | ||
})(({ theme }) => ({ | ||
fontFamily: theme.font.bold, | ||
fontSize: '1rem', | ||
color: theme.color.headline, | ||
wordBreak: 'break-word', | ||
display: 'flex', | ||
alignItems: 'center', | ||
columnGap: theme.spacing(2), | ||
})); | ||
|
||
export const CardBaseSubheading = styled('div', { | ||
label: 'CardBaseSubheading', | ||
})(({ theme }) => ({ | ||
color: theme.palette.text.primary, | ||
fontSize: '0.875rem', | ||
})); | ||
5 changes: 2 additions & 3 deletions
5
packages/manager/src/components/SelectionCard/CardBase.test.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
102 changes: 0 additions & 102 deletions
102
packages/manager/src/components/SelectionCard/SelectionCard.stories.mdx
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
packages/manager/src/components/SelectionCard/SelectionCard.stories.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as React from 'react'; | ||
import Alarm from '@mui/icons-material/Alarm'; | ||
import InsertPhoto from '@mui/icons-material/InsertPhoto'; | ||
import DE from 'flag-icons/flags/4x3/de.svg'; | ||
import US from 'flag-icons/flags/4x3/us.svg'; | ||
import { Chip } from 'src/components/core/Chip'; | ||
import { SelectionCard } from './SelectionCard'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import type { SelectionCardProps } from './SelectionCard'; | ||
|
||
const iconOptions = { | ||
None: () => null, | ||
Photo: () => <InsertPhoto />, | ||
Alarm: () => <Alarm />, | ||
'DE Flag': () => <DE width="32" height="24" viewBox="0 0 640 480" />, | ||
'US Flag': () => <US width="32" height="24" viewBox="0 0 720 480" />, | ||
'Arch Linux': () => <span className="fl-archlinux" />, | ||
Debian: () => <span className="fl-debian" />, | ||
}; | ||
|
||
const variantOptions = { | ||
None: () => null, | ||
Chip: () => <Chip label="DEFAULT" component="span" />, | ||
}; | ||
|
||
export const Default: StoryObj<SelectionCardProps> = { | ||
render: (args) => <SelectionCard {...args} />, | ||
}; | ||
|
||
const meta: Meta<SelectionCardProps> = { | ||
title: 'Components/SelectionCard', | ||
component: SelectionCard, | ||
args: { | ||
heading: 'Photos', | ||
subheadings: ['Use a photo', 'Select up to 3'], | ||
checked: false, | ||
disabled: false, | ||
renderIcon: iconOptions.Photo, | ||
renderVariant: variantOptions.Chip, | ||
tooltip: '', | ||
}, | ||
argTypes: { | ||
renderIcon: { | ||
control: { type: 'select' }, | ||
options: iconOptions, | ||
}, | ||
renderVariant: { | ||
control: { type: 'select' }, | ||
options: variantOptions, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; |
Oops, something went wrong.
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.
Nothing new, just putting styles in their own files per out standard practices