Skip to content

Commit 0770bf6

Browse files
adjusted styling, removed javascript for fixed position
1 parent b3abf67 commit 0770bf6

File tree

4 files changed

+50
-53
lines changed

4 files changed

+50
-53
lines changed

src/welcome/admin.js

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SVGSectionIcon from './images/settings-icon-section.svg'
1111
*/
1212
import { __ } from '@wordpress/i18n'
1313
import {
14-
useEffect, useState, useCallback, useRef, useMemo, lazy, Suspense,
14+
useEffect, useState, useCallback, useMemo, lazy, Suspense,
1515
} from '@wordpress/element'
1616
import domReady from '@wordpress/dom-ready'
1717
import { Spinner, CheckboxControl } from '@wordpress/components'
@@ -337,28 +337,9 @@ const Sidenav = ( {
337337
},
338338
], [] )
339339

340-
const sidenavRef = useRef( null )
341-
342-
useEffect( () => {
343-
const handleScroll = () => {
344-
const header = document.querySelector( '.s-header-settings' )
345-
346-
if ( header ) {
347-
// If the header is scrolled out of view, make the sidebar fixed
348-
if ( header.getBoundingClientRect().bottom <= 32 ) {
349-
sidenavRef.current.classList.add( 's-sidenav-fixed' )
350-
} else {
351-
sidenavRef.current.classList.remove( 's-sidenav-fixed' )
352-
}
353-
}
354-
}
355-
window.addEventListener( 'scroll', handleScroll )
356-
return () => window.removeEventListener( 'scroll', handleScroll )
357-
}, [] )
358-
359340
return (
360341
<>
361-
<nav className="s-sidenav" ref={ sidenavRef }>
342+
<nav className="s-sidenav">
362343
<div>
363344
{ tabList.map( ( {
364345
id,
@@ -384,13 +365,15 @@ const Sidenav = ( {
384365
</button>
385366
)
386367
} ) }
368+
<div className="s-save-changes-wrapper">
369+
<button
370+
className="s-save-changes"
371+
onClick={ handleSettingsSave }
372+
>
373+
{ isSaving ? <Spinner /> : __( 'Save Changes', i18n ) }
374+
</button>
375+
</div>
387376
</div>
388-
<button
389-
className="s-save-changes"
390-
onClick={ handleSettingsSave }
391-
>
392-
{ isSaving ? <Spinner /> : __( 'Save Changes', i18n ) }
393-
</button>
394377
</nav>
395378
</>
396379
)

src/welcome/admin.scss

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ body.toplevel_page_stk-custom-fields {
398398
margin-bottom: 30px;
399399
transition: all 0.3s ease;
400400
position: relative;
401-
min-height: 70vh;
402401
&.s-box-spaced {
403402
padding-left: 4vw;
404403
padding-right: 4vw;
@@ -476,9 +475,6 @@ body.toplevel_page_stk-custom-fields {
476475
display: flex;
477476
flex-direction: column;
478477
}
479-
&.s-body-container-with-sidenav {
480-
margin-left: 250px;
481-
}
482478
p,
483479
li {
484480
line-height: 1.6;
@@ -496,16 +492,27 @@ body.toplevel_page_stk-custom-fields {
496492
margin-bottom: 0 !important;
497493
}
498494
}
495+
#settings-content {
496+
position: relative;
497+
display: grid;
498+
grid-template-columns: 250px 1fr;
499+
}
499500
.s-sidenav {
500501
min-height: 90vh;
501502
width: 250px;
502503
left: 0;
503-
position: absolute;
504504
background-color: #fff;
505-
padding-top: 20px;
505+
padding-top: 40px;
506506
display: flex;
507507
flex-direction: column;
508508
justify-content: flex-start;
509+
> * {
510+
position: sticky;
511+
height: 100vh;
512+
display: flex;
513+
flex-direction: column;
514+
top: 50px;
515+
}
509516
.s-sidenav-item {
510517
color: #444;
511518
font-size: 14px;
@@ -526,13 +533,14 @@ body.toplevel_page_stk-custom-fields {
526533
font-weight: 600;
527534
color: var(--stk-welcome-primary) !important;
528535
transition: color 0.3s ease;
536+
background: #f1f1f1;
529537
&::after {
530538
content: "";
531539
position: absolute;
532540
right: 0;
533541
top: 0;
534542
bottom: 0;
535-
width: 2px;
543+
width: 4px;
536544
background-color: var(--stk-welcome-primary);
537545
transition: width 0.3s ease;
538546
}
@@ -541,10 +549,20 @@ body.toplevel_page_stk-custom-fields {
541549
font-weight: bold;
542550
}
543551
}
552+
.s-save-changes-wrapper {
553+
bottom: 0;
554+
padding: 20px;
555+
flex: 1 0 auto;
556+
display: flex;
557+
flex-direction: column;
558+
justify-content: end;
559+
}
544560
// This is a button, render this in the bottom of the side bar
545561
// The side bar is a flex container, so this will be at the bottom.
546562
.s-save-changes {
547563
background: linear-gradient(135deg, #b300be, #f00069);
564+
width: 100%;
565+
margin: 0;
548566
transition: all 0.1s ease-in-out;
549567
text-decoration: none;
550568
border: none;
@@ -556,22 +574,14 @@ body.toplevel_page_stk-custom-fields {
556574
cursor: pointer;
557575
box-sizing: border-box !important;
558576
display: inline-block;
559-
margin: 20px 20px 0;
577+
position: sticky;
578+
bottom: 20px;
560579
&:hover {
561580
opacity: 0.85;
562581
box-shadow: none !important;
563582
}
564583
}
565584
}
566-
.s-sidenav-fixed {
567-
position: fixed;
568-
height: 100%;
569-
top: 32px;
570-
left: 160px;
571-
.s-save-changes {
572-
margin: 120px 20px 0;
573-
}
574-
}
575585
.s-search-setting {
576586
display: flex;
577587
justify-content: end;
@@ -680,11 +690,19 @@ body.toplevel_page_stk-custom-fields {
680690
}
681691
}
682692
.stackable_notice_wrapper {
683-
outline: 2px solid #f00069;
684-
margin-bottom: 30px;
693+
// outline: 2px solid #f00069;
694+
margin: 0;
695+
padding: 20px;
696+
background: #e9ebee;
685697
}
686698
.stackable_notice {
687699
margin-bottom: 35px;
700+
> *:last-child {
701+
margin-bottom: 0;
702+
}
703+
}
704+
#editor-settings {
705+
margin-bottom: 0;
688706
}
689707
.s-settings-header {
690708
text-align: right;
@@ -879,10 +897,6 @@ body.toplevel_page_stk-custom-fields {
879897
.s-body-container {
880898
grid-template-columns: 1fr !important;
881899
}
882-
// Matched the width of wordpress admin menu
883-
.s-sidenav-fixed {
884-
left: 36px !important;
885-
}
886900
}
887901

888902
// Save spinner for the additional options.

src/welcome/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ public function stackable_settings_content() {
185185
<div class="s-rest-settings-notice"></div>
186186
<div class="s-save-settings-notice"></div>
187187
</section>
188+
<?php stackable_welcome_notification() ?>
188189
<section class="s-body-container s-body-container-with-sidenav">
189190
<div class="s-body" id="settings-body">
190-
<?php stackable_welcome_notification() ?>
191191
<?php do_action( 'stackable_settings_page' ) ?>
192-
192+
193193
<div class="s-content" id="settings-content"></div>
194194
<?php do_action( 'stackable_settings_page_mid' ); ?>
195195
<!-- We put all the other options here. -->

src/welcome/notification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function() {
135135
?>
136136
<div class="stackable_notice">
137137
<?php echo wp_kses_post( $notification['message'] ) ?>
138-
<p><button class="button" data-id="<?php echo esc_attr( $notification['id'] ) ?>" onclick="stackable_dismiss(this); event.preventDefault();"><?php _e( 'Don\'t show me this anymore', STACKABLE_I18N ) ?></button></p>
138+
<p><button class="button button-primary" data-id="<?php echo esc_attr( $notification['id'] ) ?>" onclick="stackable_dismiss(this); event.preventDefault();"><?php _e( 'Don\'t show me this anymore', STACKABLE_I18N ) ?></button></p>
139139
</div>
140140
<?php
141141
}

0 commit comments

Comments
 (0)