{/* translators: [admin] */ __('Loading…', 'amnesty')}
++ {/* translators: [admin] */ __('Select an author.', 'amnesty')} +
++ {/* translators: [admin] */ __('No Items found', 'amnesty')} +
+{/* translators: [admin] */ __('Loading…', 'amnesty')}
++ {/* translators: [admin] */ __('Select a category.', 'amnesty')} +
++ {/* translators: [admin] */ __('No Items found', 'amnesty')} +
+{/* translators: [admin] */ __('Loading…', 'amnesty')}
++ {/* translators: [admin] */ __('No Items found', 'amnesty')} +
+{/* translators: [admin] */ __('Loading…', 'amnesty')}
++ {/* translators: [admin] */ __('Select a taxonomy.', 'amnesty')} +
++ {/* translators: [admin] */ __('No Items found', 'amnesty')} +
+{__('Loading…', 'amnesty')}
; + } + + if (!posts.length > 0) { + /* translators: [admin] */ + return{__('No Posts.', 'amnesty')}
; + } + + if (props.style === 'grid') { + return [1, 2, 3, 5, 6, 7].indexOf(posts.length) > -1 ? ( +
+ {/* translators: [admin/front] */}
+ {__('Author:', 'amnesty')}
+
{__('Loading Posts…', 'amnesty')}
; + } + + if (filtered && posts.length < 1) { + return ( ++ { + /* translators: [admin] */ __( + 'Your query yielded no results, please try again.', + 'amnesty', + ) + } +
+{/* translators: [admin] */ __('No Posts.', 'amnesty')}
; + } + + function handleOnDragEnd(result) { + props.reorderPosts(result); + } + + return ( +{content}
+ + {linkText} + +{content}
+ + {linkText} + +{content}
+ + {/* translators: [admin] */ __('Act Now', 'amnesty')} + +{content}
+ + {/* translators: [admin] */ __('Act Now', 'amnesty')} + +++ ); + }, +}; + +const v1 = { + supports: { + className: false, + }, + attributes: { + align: { + type: 'string', + }, + size: { + type: 'string', + }, + colour: { + type: 'string', + }, + capitalise: { + type: 'boolean', + }, + lined: { + type: 'boolean', + }, + content: { + type: 'string', + }, + citation: { + type: 'string', + }, + }, + + save({ attributes }) { + const { + align = '', + size = '', + colour = '', + capitalise = false, + lined = true, + content = '', + citation = '', + } = attributes; + + const classes = classnames('blockquote', { + [`align-${align}`]: !!align, + [`is-${size}`]: !!size, + [`is-${colour}`]: !!colour, + 'is-capitalised': capitalise, + 'is-lined': lined, + }); + + const quoteStyle = {}; + if (Object.prototype.hasOwnProperty.call(window, 'amnestyCoreI18n')) { + const { openDoubleQuote, closeDoubleQuote, openSingleQuote, closeSingleQuote } = + window.amnestyCoreI18n; + + quoteStyle.quotes = `"${openDoubleQuote}" "${closeDoubleQuote}" "${openSingleQuote}" "${closeSingleQuote}";`; + } + + return ( ++ +
++ ); + }, +}; + +const deprecated = [v2, v1]; + +export default deprecated; diff --git a/private/src/blocks/blockquote/edit.jsx b/private/src/blocks/blockquote/edit.jsx new file mode 100644 index 00000000..914c87ea --- /dev/null +++ b/private/src/blocks/blockquote/edit.jsx @@ -0,0 +1,146 @@ +import classnames from 'classnames'; + +import { InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor'; +import { PanelBody, SelectControl, ToggleControl } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; + +const isRightToLeft = document.documentElement.getAttribute('dir') === 'rtl'; +const hasI18n = Object.prototype.hasOwnProperty.call(window, 'amnestyCoreI18n'); + +const getDirections = () => { + const directionalOptions = [ + /* translators: [admin] text alignment. for RTL languages, localise as 'Right' */ + { value: 'start', label: __('Left', 'amnesty') }, + /* translators: [admin] text alignment */ + { value: '', label: __('Default', 'amnesty') }, + ]; + + if (!isRightToLeft) { + /* translators: [admin] text alignment. for RTL languages, localise as 'Left' */ + directionalOptions.push({ value: 'end', label: __('Right', 'amnesty') }); + } + + return directionalOptions; +}; + +const getQuoteStyles = () => { + if (!hasI18n) { + return ''; + } + + const { openDoubleQuote, closeDoubleQuote, openSingleQuote, closeSingleQuote } = + window.amnestyCoreI18n; + + return `.blockquote { + quotes: '${openDoubleQuote}' '${closeDoubleQuote}' "${openSingleQuote}" "${closeSingleQuote}"; + }`; +}; + +export default function Edit({ attributes, setAttributes }) { + const { + align = '', + size = '', + colour = '', + capitalise = false, + lined = true, + content = '', + citation = '', + } = attributes; + + const classes = classnames('blockquote', { + [`align-${align}`]: !!align, + [`is-${size}`]: !!size, + [`is-${colour}`]: !!colour, + 'is-capitalised': capitalise, + 'is-lined': lined, + }); + + const blockProps = useBlockProps({ + className: classes, + }); + + return ( + <> ++ {citation && } +
> + + + + + + +diff --git a/private/src/blocks/blockquote/style.scss b/private/src/blocks/blockquote/style.scss new file mode 100644 index 00000000..84a532ba --- /dev/null +++ b/private/src/blocks/blockquote/style.scss @@ -0,0 +1,296 @@ +.blockquote { + position: relative; + margin: 70px auto 24px; + font-family: var(--wp--preset--font-family--secondary); + text-align: center; + + @media all and (min-width: 760px) { + max-width: calc(var(--wp--preset--layout--contentSize) / 2); + } +} + +.blockquote::before { + content: open-quote; + position: absolute; + left: calc(50% - 16px); + font-family: var(--wp--preset--font-family--secondary) !important; + font-weight: bold; + font-size: 60px !important; + line-height: 1px; + + @media all and (min-width: 540px) { + font-size: 70px !important; + } + + @media all and (min-width: 940px) { + font-size: 80px !important; + } + + [lang*="fr"] & { + top: -20px; + left: 50%; + transform: translateX(-50%); + } + + [lang*="fa-IR"] & { + top: -40px; + } +} + +.blockquote::after { + content: close-quote; + position: absolute !important; + overflow: hidden !important; + width: 1px !important; + height: 1px !important; + padding: 0 !important; + border: 0 !important; + clip: rect(1px, 1px, 1px, 1px) !important; +} + +.blockquote.is-grey { + color: var(--wp--preset--color--grey-light); + border-color: var(--wp--preset--color--grey-light); +} + +.blockquote.is-white { + color: var(--wp--preset--color--white); + border-color: var(--wp--preset--color--white); +} + +.blockquote[class*="align-"] { + margin-top: 24px !important; +} + +.blockquote.align-start::before, +.blockquote.align-end::before { + display: none; +} + +.blockquote.align-start { + margin-left: 0; + text-align: left; + + .rtl & { + margin-right: 0; + margin-left: auto !important; + text-align: right; + } +} + +.blockquote.align-end { + margin-right: 0; + text-align: right; + + .rtl & { + margin-right: auto !important; + margin-left: 0; + text-align: left; + } +} + +.blockquote.align-end p { + line-height: 1.2 !important; +} + +.blockquote p { + position: relative; + margin-bottom: 20px; + font-weight: bold; + font-size: 24px !important; + line-height: 1.2 !important; + + &:last-of-type { + margin-bottom: 0; + } + + @media all and (min-width: 540px) { + font-size: 32px !important; + } + + @media all and (min-width: 940px) { + font-size: 36px !important; + } +} + +.blockquote.is-medium p { + font-size: 20px !important; + + @media all and (min-width: 540px) { + font-size: 28px !important; + } + + @media all and (min-width: 940px) { + font-size: 32px !important; + } +} + +.blockquote.is-small p { + font-size: 16px !important; + line-height: 1.2 !important; + + @media all and (min-width: 540px) { + font-size: 24px !important; + } + + @media all and (min-width: 940px) { + font-size: 28px !important; + } +} + +.blockquote[class*="align-"] p:first-of-type::before, +.blockquote[class*="align-"] p:last-of-type::after { + display: inline-block; + font-size: 24px; + + @media all and (min-width: 760px) { + font-size: 32px; + } +} + +.blockquote[class*="align-"] p:first-of-type::before { + content: open-quote; + + [lang*="fr"] & { + margin-right: .2em; + } +} + +.blockquote[class*="align-"] p:last-of-type::after { + content: close-quote; + + [lang*="fr"] & { + margin-left: .2em; + } +} + +.blockquote.align-start p:first-of-type::before { + text-indent: -7px; + + @media all and (min-width: 940px) { + text-indent: -15px; + } +} + +.rtl .blockquote.align-end p:first-of-type::before { + right: 0; +} + +.blockquote.align-end p:last-of-type::after { + position: absolute; +} + +.blockquote cite { + display: inline-block; + font-style: normal; + font-size: 18px !important; + font-weight: bold !important; + line-height: 40px !important; + padding-bottom: 24px; + + @media all and (min-width: 540px) { + font-size: 20px !important; + } + + @media all and (min-width: 940px) { + font-size: 24px !important; + } +} + +.blockquote.is-lined:not([class*="align"]) cite::after { + content: ""; + display: block; + margin: 8px auto 0; + max-width: 200px; + height: 6px; + background-color: var(--wp--preset--color--black); + + @media all and (min-width: 940px) { + height: 8px; + } +} + +.blockquote.is-medium cite { + font-size: 16px !important; + + @media all and (min-width: 540px) { + font-size: 20px !important; + } + + @media all and (min-width: 940px) { + font-size: 22px !important; + } +} + +.blockquote.is-small cite { + font-size: 14px !important; + line-height: 40px !important; + + @media all and (min-width: 540px) { + font-size: 18px !important; + } + + @media all and (min-width: 940px) { + font-size: 20px !important; + + &::after { + height: 6px; + } + } +} + +.blockquote.is-capitalised p { + text-transform: uppercase; +} + +.blockquote.align-start cite, +.blockquote.align-end cite { + border-bottom: none; + line-height: 40px !important; +} + +.ltr .blockquote.align-start.is-lined { + padding-left: 35px; + border-left: 8px solid; +} + +.rtl .blockquote.align-start.is-lined, +.ltr .blockquote.align-end.is-lined { + padding-right: 35px; + border-right: 8px solid; +} + +.page-template-templates .blockquote.align-start { + margin-left: auto; +} + +.page-template-templates .blockquote.align-end { + margin-right: auto; +} + +.rtl .blockquote.align-end.is-lined { + padding-left: 35px; + border-left: 8px solid; +} + +.blockquote[class*="align-"].is-small p:first-of-type::before, +.blockquote[class*="align-"].is-small p:last-of-type::after { + display: inline-block; + font-size: 16px; + + @media all and (min-width: 760px) { + font-size: 28px; + } +} + +.section > .container .blockquote { + margin-top: 70px; +} + +.blockquote.is-white.is-lined cite::after { + background-color: var(--wp--preset--color--white); +} + +.blockquote.is-grey.is-lined cite::after { + background-color: var(--wp--preset--color--grey-light); +} diff --git a/private/src/blocks/blockquote/transforms.jsx b/private/src/blocks/blockquote/transforms.jsx new file mode 100644 index 00000000..507dd0d4 --- /dev/null +++ b/private/src/blocks/blockquote/transforms.jsx @@ -0,0 +1,107 @@ +import { createBlock } from '@wordpress/blocks'; +import { getPhrasingContentSchema } from '@wordpress/dom'; + +const transforms = { + from: [ + { + type: 'block', + isMultiBlock: true, + blocks: ['core/heading'], + transform: (attributes) => + attributes.map(({ content }) => createBlock('amnesty-core/quote', { content })), + }, + { + type: 'block', + isMultiBlock: true, + blocks: ['core/paragraph'], + transform: (attributes) => + attributes.map(({ content }) => createBlock('amnesty-core/quote', { content })), + }, + { + type: 'block', + blocks: ['core/pullquote'], + transform: ({ value, citation }) => + createBlock('amnesty-core/quote', { + content: value, + citation, + }), + }, + { + type: 'pattern', + regExp: /^>\s/, + transform: ({ content }) => + createBlock('amnesty-core/quote', { + content: `
${content}
`, + }), + }, + { + type: 'raw', + selector: 'blockquote', + schema: { + blockquote: { + children: { + p: { + children: getPhrasingContentSchema(), + }, + }, + }, + }, + transform: (node) => { + const content = node.querySelector('p')?.innerHTML || ''; + const citation = node.querySelector('cite')?.innerHTML || ''; + return createBlock('amnesty-core/quote', { content, citation }); + }, + }, + ], + to: [ + { + type: 'block', + blocks: ['core/heading'], + transform: ({ content, citation, ...attrs }) => { + if (content === '') { + return createBlock('core/heading', { + ...attrs, + content: citation, + }); + } + + return [content, citation].filter(Boolean).map((item) => + createBlock('core/heading', { + ...attrs, + content: item, + }), + ); + }, + }, + { + type: 'block', + blocks: ['core/paragraph'], + transform: ({ content, citation, ...attrs }) => { + if (content === '') { + return createBlock('core/paragraph', { + ...attrs, + content: citation, + }); + } + + return [content, citation].filter(Boolean).map((item) => + createBlock('core/paragraph', { + ...attrs, + content: item, + }), + ); + }, + }, + { + type: 'block', + blocks: ['core/pullquote'], + transform: ({ content, citation }) => + createBlock('core/pullquote', { + value: content, + citation, + }), + }, + ], +}; + +export default transforms; diff --git a/private/src/blocks/call-to-action/block.json b/private/src/blocks/call-to-action/block.json new file mode 100644 index 00000000..3390ea9e --- /dev/null +++ b/private/src/blocks/call-to-action/block.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "amnesty-core/block-call-to-action", + "title": "Call to Action", + "category": "amnesty-core", + "description": "", + "icon": "megaphone", + "textdomain": "amnesty", + "editorScript": "file:./index.js", + "editorStyle": "file:./index.css", + "style": "file:./style-index.css", + "render": "file:./render.php", + "supports": { + "className": false, + "multiple": true, + "inserter": false + }, + "attributes": { + "preheading": { + "type": "string", + "default": "" + }, + "title": { + "type": "string", + "default": "" + }, + "content": { + "type": "string", + "default": "" + }, + "background": { + "type": "string", + "default": "" + }, + "actionType": { + "type": "string", + "default": "" + } + } +} diff --git a/private/src/blocks/call-to-action/deprecated.jsx b/private/src/blocks/call-to-action/deprecated.jsx new file mode 100644 index 00000000..fe5f1582 --- /dev/null +++ b/private/src/blocks/call-to-action/deprecated.jsx @@ -0,0 +1,220 @@ +import classnames from 'classnames'; + +import { assign, isEmpty, omit } from 'lodash'; +import { InnerBlocks, RichText } from '@wordpress/block-editor'; +import { createBlock } from '@wordpress/blocks'; + +const blockAttributes = { + preheading: { + type: 'array', + }, + title: { + type: 'string', + }, + content: { + type: 'array', + }, + ctaLink: { + type: 'string', + }, + ctaText: { + type: 'array', + }, + background: { + type: 'string', + }, + style: { + type: 'string', + }, + actionType: { + type: 'string', + }, +}; + +const v4 = { + supports: { + className: false, + multiple: true, + }, + attributes: assign({}, blockAttributes, { + preheading: { + type: 'string', + }, + content: { + type: 'string', + }, + }), + save: ({ attributes }) => { + const { background = false, preheading, title, content } = attributes; + const divClasses = classnames('callToAction', { [`callToAction--${background}`]: background }); + + return ( +