Skip to content

Commit 8061849

Browse files
simplified modal
1 parent 7fa798e commit 8061849

File tree

3 files changed

+53
-82
lines changed

3 files changed

+53
-82
lines changed

src/components/admin-toolbar-setting/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const AdminToolbarSetting = props => {
2828
const tabindex = isSelected ? '0' : '-1'
2929
const isDisabled = props.disabledValues ? props.disabledValues.includes( option.value ) : false
3030

31+
// Do not show the button if disabled.
32+
if ( isDisabled ) {
33+
return null
34+
}
35+
3136
return <Button
3237
style={ option.selectedColor && isSelected ? { color: option.selectedColor } : {} }
3338
isPrimary={ ! option.selectedColor && isSelected }

src/welcome/admin.js

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import SVGSectionIcon from './images/settings-icon-section.svg'
99
/**
1010
* WordPress dependencies
1111
*/
12-
import { __ } from '@wordpress/i18n'
12+
import { __, sprintf } from '@wordpress/i18n'
1313
import {
1414
useEffect, useState, useCallback, useMemo, lazy, Suspense,
1515
} from '@wordpress/element'
1616
import domReady from '@wordpress/dom-ready'
17-
import { Spinner, CheckboxControl } from '@wordpress/components'
17+
import {
18+
Button, Flex, FlexItem, Spinner, CheckboxControl, Modal,
19+
} from '@wordpress/components'
1820
import { loadPromise, models } from '@wordpress/api'
1921
import { applyFilters } from '@wordpress/hooks'
2022

@@ -393,37 +395,48 @@ const ToggleBlockDialog = ( {
393395
const blockTitle = getBlockTitle( blockName )
394396

395397
return (
396-
<div className="s-toggle-block-dialog">
397-
<div className="s-toggle-block-dialog-content">
398-
{ isDisabled
399-
? <p>{ __( 'Disabling ' + blockTitle + ' will also disable the blocks that require it:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
400-
: <p>{ __( 'Enabling ' + blockTitle + ' will also enable its required innerblocks:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
401-
}
402-
<ul>
403-
{ blockList.map( ( block, i ) => (
404-
<li key={ i }>{ getBlockTitle( block ) }</li>
405-
) ) }
406-
</ul>
407-
{ isDisabled
408-
? <p>{ __( 'Are you sure you want to disable this block?', i18n ) }</p>
409-
: <p>{ __( 'Are you sure you want to enable this block?', i18n ) }</p>
410-
}
411-
<div>
412-
<button
413-
className="s-dialog-button s-dialog-button-confirm"
414-
onClick={ onConfirm }
415-
>
416-
{ __( 'Yes', i18n ) }
417-
</button>
418-
<button
419-
className="s-dialog-button s-dialog-button-cancel"
398+
<Modal
399+
className="s-confirm-modal"
400+
size="medium"
401+
title={ isDisabled
402+
? sprintf( __( 'Disable %s block?', i18n ), blockTitle )
403+
: sprintf( __( 'Enable %s block?', i18n ), blockTitle ) }
404+
onRequestClose={ onCancel }
405+
>
406+
{ isDisabled
407+
? <p>{ __( 'Disabling this block will also disable these blocks that require this block to function:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
408+
: <p>{ __( 'Enabling this block will also enable these blocks that are needed for this block to function:', i18n ) }</p> // eslint-disable-line @wordpress/i18n-no-variables
409+
}
410+
<ul>
411+
{ blockList.map( ( block, i ) => (
412+
<li key={ i }>{ getBlockTitle( block ) }</li>
413+
) ) }
414+
</ul>
415+
<Flex
416+
justify="flex-end"
417+
expanded={ false }
418+
>
419+
<FlexItem>
420+
<Button
421+
variant="secondary"
420422
onClick={ onCancel }
421423
>
422-
{ __( 'No', i18n ) }
423-
</button>
424-
</div>
425-
</div>
426-
</div>
424+
{ __( 'Cancel', i18n ) }
425+
</Button>
426+
</FlexItem>
427+
<FlexItem>
428+
<Button
429+
variant="primary"
430+
onClick={ onConfirm }
431+
>
432+
{ isDisabled
433+
? __( 'Disable', i18n )
434+
: __( 'Enable', i18n )
435+
}
436+
</Button>
437+
</FlexItem>
438+
</Flex>
439+
</Modal>
427440
)
428441
}
429442

src/welcome/admin.scss

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -626,57 +626,10 @@ body.toplevel_page_stk-custom-fields {
626626
display: none;
627627
}
628628

629-
.s-toggle-block-dialog {
630-
position: fixed;
631-
top: 0;
632-
left: 0;
633-
width: 100%;
634-
height: 100%;
635-
background-color: rgba(0, 0, 0, 0.5); // Semi-transparent black
636-
display: flex;
637-
justify-content: center;
638-
align-items: center;
639-
z-index: 1000;
640-
.s-toggle-block-dialog-content {
641-
background-color: #fff;
642-
padding: 20px;
643-
border-radius: 8px;
644-
text-align: center;
645-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
646-
max-width: 400px;
647-
width: 100%;
648-
ul {
649-
display: inline-block;
650-
text-align: left;
651-
}
652-
}
653-
.s-dialog-button {
654-
margin-top: 20px;
655-
&.s-dialog-button-confirm {
656-
background-color: #28a745;
657-
color: #fff;
658-
border: none;
659-
padding: 10px 20px;
660-
border-radius: 5px;
661-
cursor: pointer;
662-
margin-right: 10px;
663-
transition: background-color 0.3s;
664-
&:hover {
665-
background-color: #218838;
666-
}
667-
}
668-
&.s-dialog-button-cancel {
669-
background-color: #dc3545;
670-
color: #fff;
671-
border: none;
672-
padding: 10px 20px;
673-
border-radius: 5px;
674-
cursor: pointer;
675-
transition: background-color 0.3s;
676-
&:hover {
677-
background-color: #c82333;
678-
}
679-
}
629+
.s-confirm-modal {
630+
.components-button {
631+
--wp-admin-theme-color: #f00069;
632+
--wp-admin-theme-color-darker-10: #c40056;
680633
}
681634
}
682635

0 commit comments

Comments
 (0)