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

Onboarding selection highlight improvements #420

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
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
13 changes: 11 additions & 2 deletions onboarding/src/Components/Sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Fuse from 'fuse.js/dist/fuse.min';

const Sites = ( { getSites, editor, category, searchQuery } ) => {
const [ maxShown, setMaxShown ] = useState( 9 );
const [ selectedStarterSite, setSelectedSite ] = useState('');
const { sites = {} } = getSites;

const getFilteredSites = () => {
Expand Down Expand Up @@ -60,13 +61,21 @@ const Sites = ( { getSites, editor, category, searchQuery } ) => {
const getBuilders = () => Object.keys( sites );

const allData = getFilteredSites();

return (
<>
{ allData.length ? (
<div className="ob-sites is-grid">
{ allData.slice( 0, maxShown ).map( ( site, index ) => {
return <StarterSiteCard key={ index } data={ site } />;
return (
<StarterSiteCard
key={ index }
data={ site }
isSelected={ selectedStarterSite === site?.slug }
toggleSelectedSite={() => {
setSelectedSite( site.slug === selectedStarterSite ? '' : site.slug );
}}
/>
);
} ) }

<VizSensor
Expand Down
27 changes: 25 additions & 2 deletions onboarding/src/Components/StarterSiteCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { withDispatch, withSelect } from '@wordpress/data';
import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { track } from '../utils/rest';
import classNames from 'classnames';

const StarterSiteCard = ( {
data,
setSite,
handleNextStep,
trackingId,
editor,
isSelected,
toggleSelectedSite
} ) => {
const { upsell, screenshot, title, category, query } = data;

Expand All @@ -36,7 +39,9 @@ const StarterSiteCard = ( {

return (
<div className="ss-card-wrap">
<div className="ss-card">
<div
className="ss-card"
>
{ upsell && (
<span className="ss-badge">
<span>
Expand All @@ -45,7 +50,25 @@ const StarterSiteCard = ( {
</span>
) }

<div className="ss-actions">
<div
className={
classNames('ss-actions', {
'card-selected': isSelected
})
}
role="button"
tabIndex={0}
onClick={(e) => {
e.preventDefault();
toggleSelectedSite();
}}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
toggleSelectedSite();
}
}}
>
<Button
isPrimary
className="ob-button"
Expand Down
8 changes: 7 additions & 1 deletion onboarding/src/scss/_starter-site-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
overflow: hidden;
margin-bottom: 14px;
position: relative;
border: 2px solid transparent;

&:hover, &:focus-within {
&:hover {
border: 2px solid #3498db;
transition: all 0.3s ease;
}

&:focus-within, .card-selected {
.ss-actions {
opacity: 1;
}
Expand Down
Loading