diff --git a/plugin/assets/css/src/block-editor.css b/plugin/assets/css/src/block-editor.css index 4f435c4a0..f0622a047 100644 --- a/plugin/assets/css/src/block-editor.css +++ b/plugin/assets/css/src/block-editor.css @@ -26,6 +26,7 @@ @import "./material-components.css"; @import "./tokens/index.css"; @import "./components/datatable-editor.css"; +@import "./components/button.css"; @media (min-width: 600px) { diff --git a/plugin/assets/css/src/components/button.css b/plugin/assets/css/src/components/button.css new file mode 100644 index 000000000..991e5d46f --- /dev/null +++ b/plugin/assets/css/src/components/button.css @@ -0,0 +1,126 @@ +/* + * 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. + */ + +.mdc-button { + align-items: center; + border: 0; + display: flex; + justify-content: center; + letter-spacing: 0.1px; + padding: 10px 24px; + + &:focus, + &:active { + outline: thin dotted; + } + + & .mdc-button__icon ~ .mdc-button__label { + margin-left: 8px; + } + + &.is-large { + height: 50px; + padding: 16px 32px; + } + + &:disabled { + cursor: not-allowed; + } +} + +.mdc-button--raised, +.mdc-button--elevated { + background-color: var(--md-sys-color-surface-variant); + border: 0 !important; /* Use !important to override the default style of the button. */ + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15); + color: var(--md-sys-color-primary); + + &:hover { + background-color: rgba(var(--md-sys-color-primary-rgb), 0.08); + } + + &:focus, + &:active { + background-color: rgba(var(--md-sys-color-primary-rgb), 0.12); + } + + &:disabled { + background-color: rgba(31, 31, 31, 0.12); + color: var(--md-sys-color-on-surface); + } +} + +.mdc-button--outlined, +.mdc-button--outlined:not(:disabled), +.mdc-button--text, +.mdc-button--text:not(:disabled) { + background: transparent; + border: 1px solid var(--md-sys-color-outline) !important; /* Use !important to override the default style of the button. */ + color: var(--md-sys-color-primary); + + &:hover { + background-color: rgba(var(--md-sys-color-primary-rgb), 0.08); + } + + &:focus, + &:active { + background-color: rgba(var(--md-sys-color-primary-rgb), 0.12); + } + + &:disabled { + border: 1px solid rgba(31, 31, 31, 0.12); + color: var(--md-sys-color-on-surface); + } +} + +.mdc-button--text, +.mdc-button--text:not(:disabled) { + border: 0 !important; /* Use !important to override the default style of the button. */ +} + +.mdc-button--text:disabled { + color: var(--md-sys-color-on-surface); +} + +.mdc-button--filled, +.mdc-button--unelevated { + background-color: var(--md-sys-color-primary); + color: var(--md-sys-color-on-primary); + + &:hover { + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15); + } + + &:disabled { + background-color: rgba(31, 31, 31, 0.12); + color: var(--md-sys-color-on-surface); + } +} + +.mdc-button--tonal { + background-color: var(--md-sys-color-secondary-container); + color: var(--md-sys-color-on-secondary-container); + + &:hover { + background-color: rgba(var(--md-sys-color-secondary-container-rgb), 0.8); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15); + } + + &:disabled { + background-color: rgba(31, 31, 31, 0.12); + color: var(--md-sys-color-on-surface); + } +} diff --git a/plugin/assets/css/src/components/card.css b/plugin/assets/css/src/components/card.css index 5ceb478f7..069bd5b60 100644 --- a/plugin/assets/css/src/components/card.css +++ b/plugin/assets/css/src/components/card.css @@ -158,7 +158,7 @@ .mdc-card__link, .single-post-card__title, .material-design-card__title { - color: var(--md-sys-color-on-surface, #000); + text-decoration: none; } diff --git a/plugin/assets/css/src/material-components.css b/plugin/assets/css/src/material-components.css index d787632d7..7259db755 100644 --- a/plugin/assets/css/src/material-components.css +++ b/plugin/assets/css/src/material-components.css @@ -33,3 +33,4 @@ @import "./components/tab-indicator.css"; @import "./components/list.css"; @import "./components/tooltip.css"; +@import "./components/button.css"; diff --git a/plugin/assets/src/block-editor/blocks/button/block.json b/plugin/assets/src/block-editor/blocks/button/block.json index a31451d63..c2afabd4e 100644 --- a/plugin/assets/src/block-editor/blocks/button/block.json +++ b/plugin/assets/src/block-editor/blocks/button/block.json @@ -15,8 +15,8 @@ "default": "text" }, "style": { - "type": "string", - "default": "raised" + "default": "raised", + "type": "string" }, "iconPosition": { "type": "string", @@ -76,6 +76,11 @@ "size": { "type": "string", "default": "normal" + }, + "elevationStyle": { + "default": "elevated", + "enum": [ "text", "outlined", "elevated", "filled", "tonal" ], + "type": "string" } } } diff --git a/plugin/assets/src/block-editor/blocks/button/deprecated.js b/plugin/assets/src/block-editor/blocks/button/deprecated.js new file mode 100644 index 000000000..bbaf3e4b0 --- /dev/null +++ b/plugin/assets/src/block-editor/blocks/button/deprecated.js @@ -0,0 +1,24 @@ +/** + * Copyright 2021 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. + */ + +/** + * Internal dependencies + */ +import { SaveM2 } from './deprecated/m2/m2-version'; + +const deprecated = [ SaveM2 ]; + +export default deprecated; diff --git a/plugin/assets/src/block-editor/blocks/button/deprecated/m2/m2-version.js b/plugin/assets/src/block-editor/blocks/button/deprecated/m2/m2-version.js new file mode 100644 index 000000000..0d3ed2351 --- /dev/null +++ b/plugin/assets/src/block-editor/blocks/button/deprecated/m2/m2-version.js @@ -0,0 +1,284 @@ +/* + * 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. + */ + +/** + * External dependencies + */ +import classNames from 'classnames'; + +/** + * Internal dependencies + */ +import hasBg from '../../utils/has-bg'; + +/** + * Button Children component. + * + * @param {Object} props - Component props. + * @param {string} props.icon - Button icon name. + * @param {string} props.iconPosition - Button icon position. + * @param {string} props.label - Button label. + * + * @return {JSX.Element} Function returning the HTML markup for the component. + */ +const ButtonChildren = ( { icon, iconPosition, label } ) => ( + <> + { icon && iconPosition === 'leading' && ( + { icon } + ) } +
+ { label } + { icon && iconPosition === 'trailing' && ( + { icon } + ) } + > +); + +const attributesM2 = { + label: { + type: 'string', + source: 'html', + selector: '.mdc-button__label', + default: '', + }, + type: { + type: 'string', + default: 'text', + }, + style: { + type: 'string', + default: 'raised', + }, + iconPosition: { + type: 'string', + default: 'leading', + }, + cornerRadius: { + type: 'number', + }, + url: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'href', + default: '', + }, + rel: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'rel', + default: '', + }, + linkTarget: { + type: 'string', + source: 'attribute', + selector: 'a', + attribute: 'target', + }, + icon: { + type: 'string', + default: '', + source: 'text', + selector: '.material-icons', + }, + backgroundColor: { + type: 'string', + }, + textColor: { + type: 'string', + }, + tooltip: { + type: 'string', + default: '', + source: 'text', + selector: '.mdc-tooltip', + }, + id: { + type: 'string', + source: 'attribute', + attribute: 'id', + selector: '*', + }, + isSubmit: { + type: 'boolean', + default: false, + }, + size: { + type: 'string', + default: 'normal', + }, +}; + +const Save = ( { + attributes: { + rel, + url, + icon, + type, + label, + style, + textColor, + linkTarget, + cornerRadius, + iconPosition, + backgroundColor, + isSubmit, + tooltip, + id, + size, + }, + className, +} ) => { + if ( 'icon' === type ) { + const tooltipId = tooltip ? `${ id }-tooltip` : false; + const tooltipProps = tooltipId + ? { + 'aria-describedby': tooltipId, + } + : {}; + + return ( +