Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release' into SLB-382-Footer-men…
Browse files Browse the repository at this point in the history
…u-styling
  • Loading branch information
Luqmaan Essop committed Jun 5, 2024
2 parents 144811e + 01525e6 commit 64cb7d1
Show file tree
Hide file tree
Showing 17 changed files with 338 additions and 265 deletions.
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@amazeelabs/gatsby-plugin-operations": "^1.1.3",
"@amazeelabs/gatsby-plugin-static-dirs": "^1.0.1",
"@amazeelabs/gatsby-source-silverback": "^1.14.0",
"@amazeelabs/publisher": "^2.4.17",
"@amazeelabs/publisher": "^2.4.30",
"@amazeelabs/strangler-netlify": "^1.1.9",
"@amazeelabs/token-auth-middleware": "^1.1.1",
"@custom/cms": "workspace:*",
Expand Down
98 changes: 79 additions & 19 deletions packages/ui/src/components/Molecules/LanguageSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,90 @@
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();

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>
{Object.values(Locale).map((locale) => (
<React.Fragment key={locale}>
{translations[locale] &&
location.pathname !== translations[locale] ? null : (
<Menu.Button className="inline-flex justify-center w-full rounded-md bg-white text-sm hover:text-blue-600">
{getLanguageName(locale)}
<ChevronDownIcon
className="ml-1 h-5 w-5"
aria-hidden="true"
/>
</Menu.Button>
)}
</React.Fragment>
))}
</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">
{Object.values(Locale).map((locale) => (
<React.Fragment key={locale}>
{translations[locale] &&
location.pathname !== translations[locale] ? (
<Menu.Item>
{({ 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>
) : null}
</React.Fragment>
))}
</div>
</Menu.Items>
</Transition>
</Menu>
</div>
);
}
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
@@ -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 @@ -24,10 +29,10 @@ export function BlockImageTeaser(
props: BlockImageTeasersFragment['teasers'][0],
) {
return (
<div className="p-8 col-span-2 lg:col-span-1 text-left h-72 lg:h-96 relative bg-gray-900">
<div className="p-8 pl-5 md:pl-14 lg:pl-20 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
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">
<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>
</ScrollPop>
</div>
);
}

Expand Down
118 changes: 63 additions & 55 deletions packages/ui/src/components/Organisms/PageHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function PageHero(props: NonNullable<PageFragment['hero']>) {
function DefaultHero(props: NonNullable<PageFragment['hero']>) {
return (
<>
<section className="default-hero relative isolate overflow-hidden bg-gray-900 pt-12 pb-24 min-h-[20rem] lg:min-h-[33rem]">
<section className="default-hero relative isolate overflow-hidden bg-gray-900 pt-12 pb-24 min-h-[20rem] lg:min-h-[33rem] container-page">
{props.image ? (
<Image
alt={props.image.alt}
Expand All @@ -27,7 +27,7 @@ function DefaultHero(props: NonNullable<PageFragment['hero']>) {
data-test-id={'hero-image'}
/>
) : null}
<div className="mx-auto max-w-7xl px-6 lg:px-8">
<div className="container-content">
<div className="mx-auto max-w-2xl lg:mx-0">
<h1 className="text-5xl font-extrabold tracking-tight leading-tight text-white drop-shadow-md">
{props.headline}
Expand Down Expand Up @@ -82,33 +82,37 @@ function FormHero(props: NonNullable<PageFragment['hero']>) {
</>
) : null}

<div className="px-4 pb-[22rem] lg:pb-96 mx-auto max-w-screen-sm text-center lg:px-6 relative">
<h1 className="text-4xl tracking-tight font-extrabold text-white drop-shadow-md">
{props.headline}
</h1>
{props.lead ? (
<p className="mt-6 text-lg leading-4 text-gray-300">{props.lead}</p>
) : null}
{props.ctaText && props.ctaUrl ? (
<Link
href={props.ctaUrl}
className="mt-7 px-5 py-2.5 text-sm font-medium text-white inline-flex items-center bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 rounded-lg text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
<svg
className="mr-2 -ml-1 w-4 h-4"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
<div className="px-4 pb-[22rem] lg:pb-96 container-page text-center lg:px-6 relative">
<div className="max-w-screen-xl mx-auto">
<h1 className="text-4xl tracking-tight font-extrabold text-white drop-shadow-md">
{props.headline}
</h1>
{props.lead ? (
<p className="mt-6 text-lg leading-4 text-gray-300">
{props.lead}
</p>
) : null}
{props.ctaText && props.ctaUrl ? (
<Link
href={props.ctaUrl}
className="mt-7 px-5 py-2.5 text-sm font-medium text-white inline-flex items-center bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 rounded-lg text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
<path
fillRule="evenodd"
d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z"
clipRule="evenodd"
></path>
</svg>
{props.ctaText}
</Link>
) : null}
<svg
className="mr-2 -ml-1 w-4 h-4"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z"
clipRule="evenodd"
></path>
</svg>
{props.ctaText}
</Link>
) : null}
</div>
</div>
</div>
{props.formUrl ? (
Expand All @@ -126,34 +130,38 @@ function NoImageHero(props: NonNullable<PageFragment['hero']>) {
return (
<>
<BreadCrumbs />
<section className="relative isolate overflow-hidden pt-12 sm:pt-20 px-6 lg:px-8">
<div className="mx-auto max-w-3xl">
<h1 className="text-4xl font-extrabold tracking-tight leading-tight">
{props.headline}
</h1>
{props.lead ? (
<p className="mt-4 text-lg leading-8 text-gray-500">{props.lead}</p>
) : null}
{props.ctaText && props.ctaUrl ? (
<Link
href={props.ctaUrl}
className="mt-5 px-5 py-2.5 text-sm font-medium text-white inline-flex items-center bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 rounded-lg text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
<svg
className="mr-2 -ml-1 w-4 h-4"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
<section className="relative isolate overflow-hidden pt-12 sm:pt-20 container-page">
<div className="container-content">
<div className="container-text">
<h1 className="text-4xl font-extrabold tracking-tight leading-tight">
{props.headline}
</h1>
{props.lead ? (
<p className="mt-4 text-lg leading-8 text-gray-500">
{props.lead}
</p>
) : null}
{props.ctaText && props.ctaUrl ? (
<Link
href={props.ctaUrl}
className="mt-5 px-5 py-2.5 text-sm font-medium text-white inline-flex items-center bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 rounded-lg text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
<path
fillRule="evenodd"
d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z"
clipRule="evenodd"
></path>
</svg>
{props.ctaText}
</Link>
) : null}
<svg
className="mr-2 -ml-1 w-4 h-4"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z"
clipRule="evenodd"
></path>
</svg>
{props.ctaText}
</Link>
) : null}
</div>
</div>
</section>
</>
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/src/components/Routes/Page.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { Page } from './Page';

export default {
component: Page,
parameters: {
layout: 'fullscreen',
},
} satisfies Meta<typeof Page>;

export const Default = {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/pages.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Default as PageStory } from './components/Routes/Page.stories';
export default {
title: 'Pages',
parameters: {
layout: 'fullscreen',
chromatic: {
// We don't want to snapshot page examples, that just causes a lot of noise.
disableSnapshot: true,
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
'postcss-import-ext-glob': {},
'postcss-import': {},
tailwindcss: require('./tailwind.config.cjs'),
'postcss-nested': {},
autoprefixer: {},
'postcss-prefix-selector': {
prefix:
Expand Down
Loading

0 comments on commit 64cb7d1

Please sign in to comment.