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

Gutenboarding Design Selector: Add heading, srcset #38465

Merged
merged 5 commits into from
Dec 17, 2019
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* External dependencies
*/
import { __ as NO__ } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { useSelect } from '@wordpress/data';
import React, { useState } from 'react';
import classnames from 'classnames';
Expand All @@ -14,6 +16,11 @@ import { SiteVertical } from '../../stores/onboard/types';

import './style.scss';

const gridWidth = 960;

const srcSet = ( src: string, widths: number[] ) =>
widths.map( width => addQueryArgs( src, { w: width } ) + ` ${ width }w` ).join( ', ' );

export default () => {
const siteVertical = useSelect(
select => select( 'automattic/onboard' ).getState().siteVertical as SiteVertical
Expand All @@ -29,20 +36,32 @@ export default () => {
const [ selectedDesign, setSelectedDesign ] = useState< string | undefined >();
return (
<div className="design-selector">
{ homepageTemplates.map( template => (
<Card
className={ classnames( 'design-selector__design-option', {
'is-selected': template.slug === selectedDesign,
} ) }
key={ template.slug }
isElevated
onClick={ () => setSelectedDesign( template.slug ) }
>
<CardMedia>
<img alt={ template.title } src={ template.preview } />
</CardMedia>
</Card>
) ) }
<h1 className="design-selector__title">
{ NO__( 'Choose a starting design for your site' ) }
</h1>
<h2 className="design-selector__subtitle">
{ NO__( "You'll be able to customize your new site in hundreds of ways." ) }
</h2>
<div className="design-selector__grid">
{ homepageTemplates.map( template => (
<Card
className={ classnames( 'design-selector__design-option', {
'is-selected': template.slug === selectedDesign,
} ) }
key={ template.slug }
isElevated
onClick={ () => setSelectedDesign( template.slug ) }
>
<CardMedia>
<img
alt={ template.title }
src={ template.preview }
srcSet={ srcSet( template.preview, [ gridWidth / 2, gridWidth / 4 ] ) }
/>
</CardMedia>
</Card>
) ) }
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
.design-selector {
@import '~@wordpress/base-styles/colors';

.design-selector__title {
color: $dark-gray-800;
font-size: 2em;
font-weight: bold;
margin-bottom: 0.25em;
text-align: center;
}

.design-selector__subtitle {
color: $dark-gray-800;
font-size: 1.3em;
margin-bottom: 3em;
text-align: center;
}

.design-selector__grid {
display: grid;
grid-gap: 4.5em;

Expand Down