Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into feat/SLB-306--info-grid
  • Loading branch information
HagerDakroury committed May 27, 2024
2 parents c1797ee + cdd3f2d commit eb72708
Show file tree
Hide file tree
Showing 23 changed files with 254 additions and 105 deletions.
1 change: 1 addition & 0 deletions apps/preview/.lagoon.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PROJECT_NAME="example"
DRUPAL_URL="https://nginx.${LAGOON_ENVIRONMENT}.${LAGOON_PROJECT}.ch4.amazee.io"
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,31 @@ _meta:
72187a1f-3e48-4b45-a9b7-189c6fd7ee26: media
default:
revision_uid:
-
target_id: 1
- target_id: 1
status:
-
value: true
- value: true
uid:
-
target_id: 1
- target_id: 1
title:
-
value: 'Blocks: complete'
- value: 'Blocks: complete'
created:
-
value: 1686759493
- value: 1686759493
promote:
-
value: false
- value: false
sticky:
-
value: false
- value: false
moderation_state:
-
value: published
- value: published
path:
-
alias: /blocks-complete
- alias: /blocks-complete
langcode: en
pathauto: 0
content_translation_source:
-
value: und
- value: und
content_translation_outdated:
-
value: false
- value: false
body:
-
value: |-
- value: |-
<!-- wp:custom/hero {"mediaEntityIds":["3a0fe860-a6d6-428a-9474-365bd57509aa"],"headline":"All kinds of blocks with maximum data","lead":"Lead text","ctaUrl":"https://example.com","ctaText":"CTA text","formId":"contact"} /-->
<!-- wp:custom/content -->
Expand Down Expand Up @@ -143,40 +131,29 @@ default:
translations:
de:
status:
-
value: true
- value: true
uid:
-
target_id: 1
- target_id: 1
title:
-
value: 'Blocks: complete DE'
- value: 'Blocks: complete DE'
created:
-
value: 1687338353
- value: 1687338353
promote:
-
value: false
- value: false
sticky:
-
value: false
- value: false
moderation_state:
-
value: published
- value: published
path:
-
alias: /blocks-complete
- alias: /blocks-complete
langcode: de
pathauto: 0
content_translation_source:
-
value: en
- value: en
content_translation_outdated:
-
value: false
- value: false
body:
-
value: |-
- value: |-
<!-- wp:custom/hero {"mediaEntityIds":["3a0fe860-a6d6-428a-9474-365bd57509aa"],"headline":"All kinds of blocks with maximum data DE","lead":"Lead text DE"} /-->
<!-- wp:custom/content -->
Expand Down Expand Up @@ -215,4 +192,4 @@ translations:
<!-- /wp:paragraph -->
<!-- /wp:custom/content -->
format: gutenberg
summary: ''
summary: ''
12 changes: 12 additions & 0 deletions packages/schema/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@ enum CTAIconPosition {
BEFORE
}

type BlockImageWithText @type(id: "custom/image-with-text") {
image: MediaImage @resolveEditorBlockMedia
textContent: BlockMarkup @resolveEditorBlockChildren @seek(pos: 0)
}

type BlockQuote @type(id: "custom/quote") {
quote: Markup @resolveEditorBlockAttribute(key: "quote")
author: String @resolveEditorBlockAttribute(key: "author")
role: String @resolveEditorBlockAttribute(key: "role")
image: MediaImage @resolveEditorBlockMedia
}

type BlockImageWithText @type(id: "custom/image-with-text") {
image: MediaImage @resolveEditorBlockMedia
imagePosition: ImagePosition!
Expand Down
97 changes: 78 additions & 19 deletions packages/ui/src/components/Molecules/LanguageSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,89 @@
import { Link, Locale, useLocation } from '@custom/schema';
import { Menu, Transition } from '@headlessui/react';
import { ChevronDownIcon } from '@heroicons/react/20/solid';
import clsx from 'clsx';
import React from 'react';
import React, { Fragment } from 'react';

import { useTranslations } from '../../utils/translations';

function getLanguageName(locale: string) {
const languageNames = new Intl.DisplayNames([locale], {
type: 'language',
});
return languageNames.of(locale);
}

export function LanguageSwitcher() {
const translations = useTranslations();
const [location] = useLocation();
const currentLocale = Object.values(Locale).find((locale) => {
const translationPath = translations[locale];
return location.pathname.includes(translationPath || '');
});

if (!currentLocale) {
console.error(
'No matching locale found in current path:',
location.pathname,
);
return null;
}

const otherLocales = Object.values(Locale).filter(
(locale) => locale !== currentLocale,
);

return (
<ul className="flex gap-2 uppercase">
{Object.values(Locale).map((locale) => (
<li key={locale}>
{translations[locale] ? (
<Link
href={translations[locale]!}
className={clsx('text-gray-500', {
underline: location.pathname !== translations[locale],
})}
>
{locale}
</Link>
) : (
<span className="text-gray-400">{locale}</span>
)}
</li>
))}
</ul>
<div className="relative inline-block text-left">
<Menu as="div" className="relative inline-block text-left">
<div>
<Menu.Button className="inline-flex justify-center w-full rounded-md bg-white text-sm hover:text-blue-600">
{getLanguageName(currentLocale as string)}
<ChevronDownIcon className="ml-1 h-5 w-5" aria-hidden="true" />
</Menu.Button>
</div>

<Transition
as={Fragment}
enter="transition ease-out duration-200"
enterFrom="opacity-0 translate-y-1"
enterTo="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-1"
>
<Menu.Items className="origin-top-right absolute z-50 right-0 mt-3 w-48 rounded bg-white shadow-md ring-1 ring-gray-100">
<div className="py-1">
{otherLocales.map((locale) => (
<Menu.Item key={locale}>
{({ focus }) =>
translations[locale] ? (
<Link
href={translations[locale]!}
className={clsx(
focus ? 'text-blue-600' : 'text-gray-500',
'block px-4 py-2 text-sm',
)}
>
{getLanguageName(locale as string)}
</Link>
) : (
<span
className={clsx(
focus ? 'bg-gray-100 text-gray-900' : 'text-gray-500',
'block px-3.5 py-2 text-sm',
)}
>
{getLanguageName(locale as string)}
</span>
)
}
</Menu.Item>
))}
</div>
</Menu.Items>
</Transition>
</Menu>
</div>
);
}
8 changes: 5 additions & 3 deletions packages/ui/src/components/Organisms/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function Footer() {
<footer
id="footer"
className={
'container-page relative z-10 bg-gray-100 text-gray-500 py-4 lg:py-16'
'container-page relative z-10 bg-gray-100 text-gray-500 py-12 lg:py-16'
}
>
<h2 className={'sr-only'}>Footer</h2>
Expand Down Expand Up @@ -130,7 +130,9 @@ export function Footer() {
</div>
<nav>
<ul
className={'md:ml-[5.625rem] flex flex-wrap justify-between grow'}
className={
'!pl-0 md:ml-[5.625rem] flex flex-wrap justify-between grow'
}
aria-label="Footer Primary"
>
{items.map((item, key) => (
Expand Down Expand Up @@ -164,7 +166,7 @@ export function Footer() {
<Link
key={child.target}
href={child.target}
className="block transition-all text-base mb-4 hover:underline"
className="text-gray-500 font-normal block transition-all text-base mb-4 hover:underline"
>
{child.title}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Organisms/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function UserActions({
return (
<div
className={clsx(
'flex w-full justify-end md:py-3.5 md:px-3 0',
'flex w-full justify-end md:py-3',
isDesktop && 'border-b border-gray-300 border-opacity-30',
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function BlockForm(
}

return (
<div className="container-page">
<div className="container-page my-10">
<div className="container-content">
<div className={clsx('container-text', props.className)}>
<SilverbackIframe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';

export function BlockHorizontalSeparator() {
return (
<div className="container-page">
<div className="container-page my-8">
<div className="container-content">
<hr className="container-text my-8 text-gray-200" />
<hr className="container-text text-gray-200" />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { BlockImageTeasersFragment, Image, Link } from '@custom/schema';
import clsx from 'clsx';
import React from 'react';

import { isTruthy } from '../../../utils/isTruthy';

export function BlockImageTeasers(props: BlockImageTeasersFragment) {
return (
// eslint-disable-next-line tailwindcss/no-custom-classname
<section className="container-page my-16 block-background-image-cards">
<div className="container-content text-center">
<div className="grid grid-cols-2 gap-2">
<section className="my-10 block-background-image-cards">
<div className="text-center">
<div
className={clsx('grid gap-2', {
'grid-cols-2': props.teasers.filter(isTruthy).length > 1,
})}
>
{props.teasers.filter(isTruthy).map((teaser, index) => (
<BlockImageTeaser key={index} {...teaser} />
))}
Expand All @@ -27,7 +32,7 @@ export function BlockImageTeaser(
<div className="p-8 col-span-2 lg:col-span-1 text-left h-72 lg:h-96 relative bg-gray-900">
{props.image ? (
<Image
className="object-cover w-full h-72 lg:h-96 mb-5 absolute top-0 left-0"
className="object-cover w-full h-72 lg:h-96 absolute top-0 left-0"
source={props.image.source}
alt={props.image.alt}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const unorderedItems: Plugin<[], Element> = () => (tree) => {

export function BlockMarkup(props: BlockMarkupFragment) {
return (
<div className="container-page mt-10">
<div className="container-page my-10">
<div className="container-content">
<div className="container-text">
<div
Expand Down
25 changes: 11 additions & 14 deletions packages/ui/src/components/Organisms/PageContent/BlockMedia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@ import { BlockMediaFragment, Html, Image } from '@custom/schema';
import React from 'react';

import { UnreachableCaseError } from '../../../utils/unreachable-case-error';
import { ScrollPop } from '../../Client/ScrollPop';

export function BlockMedia(props: BlockMediaFragment) {
if (!props.media) {
return null;
}
return (
<ScrollPop>
<div className="container-page">
<div className="container-content">
<figure className="mt-16 container-text">
<Media {...props.media} />
{props.caption ? (
<figcaption className="mt-3 flex justify-center gap-x-2 text-sm leading-6 text-gray-500">
<Html markup={props.caption} />
</figcaption>
) : null}
</figure>
</div>
<div className="container-page mt-16 mb-8">
<div className="container-content">
<figure className="container-text">
<Media {...props.media} />
{props.caption ? (
<figcaption className="mt-3 flex justify-center gap-x-2 text-sm leading-6 text-gray-500">
<Html markup={props.caption} />
</figcaption>
) : null}
</figure>
</div>
</ScrollPop>
</div>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import React from 'react';

export function BlockQuote(props: BlockQuoteFragment) {
return (
<div className="container-page">
<div className="container-page mt-16 mb-8">
<div className="container-content">
<div className="container-text">
<div className="prose lg:prose-xl prose-p:text-xl prose-p:font-bold prose-p:leading-8 prose-p:text-[#111928]">
<blockquote className="border-l-0 relative pl-0 pb-8 pt-16">
<blockquote className="border-l-0 relative pl-0">
<svg
width="32"
height="24"
Expand Down
Loading

0 comments on commit eb72708

Please sign in to comment.