Skip to content

Commit

Permalink
Merge pull request #771 from DTS-STN/ken/collapse-slim-variant
Browse files Browse the repository at this point in the history
Add variant for collapse component styling
  • Loading branch information
ken-blanchard authored Nov 15, 2024
2 parents 308ea0b + e1a0c45 commit 544de49
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 40 deletions.
19 changes: 8 additions & 11 deletions src/components/Collapse.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import { useId } from 'react'

const variants = {
slim: 'text-base',
default: 'rounded border',
}
export interface CollapseProps {
title: string
children?: React.ReactNode
detailProps?: string
summaryProps?: string
variant?: keyof typeof variants
}

const Collapse = ({
title,
children,
detailProps,
summaryProps,
}: CollapseProps) => {
const Collapse = ({ title, children, variant = 'default' }: CollapseProps) => {
const id = useId()
return (
<details
aria-describedby={`${id}-details-summary`}
className={'mb-3 max-w-prose p-3 ' + detailProps}
className={`mb-3 max-w-prose p-3 ${variants[variant]}`}
>
<summary
id={`${id}-details-summary`}
className={
'cursor-pointer text-blue-light hover:text-link-selected focus:text-link-selected ' +
summaryProps
'cursor-pointer text-blue-light hover:text-link-selected hover:underline focus:text-link-selected focus:underline '
}
>
{title}
Expand Down
7 changes: 2 additions & 5 deletions src/pages/email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ const Email = () => {
required
helpMessage={t('email.help-message')}
extraContent={
<Collapse
title={t('email.for-child.title')}
detailProps="text-base"
>
<Collapse title={t('email.for-child.title')} variant="slim">
<p className="mt-4 border-l-[6px] border-gray-400 pl-6 text-base text-gray-600">
<Trans i18nKey="email.for-child.help-message" ns="email" />
</p>
Expand All @@ -270,7 +267,7 @@ const Email = () => {
<Trans i18nKey="given-name.help-message" ns="email" />
}
extraContent={
<Collapse title={t('given-name.title')} detailProps="text-base">
<Collapse title={t('given-name.title')} variant="slim">
<p className="mt-4 border-l-[6px] border-gray-400 pl-6 text-base text-gray-600">
<Trans i18nKey="one-name" ns="email" />
</p>
Expand Down
6 changes: 1 addition & 5 deletions src/pages/expectations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ const Expectations = () => {
<p>{t('not-liable')}</p>
<h2 className="h2">{t('header-privacy')}</h2>
<p>{t('privacy-description')}</p>
<Collapse
title={t('header-privacy')}
detailProps="rounded border"
summaryProps="hover:underline focus:underline"
>
<Collapse title={t('header-privacy')}>
<p>
<Trans i18nKey={'description-privacy.1'} ns="expectations" />
</p>
Expand Down
18 changes: 3 additions & 15 deletions src/pages/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ const Landing = () => {
{t('where-to-find.applied-in-person.header')}
</h3>
<p>{t('where-to-find.applied-in-person.text')}</p>
<Collapse
title={t('receipt-image-1.title')}
detailProps="rounded border"
summaryProps="hover:underline focus:underline"
>
<Collapse title={t('receipt-image-1.title')}>
<div className="mt-3 max-w-prose border-t p-3">
<ExampleImage
imageProps={{
Expand Down Expand Up @@ -85,11 +81,7 @@ const Landing = () => {
</ul>
</div>
</Collapse>
<Collapse
title={t('receipt-image-2.title')}
detailProps="rounded border"
summaryProps="hover:underline focus:underline"
>
<Collapse title={t('receipt-image-2.title')}>
<div className="mt-3 max-w-prose border-t p-3">
<ExampleImage
imageProps={{
Expand Down Expand Up @@ -138,11 +130,7 @@ const Landing = () => {
</ul>
</div>
</Collapse>
<Collapse
title={t('receipt-image-3.title')}
detailProps="rounded border"
summaryProps="hover:underline focus:underline"
>
<Collapse title={t('receipt-image-3.title')}>
<div className="mt-3 max-w-prose border-t p-3">
<ExampleImage
imageProps={{
Expand Down
5 changes: 1 addition & 4 deletions src/pages/status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ const Status = () => {
<Trans i18nKey="given-name.help-message" ns="status" />
}
extraContent={
<Collapse
title={t('given-name.title')}
detailProps="text-base"
>
<Collapse title={t('given-name.title')} variant="slim">
<p className="mt-4 border-l-[6px] border-gray-400 pl-6 text-base text-gray-600">
<Trans i18nKey="one-name" ns="status" />
</p>
Expand Down

0 comments on commit 544de49

Please sign in to comment.