From 4c562a6b8eec3cc2efed94a168d49821be22d443 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Thu, 19 Dec 2024 15:24:54 +0200 Subject: [PATCH] refactor: show Select on card selection, add highlight on hover --- onboarding/src/Components/Sites.js | 13 ++++++++-- onboarding/src/Components/StarterSiteCard.js | 27 ++++++++++++++++++-- onboarding/src/scss/_starter-site-card.scss | 8 +++++- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/onboarding/src/Components/Sites.js b/onboarding/src/Components/Sites.js index 35fe27cc..4827d716 100644 --- a/onboarding/src/Components/Sites.js +++ b/onboarding/src/Components/Sites.js @@ -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 = () => { @@ -60,13 +61,21 @@ const Sites = ( { getSites, editor, category, searchQuery } ) => { const getBuilders = () => Object.keys( sites ); const allData = getFilteredSites(); - return ( <> { allData.length ? (
{ allData.slice( 0, maxShown ).map( ( site, index ) => { - return ; + return ( + { + setSelectedSite( site.slug === selectedStarterSite ? '' : site.slug ); + }} + /> + ); } ) } { const { upsell, screenshot, title, category, query } = data; @@ -36,7 +39,9 @@ const StarterSiteCard = ( { return (
-
+
{ upsell && ( @@ -45,7 +50,25 @@ const StarterSiteCard = ( { ) } -
+
{ + e.preventDefault(); + toggleSelectedSite(); + }} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + toggleSelectedSite(); + } + }} + >