Skip to content

Commit 2cdc940

Browse files
committed
fix: styles and media queries, spinner on saved
1 parent c92aa4f commit 2cdc940

File tree

2 files changed

+16
-30
lines changed

2 files changed

+16
-30
lines changed

src/welcome/admin.js

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,6 @@ const RestSettingsNotice = () => {
187187
)
188188
}
189189

190-
const SaveSettingsNotice = () => {
191-
const [ isDismissed, setIsDismissed ] = useState( false )
192-
193-
if ( isDismissed ) {
194-
return null
195-
}
196-
197-
return (
198-
<div className="notice notice-success is-dismissible" >
199-
<p>{ __( 'Settings saved.', i18n ) }</p>
200-
<button type="button" className="notice-dismiss" onClick={ () => setIsDismissed( true ) }>
201-
<span className="screen-reader-text">Dismiss this notice.</span>
202-
</button>
203-
</div>
204-
)
205-
}
206-
207190
// Confirmation dialog when disabling a block that is dependent on another block.
208191
const ToggleBlockDialog = ( {
209192
blockName,
@@ -247,13 +230,13 @@ const ToggleBlockDialog = ( {
247230
)
248231
}
249232

250-
// TODO: Proper tab nesting
251-
// Implement other highlight without admin base
233+
// Side navigation with the save changes button and search on tabs
252234
const Sidenav = ( {
253235
currentTab,
254236
handleTabChange,
255237
handleSettingsSave,
256238
currentSearch,
239+
isSaving,
257240
} ) => {
258241
const tabList = useMemo( () => [
259242
{
@@ -406,7 +389,7 @@ const Sidenav = ( {
406389
className="s-save-changes"
407390
onClick={ handleSettingsSave }
408391
>
409-
{ __( 'Save Changes', i18n ) }
392+
{ isSaving ? <Spinner /> : __( 'Save Changes', i18n ) }
410393
</button>
411394
</nav>
412395
</>
@@ -436,27 +419,24 @@ const Settings = () => {
436419
const [ unsavedChanges, setUnsavedChanges ] = useState( {} )
437420
const [ currentTab, setCurrentTab ] = useState( 'editor-settings' )
438421
const [ currentSearch, setCurrentSearch ] = useState( '' )
422+
const [ isSaving, setIsSaving ] = useState( false )
439423

440424
const handleSettingsChange = useCallback( newSettings => {
441425
setSettings( prev => ( { ...prev, ...newSettings } ) )
442426
setUnsavedChanges( prev => ( { ...prev, ...newSettings } ) )
443427
}, [] )
444428

445429
const handleSettingsSave = useCallback( () => {
446-
console.log( unsavedChanges ) // eslint-disable-line no-console
447430
if ( Object.keys( unsavedChanges ).length === 0 ) {
448431
return
449432
}
433+
setIsSaving( true )
450434
const model = new models.Settings( unsavedChanges )
451435
model.save().then( () => {
452-
if ( document.querySelector( '.s-save-settings-notice' ) ) {
453-
createRoot(
454-
document.querySelector( '.s-save-settings-notice' )
455-
).render(
456-
<SaveSettingsNotice />
457-
)
458-
window.scrollTo( { top: 0, behavior: 'smooth' } )
459-
}
436+
// Add a little more time for the spinner for better feedback
437+
setTimeout( () => {
438+
setIsSaving( false )
439+
}, 500 )
460440
} )
461441
setUnsavedChanges( {} )
462442
}, [ unsavedChanges, settings ] )
@@ -482,6 +462,7 @@ const Settings = () => {
482462
handleTabChange={ setCurrentTab }
483463
handleSettingsSave={ handleSettingsSave }
484464
currentSearch={ currentSearch }
465+
isSaving={ isSaving }
485466
/>
486467
<article className="s-box" id={ currentTab }>
487468
<Searchbar currentSearch={ currentSearch } handleSearchChange={ setCurrentSearch } />

src/welcome/admin.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ body.toplevel_page_stk-custom-fields {
398398
margin-bottom: 30px;
399399
transition: all 0.3s ease;
400400
position: relative;
401+
min-height: 70vh;
401402
&.s-box-spaced {
402403
padding-left: 4vw;
403404
padding-right: 4vw;
@@ -873,11 +874,15 @@ body.toplevel_page_stk-custom-fields {
873874
grid-template-columns: 1fr 1fr 1fr;
874875
}
875876

876-
// Collapse to a single column for mobile.
877877
@media screen and (max-width: 960px) {
878+
// Collapse to a single column for mobile.
878879
.s-body-container {
879880
grid-template-columns: 1fr !important;
880881
}
882+
// Matched the width of wordpress admin menu
883+
.s-sidenav-fixed {
884+
left: 36px !important;
885+
}
881886
}
882887

883888
// Save spinner for the additional options.

0 commit comments

Comments
 (0)