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

UI bug fixes reported #436

Merged
merged 15 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
Expand Up @@ -2,7 +2,7 @@
import { forwardRef, useImperativeHandle } from 'react';
import { useState, useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { PanelBody, PanelRow, Button, Dashicon } from '@wordpress/components';
import { PanelBody, PanelRow, Button } from '@wordpress/components';
import './stylesheet.scss';
import { store as nfdOnboardingStore } from '../../../../../store';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -154,17 +154,11 @@ const CustomFontsDisplay = ( {
role="presentation"
onClick={ () => handleGroupSelect( 'custom' ) }
>
<Dashicon
className={ `${ baseClassName }__font-group__container__button__icon` }
icon={ 'yes-alt' }
size={ 30 }
style={ {
color:
selectedGroup === 'custom'
? 'var(--nfd-onboarding-sitegen-customize-icon-selected)'
: 'var(--nfd-onboarding-sitegen-customize-grey-1)',
} }
/>
<span
className={ `${ baseClassName }__font-group__container__button__icon${
selectedGroup === 'custom' ? ` selected` : ``
}` }
></span>
<div
className={ `${ baseClassName }__font-group__container__button__font-name__container` }
>
Expand Down
198 changes: 128 additions & 70 deletions src/OnboardingSPA/steps/SiteGen/Editor/Header/center.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,19 @@
import { Icon, chevronDown, reusableBlock } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { useViewportMatch } from '@wordpress/compose';
import { useRef } from '@wordpress/element';
import { useRef, useState, useEffect, memo } from '@wordpress/element';
import { ReactComponent as FavoriteIconStroked } from '../../../../static/icons/sitegen/heart-stroked.svg';
import { ReactComponent as FavoriteFilled } from '../../../../static/icons/sitegen/heart-filled.svg';
import { Dropdown, MenuGroup, MenuItem } from '@wordpress/components';

const StepEditorHeaderCenter = ( {
handleFavorite,
handleRename,
handleViewAll,
handleRegenerate,
handleCustomize,
handleIsRenaming,
isRenaming,
homepageTitle,
isFavorite,
} ) => {
const isLargeViewport = useViewportMatch( 'medium' );
const inputRef = useRef( null );

const onRegenerate = () => {
if ( typeof handleRegenerate === 'function' ) {
return handleRegenerate();
}
};

const onFavorite = () => {
if ( typeof onFavorite === 'function' ) {
return handleFavorite();
}
};

const onCustomize = () => {
if ( typeof handleCustomize === 'function' ) {
return handleCustomize();
}
};

const onViewAll = () => {
if ( typeof handleViewAll === 'function' ) {
return handleViewAll();
}
};

const onRenameItemSelect = () => {
if ( typeof handleIsRenaming === 'function' ) {
handleIsRenaming( true );
return inputRef.current.focus();
}
};

const onRename = () => {
if ( typeof handleRename === 'function' ) {
handleRename( inputRef.current.value );
}
};

const onTitleInputBlur = () => {
if ( typeof handleIsRenaming === 'function' ) {
return handleIsRenaming( false );
}
};

if ( isRenaming ) {
inputRef.current.focus();
}

const DropDownMenu = () => {
const DropDownMenu = memo(
( {
onRegenerate,
onCustomize,
onRenameItemSelect,
onViewAll,
isLargeViewport,
} ) => {
return (
<MenuGroup className="nfd-onboarding-header__version_dropdown-menu">
{ ! isLargeViewport && (
Expand All @@ -91,9 +37,46 @@ const StepEditorHeaderCenter = ( {
</MenuItem>
</MenuGroup>
);
};
}
);

const TitleContent = memo(
( {
isFavorite,
homepageTitle,
onFavorite,
onRename,
inputRef,
onRegenerate,
onCustomize,
onRenameItemSelect,
onViewAll,
isLargeViewport,
isInputEnabled,
enableInput,
} ) => {
const [ renameInputValue, setRenameInputValue ] =
useState( homepageTitle );

const handleOnChange = () => {
setRenameInputValue( inputRef.current.value );
};

const onTitleInputBlur = () => {
onRename();
enableInput( false );
};

useEffect( () => {
if ( isInputEnabled ) {
inputRef.current?.focus();
}
}, [ isInputEnabled, inputRef ] );

useEffect( () => {
setRenameInputValue( homepageTitle );
}, [ homepageTitle ] );

const TitleContent = () => {
return (
<Dropdown
renderToggle={ ( { isOpen, onToggle } ) => (
Expand Down Expand Up @@ -122,12 +105,12 @@ const StepEditorHeaderCenter = ( {
</div>
<input
ref={ inputRef }
disabled={ ! isInputEnabled }
className="nfd-onboarding-header__center-input"
disabled={ ! isRenaming }
type="text"
value={ homepageTitle }
value={ renameInputValue }
onBlur={ onTitleInputBlur }
onChange={ onRename }
onChange={ handleOnChange }
/>
<Icon
icon={ chevronDown }
Expand All @@ -140,14 +123,89 @@ const StepEditorHeaderCenter = ( {
/>
</div>
) }
renderContent={ DropDownMenu }
renderContent={ () => (
<DropDownMenu
onRegenerate={ onRegenerate }
onCustomize={ onCustomize }
onRenameItemSelect={ onRenameItemSelect }
onViewAll={ onViewAll }
isLargeViewport={ isLargeViewport }
/>
) }
/>
);
}
);

const StepEditorHeaderCenter = ( {
handleFavorite,
handleRename,
handleViewAll,
handleRegenerate,
handleCustomize,
homepageTitle,
isFavorite,
} ) => {
const isLargeViewport = useViewportMatch( 'medium' );
const inputRef = useRef( null );
const [ isInputEnabled, setInputEnabled ] = useState( false );
const enableInput = ( isEnabled ) => {
setInputEnabled( isEnabled );
if ( isEnabled ) {
inputRef.current?.focus();
}
};

const onRegenerate = () => {
if ( typeof handleRegenerate === 'function' ) {
return handleRegenerate();
}
};

const onFavorite = () => {
if ( typeof onFavorite === 'function' ) {
return handleFavorite();
}
};

const onCustomize = () => {
if ( typeof handleCustomize === 'function' ) {
return handleCustomize();
}
};

const onViewAll = () => {
if ( typeof handleViewAll === 'function' ) {
return handleViewAll();
}
};

const onRenameItemSelect = () => {
enableInput( true );
};

const onRename = () => {
if ( typeof handleRename === 'function' ) {
handleRename( inputRef.current.value );
ajayadav09 marked this conversation as resolved.
Show resolved Hide resolved
}
};

return (
<div className="nfd-onboarding-header__step-navigation">
<TitleContent />
<TitleContent
isFavorite={ isFavorite }
homepageTitle={ homepageTitle }
onFavorite={ onFavorite }
onRename={ onRename }
inputRef={ inputRef }
onRegenerate={ onRegenerate }
onCustomize={ onCustomize }
onRenameItemSelect={ onRenameItemSelect }
onViewAll={ onViewAll }
isLargeViewport={ isLargeViewport }
isInputEnabled={ isInputEnabled }
enableInput={ enableInput }
/>
</div>
);
};
Expand Down
11 changes: 3 additions & 8 deletions src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
const [ homepage, setHomepage ] = useState();
const [ isSaving, setIsSaving ] = useState( false );
const [ isRegenerating, setIsRegenerating ] = useState( false );
const [ isEditingTitle, setIsEditingTitle ] = useState( false );

const isLargeViewport = useViewportMatch( 'medium' );

Expand Down Expand Up @@ -126,7 +125,7 @@

useEffect( () => {
handleCustomize();
}, [] );

Check warning on line 128 in src/OnboardingSPA/steps/SiteGen/Editor/Header/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'handleCustomize'. Either include it or remove the dependency array

useEffect( () => {
if ( currentData?.sitegen?.homepages?.active ) {
Expand Down Expand Up @@ -176,13 +175,9 @@
handleViewAll={ handleViewAll }
handleCustomize={ handleCustomize }
handleRegenerate={ handleRegenerate }
handleIsRenaming={ ( isRenaming ) =>
setIsEditingTitle( isRenaming )
}
handleRename={ handleRename }
homepageTitle={ homepage.title }
isFavorite={ homepage.isFavorite }
isRenaming={ isEditingTitle }
/>
</div>
) }
Expand Down Expand Up @@ -215,9 +210,9 @@
>
{ isLargeViewport
? __(
'Save & Continue',
'wp-module-onboarding'
)
'Save & Continue',
'wp-module-onboarding'
)
: __( 'Next', 'wp-module-onboarding' ) }
</div>
{ isSaving ? (
Expand Down
9 changes: 9 additions & 0 deletions src/OnboardingSPA/steps/SiteGen/Editor/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@
color: var(--nfd-onboarding-header-contrast);
background-color: var(--nfd-onboarding-header-base);
width: 150px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

@media (max-width: #{ ($break-small) }) {
width: 80px;
}

&:focus {
overflow: visible;
white-space: normal;
text-overflow: clip;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/OnboardingSPA/steps/SiteGen/Preview/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

&__options {

@media (max-width: #{ ($break-xlarge) }) {
@media (max-width: #{ ($break-medium) }) {
flex-direction: column;
}

Expand All @@ -55,6 +55,8 @@
margin: 10px 10px 55px 10px;
flex-wrap: wrap;
max-width: 1440px;
align-items: center;
justify-content: center;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-01-31 at 7 15 14 PM
Screenshot 2024-01-31 at 7 15 47 PM

Doesn't look right 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@officiallygod Have updated the code with by adding width to the parent container. The width will be different for devices.

}

&__note {
Expand Down
Loading