-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Site Editor]: Add clear customizations to template card (#41743)
- Loading branch information
1 parent
48e96d5
commit 9f37df4
Showing
3 changed files
with
107 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 49 additions & 35 deletions
84
packages/edit-site/src/components/sidebar/template-card/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,65 @@ | ||
.edit-site-template-card { | ||
display: flex; | ||
align-items: flex-start; | ||
} | ||
|
||
.edit-site-template-card__content { | ||
flex-grow: 1; | ||
margin-bottom: $grid-unit-05; | ||
} | ||
&__content { | ||
flex-grow: 1; | ||
margin-bottom: $grid-unit-05; | ||
} | ||
|
||
.edit-site-template-card__title { | ||
font-weight: 500; | ||
line-height: $icon-size; | ||
&.edit-site-template-card__title { | ||
margin: 0 0 $grid-unit-05; | ||
&__title { | ||
font-weight: 500; | ||
line-height: $icon-size; | ||
&.edit-site-template-card__title { | ||
margin: 0; | ||
} | ||
} | ||
} | ||
|
||
.edit-site-template-card__description { | ||
font-size: $default-font-size; | ||
margin: 0 0 $grid-unit-20; | ||
} | ||
&__description { | ||
font-size: $default-font-size; | ||
margin: 0 0 $grid-unit-20; | ||
} | ||
|
||
.edit-site-template-card__icon { | ||
flex: 0 0 $icon-size; | ||
margin-right: $grid-unit-15; | ||
width: $icon-size; | ||
height: $icon-size; | ||
} | ||
&__icon { | ||
flex: 0 0 $icon-size; | ||
margin-right: $grid-unit-15; | ||
width: $icon-size; | ||
height: $icon-size; | ||
} | ||
|
||
h3.edit-site-template-card__template-areas-title { | ||
font-weight: 500; | ||
margin: 0 0 $grid-unit-10; | ||
} | ||
&__template-areas-list { | ||
margin: 0; | ||
|
||
.edit-site-template-card__template-areas-list { | ||
margin: 0; | ||
> li { | ||
margin: 0; | ||
} | ||
} | ||
|
||
> li { | ||
margin: 0; | ||
&__template-areas-item { | ||
width: 100%; | ||
|
||
// Override the default padding. | ||
&.components-button.has-icon { | ||
padding: 0; | ||
} | ||
} | ||
} | ||
|
||
.edit-site-template-card__template-areas-item { | ||
width: 100%; | ||
&__header { | ||
display: flex; | ||
justify-content: space-between; | ||
margin: 0 0 $grid-unit-05; | ||
} | ||
|
||
// Override the default padding. | ||
&.components-button.has-icon { | ||
padding: 0; | ||
&__actions { | ||
line-height: 0; | ||
> .components-button.is-small.has-icon { | ||
padding: 0; | ||
min-width: auto; | ||
} | ||
} | ||
} | ||
|
||
h3.edit-site-template-card__template-areas-title { | ||
font-weight: 500; | ||
margin: 0 0 $grid-unit-10; | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/edit-site/src/components/sidebar/template-card/template-actions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useDispatch } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components'; | ||
import { moreVertical } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../../store'; | ||
import isTemplateRevertable from '../../../utils/is-template-revertable'; | ||
|
||
export default function Actions( { template } ) { | ||
const { revertTemplate } = useDispatch( editSiteStore ); | ||
const isRevertable = isTemplateRevertable( template ); | ||
if ( ! isRevertable ) { | ||
return null; | ||
} | ||
return ( | ||
<DropdownMenu | ||
icon={ moreVertical } | ||
label={ __( 'Actions' ) } | ||
className="edit-site-template-card__actions" | ||
toggleProps={ { isSmall: true } } | ||
> | ||
{ ( { onClose } ) => ( | ||
<MenuGroup> | ||
<MenuItem | ||
info={ __( 'Restore to default state' ) } | ||
onClick={ () => { | ||
revertTemplate( template ); | ||
onClose(); | ||
} } | ||
> | ||
{ __( 'Clear customizations' ) } | ||
</MenuItem> | ||
</MenuGroup> | ||
) } | ||
</DropdownMenu> | ||
); | ||
} |