-
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.
* WIP * WIP 2 * Fix styling * Fix StackScripts to use new SelectImagePanel * Fix tab labels * Add empty state for private images * Review feedback - Combine renderPublicImages and renderOlderPublicImages into a single function - Use <span> instead of <Typography> for placeholder message - Only pass needed props to FromImageContent * Pass fewer props to other FromImagesContent instance * Clean up post-rebase
- Loading branch information
Showing
8 changed files
with
287 additions
and
145 deletions.
There are no files selected for viewing
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,48 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
StyleRulesCallback, | ||
withStyles, | ||
WithStyles | ||
} from 'src/components/core/styles'; | ||
|
||
import Paper from 'src/components/core/Paper'; | ||
import Typography from 'src/components/core/Typography'; | ||
import Notice from 'src/components/Notice'; | ||
|
||
type ClassNames = 'root' | 'flatImagePanel'; | ||
|
||
const styles: StyleRulesCallback<ClassNames> = theme => ({ | ||
flatImagePanel: { | ||
padding: theme.spacing.unit * 3 | ||
}, | ||
root: {} | ||
}); | ||
|
||
interface Props { | ||
children: React.ReactElement; | ||
error?: string; | ||
title?: string; | ||
} | ||
|
||
type CombinedProps = Props & WithStyles<ClassNames>; | ||
|
||
const Panel: React.StatelessComponent<CombinedProps> = (props) => { | ||
const { classes, children, error, title } = props; | ||
return ( | ||
<Paper | ||
className={classes.flatImagePanel} | ||
data-qa-tp="Select Image" | ||
> | ||
{error && <Notice text={error} error />} | ||
<Typography role="header" variant="h2" data-qa-tp="Select Image"> | ||
{title || 'Select an Image'} | ||
</Typography> | ||
{children} | ||
</Paper> | ||
) | ||
} | ||
|
||
const styled = withStyles(styles); | ||
|
||
export default styled(Panel); |
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,51 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
StyleRulesCallback, | ||
withStyles, | ||
WithStyles | ||
} from 'src/components/core/styles'; | ||
import Grid from 'src/components/Grid'; | ||
import SelectionCard from 'src/components/SelectionCard'; | ||
|
||
type ClassNames = 'root' | 'flatImagePanelSelections'; | ||
|
||
const styles: StyleRulesCallback<ClassNames> = theme => ({ | ||
flatImagePanelSelections: { | ||
marginTop: theme.spacing.unit * 2, | ||
padding: `${theme.spacing.unit}px 0` | ||
}, | ||
root: {} | ||
}); | ||
interface Props { | ||
images: Linode.Image[]; | ||
disabled?: boolean; | ||
selectedImageID?: string; | ||
handleSelection: (id: string) => void; | ||
} | ||
|
||
type CombinedProps = Props & WithStyles<ClassNames>; | ||
|
||
const PrivateImages: React.StatelessComponent<CombinedProps> = (props) => { | ||
const { classes, disabled, handleSelection, images, selectedImageID } = props; | ||
return ( | ||
<Grid container className={classes.flatImagePanelSelections} > | ||
{images && | ||
images.map((image: Linode.Image, idx: number) => ( | ||
<SelectionCard | ||
key={idx} | ||
checked={image.id === String(selectedImageID)} | ||
onClick={() => handleSelection(image.id)} | ||
renderIcon={() => <span className="fl-tux" />} | ||
heading={image.label as string} | ||
subheadings={[image.description as string]} | ||
disabled={disabled} | ||
/> | ||
))} | ||
</Grid> | ||
) | ||
} | ||
|
||
const styled = withStyles(styles); | ||
|
||
export default styled(PrivateImages); |
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,89 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
StyleRulesCallback, | ||
withStyles, | ||
WithStyles | ||
} from 'src/components/core/styles'; | ||
import Grid from 'src/components/Grid'; | ||
import SelectionCard from 'src/components/SelectionCard'; | ||
import ShowMoreExpansion from 'src/components/ShowMoreExpansion'; | ||
|
||
type ClassNames = 'root' | 'flatImagePanelSelections'; | ||
|
||
const styles: StyleRulesCallback<ClassNames> = theme => ({ | ||
flatImagePanelSelections: { | ||
marginTop: theme.spacing.unit * 2, | ||
padding: `${theme.spacing.unit}px 0` | ||
}, | ||
root: {} | ||
}); | ||
interface Props { | ||
images: Linode.Image[]; | ||
oldImages: Linode.Image[]; | ||
selectedImageID?: string; | ||
disabled?: boolean; | ||
handleSelection: (id: string) => void; | ||
} | ||
|
||
type CombinedProps = Props & WithStyles<ClassNames>; | ||
|
||
const distroIcons = { | ||
Arch: 'archlinux', | ||
CentOS: 'centos', | ||
CoreOS: 'coreos', | ||
Debian: 'debian', | ||
Fedora: 'fedora', | ||
Gentoo: 'gentoo', | ||
openSUSE: 'opensuse', | ||
Slackware: 'slackware', | ||
Ubuntu: 'ubuntu' | ||
}; | ||
|
||
const PublicImages: React.StatelessComponent<CombinedProps> = props => { | ||
const { | ||
classes, | ||
disabled, | ||
images, | ||
handleSelection, | ||
oldImages, | ||
selectedImageID | ||
} = props; | ||
const renderImages = (images: Linode.Image[]) => | ||
images.length && | ||
images.map((image: Linode.Image, idx: number) => ( | ||
<SelectionCard | ||
key={idx} | ||
checked={image.id === String(selectedImageID)} | ||
onClick={() => handleSelection(image.id)} | ||
renderIcon={() => { | ||
return ( | ||
<span className={`fl-${distroIcons[image.vendor as string]}`} /> | ||
); | ||
}} | ||
heading={image.vendor as string} | ||
subheadings={[image.label]} | ||
data-qa-selection-card | ||
disabled={disabled} | ||
/> | ||
)); | ||
|
||
return ( | ||
<> | ||
<Grid className={classes.flatImagePanelSelections} container> | ||
{renderImages(images)} | ||
</Grid> | ||
{oldImages.length > 0 && ( | ||
<ShowMoreExpansion name="Show Older Images"> | ||
<Grid container spacing={16} style={{ marginTop: 16 }}> | ||
{renderImages(oldImages)} | ||
</Grid> | ||
</ShowMoreExpansion> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
const styled = withStyles(styles); | ||
|
||
export default styled(PublicImages); |
Oops, something went wrong.