-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'full-site-editing' into fse/page
- Loading branch information
Showing
33 changed files
with
695 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,5 +46,10 @@ | |
}, | ||
"parserOptions": { | ||
"requireConfigFile": false | ||
}, | ||
"settings": { | ||
"jsdoc": { | ||
"mode": "typescript" | ||
} | ||
} | ||
} |
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
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,19 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
header.wp-block-template-part + * { | ||
margin-top: 12rem; | ||
} |
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
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
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
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
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
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
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
28 changes: 28 additions & 0 deletions
28
theme/assets/src/block-editor/blocks/search-header-title/block.json
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,28 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "material/search-title", | ||
"textdomain": "material-design-google", | ||
"category": "material", | ||
"attributes": { | ||
"textAlign": { | ||
"type": "string" | ||
}, | ||
"level": { | ||
"type": "number", | ||
"default": 2 | ||
}, | ||
"title": { | ||
"type": "string", | ||
"default": "Search Results for:" | ||
} | ||
}, | ||
"title": "Material Search Title", | ||
"supports": {}, | ||
"description": "Material search title", | ||
"editorStyle": [ | ||
"material-google-fonts", | ||
"material-block-editor-css-theme" | ||
], | ||
"editorScript": "material-block-editor-js-theme" | ||
} |
95 changes: 95 additions & 0 deletions
95
theme/assets/src/block-editor/blocks/search-header-title/edit.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,95 @@ | ||
/** | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
AlignmentControl, | ||
BlockControls, | ||
InspectorControls, | ||
useBlockProps, | ||
} from '@wordpress/block-editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
import HeadingLevelDropdown from './heading-level-dropdown'; | ||
import { PanelBody, TextControl } from '@wordpress/components'; | ||
|
||
/** | ||
* Edit. | ||
* | ||
* @param {Object} props | ||
* @param {Object} props.attributes | ||
* @param {string} props.attributes.textAlign | ||
* @param {string} props.attributes.title | ||
* @param {number} props.attributes.level | ||
* @param {Function} props.setAttributes | ||
* @return {JSX.Element} Block edit. | ||
*/ | ||
const Edit = ( { attributes: { textAlign, level, title }, setAttributes } ) => { | ||
const TagName = 0 === level ? 'p' : 'h' + level; | ||
const blockProps = useBlockProps( { | ||
className: classnames( | ||
{ | ||
[ `has-text-align-${ textAlign }` ]: textAlign, | ||
}, | ||
'page-title', | ||
'mdc-typography', | ||
`mdc-typography--headline-${ level }` | ||
), | ||
} ); | ||
return ( | ||
<> | ||
<BlockControls group="block"> | ||
<HeadingLevelDropdown | ||
selectedLevel={ level } | ||
onChange={ newLevel => | ||
setAttributes( { level: newLevel } ) | ||
} | ||
/> | ||
<AlignmentControl | ||
value={ textAlign } | ||
onChange={ nextAlign => { | ||
setAttributes( { textAlign: nextAlign } ); | ||
} } | ||
/> | ||
</BlockControls> | ||
<InspectorControls> | ||
<PanelBody title={ __( 'Link settings' ) }> | ||
<TextControl | ||
label={ __( 'Search title', 'material-design-google' ) } | ||
value={ title } | ||
onChange={ newTitle => | ||
setAttributes( { title: newTitle } ) | ||
} | ||
/> | ||
</PanelBody> | ||
</InspectorControls> | ||
<TagName { ...blockProps }> | ||
{ title } | ||
<span> | ||
{ __( ' search keyword', 'material-design-google' ) } | ||
</span> | ||
</TagName> | ||
</> | ||
); | ||
}; | ||
|
||
export default Edit; |
72 changes: 72 additions & 0 deletions
72
theme/assets/src/block-editor/blocks/search-header-title/heading-level-dropdown.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,72 @@ | ||
/** | ||
* Source: https://github.com/WordPress/gutenberg/blob/5062a1ebac941d3feabb66da34c9205c8247d6b0/packages/block-library/src/heading/heading-level-dropdown.js | ||
*/ | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { ToolbarDropdownMenu } from '@wordpress/components'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import HeadingLevelIcon from './heading-level-icon'; | ||
|
||
const HEADING_LEVELS = [ 1, 2, 3, 4, 5, 6 ]; | ||
|
||
const POPOVER_PROPS = { | ||
className: 'block-library-heading-level-dropdown', | ||
}; | ||
|
||
/** @typedef {import('@wordpress/element').WPComponent} WPComponent */ | ||
|
||
/** | ||
* HeadingLevelDropdown props. | ||
* | ||
* @typedef WPHeadingLevelDropdownProps | ||
* | ||
* @property {number} selectedLevel The chosen heading level. | ||
* @property {(newValue:number)=>any} onChange Callback to run when | ||
* toolbar value is changed. | ||
*/ | ||
|
||
/** | ||
* Dropdown for selecting a heading level (1 through 6). | ||
* | ||
* @param {WPHeadingLevelDropdownProps} props Component props. | ||
* | ||
* @return {WPComponent} The toolbar. | ||
*/ | ||
export default function HeadingLevelDropdown( { selectedLevel, onChange } ) { | ||
return ( | ||
<ToolbarDropdownMenu | ||
popoverProps={ POPOVER_PROPS } | ||
icon={ <HeadingLevelIcon level={ selectedLevel } /> } | ||
label={ __( 'Change heading level' ) } | ||
controls={ HEADING_LEVELS.map( targetLevel => { | ||
{ | ||
const isActive = targetLevel === selectedLevel; | ||
|
||
return { | ||
icon: ( | ||
<HeadingLevelIcon | ||
level={ targetLevel } | ||
isPressed={ isActive } | ||
/> | ||
), | ||
label: sprintf( | ||
// translators: %s: heading level e.g: "1", "2", "3" | ||
__( 'Heading %d' ), | ||
targetLevel | ||
), | ||
isActive, | ||
onClick() { | ||
onChange( targetLevel ); | ||
}, | ||
}; | ||
} | ||
} ) } | ||
/> | ||
); | ||
} |
55 changes: 55 additions & 0 deletions
55
theme/assets/src/block-editor/blocks/search-header-title/heading-level-icon.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,55 @@ | ||
/** | ||
* Source: https://github.com/WordPress/gutenberg/blob/5062a1ebac941d3feabb66da34c9205c8247d6b0/packages/block-library/src/heading/heading-level-icon.js | ||
*/ | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Path, SVG } from '@wordpress/components'; | ||
|
||
// eslint-disable-next-line jsdoc/valid-types,jsdoc/valid-types | ||
/** @typedef {import('@wordpress/element').WPComponent} WPComponent */ | ||
|
||
/** | ||
* HeadingLevelIcon props. | ||
* | ||
* @typedef WPHeadingLevelIconProps | ||
* | ||
* @property {number} level The heading level to show an icon for. | ||
* @property {?boolean} isPressed Whether or not the icon should appear pressed; default: false. | ||
*/ | ||
|
||
/** @typedef {import('@wordpress/element').WPComponent} WPComponent */ | ||
|
||
/** | ||
* Heading level icon. | ||
* | ||
* @param {WPHeadingLevelIconProps} props Component props. | ||
* | ||
* @return {?WPComponent} The icon. | ||
*/ | ||
export default function HeadingLevelIcon( { level, isPressed = false } ) { | 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5.1-.2.1-.5.1-.7 0-.4-.1-.8-.4-1.1-.3-.2-.7-.3-1.1-.3-.3 0-.7.1-1 .2-.4.2-.7.4-1 .7 0 .3.1.7.3 1 .1.2.3.4.4.6.2.1.3.3.5.3.2.1.5.2.7.1z', | ||
}; | ||
if ( ! levelToPath.hasOwnProperty( level ) ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<SVG | ||
width="24" | ||
height="24" | ||
viewBox="0 0 20 20" | ||
xmlns="http://www.w3.org/2000/svg" | ||
isPressed={ isPressed } | ||
> | ||
<Path d={ levelToPath[ level ] } /> | ||
</SVG> | ||
); | ||
} |
Oops, something went wrong.