From ff893a84bce2cc81aec89cb3ebac536f9aae618f Mon Sep 17 00:00:00 2001 From: Christophe Jossart Date: Thu, 11 Jul 2024 18:57:24 +0200 Subject: [PATCH 001/100] chore: bump default php memory limit --- .lagoon/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.lagoon/Dockerfile b/.lagoon/Dockerfile index db5094463..5c0858c05 100644 --- a/.lagoon/Dockerfile +++ b/.lagoon/Dockerfile @@ -60,6 +60,7 @@ COPY --from=builder /tmp/.deploy/cms /app WORKDIR /app ENV WEBROOT=web +ENV PHP_MEMORY_LIMIT=2048 # ==================================================================================================== # PHP IMAGE @@ -73,6 +74,7 @@ COPY --from=cli /app /app WORKDIR /app ENV WEBROOT=web +ENV PHP_MEMORY_LIMIT=2048 # ==================================================================================================== # NGINX IMAGE From 3091d2d1a9954ac0a5ed9f1baf3c4478010ac149 Mon Sep 17 00:00:00 2001 From: Alex Tkachev Date: Sun, 14 Jul 2024 13:45:16 +0400 Subject: [PATCH 002/100] feat(SLB-451): conditional content block --- .../src/blocks/conditional.tsx | 171 ++++++++++++++++++ packages/drupal/gutenberg_blocks/src/index.ts | 1 + .../52ee5cc7-0ac5-49b5-8550-ce59476bd4ac.yml | 62 +++++++ packages/schema/src/fragments/Page.gql | 1 + .../PageContent/BlockConditional.gql | 17 ++ packages/schema/src/schema.graphql | 19 ++ .../PageContent/BlockConditional.tsx | 30 +++ .../src/components/Organisms/PageDisplay.tsx | 61 ++++--- tests/schema/specs/blocks.spec.ts | 55 ++++++ 9 files changed, 393 insertions(+), 24 deletions(-) create mode 100644 packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx create mode 100644 packages/drupal/test_content/content/node/52ee5cc7-0ac5-49b5-8550-ce59476bd4ac.yml create mode 100644 packages/schema/src/fragments/PageContent/BlockConditional.gql create mode 100644 packages/ui/src/components/Organisms/PageContent/BlockConditional.tsx diff --git a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx new file mode 100644 index 000000000..131c59b2f --- /dev/null +++ b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx @@ -0,0 +1,171 @@ +import clsx from 'clsx'; +import { InnerBlocks, InspectorControls } from 'wordpress__block-editor'; +import { registerBlockType } from 'wordpress__blocks'; +import { BaseControl, PanelBody } from 'wordpress__components'; + +// @ts-ignore +const { t: __ } = Drupal; + +registerBlockType(`custom/conditional`, { + title: __('Conditional content'), + category: 'layout', + icon: 'category', + // Allow the block only at the root level to avoid GraphQL fragment recursion. + parent: ['custom/content'], + attributes: { + displayFrom: { + type: 'string', + default: '', + }, + displayTo: { + type: 'string', + default: '', + }, + purpose: { + type: 'string', + default: '', + }, + }, + edit(props) { + const { attributes, setAttributes } = props; + + const displayFrom = attributes.displayFrom as string | undefined; + const displayTo = attributes.displayTo as string | undefined; + const purpose = ((attributes.purpose as string) || '').trim(); + + // Same logic as in BlockConditional.tsx + const active = { + scheduledDisplay: [ + displayFrom + ? new Date(displayFrom).getTime() <= new Date().getTime() + : true, + displayTo ? new Date(displayTo).getTime() > new Date().getTime() : true, + ].every(Boolean), + }; + const isActive = Object.values(active).every(Boolean); + + const conditions = { + scheduledDisplay: + displayFrom || displayTo + ? '🕒 ' + + __('Scheduled display') + + ': ' + + [ + displayFrom + ? __('From') + ' ' + new Date(displayFrom).toLocaleString() + : '', + displayTo + ? __('To') + ' ' + new Date(displayTo).toLocaleString() + : '', + ] + .filter(Boolean) + .join(' ') + : '', + }; + const hasConditions = Object.values(conditions).some(Boolean); + const summary = hasConditions ? ( + Object.entries(conditions) + .filter(([, value]) => !!value) + .map(([key, value]) =>
{value}
) + ) : ( +
{'ℹī¸ ' + __('No conditions set')}
+ ); + + return ( +
+
{__('Conditional content')}
+
{summary}
+
+ + {purpose || __('Content')} + + +
+ + + + { + setAttributes({ purpose: event.target.value }); + }} + /> + + +
+ + + + +
+ { + setAttributes({ + displayFrom: event.target.value + ? localToIsoTime(event.target.value) + : '', + }); + }} + /> +
+ +
+ { + setAttributes({ + displayTo: event.target.value + ? localToIsoTime(event.target.value) + : '', + }); + }} + /> +
+ +
+ + + +
+ ); + }, + + save() { + return ; + }, +}); + +function localToIsoTime(localTime: string) { + return new Date(localTime).toISOString(); +} + +function isoToLocalTime(isoTime: string) { + const date = new Date(isoTime); + date.setMinutes(date.getMinutes() - date.getTimezoneOffset()); + return date.toISOString().slice(0, 16); +} diff --git a/packages/drupal/gutenberg_blocks/src/index.ts b/packages/drupal/gutenberg_blocks/src/index.ts index 9a846e2b3..256fb2d0c 100644 --- a/packages/drupal/gutenberg_blocks/src/index.ts +++ b/packages/drupal/gutenberg_blocks/src/index.ts @@ -10,6 +10,7 @@ import './blocks/image-with-text'; import './filters/list'; import './blocks/cta'; import './blocks/quote'; +import './blocks/conditional'; import './blocks/horizontal-separator'; import './blocks/accordion'; import './blocks/accordion-item-text'; diff --git a/packages/drupal/test_content/content/node/52ee5cc7-0ac5-49b5-8550-ce59476bd4ac.yml b/packages/drupal/test_content/content/node/52ee5cc7-0ac5-49b5-8550-ce59476bd4ac.yml new file mode 100644 index 000000000..d59c3dc67 --- /dev/null +++ b/packages/drupal/test_content/content/node/52ee5cc7-0ac5-49b5-8550-ce59476bd4ac.yml @@ -0,0 +1,62 @@ +_meta: + version: '1.0' + entity_type: node + uuid: 52ee5cc7-0ac5-49b5-8550-ce59476bd4ac + bundle: page + default_langcode: en +default: + revision_uid: + - + target_id: 1 + status: + - + value: true + uid: + - + target_id: 1 + title: + - + value: 'Conditional blocks' + created: + - + value: 1715684657 + promote: + - + value: false + sticky: + - + value: false + moderation_state: + - + value: published + path: + - + alias: /conditional-blocks + langcode: en + pathauto: 0 + content_translation_source: + - + value: und + content_translation_outdated: + - + value: false + body: + - + value: |- + + + + + +

Complete

+ + + + + +

No conditions

+ + + + format: gutenberg + summary: '' diff --git a/packages/schema/src/fragments/Page.gql b/packages/schema/src/fragments/Page.gql index 28f7127f2..33a67a4d5 100644 --- a/packages/schema/src/fragments/Page.gql +++ b/packages/schema/src/fragments/Page.gql @@ -38,6 +38,7 @@ fragment Page on Page { ...BlockHorizontalSeparator ...BlockAccordion ...BlockInfoGrid + ...BlockConditional } metaTags { tag diff --git a/packages/schema/src/fragments/PageContent/BlockConditional.gql b/packages/schema/src/fragments/PageContent/BlockConditional.gql new file mode 100644 index 000000000..5016b930f --- /dev/null +++ b/packages/schema/src/fragments/PageContent/BlockConditional.gql @@ -0,0 +1,17 @@ +fragment BlockConditional on BlockConditional { + displayFrom + displayTo + content { + __typename + ...BlockMarkup + ...BlockMedia + ...BlockForm + ...BlockImageTeasers + ...BlockCta + ...BlockImageWithText + ...BlockQuote + ...BlockHorizontalSeparator + ...BlockAccordion + ...BlockInfoGrid + } +} diff --git a/packages/schema/src/schema.graphql b/packages/schema/src/schema.graphql index 8784b0a90..5d47f54fc 100644 --- a/packages/schema/src/schema.graphql +++ b/packages/schema/src/schema.graphql @@ -198,6 +198,18 @@ type Hero { @webformIdToUrl(id: "$") } +union CommonContent @resolveEditorBlockType = + | BlockMarkup + | BlockMedia + | BlockForm + | BlockImageTeasers + | BlockCta + | BlockImageWithText + | BlockQuote + | BlockHorizontalSeparator + | BlockAccordion + | BlockInfoGrid + union PageContent @resolveEditorBlockType = | BlockMarkup | BlockMedia @@ -209,6 +221,7 @@ union PageContent @resolveEditorBlockType = | BlockHorizontalSeparator | BlockAccordion | BlockInfoGrid + | BlockConditional type BlockForm @type(id: "custom/form") { url: Url @resolveEditorBlockAttribute(key: "formId") @webformIdToUrl(id: "$") @@ -318,6 +331,12 @@ type BlockHorizontalSeparator @type(id: "custom/horizontal-separator") { markup: Markup! @resolveEditorBlockMarkup } +type BlockConditional @type(id: "custom/conditional") { + displayFrom: String @resolveEditorBlockAttribute(key: "displayFrom") + displayTo: String @resolveEditorBlockAttribute(key: "displayTo") + content: [CommonContent] @resolveEditorBlockChildren +} + input PaginationInput { limit: Int! offset: Int! diff --git a/packages/ui/src/components/Organisms/PageContent/BlockConditional.tsx b/packages/ui/src/components/Organisms/PageContent/BlockConditional.tsx new file mode 100644 index 000000000..b401ead14 --- /dev/null +++ b/packages/ui/src/components/Organisms/PageContent/BlockConditional.tsx @@ -0,0 +1,30 @@ +import { BlockConditionalFragment } from '@custom/schema'; +import React, { useEffect, useState } from 'react'; + +import { isTruthy } from '../../../utils/isTruthy'; +import { CommonContent } from '../PageDisplay'; + +export function BlockConditional(props: BlockConditionalFragment) { + const [isActive, setIsActive] = useState(false); + useEffect(() => { + const active = { + scheduledDisplay: [ + props.displayFrom + ? new Date(props.displayFrom).getTime() <= new Date().getTime() + : true, + props.displayTo + ? new Date(props.displayTo).getTime() > new Date().getTime() + : true, + ].every(Boolean), + }; + setIsActive(Object.values(active).every(Boolean)); + }, []); + + return isActive ? ( + <> + {props.content?.filter(isTruthy).map((block, index) => { + return ; + })} + + ) : null; +} diff --git a/packages/ui/src/components/Organisms/PageDisplay.tsx b/packages/ui/src/components/Organisms/PageDisplay.tsx index c5999faf9..a97ef64ce 100644 --- a/packages/ui/src/components/Organisms/PageDisplay.tsx +++ b/packages/ui/src/components/Organisms/PageDisplay.tsx @@ -1,5 +1,5 @@ 'use client'; -import { PageFragment } from '@custom/schema'; +import { BlockConditionalFragment, PageFragment } from '@custom/schema'; import React from 'react'; import { isTruthy } from '../../utils/isTruthy'; @@ -7,6 +7,7 @@ import { UnreachableCaseError } from '../../utils/unreachable-case-error'; import { BreadCrumbs } from '../Molecules/Breadcrumbs'; import { PageTransition } from '../Molecules/PageTransition'; import { BlockAccordion } from './PageContent/BlockAccordion'; +import { BlockConditional } from './PageContent/BlockConditional'; import { BlockCta } from './PageContent/BlockCta'; import { BlockForm } from './PageContent/BlockForm'; import { BlockHorizontalSeparator } from './PageContent/BlockHorizontalSeparator'; @@ -25,32 +26,44 @@ export function PageDisplay(page: PageFragment) { {!page.hero && } {page.hero && } {page?.content?.filter(isTruthy).map((block, index) => { - switch (block.__typename) { - case 'BlockMedia': - return ; - case 'BlockMarkup': - return ; - case 'BlockForm': - return ; - case 'BlockImageTeasers': - return ; - case 'BlockCta': - return ; - case 'BlockImageWithText': - return ; - case 'BlockQuote': - return
; - case 'BlockHorizontalSeparator': - return ; - case 'BlockAccordion': - return ; - case 'BlockInfoGrid': - return ; - default: - throw new UnreachableCaseError(block); + if (block.__typename === 'BlockConditional') { + return ; + } else { + return ; } })}
); } + +type CommonContentBlock = NonNullable< + Required['content'][number] +>; + +export function CommonContent(props: CommonContentBlock) { + switch (props.__typename) { + case 'BlockMedia': + return ; + case 'BlockMarkup': + return ; + case 'BlockForm': + return ; + case 'BlockImageTeasers': + return ; + case 'BlockCta': + return ; + case 'BlockImageWithText': + return ; + case 'BlockQuote': + return
; + case 'BlockHorizontalSeparator': + return ; + case 'BlockAccordion': + return ; + case 'BlockInfoGrid': + return ; + default: + throw new UnreachableCaseError(props); + } +} diff --git a/tests/schema/specs/blocks.spec.ts b/tests/schema/specs/blocks.spec.ts index 6ac6df879..397b4f543 100644 --- a/tests/schema/specs/blocks.spec.ts +++ b/tests/schema/specs/blocks.spec.ts @@ -643,3 +643,58 @@ test('Block - info grid', async () => { } `); }); + +test('Conditional', async () => { + const result = await fetch(gql` + { + _loadDrupalPage(id: "52ee5cc7-0ac5-49b5-8550-ce59476bd4ac") { + content { + __typename + ... on BlockConditional { + content { + ... on BlockMarkup { + markup + } + } + displayFrom + displayTo + } + } + } + } + `); + expect(result).toMatchInlineSnapshot(` + { + "data": { + "_loadDrupalPage": { + "content": [ + { + "__typename": "BlockConditional", + "content": [ + { + "markup": " +

Complete

+ ", + }, + ], + "displayFrom": "2024-05-16T11:05:00.000Z", + "displayTo": "2024-05-23T13:03:00.000Z", + }, + { + "__typename": "BlockConditional", + "content": [ + { + "markup": " +

No conditions

+ ", + }, + ], + "displayFrom": null, + "displayTo": null, + }, + ], + }, + }, + } + `); +}); From 212a3ebaadd57c4da14e5b9c0f0e61d29fa12f9d Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Fri, 19 Jul 2024 07:42:27 +0000 Subject: [PATCH 003/100] feat(SLB:455): a11y enhancements --- .../src/components/Organisms/ContentHub.tsx | 85 ++++++++++--------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/packages/ui/src/components/Organisms/ContentHub.tsx b/packages/ui/src/components/Organisms/ContentHub.tsx index 5dface3d5..978b7c304 100644 --- a/packages/ui/src/components/Organisms/ContentHub.tsx +++ b/packages/ui/src/components/Organisms/ContentHub.tsx @@ -1,5 +1,11 @@ import { useIntl } from '@amazeelabs/react-intl'; -import { ContentHubQuery, Image, Link, Locale } from '@custom/schema'; +import { + ContentHubQuery, + ContentHubResultItemFragment, + Image, + Link, + Locale, +} from '@custom/schema'; import qs from 'query-string'; import React from 'react'; @@ -52,43 +58,7 @@ export function ContentHub({ pageSize = 10 }: { pageSize: number }) {
    {data?.contentHub.items.filter(isTruthy).map((item) => (
  • -
    - - {item.teaserImage ? ( - - ) : ( -
    - )} - -
    - -
    - {item.title} -
    - - - Read more - - -
    -
    +
  • ))}
@@ -99,3 +69,42 @@ export function ContentHub({ pageSize = 10 }: { pageSize: number }) {
); } + +export const Card = (item: ContentHubResultItemFragment) => ( +
+
+ {item.teaserImage ? ( + + ) : ( +
+ )} +
+
+
+ {item.title} +
+ + {item.title} + Read more + + +
+
+); From 52926988f4fa25340391ad9ecde2d387e3a04786 Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Fri, 19 Jul 2024 08:02:47 +0000 Subject: [PATCH 004/100] chore(SLB:455): update tests --- tests/e2e/specs/drupal/content-hub.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/specs/drupal/content-hub.spec.ts b/tests/e2e/specs/drupal/content-hub.spec.ts index a65b17fc1..d3cc1fac2 100644 --- a/tests/e2e/specs/drupal/content-hub.spec.ts +++ b/tests/e2e/specs/drupal/content-hub.spec.ts @@ -10,7 +10,8 @@ test.describe('content hub', () => { test('lists pages in alphabetic order', async ({ page }) => { await page.goto(websiteUrl('/en/content-hub')); const content = await page.getByRole('main'); - await expect(content.getByText('Architecture')).toBeVisible(); + const heading = page.getByRole('heading', { name: 'Architecture', level: 5 }); + await expect(heading).toBeVisible(); await expect(content.getByText('PHP')).not.toBeVisible(); }); From f8f0deba1ba0ba3586a1658c20da0f4b1a98a96d Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Fri, 19 Jul 2024 08:05:28 +0000 Subject: [PATCH 005/100] chore(SLB:455): prettier --- tests/e2e/specs/drupal/content-hub.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/e2e/specs/drupal/content-hub.spec.ts b/tests/e2e/specs/drupal/content-hub.spec.ts index d3cc1fac2..de78f4fa8 100644 --- a/tests/e2e/specs/drupal/content-hub.spec.ts +++ b/tests/e2e/specs/drupal/content-hub.spec.ts @@ -10,7 +10,10 @@ test.describe('content hub', () => { test('lists pages in alphabetic order', async ({ page }) => { await page.goto(websiteUrl('/en/content-hub')); const content = await page.getByRole('main'); - const heading = page.getByRole('heading', { name: 'Architecture', level: 5 }); + const heading = page.getByRole('heading', { + name: 'Architecture', + level: 5, + }); await expect(heading).toBeVisible(); await expect(content.getByText('PHP')).not.toBeVisible(); }); From 59c0413941725fc3f2fe094977b775b513b70046 Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Fri, 19 Jul 2024 09:02:14 +0000 Subject: [PATCH 006/100] chore(SLB:455): update tests --- tests/e2e/specs/drupal/content-hub.spec.ts | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/e2e/specs/drupal/content-hub.spec.ts b/tests/e2e/specs/drupal/content-hub.spec.ts index de78f4fa8..dfed98e72 100644 --- a/tests/e2e/specs/drupal/content-hub.spec.ts +++ b/tests/e2e/specs/drupal/content-hub.spec.ts @@ -21,10 +21,14 @@ test.describe('content hub', () => { test('allows to switch pages', async ({ page }) => { await page.goto(websiteUrl('/en/content-hub')); const content = await page.getByRole('main'); - await expect(content.getByText('Architecture')).toBeVisible(); + const heading = page.getByRole('heading', { + name: 'Architecture', + level: 5, + }); + await expect(heading).toBeVisible(); await expect(content.getByText('Gatsby')).not.toBeVisible(); await content.getByText('Next').click(); - await expect(content.getByText('Architecture')).not.toBeVisible(); + await expect(heading).not.toBeVisible(); await expect(content.getByText('Gatsby')).toBeVisible(); }); @@ -33,7 +37,11 @@ test.describe('content hub', () => { const content = await page.getByRole('main'); await content.getByPlaceholder('Keyword').fill('technologies'); await content.getByRole('button', { name: 'Search' }).click(); - await expect(content.getByText('Architecture')).not.toBeVisible(); + const heading = page.getByRole('heading', { + name: 'Architecture', + level: 5, + }); + await expect(heading).not.toBeVisible(); await expect(content.getByText('Technologies')).toBeVisible(); }); @@ -43,8 +51,16 @@ test.describe('content hub', () => { // Change language to German. await quickActions.changeLanguageTo(SiteLanguage.Deutsch); const content = await page.getByRole('main'); - await expect(content.getByText('Architektur')).toBeVisible(); - await expect(content.getByText('Architecture')).not.toBeVisible(); + const deHeading = page.getByRole('heading', { + name: 'Architektur', + level: 5, + }); + const enHeading = page.getByRole('heading', { + name: 'Architecture', + level: 5, + }); + await expect(deHeading).toBeVisible(); + await expect(enHeading).not.toBeVisible(); await expect(content.getByText('Gatsby')).not.toBeVisible(); }); }); From 650149651edbc027e20aaa98a2056149f9060af0 Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Fri, 19 Jul 2024 09:30:17 +0000 Subject: [PATCH 007/100] chore(SLB:455): update tests --- tests/e2e/specs/drupal/content-hub.spec.ts | 73 +++++++++++++++------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/tests/e2e/specs/drupal/content-hub.spec.ts b/tests/e2e/specs/drupal/content-hub.spec.ts index dfed98e72..e6e9a55ad 100644 --- a/tests/e2e/specs/drupal/content-hub.spec.ts +++ b/tests/e2e/specs/drupal/content-hub.spec.ts @@ -21,15 +21,27 @@ test.describe('content hub', () => { test('allows to switch pages', async ({ page }) => { await page.goto(websiteUrl('/en/content-hub')); const content = await page.getByRole('main'); - const heading = page.getByRole('heading', { - name: 'Architecture', - level: 5, - }); - await expect(heading).toBeVisible(); + + await expect( + content.getByRole('heading', { + name: 'Architecture', + level: 5, + }), + ).toBeVisible(); await expect(content.getByText('Gatsby')).not.toBeVisible(); await content.getByText('Next').click(); - await expect(heading).not.toBeVisible(); - await expect(content.getByText('Gatsby')).toBeVisible(); + await expect( + content.getByRole('heading', { + name: 'Architecture', + level: 5, + }), + ).not.toBeVisible(); + await expect( + content.getByRole('heading', { + name: 'Gatsby', + level: 5, + }), + ).toBeVisible(); }); test('allows to search for items', async ({ page }) => { @@ -37,12 +49,18 @@ test.describe('content hub', () => { const content = await page.getByRole('main'); await content.getByPlaceholder('Keyword').fill('technologies'); await content.getByRole('button', { name: 'Search' }).click(); - const heading = page.getByRole('heading', { - name: 'Architecture', - level: 5, - }); - await expect(heading).not.toBeVisible(); - await expect(content.getByText('Technologies')).toBeVisible(); + await expect( + content.getByRole('heading', { + name: 'Architecture', + level: 5, + }), + ).not.toBeVisible(); + await expect( + content.getByRole('heading', { + name: 'Technologies', + level: 5, + }), + ).toBeVisible(); }); test('returns language specific results', async ({ page }) => { @@ -51,16 +69,23 @@ test.describe('content hub', () => { // Change language to German. await quickActions.changeLanguageTo(SiteLanguage.Deutsch); const content = await page.getByRole('main'); - const deHeading = page.getByRole('heading', { - name: 'Architektur', - level: 5, - }); - const enHeading = page.getByRole('heading', { - name: 'Architecture', - level: 5, - }); - await expect(deHeading).toBeVisible(); - await expect(enHeading).not.toBeVisible(); - await expect(content.getByText('Gatsby')).not.toBeVisible(); + await expect( + content.getByRole('heading', { + name: 'Architektur', + level: 5, + }), + ).toBeVisible(); + await expect( + content.getByRole('heading', { + name: 'Architecture', + level: 5, + }), + ).not.toBeVisible(); + await expect( + content.getByRole('heading', { + name: 'Gatsby', + level: 5, + }), + ).not.toBeVisible(); }); }); From 149dddac0d5b5ead02196771aa2e011caf0ba812 Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Thu, 25 Jul 2024 08:31:02 +0000 Subject: [PATCH 008/100] style(SLB-455): a11y adjustments --- .../src/components/Organisms/ContentHub.tsx | 84 +++++++++++-------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/packages/ui/src/components/Organisms/ContentHub.tsx b/packages/ui/src/components/Organisms/ContentHub.tsx index 978b7c304..480c9b4c3 100644 --- a/packages/ui/src/components/Organisms/ContentHub.tsx +++ b/packages/ui/src/components/Organisms/ContentHub.tsx @@ -70,41 +70,51 @@ export function ContentHub({ pageSize = 10 }: { pageSize: number }) { ); } -export const Card = (item: ContentHubResultItemFragment) => ( -
-
- {item.teaserImage ? ( - - ) : ( -
- )} -
-
-
- {item.title} -
- - {item.title} - Read more -
+
- - - -
-
-); + {item.title} + + + {item.title} + Read more + + + +
+ {item.teaserImage ? ( + + ) : ( +
+ )} +
+ + ); +}; From 99567c6dd6975f267d433a176db79b8bcb05d20c Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Thu, 25 Jul 2024 09:08:36 +0000 Subject: [PATCH 009/100] style(SLB-455): a11y adjustments more --- .../src/components/Organisms/ContentHub.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/ui/src/components/Organisms/ContentHub.tsx b/packages/ui/src/components/Organisms/ContentHub.tsx index 480c9b4c3..90148d9a8 100644 --- a/packages/ui/src/components/Organisms/ContentHub.tsx +++ b/packages/ui/src/components/Organisms/ContentHub.tsx @@ -56,9 +56,9 @@ export function ContentHub({ pageSize = 10 }: { pageSize: number }) { {data?.contentHub.total ? ( <>
    - {data?.contentHub.items.filter(isTruthy).map((item) => ( + {data?.contentHub.items.filter(isTruthy).map((item, index) => (
  • - +
  • ))}
@@ -70,24 +70,28 @@ export function ContentHub({ pageSize = 10 }: { pageSize: number }) { ); } -const Card = (item: ContentHubResultItemFragment) => { - const id = item.title.toLowerCase().replace(/\s+/g, '-'); - +const Card = ({ + item, + id, +}: { + item: ContentHubResultItemFragment; + id: number; +}) => { return (
{item.title}
{item.title} Read more From 1db61021d425c9f93bae67f262004cba73e2b031 Mon Sep 17 00:00:00 2001 From: Luqmaan Essop Date: Thu, 25 Jul 2024 12:29:08 +0000 Subject: [PATCH 010/100] style(SLB-455): a11y adjustments more --- .../src/components/Organisms/ContentHub.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/ui/src/components/Organisms/ContentHub.tsx b/packages/ui/src/components/Organisms/ContentHub.tsx index 90148d9a8..854c77fa9 100644 --- a/packages/ui/src/components/Organisms/ContentHub.tsx +++ b/packages/ui/src/components/Organisms/ContentHub.tsx @@ -56,11 +56,14 @@ export function ContentHub({ pageSize = 10 }: { pageSize: number }) { {data?.contentHub.total ? ( <>
    - {data?.contentHub.items.filter(isTruthy).map((item, index) => ( -
  • - -
  • - ))} + {data?.contentHub.items.filter(isTruthy).map((item, index) => { + const formattedIndex = index.toString(); + return ( +
  • + +
  • + ); + })}
@@ -75,16 +78,16 @@ const Card = ({ id, }: { item: ContentHubResultItemFragment; - id: number; + id: string; }) => { return (
{item.title} From 5b52d3535ed99a3d6a5ff2b6ba5f7241b0fa594f Mon Sep 17 00:00:00 2001 From: Alex Tkachev Date: Sun, 28 Jul 2024 13:52:36 +0400 Subject: [PATCH 011/100] chore(SLB-451): behavior/style improvements WIP --- packages/drupal/gutenberg_blocks/css/edit.css | 31 ++++++++++ .../src/blocks/conditional.tsx | 60 +++++++++++++++---- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/packages/drupal/gutenberg_blocks/css/edit.css b/packages/drupal/gutenberg_blocks/css/edit.css index 7dc32cdc3..cad110943 100644 --- a/packages/drupal/gutenberg_blocks/css/edit.css +++ b/packages/drupal/gutenberg_blocks/css/edit.css @@ -27,6 +27,14 @@ min-height: 250px; } +.gutenberg__editor .container-wrapper.no-margin { + margin: 0; +} + +.gutenberg__editor .container-wrapper.no-min-height { + min-height: 0; +} + .gutenberg__editor .container-wrapper .container-label { font: bold 12px Sans-Serif; letter-spacing: 2px; @@ -129,3 +137,26 @@ .gutenberg__editor .drupal-preview-sidebar--header button { margin-right: 5px; } + +.gutenberg__editor .collapsible-container .title { + display: flex; + cursor: pointer; +} + +.gutenberg__editor .collapsible-container .title .left { + width: 34px; + background-color: #666666; + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3e%3cpath d='M5.21 1.314L3.79 2.723l5.302 5.353-5.303 5.354 1.422 1.408 6.697-6.762z' fill='%230036B1'/%3e%3c/svg%3e"); + background-repeat: no-repeat; + background-position: 10px; + rotate: -90deg; +} + +.gutenberg__editor .collapsible-container.is-open .title .left { + rotate: 90deg; +} + +.gutenberg__editor .collapsible-container .title .right { + flex: 1; + padding-left: 10px; +} diff --git a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx index 131c59b2f..d4668c86d 100644 --- a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx +++ b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx @@ -1,4 +1,5 @@ import clsx from 'clsx'; +import { PropsWithChildren, useState } from 'react'; import { InnerBlocks, InspectorControls } from 'wordpress__block-editor'; import { registerBlockType } from 'wordpress__blocks'; import { BaseControl, PanelBody } from 'wordpress__components'; @@ -72,21 +73,18 @@ registerBlockType(`custom/conditional`, { ); return ( -
-
{__('Conditional content')}
-
{summary}
-
- - {purpose || __('Content')} - + <> + +
{summary}
-
+ @@ -151,7 +149,7 @@ registerBlockType(`custom/conditional`, { -
+ ); }, @@ -169,3 +167,41 @@ function isoToLocalTime(isoTime: string) { date.setMinutes(date.getMinutes() - date.getTimezoneOffset()); return date.toISOString().slice(0, 16); } + +function CollapsibleContainer({ + children, + label, + title, + isActive, +}: PropsWithChildren<{ label: string; title: string; isActive: boolean }>) { + const [isOpen, setIsOpen] = useState(isActive); + return ( +
+
{ + setIsOpen(!isOpen); + }} + > +
+
{title}
+
+ + {isOpen ? ( +
+
{label}
+ {children} +
+ ) : null} +
+ ); +} From ed55134d9619c08aaa984af0273562ece9af94dc Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Mon, 29 Jul 2024 14:27:47 +0200 Subject: [PATCH 012/100] style(SLB-455): set formattted id --- packages/ui/src/components/Organisms/ContentHub.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/ui/src/components/Organisms/ContentHub.tsx b/packages/ui/src/components/Organisms/ContentHub.tsx index 854c77fa9..e7947048d 100644 --- a/packages/ui/src/components/Organisms/ContentHub.tsx +++ b/packages/ui/src/components/Organisms/ContentHub.tsx @@ -57,10 +57,9 @@ export function ContentHub({ pageSize = 10 }: { pageSize: number }) { <>
    {data?.contentHub.items.filter(isTruthy).map((item, index) => { - const formattedIndex = index.toString(); return (
  • - +
  • ); })} @@ -78,16 +77,18 @@ const Card = ({ id, }: { item: ContentHubResultItemFragment; - id: string; + id: number; }) => { + const formattedID = 'heading-' + id; + return (
    {item.title} From 932a63ca9a83201b35f575036781f177a612c605 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 14:31:13 +0200 Subject: [PATCH 013/100] fix: move nested plugin above tailwindcss to remove error about nesting configuration --- packages/ui/src/postcss.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/postcss.config.cjs b/packages/ui/src/postcss.config.cjs index 00af9fd0b..e333492ca 100644 --- a/packages/ui/src/postcss.config.cjs +++ b/packages/ui/src/postcss.config.cjs @@ -2,8 +2,8 @@ module.exports = { plugins: { 'postcss-import-ext-glob': {}, 'postcss-import': {}, + 'tailwindcss/nesting': 'postcss-nested', tailwindcss: require('./tailwind.config.cjs'), - 'postcss-nested': {}, autoprefixer: {}, 'postcss-prefix-selector': { prefix: From 25e65ba9987f6aa7f92c18e6ef6b13d4fee47dfc Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 17:51:04 +0200 Subject: [PATCH 014/100] chore(SLB-459): add focusable false to accordion --- .../Organisms/PageContent/BlockAccordion.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index 994fad5dd..bce6e7674 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -30,7 +30,7 @@ export function BlockAccordion(props: BlockAccordionFragment) {
    {props.items.map((item, index) => ( - + {({ open }) => ( <> {open ? ( - + ) : ( - + )} @@ -98,19 +98,19 @@ export function BlockAccordion(props: BlockAccordionFragment) { ); } -function AccordionIcon({ icon }: { icon: string }) { +function AccordionIcon({ icon, focusable = false }: { icon: string, focusable?: boolean }) { switch (icon) { case 'questionmark': return ( - + ); case 'checkmark': return ( - + ); case 'arrow': return ( - + ); default: return null; From d0949115b0c998eb2204baed189ffe8ca525f8f5 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 17:51:41 +0200 Subject: [PATCH 015/100] chore(SLB-459): add heading with adjustable level based on props to accordion --- .../Organisms/PageContent/BlockAccordion.tsx | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index bce6e7674..e16820778 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -24,7 +24,26 @@ const unorderedItems: Plugin<[], Element> = () => (tree) => { }); }; -export function BlockAccordion(props: BlockAccordionFragment) { +const Heading = ({ level, className, children }: { level?: string; className?: string, children: React.ReactNode }) => { + switch (level) { + case 'h1': + return

    {children}

    ; + case 'h2': + return

    {children}

    ; + case 'h3': + return

    {children}

    ; + case 'h4': + return

    {children}

    ; + case 'h5': + return
    {children}
    ; + case 'h6': + return
    {children}
    ; + default: + return

    {children}

    ; + } +} + +export function BlockAccordion(props: BlockAccordionFragment & { headingLevel?: string }) { return (
    @@ -33,24 +52,26 @@ export function BlockAccordion(props: BlockAccordionFragment) { {({ open }) => ( <> - - - {item.icon && }{' '} - {item.title} - - - {open ? ( - - ) : ( - + + - + > + + {item.icon && }{' '} + {item.title} + + + {open ? ( + + ) : ( + + )} + + + Date: Tue, 30 Jul 2024 18:06:45 +0200 Subject: [PATCH 016/100] chore(SLB-459): use a type with union --- .../components/Organisms/PageContent/BlockAccordion.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index e16820778..a22c03063 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -24,7 +24,12 @@ const unorderedItems: Plugin<[], Element> = () => (tree) => { }); }; -const Heading = ({ level, className, children }: { level?: string; className?: string, children: React.ReactNode }) => { +type HeadingProps = { + level: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6', + className?: string, + children: React.ReactNode, +}; +const Heading = ({ level, className, children }: HeadingProps) => { switch (level) { case 'h1': return

    {children}

    ; From 9951346c69282406f6ecc05162ab6e9387c9ef2b Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 18:14:20 +0200 Subject: [PATCH 017/100] chore(SLB-459): revert the union type till we implement backend --- .../ui/src/components/Organisms/PageContent/BlockAccordion.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index a22c03063..3d8d58f73 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -25,7 +25,7 @@ const unorderedItems: Plugin<[], Element> = () => (tree) => { }; type HeadingProps = { - level: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6', + level?: string, className?: string, children: React.ReactNode, }; From 0b0bd85e98164f2ef69f623e3563d77005b881f0 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 18:18:37 +0200 Subject: [PATCH 018/100] chore(SLB-459): pnpm test:format:fix --- .../Organisms/PageContent/BlockAccordion.tsx | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index 3d8d58f73..75c64244c 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -25,9 +25,9 @@ const unorderedItems: Plugin<[], Element> = () => (tree) => { }; type HeadingProps = { - level?: string, - className?: string, - children: React.ReactNode, + level?: string; + className?: string; + children: React.ReactNode; }; const Heading = ({ level, className, children }: HeadingProps) => { switch (level) { @@ -46,9 +46,11 @@ const Heading = ({ level, className, children }: HeadingProps) => { default: return

    {children}

    ; } -} +}; -export function BlockAccordion(props: BlockAccordionFragment & { headingLevel?: string }) { +export function BlockAccordion( + props: BlockAccordionFragment & { headingLevel?: string }, +) { return (
    @@ -70,9 +72,15 @@ export function BlockAccordion(props: BlockAccordionFragment & { headingLevel?: {open ? ( - + ) : ( - + )} @@ -124,19 +132,34 @@ export function BlockAccordion(props: BlockAccordionFragment & { headingLevel?: ); } -function AccordionIcon({ icon, focusable = false }: { icon: string, focusable?: boolean }) { +function AccordionIcon({ + icon, + focusable = false, +}: { + icon: string; + focusable?: boolean; +}) { switch (icon) { case 'questionmark': return ( - + ); case 'checkmark': return ( - + ); case 'arrow': return ( - + ); default: return null; From fa89bf3c4fa277220633eb4d9b8a4c41ca47d879 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 18:38:43 +0200 Subject: [PATCH 019/100] chore(SLB-459): fix border styling for accordion items --- .../src/components/Organisms/PageContent/BlockAccordion.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index 75c64244c..d8db34e8b 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -56,13 +56,13 @@ export function BlockAccordion(
    {props.items.map((item, index) => ( - + {({ open }) => ( <> @@ -88,7 +88,6 @@ export function BlockAccordion(
    From fd3af15f18080b7c0e5a09f4840f83ea87c0a539 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 20:48:34 +0200 Subject: [PATCH 020/100] chore(SLB-459): pnpm test:format:fix --- .../Organisms/PageContent/BlockAccordion.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index d8db34e8b..4af11434b 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -56,7 +56,11 @@ export function BlockAccordion(
    {props.items.map((item, index) => ( - + {({ open }) => ( <> @@ -86,9 +90,7 @@ export function BlockAccordion(
    {item.textContent?.markup && ( From 73b982d72b423881951f4377e1020561231476e5 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 22:15:29 +0200 Subject: [PATCH 021/100] chore(SLB-459): add new heading level select field to accordion gutenberg block --- .../gutenberg_blocks/src/blocks/accordion.tsx | 68 ++++++++++++++++--- .../fragments/PageContent/BlockAccordion.gql | 1 + packages/schema/src/schema.graphql | 1 + .../Organisms/PageContent/BlockAccordion.tsx | 2 +- 4 files changed, 60 insertions(+), 12 deletions(-) diff --git a/packages/drupal/gutenberg_blocks/src/blocks/accordion.tsx b/packages/drupal/gutenberg_blocks/src/blocks/accordion.tsx index 924746dd8..8097819ea 100644 --- a/packages/drupal/gutenberg_blocks/src/blocks/accordion.tsx +++ b/packages/drupal/gutenberg_blocks/src/blocks/accordion.tsx @@ -1,24 +1,70 @@ -import { InnerBlocks } from 'wordpress__block-editor'; +import { InnerBlocks, InspectorControls } from 'wordpress__block-editor'; import { registerBlockType } from 'wordpress__blocks'; +import { PanelBody, SelectControl } from 'wordpress__components'; // @ts-ignore const { t: __ } = Drupal; +enum HeadingLevels { + H2 = 'h2', + H3 = 'h3', + H4 = 'h4', + H5 = 'h5', +} + registerBlockType('custom/accordion', { title: __('Accordion'), icon: 'menu', category: 'layout', - attributes: {}, - edit: () => { + attributes: { + headingLevel: { + type: 'string', + default: HeadingLevels.H2, + }, + }, + edit: (props) => { + const { setAttributes } = props; + return ( -
    -
    {__('Accordion')}
    - -
    + <> + + + { + setAttributes({ headingLevel }); + }} + /> + + + +
    +
    {__('Accordion')}
    + +
    + ); }, save: () => , diff --git a/packages/schema/src/fragments/PageContent/BlockAccordion.gql b/packages/schema/src/fragments/PageContent/BlockAccordion.gql index 0f77b257d..fe6e3681e 100644 --- a/packages/schema/src/fragments/PageContent/BlockAccordion.gql +++ b/packages/schema/src/fragments/PageContent/BlockAccordion.gql @@ -1,4 +1,5 @@ fragment BlockAccordion on BlockAccordion { + headingLevel items { ...BlockAccordionItemText } diff --git a/packages/schema/src/schema.graphql b/packages/schema/src/schema.graphql index fd351b736..7a2dc72dd 100644 --- a/packages/schema/src/schema.graphql +++ b/packages/schema/src/schema.graphql @@ -254,6 +254,7 @@ type BlockImageTeaser @default @value { } type BlockAccordion @type(id: "custom/accordion") { + headingLevel: String! @resolveEditorBlockAttribute(key: "headingLevel") items: [BlockAccordionItemText!]! @resolveEditorBlockChildren } diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index 4af11434b..2501cbb98 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -49,7 +49,7 @@ const Heading = ({ level, className, children }: HeadingProps) => { }; export function BlockAccordion( - props: BlockAccordionFragment & { headingLevel?: string }, + props: BlockAccordionFragment, ) { return (
    From b8ea4ae3f7b55d0520a4197f763d4367036ea667 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 30 Jul 2024 22:19:04 +0200 Subject: [PATCH 022/100] chore(SLB-459): pnpm test:format:fix --- .../src/components/Organisms/PageContent/BlockAccordion.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx index 2501cbb98..ddf3a6ca0 100644 --- a/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx +++ b/packages/ui/src/components/Organisms/PageContent/BlockAccordion.tsx @@ -48,9 +48,7 @@ const Heading = ({ level, className, children }: HeadingProps) => { } }; -export function BlockAccordion( - props: BlockAccordionFragment, -) { +export function BlockAccordion(props: BlockAccordionFragment) { return (
    From 9e1c24112ee58f927ef387cc6b83b069f5264e7b Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Wed, 31 Jul 2024 10:30:59 +0200 Subject: [PATCH 023/100] chore: update github actions to latest --- .github/actions/setup/action.yml | 6 +++--- .github/workflows/deploy.yml | 4 ++-- .github/workflows/estimate.yml | 4 ++-- .github/workflows/high_content_volume.yml | 2 +- .github/workflows/merge_dev_to_stage.yml | 2 +- .github/workflows/tag_release.yml | 4 ++-- .github/workflows/test.yml | 14 +++++++------- .github/workflows/test_without_turbo_cache.yml | 6 +++--- .github/workflows/write-dashboard.yml | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index a8a611e13..345d9b371 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -4,7 +4,7 @@ runs: using: 'composite' steps: - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 @@ -16,14 +16,14 @@ runs: - uses: pnpm/action-setup@v4 name: Install pnpm with: - version: 8.6.12 + version: 9.4.0 - name: Get pnpm store directory id: pnpm-cache shell: bash run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Setup pnpm cache with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 83587e7ac..256e3f6df 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,10 +8,10 @@ on: jobs: test: name: Deploy - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/estimate.yml b/.github/workflows/estimate.yml index d492e2c0c..8b6b76fc4 100644 --- a/.github/workflows/estimate.yml +++ b/.github/workflows/estimate.yml @@ -6,7 +6,7 @@ jobs: estimate: name: Estimate if: vars.JIRA_PROJECT_ID != '' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Start Check Run id: check @@ -27,7 +27,7 @@ jobs: run: npm install -g @amazeelabs/estimator - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/high_content_volume.yml b/.github/workflows/high_content_volume.yml index 88bbda211..b3474552a 100644 --- a/.github/workflows/high_content_volume.yml +++ b/.github/workflows/high_content_volume.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 1 diff --git a/.github/workflows/merge_dev_to_stage.yml b/.github/workflows/merge_dev_to_stage.yml index 55ca2f714..78edc2398 100644 --- a/.github/workflows/merge_dev_to_stage.yml +++ b/.github/workflows/merge_dev_to_stage.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: 'dev' diff --git a/.github/workflows/tag_release.yml b/.github/workflows/tag_release.yml index 3d2c2dcf5..6d60fa34a 100644 --- a/.github/workflows/tag_release.yml +++ b/.github/workflows/tag_release.yml @@ -15,11 +15,11 @@ jobs: id: date run: echo "::set-output name=date::$(date +'%Y-%m-%d/%H/%M/%S')" - name: Checkout branch "prod" - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: prod - name: Create Git tag for PR - uses: actions/github-script@v4 + uses: actions/github-script@v7 with: script: | github.git.createRef({ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d23873f19..edf0ade21 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: jobs: test: name: Test - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Init check if: ${{ github.repository != 'AmazeeLabs/silverback-template'}} @@ -14,7 +14,7 @@ jobs: instructions.' && false - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -38,7 +38,7 @@ jobs: TURBO_TEAM: 'local' - name: Upload Playwright report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: playwright-report @@ -56,7 +56,7 @@ jobs: fi - name: Publish to Chromatic - uses: chromaui/action@v1 + uses: chromaui/action@v11 with: token: ${{ secrets.GITHUB_TOKEN }} projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} @@ -94,13 +94,13 @@ jobs: update_dashboard: name: Update dashboard if: github.ref == 'refs/heads/release' && vars.JIRA_PROJECT_ID != '' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Install estimator run: npm install -g @amazeelabs/estimator - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -118,7 +118,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 1 - name: Setup Ruby diff --git a/.github/workflows/test_without_turbo_cache.yml b/.github/workflows/test_without_turbo_cache.yml index 757b757c0..7faf17889 100644 --- a/.github/workflows/test_without_turbo_cache.yml +++ b/.github/workflows/test_without_turbo_cache.yml @@ -5,7 +5,7 @@ on: jobs: test: name: Test - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Init check if: ${{ github.repository != 'AmazeeLabs/silverback-template'}} @@ -14,7 +14,7 @@ jobs: instructions.' && false - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -35,7 +35,7 @@ jobs: TURBO_TEAM: 'local' - name: Upload Playwright report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: playwright-report diff --git a/.github/workflows/write-dashboard.yml b/.github/workflows/write-dashboard.yml index 418c9c555..01186ab98 100644 --- a/.github/workflows/write-dashboard.yml +++ b/.github/workflows/write-dashboard.yml @@ -6,13 +6,13 @@ jobs: write_dashboard: name: Write dashboard history if: github.ref == 'refs/heads/release' && vars.JIRA_PROJECT_ID != '' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Install estimator run: npm install -g @amazeelabs/estimator - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 From a551977398c5174237a47356a368e2ab1b31fbba Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Wed, 31 Jul 2024 14:29:57 +0200 Subject: [PATCH 024/100] fix: revert pnpm change --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 345d9b371..658c20cda 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -16,7 +16,7 @@ runs: - uses: pnpm/action-setup@v4 name: Install pnpm with: - version: 9.4.0 + version: 8.6.12 - name: Get pnpm store directory id: pnpm-cache From 7bb0ea6870776058a776745009843b7bb5799bcd Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Mon, 5 Aug 2024 20:53:29 +0200 Subject: [PATCH 025/100] fix: type drupal --- packages/schema/codegen.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/schema/codegen.ts b/packages/schema/codegen.ts index 7dc41889a..7a0ea92c9 100644 --- a/packages/schema/codegen.ts +++ b/packages/schema/codegen.ts @@ -40,7 +40,7 @@ const config: CodegenConfig = { context: ['gatsby'], }, }, - // Directive autoloader for Drupla. + // Directive autoloader for Drupal. 'build/drupal-autoload.json': { plugins: ['@amazeelabs/codegen-autoloader'], config: { From 279f85554f7c9c6e5b6d15ac5b90a90af4636a19 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Tue, 6 Aug 2024 09:16:21 +0200 Subject: [PATCH 026/100] chore(SLB-451): update sidebar styling, manually add built tailwind css classes to edit.css for now --- .idea/prettier.xml | 3 +- packages/drupal/gutenberg_blocks/css/edit.css | 45 +++---- .../src/blocks/conditional.tsx | 123 ++++++++++-------- .../drupal/gutenberg_blocks/vite.config.ts | 2 + 4 files changed, 94 insertions(+), 79 deletions(-) diff --git a/.idea/prettier.xml b/.idea/prettier.xml index 0d96645cd..a3175fe71 100644 --- a/.idea/prettier.xml +++ b/.idea/prettier.xml @@ -1,8 +1,9 @@ + - + \ No newline at end of file diff --git a/packages/drupal/gutenberg_blocks/css/edit.css b/packages/drupal/gutenberg_blocks/css/edit.css index cad110943..03f6ad69b 100644 --- a/packages/drupal/gutenberg_blocks/css/edit.css +++ b/packages/drupal/gutenberg_blocks/css/edit.css @@ -27,14 +27,6 @@ min-height: 250px; } -.gutenberg__editor .container-wrapper.no-margin { - margin: 0; -} - -.gutenberg__editor .container-wrapper.no-min-height { - min-height: 0; -} - .gutenberg__editor .container-wrapper .container-label { font: bold 12px Sans-Serif; letter-spacing: 2px; @@ -138,25 +130,34 @@ margin-right: 5px; } -.gutenberg__editor .collapsible-container .title { +.\[\&\>div\]\:flex > div { display: flex; - cursor: pointer; } -.gutenberg__editor .collapsible-container .title .left { - width: 34px; - background-color: #666666; - background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3e%3cpath d='M5.21 1.314L3.79 2.723l5.302 5.353-5.303 5.354 1.422 1.408 6.697-6.762z' fill='%230036B1'/%3e%3c/svg%3e"); - background-repeat: no-repeat; - background-position: 10px; - rotate: -90deg; +.\[\&\>div\]\:flex-col-reverse > div { + flex-direction: column-reverse; } -.gutenberg__editor .collapsible-container.is-open .title .left { - rotate: 90deg; +.\[\&\>div\]\:gap-4 > div { + gap: 1rem; } -.gutenberg__editor .collapsible-container .title .right { - flex: 1; - padding-left: 10px; +.flex { + display: flex; +} + +.flex-col { + flex-direction: column; +} + +.items-start { + align-items: flex-start; +} + +.gap-4 { + gap: 1rem; +} + +.\!m-0 { + margin: 0 !important; } diff --git a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx index d4668c86d..376415e28 100644 --- a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx +++ b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx @@ -2,7 +2,12 @@ import clsx from 'clsx'; import { PropsWithChildren, useState } from 'react'; import { InnerBlocks, InspectorControls } from 'wordpress__block-editor'; import { registerBlockType } from 'wordpress__blocks'; -import { BaseControl, PanelBody } from 'wordpress__components'; +import { + BaseControl, + PanelBody, + PanelRow, + TextControl, +} from 'wordpress__components'; // @ts-ignore const { t: __ } = Drupal; @@ -87,66 +92,73 @@ registerBlockType(`custom/conditional`, { - - + { - setAttributes({ purpose: event.target.value }); - }} + label={__( + 'The value is not exposed to the frontend and serves to identify the reason of the conditional content (e.g. Summer Campaign).', + )} + value={purpose} + onChange={(value: string) => setAttributes({ purpose: value })} + className={ + '[&>div]:flex [&>div]:gap-4 [&>div]:flex-col-reverse' + } /> - - -
    - + + - -
    - + { - setAttributes({ - displayFrom: event.target.value - ? localToIsoTime(event.target.value) - : '', - }); - }} - /> - - -
    - div]:flex [&>div]:gap-4 !m-0'} + > + { + setAttributes({ + displayFrom: event.target.value + ? localToIsoTime(event.target.value) + : '', + }); + }} + /> +
    + { - setAttributes({ - displayTo: event.target.value - ? localToIsoTime(event.target.value) - : '', - }); + label={__('To')} + className={'[&>div]:flex [&>div]:gap-4 !m-0'} + > + { + setAttributes({ + displayTo: event.target.value + ? localToIsoTime(event.target.value) + : '', + }); + }} + /> + + + +

    - - -

    - + > + {__('Time zone') + + ': ' + + Intl.DateTimeFormat().resolvedOptions().timeZone} +

    + @@ -188,8 +200,7 @@ function CollapsibleContainer({ setIsOpen(!isOpen); }} > -
    -
    {title}
    +
    {title}
    {isOpen ? ( diff --git a/packages/drupal/gutenberg_blocks/vite.config.ts b/packages/drupal/gutenberg_blocks/vite.config.ts index 427f3514a..07a4dfe53 100644 --- a/packages/drupal/gutenberg_blocks/vite.config.ts +++ b/packages/drupal/gutenberg_blocks/vite.config.ts @@ -10,6 +10,7 @@ export default defineConfig({ fileName: 'gutenberg_blocks', }, rollupOptions: { + strictDeprecations: true, external: [ 'react', 'react-dom', @@ -23,6 +24,7 @@ export default defineConfig({ 'wordpress__hooks', ], output: { + strict: true, globals: { react: 'React', wordpress__blocks: 'wp.blocks', From 5c1df253b3d8cad236196a51c1a8c83758ff79f5 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Wed, 7 Aug 2024 09:18:39 +0200 Subject: [PATCH 027/100] chore: adjust the details styling a bit --- .../src/blocks/conditional.tsx | 64 +++++++++---------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx index 376415e28..adacee75c 100644 --- a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx +++ b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx @@ -84,25 +84,26 @@ registerBlockType(`custom/conditional`, { label={__('Conditional content')} isActive={isActive} > -
    {summary}
    - +
    {summary}
    +
    + +
    setAttributes({ purpose: value })} - className={ - '[&>div]:flex [&>div]:gap-4 [&>div]:flex-col-reverse' - } + help={__( + 'The value is not exposed to the frontend and serves to identify the reason of the conditional content (e.g. Summer Campaign).', + )} /> @@ -186,33 +187,26 @@ function CollapsibleContainer({ title, isActive, }: PropsWithChildren<{ label: string; title: string; isActive: boolean }>) { - const [isOpen, setIsOpen] = useState(isActive); + const isLabelDifferentToTitle = label !== title; + return ( -
    + <>
    { - setIsOpen(!isOpen); - }} + className={clsx('border border-gray-200', { + 'bg-red-100': !isActive, + })} > -
    {title}
    -
    +
    + + {title}{' '} + {isLabelDifferentToTitle ? ( + ({label}) + ) : null}{' '} + - {isOpen ? ( -
    -
    {label}
    - {children} -
    - ) : null} -
    +
    {children}
    + +
    + ); } From 1047a5106627abd415b974719890f7e04dbe5d69 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Wed, 7 Aug 2024 09:45:10 +0200 Subject: [PATCH 028/100] fix: remove unused import --- packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx index adacee75c..0af6e9133 100644 --- a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx +++ b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import { PropsWithChildren, useState } from 'react'; +import { PropsWithChildren } from 'react'; import { InnerBlocks, InspectorControls } from 'wordpress__block-editor'; import { registerBlockType } from 'wordpress__blocks'; import { From 633b7b66f792f21d65347fa432334a07e129edd1 Mon Sep 17 00:00:00 2001 From: Dan Lemon Date: Wed, 7 Aug 2024 13:57:57 +0200 Subject: [PATCH 029/100] chore: finalise styling, add support for multiple conditions --- packages/drupal/gutenberg_blocks/css/edit.css | 64 +++++++++ .../src/blocks/conditional.tsx | 132 +++++++++++------- 2 files changed, 142 insertions(+), 54 deletions(-) diff --git a/packages/drupal/gutenberg_blocks/css/edit.css b/packages/drupal/gutenberg_blocks/css/edit.css index 03f6ad69b..3702388d1 100644 --- a/packages/drupal/gutenberg_blocks/css/edit.css +++ b/packages/drupal/gutenberg_blocks/css/edit.css @@ -142,6 +142,43 @@ gap: 1rem; } +.\[\&\>div\>label\]\:w-4 > div > label { + width: 1rem; +} + +.\[\&\>div\>label\]\:mb-0 > div > label { + margin-bottom: 0; +} + +.\[\&\>div\>label\]\:my-auto > div > label { + margin-top: auto; + margin-bottom: auto; +} + +.font-extralight { + font-weight: 200; +} + +.text-gray-600 { + --tw-text-opacity: 1; + color: rgb(75 85 99 / var(--tw-text-opacity)); +} + +.text-neutral-500 { + --tw-text-opacity: 1; + color: rgb(115 115 115 / var(--tw-text-opacity)); +} + +.text-sm { + font-size: 0.875rem; + line-height: 1.25rem; +} + +.text-xs { + font-size: 0.75rem; + line-height: 1rem; +} + .flex { display: flex; } @@ -161,3 +198,30 @@ .\!m-0 { margin: 0 !important; } + +details[open] { + padding-bottom: 1em; +} + +details[open] > summary::before { + transform: rotate(-90deg); +} + +summary::marker { + content: none; +} + +summary::before { + position: relative; + left: calc(var(--space-s) * -1); + display: inline-block; + width: var(--space-m); + height: var(--space-m); + margin-top: calc(var(--space-m) / -2); + content: ''; + transition: transform var(--details-transform-transition-duration) ease-in 0s; + transform: rotate(90deg); + text-align: center; + background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3e%3cpath d='M5.21 1.314L3.79 2.723l5.302 5.353-5.303 5.354 1.422 1.408 6.697-6.762z' fill='%23545560'/%3e%3c/svg%3e"); + background-size: contain; +} diff --git a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx index 0af6e9133..36b10528d 100644 --- a/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx +++ b/packages/drupal/gutenberg_blocks/src/blocks/conditional.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import { PropsWithChildren } from 'react'; +import React, { PropsWithChildren } from 'react'; import { InnerBlocks, InspectorControls } from 'wordpress__block-editor'; import { registerBlockType } from 'wordpress__blocks'; import { @@ -12,8 +12,18 @@ import { // @ts-ignore const { t: __ } = Drupal; +type ConditionsType = { + [key: string]: { + label: string; + visible: boolean; + template: JSX.Element; + }; +}; + +const blockTitle = __('Conditional content'); + registerBlockType(`custom/conditional`, { - title: __('Conditional content'), + title: blockTitle, category: 'layout', icon: 'category', // Allow the block only at the root level to avoid GraphQL fragment recursion. @@ -50,41 +60,61 @@ registerBlockType(`custom/conditional`, { }; const isActive = Object.values(active).every(Boolean); - const conditions = { - scheduledDisplay: - displayFrom || displayTo - ? '🕒 ' + - __('Scheduled display') + - ': ' + - [ - displayFrom - ? __('From') + ' ' + new Date(displayFrom).toLocaleString() - : '', - displayTo - ? __('To') + ' ' + new Date(displayTo).toLocaleString() - : '', - ] - .filter(Boolean) - .join(' ') - : '', + const conditions: ConditionsType = { + scheduledDisplay: { + label: '⏱ī¸ ' + __('Scheduled display'), + visible: !!(displayFrom || displayTo), + template: ( + <> + {displayFrom ? ( + <> + {__('From')}{' '} + {new Date(displayFrom).toLocaleString()} + + ) : null} + {displayFrom && displayTo ? {' - '} : null} + {displayTo ? ( + <> + {__('To')}{' '} + {new Date(displayTo).toLocaleString()} + + ) : null} + + ), + }, + device: { + label: '📱 ' + __('Device'), + visible: false, + template: <>{'Mobile only.'}, + }, }; - const hasConditions = Object.values(conditions).some(Boolean); - const summary = hasConditions ? ( + + const hasConditions = Object.values(conditions) + .filter(({ visible }) => visible) + .some(Boolean); + + const conditionsSummary = hasConditions ? ( Object.entries(conditions) .filter(([, value]) => !!value) - .map(([key, value]) =>
    {value}
    ) + .filter(([, { visible }]) => visible) + .map(([key, { label, template }]) => ( + <> +
    {label}
    + {template} + + )) ) : ( -
    {'ℹī¸ ' + __('No conditions set')}
    + <>{'ℹī¸ ' + __('No conditions set')} ); return ( <> -
    {summary}
    +
    {conditionsSummary}
    div]:flex [&>div]:gap-4 !m-0'} + className={ + '[&>div]:flex [&>div]:gap-4 [&>div>label]:w-4 [&>div>label]:my-auto !m-0' + } > div]:flex [&>div]:gap-4 !m-0'} + className={ + '[&>div]:flex [&>div]:gap-4 [&>div>label]:w-4 [&>div>label]:mb-0 [&>div>label]:my-auto !m-0' + } > -

    +

    {__('Time zone') + ': ' + Intl.DateTimeFormat().resolvedOptions().timeZone} @@ -171,42 +199,38 @@ registerBlockType(`custom/conditional`, { }, }); -function localToIsoTime(localTime: string) { +const localToIsoTime = (localTime: string) => { return new Date(localTime).toISOString(); -} +}; -function isoToLocalTime(isoTime: string) { +const isoToLocalTime = (isoTime: string) => { const date = new Date(isoTime); date.setMinutes(date.getMinutes() - date.getTimezoneOffset()); return date.toISOString().slice(0, 16); -} +}; -function CollapsibleContainer({ +const CollapsibleContainer = ({ children, label, title, isActive, -}: PropsWithChildren<{ label: string; title: string; isActive: boolean }>) { +}: PropsWithChildren<{ label: string; title: string; isActive: boolean }>) => { const isLabelDifferentToTitle = label !== title; return ( <> -

    -
    - - {title}{' '} - {isLabelDifferentToTitle ? ( - ({label}) - ) : null}{' '} - +
    +
    {label}
    +
    + {title}
    {children}
    ); -} +}; From 38e1df0ba5e3a5888841bcac822540f92c11ad1c Mon Sep 17 00:00:00 2001 From: Christophe Jossart Date: Thu, 27 Jun 2024 14:32:25 +0200 Subject: [PATCH 030/100] refactor(SLB-442): adjust preview tablet size --- packages/drupal/gutenberg_blocks/src/preview.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/drupal/gutenberg_blocks/src/preview.ts b/packages/drupal/gutenberg_blocks/src/preview.ts index 1fdd5e874..659d4a5e9 100644 --- a/packages/drupal/gutenberg_blocks/src/preview.ts +++ b/packages/drupal/gutenberg_blocks/src/preview.ts @@ -20,8 +20,8 @@ { label: Drupal.t('Tablet'), id: 'tablet', - width: 1024, - height: 824, + width: 768, + height: 1024, iconPath: '/modules/contrib/silverback_external_preview/icons/tablet.svg', }, From c2065aa5ac2905c38561b0ee44ee90daab4cd406 Mon Sep 17 00:00:00 2001 From: Christophe Jossart Date: Thu, 27 Jun 2024 18:10:55 +0200 Subject: [PATCH 031/100] feat(SLB-442): improve preview ui --- packages/drupal/gutenberg_blocks/css/edit.css | 37 ++++++++++ .../drupal/gutenberg_blocks/src/preview.ts | 68 ++++++++++--------- 2 files changed, 72 insertions(+), 33 deletions(-) diff --git a/packages/drupal/gutenberg_blocks/css/edit.css b/packages/drupal/gutenberg_blocks/css/edit.css index 7dc32cdc3..55c0ecd92 100644 --- a/packages/drupal/gutenberg_blocks/css/edit.css +++ b/packages/drupal/gutenberg_blocks/css/edit.css @@ -129,3 +129,40 @@ .gutenberg__editor .drupal-preview-sidebar--header button { margin-right: 5px; } + +.gutenberg__editor .drupal-preview-sidebar--header select { + min-width: 350px; + position: relative; + appearance: none; + -webkit-appearance: none; + padding: 0.455em 6em 0.575em 1em; + background-color: #fff; + border: 1px solid #caced1; + border-radius: 0.25rem; + color: #000; + cursor: pointer; +} + +/* Preview select */ +.gutenberg__editor .drupal-preview-sidebar--header select::before, +.gutenberg__editor .drupal-preview-sidebar--header select::after { + --size: 0.3rem; + content: ""; + position: absolute; + right: 1rem; + pointer-events: none; +} + +.gutenberg__editor .drupal-preview-sidebar--header select::before { + border-left: var(--size) solid transparent; + border-right: var(--size) solid transparent; + border-bottom: var(--size) solid black; + top: 40%; +} + +.gutenberg__editor .drupal-preview-sidebar--header select::after { + border-left: var(--size) solid transparent; + border-right: var(--size) solid transparent; + border-top: var(--size) solid black; + top: 55%; +} diff --git a/packages/drupal/gutenberg_blocks/src/preview.ts b/packages/drupal/gutenberg_blocks/src/preview.ts index 659d4a5e9..5d2f15f5e 100644 --- a/packages/drupal/gutenberg_blocks/src/preview.ts +++ b/packages/drupal/gutenberg_blocks/src/preview.ts @@ -22,42 +22,35 @@ id: 'tablet', width: 768, height: 1024, - iconPath: - '/modules/contrib/silverback_external_preview/icons/tablet.svg', }, { label: Drupal.t('Laptop'), id: 'laptop', width: 1366, height: 786, - iconPath: - '/modules/contrib/silverback_external_preview/icons/laptop.svg', }, { label: Drupal.t('Desktop'), id: 'desktop', width: 1920, height: 1080, - iconPath: - '/modules/contrib/silverback_external_preview/icons/desktop.svg', - }, - { - label: Drupal.t('Full'), - id: 'full', - width: -1, - height: -1, - iconPath: - '/modules/contrib/silverback_external_preview/icons/full.svg', }, ]; - let previewButtons = ''; - previewSizes.forEach((size) => { - previewButtons += ` - `; - }); + const previewButton = `` + + const getPreviewSelect = () => { + let previewSelect = ''; + return previewSelect; + } + const previewSelect = getPreviewSelect(); const previewSidebarMarkup = `
    @@ -80,7 +73,7 @@
    - ${previewButtons} + ${previewSelect} ${previewButton}