Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/apps/pages/sections/Banner.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Container from '@components/Container.astro';
import LinkButton from '@components/LinkButton';
import SearchBar from '@apps/pages/sections/SearchBar';
import RichText from '@apps/pages/sections/RichText.astro';
import { toBackgroundClass, toTextClass } from '@utils/pageBuilder';

const Height = {
small: 'small',
Expand All @@ -15,9 +16,9 @@ const {
background,
buttonText,
clip,
color,
content,
darken,
darkText,
height,
image,
imageAlt,
Expand All @@ -32,15 +33,13 @@ const {
<div
class={clsx(
'w-full relative flex flex-col justify-center',
toBackgroundClass(background),
{ 'items-center': textAlignment === 'center' },
{ 'overflow-hidden': clip },
{ 'bg-primary': background === 'primary' },
{ 'bg-secondary': background === 'secondary' },
{ 'bg-white': background === 'white' },
{ 'bg-black': background === 'black' },
{ 'min-h-[220px]': height === Height.small },
{ 'min-h-[420px]': height === Height.medium },
{ 'min-h-[720px]': height === Height.large }
{ 'min-h-[720px]': height === Height.large },
{ 'text-text-inverse': !darkText }
)}
>
{ image && (
Expand All @@ -55,7 +54,7 @@ const {
) }
{ darken && (
<div
class='absolute top-0 left-0 w-full h-full bg-gray-900/30'
class='absolute top-0 left-0 w-full h-full bg-tertiary mix-blend-multiply'
/>
) }
<div class={clsx(
Expand Down Expand Up @@ -104,9 +103,8 @@ const {
{ content && content.children?.length ? (
<div class={clsx(
'prose max-w-none py-8 lg:py-16 z-10',
{ '!text-white': color === 'white' },
{ '!text-black': !color || color === 'black'},
{ 'text-center': textAlignment === 'center' }
{ 'text-center': textAlignment === 'center' },
{ 'text-text-inverse': !darkText }
)}>
<RichText content={content} />
</div>
Expand Down
11 changes: 7 additions & 4 deletions src/apps/pages/sections/ColumnContent.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ const BlockTypes = {

---
{ item.__typename.endsWith(BlockTypes.image) && (
<img src={item.image} class='w-full object-cover' />
<img src={item.image} class={clsx(
'w-full object-cover',
{ 'rounded-md': item.rounded }
)} />
)}

{ item.__typename.endsWith(BlockTypes.text) && (
<div class="prose max-w-none">
<div class='prose max-w-none px-6 py-4 text-inherit'>
<RichText content={item.text} />
</div>
)}
Expand Down Expand Up @@ -64,7 +67,7 @@ const BlockTypes = {
{ item.__typename.endsWith(BlockTypes.quote) && (
<div class={clsx(
'flex flex-col relative h-full p-6 gap-6',
toTextClass(item.text_color),
item.text_color,
toBorderClass(item.border_color)
)}>
<img src={item.icon} class='absolute top-4 left-4 w-12 h-12 opacity-20' />
Expand All @@ -83,7 +86,7 @@ const BlockTypes = {
<img src={item.image} class='w-full h-full object-contain'/>
{ item.overlay && (
<div class='absolute h-full w-full inset-0 bg-gradient-to-b to-black/60 p-6 flex flex-col justify-end'>
<h2 class='text-text-light text-[2.4rem] font-serif'>{ item.overlay }</h2>
<h2 class='text-text-inverse text-[2.4rem] font-serif'>{ item.overlay }</h2>
</div>
)}
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/apps/pages/sections/FeatureQuote.astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const {
class={clsx(
'w-full relative flex flex-col justify-center items-center font-serif',
toBackgroundClass(background),
toTextClass(text)
text
)}
>
<Container className={clsx(
Expand Down
11 changes: 9 additions & 2 deletions src/apps/pages/sections/MultiColumn.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import clsx from 'clsx';
import _ from 'underscore';
import LinkButton from '@components/LinkButton';
import Column from '@apps/pages/sections/Column.astro';
import { toBorderClass } from '@utils/pageBuilder';

const {
buttonText,
Expand Down Expand Up @@ -34,7 +35,7 @@ const gridCols = total === TOTAL_COLUMNS ? 'lg:grid-cols-12' : 'lg:auto-cols-fr
{ title && (
<h2
class={clsx(
'text-4xl font-bold py-4',
'text-4xl font-bold py-8',
{ 'flex justify-center': textAlignment === 'center' }
)}
>
Expand All @@ -51,7 +52,13 @@ const gridCols = total === TOTAL_COLUMNS ? 'lg:grid-cols-12' : 'lg:auto-cols-fr
>
{
_.map(content, (col: any) => (
<Column items={col.content} className={clsx({ [col.width] : total === TOTAL_COLUMNS })} />
<Column items={col.content} className={clsx(
{ [col.width] : total === TOTAL_COLUMNS },
toBorderClass(col.border),
{ 'rounded-md': col.rounded },
col.justify,
col.align
)} />
))
}
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/apps/pages/sections/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ const SearchBar = (props: SearchBarProps) => {
}, [searchName, query, language]);

return (
<div className='not-prose w-[840px] border rounded-md border-black text-black text-sm'>
<div className='not-prose w-[840px] border rounded-md border-black text-sm'>
<form
id='search-bar'
className='relative flex flex-row items-center'
onSubmit={onSubmit}
>
<input
className='py-4 pe-4 ps-13 w-[720px] h-full rounded-l-md bg-white'
className='py-4 pe-4 ps-13 w-[720px] h-full rounded-l-md bg-white text-black'
type='text'
name='query'
placeholder={placeholder}
Expand All @@ -40,7 +40,7 @@ const SearchBar = (props: SearchBarProps) => {
<button
type='submit'
name='submit'
className='w-30 h-full bg-black rounded-r-md py-4 px-6 flex justify-center items-center font-semibold text-white'
className='w-30 h-full bg-secondary rounded-r-md py-4 px-6 flex justify-center items-center font-semibold text-inherit'
>
{buttonText}
</button>
Expand Down
11 changes: 9 additions & 2 deletions src/components/Card.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
---
const { alt, date, dateOptions = {}, category, title, author, slug, imageUrl, blurb, t } = Astro.props;
import clsx from "clsx";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single quotes.

import { toBorderClass } from "@utils/pageBuilder";
const { alt, border, date, dateOptions = {}, category, title, author, slug, imageUrl, blurb, t, rounded } = Astro.props;
const dateString = date ? new Date(date).toLocaleDateString(undefined, dateOptions) : null;
---

<article
class='flex max-w-xl flex-col items-start justify-between bg-neutral-light'
class={clsx(
'flex max-w-xl flex-col items-start justify-between bg-neutral-light',
{ 'rounded-md': rounded },
toBorderClass(border)
)}
>
<div
class='relative w-full'
Expand Down
16 changes: 6 additions & 10 deletions src/components/LinkButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import clsx from 'clsx';
import { ColorValues } from '@root/tina/content/pages';
import { ArrowRightIcon } from '@heroicons/react/24/outline';
import { toBackgroundClass, toBorderClass, toTextClass } from '@utils/pageBuilder';

interface Props {
arrow?: boolean;
border?: string;
className?: string;
color?: string;
content: JSX.Element | string;
Expand All @@ -14,15 +15,10 @@ interface Props {
const LinkButton = ({ className, content, href, ...props }: Props) => (
<a
className={clsx(
'inline-flex mt-4 rounded-md px-6 py-3 hover:bg-opacity-95 cursor-pointer flex-row gap-4 items-center no-underline mx-6',
{ 'bg-primary': props.color === ColorValues.primary },
{ 'bg-secondary': props.color === ColorValues.secondary },
{ 'bg-white': props.color === ColorValues.white },
{ 'bg-black': props.color === ColorValues.black },
{ 'text-primary': props.text === ColorValues.primary },
{ 'text-secondary': props.text === ColorValues.secondary },
{ 'text-white': props.text === ColorValues.white },
{ 'text-black': props.text === ColorValues.black },
'link-button inline-flex mt-4 rounded-md px-6 py-3 hover:bg-opacity-95 cursor-pointer flex-row gap-4 items-center no-underline',
toBackgroundClass(props.color),
toTextClass(props.text),
toBorderClass(props.border),
className
)}
href={href}
Expand Down
6 changes: 2 additions & 4 deletions src/components/Spacer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import clsx from 'clsx';
import { toBackgroundClass } from '../utils/pageBuilder';

interface SpacerProps {
size: string;
Expand All @@ -13,10 +14,7 @@ const Spacer = (props: SpacerProps) => (
{ 'my-4 lg:my-8': props.size === 'small' },
{ 'my-8 lg:my-16': props.size === 'medium' },
{ 'my-16 lg:my-32': props.size === 'large' },
{ 'bg-primary': props.color === 'primary' },
{ 'bg-secondary': props.color === 'secondary' },
{ 'bg-white': props.color === 'white' },
{ 'bg-black': props.color === 'black' }
toBackgroundClass(props.color)
)}
/>
);
Expand Down
8 changes: 6 additions & 2 deletions src/layouts/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ const {
image,
imageAlt,
items,
title
title,
transparent
} = Astro.props;

---

<div
class='flex flex-row justify-center w-full bg-primary'
class={clsx(
'flex flex-row justify-center w-full z-20 text-text-primary',
{ 'bg-primary': !transparent }
)}
>
<div
class={clsx(
Expand Down
39 changes: 32 additions & 7 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,35 @@ const { header, footer } = branding;

const { font_header: fontHeader, font_body: fontBody } = branding;

const colorPrimary = branding.primary_color;
const textPrimary = useBlackText(colorPrimary) ? 'var(--color-black)' : 'var(--color-white)';
//dark and light mode default text color
const content = branding.content_color || 'var(--color-black)';
const contentInverse = branding.content_inverse || 'var(--color-white)';
const contentAlternate = branding.content_alternate || 'var(--color-neutral-dark)';
const contentInverseAlternate = branding.content_inverse_alternate || 'var(--color-neutral-light)';

const colorPrimary = branding.primary_color;
const colorSecondary = branding.secondary_color;
const textSecondary = !colorSecondary || useBlackText(colorSecondary) ? 'var(--color-black)' : 'var(--color-white)';
const colorTertiary = branding.tertiary_color || 'var(--color-black)';

//these are for use in layout components like header and footer
const primaryContent = useBlackText(colorPrimary) ? content : contentInverse;
const secondaryContent = !colorSecondary || useBlackText(colorSecondary) ? content : contentInverse;
const tertiaryContent = !colorTertiary || useBlackText(colorTertiary) ? content : contentInverse;

const colorLayout = branding.background_color || 'var(--color-white)';
const layoutContent = !branding.background_color || useBlackText(branding.background_color) ? content : contentInverse;
const layoutContentAlternate = !branding.background_color || useBlackText(branding.background_color) ? contentAlternate : contentInverseAlternate;

const colorLayoutAlternate = branding.background_alternate || 'var(--color-neutral-light)';
const layoutAlternateContent = !branding.background_alternate || useBlackText(branding.background_alternate) ? content : contentInverse;
const layoutAlternateContentAlternate = !branding.background_alternate || useBlackText(branding.background_alternate) ? contentAlternate : contentInverseAlternate; //this naming scheme could be better....

const currentLocale = Astro.currentLocale;
const lang = getLanguageFromUrl(Astro.url.pathname);

const pages = await getPages(currentLocale);

const { footer: includeFooter, fullscreen, name, title, t, tab } = Astro.props;
const { footer: includeFooter, fullscreen, name, title, t, tab, transparent } = Astro.props;

const NavKeys = {
gallery: 'gallery',
Expand Down Expand Up @@ -132,11 +147,20 @@ if (config.gallery) {
define:vars={{
customFontHeader: fontHeader,
customFontBody: fontBody,
customLayout: colorLayout,
customLayoutAlternate: colorLayoutAlternate,
customColorPrimary: colorPrimary,
customColorSecondary: colorSecondary,
customTextPrimary: textPrimary,
customTextSecondary: textSecondary,
customColorLayout: colorLayout
customColorTertiary: colorTertiary,
customPrimaryContent: primaryContent,
customSecondaryContent: secondaryContent,
customTertiaryContent: tertiaryContent,
customContent: layoutContent,
customContentAlternate: layoutContentAlternate,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These names are a little confusing (content alternate, alternate content, etc). Could we keep the naming more consistent with the fields in Tina? (e.g. main background, alternate background, main text, main text inverted, etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's tricky... I was attempting to match the language that's used in the Figma designs as much as possible, which is why I switched to content over text, but I don't have strong feelings about that either way.

The thing about "main text", "main text inverted" etc. is that those are not the same variables as these; they are the options from which these theme variables are selected. For example, imagine a site with the following theme:

Primary: light pink
Main background: dark purple
Alternate background: white
Main content (for light background): black
Main content inverse (for dark background): white

In this case (with the current naming), we'd have primaryContent = black (because the primary color is light), layoutContent = white (because the main background color is dark), layoutAlternateContent = black (because the alternate background color is light). However, if the theme were the same except the main background was light blue, then layoutContent would become black.

The reason for doing it this way is that in some cases in the designs we want to select the text color just based on whether it's dark or light (for example on these cards -- this isn't based on a theme color, we're just applying a black gradient over the image to make the light text pop:)
image
So in that case we do want to use contentInverse, but in most other cases we want to use the text color based on the themed background value, and so whether it's content or contentInverse will depend on the value of the background. So that's the difference between content (always dark), contentInverse (always light), and layoutContent (depends on value of colorLayout).

Sorry for the overly labored explanation, but that's the complexity I'm trying to wrangle here. The user never has to see any of this -- from the perspective of an editor in Tina, they just have to select the text color they want for dark backgrounds and for light backgrounds, and the correct one will be chosen based on the background color for each section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. It's a complicated concept. I'm just thinking of another developer (myself included) coming in here to make adjustments, it's a little hard to follow which colors are being applied where.

customAlternateContent: layoutAlternateContent,
customAlternateContentAlternate: layoutAlternateContentAlternate,
customText: content,
customTextInverse: contentInverse
}}
>
</style>
Expand All @@ -153,6 +177,7 @@ if (config.gallery) {
items={NavItems}
pages={pages}
title={header?.hide_title ? undefined : branding.title}
transparent={transparent}
/>
<NotificationPanel
client:only='react'
Expand Down
15 changes: 12 additions & 3 deletions src/layouts/Page.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { getTranslations } from '@backend/i18n';
import { fetchPage } from '@backend/tina';
import Container from '@components/Container.astro';
import Layout from '@layouts/Layout.astro';
import clsx from 'clsx';
import _ from 'underscore';
import { toBackgroundClass, toTextClass } from '@utils/pageBuilder';

const { slug } = Astro.props;
const locale = Astro.currentLocale;
Expand All @@ -38,10 +40,17 @@ const SectionTypes = {
t={t}
tab={page?._sys?.filename}
title={page?.title}
transparent={page?.transparent}
>
{ _.map(page?.sections, section => (
{ _.map(page?.sections, (section, idx) => (
<section
class='relative'
class={clsx(
'page-builder',
'relative',
toBackgroundClass(section.background),
section.text,
{ '-mt-20': page.transparent && idx === 0 }
)}
>
{ section.__typename === SectionTypes.carousel && (
<Container>
Expand Down Expand Up @@ -108,9 +117,9 @@ const SectionTypes = {
background={section.background}
buttonText={section.button_text}
clip={section.clip}
color={section.color}
content={section.content}
darken={section.darken}
darkText={section.dark_text}
fullWidth={section.full_width}
height={section.height}
image={section.background_image}
Expand Down
Loading