-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: refa
DonAndDonts
to work without an image (#4023)
* docs: refa `DonAndDonts` to work without an image * Create great-rabbits-join.md * whoops * fix
- Loading branch information
Showing
5 changed files
with
151 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@marigold/docs": patch | ||
--- | ||
|
||
docs: refa `DonAndDonts` to work without an image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Internal | ||
caption: A page to test stuff | ||
--- | ||
|
||
## Do's and Don'ts | ||
|
||
<Columns columns={[1, 1]} space={4}> | ||
<Do> | ||
<Do.Figure> | ||
<Image | ||
className="aspect-square" | ||
width={700} | ||
height={700} | ||
unoptimized | ||
src="https://upload.wikimedia.org/wikipedia/commons/1/18/Dog_Breeds.jpg" | ||
alt="Don't" | ||
/> | ||
</Do.Figure> | ||
<Do.Description> | ||
Use one primary call to action to help people to proceed | ||
</Do.Description> | ||
</Do> | ||
<Dont> | ||
<Dont.Figure> | ||
<Image | ||
className="aspect-square" | ||
width={700} | ||
height={700} | ||
unoptimized | ||
src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/220px-Cat03.jpg" | ||
alt="Don't" | ||
/> | ||
</Dont.Figure> | ||
<Dont.Description> | ||
Don’t use many calls to action in one page or container. | ||
</Dont.Description> | ||
</Dont> | ||
</Columns> | ||
|
||
<Columns columns={[1, 1]} space={4}> | ||
<Do> | ||
<Do.Description> | ||
<ul> | ||
<li>Cheese</li> | ||
<li>Milk</li> | ||
<li>Bread</li> | ||
</ul> | ||
</Do.Description> | ||
</Do> | ||
<Dont> | ||
<Dont.Description> | ||
<ul> | ||
<li>Cheese</li> | ||
<li>Milk</li> | ||
<li>Bread</li> | ||
</ul> | ||
</Dont.Description> | ||
</Dont> | ||
</Columns> | ||
|
||
- foo | ||
- bar | ||
- baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const AppearanceDemo = () => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,83 @@ | ||
import React, { ReactNode } from 'react'; | ||
|
||
import { cn } from '../../packages/system/dist'; | ||
|
||
interface Props { | ||
description: string; | ||
variant: 'do' | 'dont'; | ||
children: ReactNode; | ||
} | ||
|
||
const advice = { | ||
do: 'DO', | ||
dont: "DON'T", | ||
}; | ||
|
||
const checkIcon = ( | ||
<svg | ||
width="10px" | ||
height="10px" | ||
viewBox="0 0 24 24" | ||
className="not-prose size-5 flex-none rounded-full bg-green-600 fill-white p-1" | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
import { cn } from '@marigold/system'; | ||
|
||
// Shared Child Components | ||
// --------------- | ||
const Container = ({ | ||
variant, | ||
children, | ||
}: PropsWithChildren<{ variant: 'do' | 'dont' }>) => ( | ||
<div | ||
className="group my-6 grid grid-cols-[1fr] grid-rows-[auto_auto_auto] [grid-template-areas:'figure''title''description']" | ||
data-type={variant} | ||
> | ||
<path d="M8.17368 16.6154L3.19528 11.637L1.5 13.3204L8.17368 19.994L22.5 5.66772L20.8167 3.98437L8.17368 16.6154Z"></path> | ||
</svg> | ||
{children} | ||
</div> | ||
); | ||
|
||
const warningIcon = ( | ||
<svg | ||
width="10px" | ||
height="10px" | ||
viewBox="0 0 24 24" | ||
className="size-5 flex-none rounded-full bg-red-600 fill-white p-1" | ||
const Title = ({ children }: PropsWithChildren) => ( | ||
<div | ||
className={cn( | ||
'[grid-area:title]', | ||
'group-data-[type=do]:bg-bg-success group-data-[type=do]:border-border-success group-data-[type=dont]:bg-bg-error group-data-[type=dont]:border-border-error', | ||
'flex items-center gap-2 border-t-4 px-4 pb-2 pt-4 font-bold uppercase' | ||
)} | ||
> | ||
<path d="M19.8281 5.74868L18.2513 4.17188L12 10.4232L5.74868 4.17188L4.17188 5.74868L10.4232 12L4.17188 18.2513L5.74868 19.8281L12 13.5768L18.2513 19.8281L19.8281 18.2513L13.5768 12L19.8281 5.74868Z"></path> | ||
</svg> | ||
{children} | ||
</div> | ||
); | ||
|
||
const Figure = ({ children }: PropsWithChildren) => ( | ||
<div className="not-prose [grid-area:figure]">{children}</div> | ||
); | ||
|
||
const Description = ({ children }: PropsWithChildren) => ( | ||
<div className="group-data-[type=do]:bg-bg-success group-data-[type=dont]:bg-bg-error px-4 pb-4 [grid-area:description] *:m-0"> | ||
{children} | ||
</div> | ||
); | ||
|
||
export const DosAndDonts = ({ description, variant, children }: Props) => { | ||
const icon = variant === 'do' ? checkIcon : warningIcon; | ||
|
||
return ( | ||
<div className="not-prose"> | ||
{children} | ||
<div | ||
className={cn('flex flex-col gap-2 border-t-4 p-4', { | ||
'border-border-error bg-bg-error': variant === 'dont', | ||
'border-border-success bg-bg-success': variant === 'do', | ||
})} | ||
// Do | ||
// --------------- | ||
export const Do = ({ children }: PropsWithChildren) => ( | ||
<Container variant="do"> | ||
<Title> | ||
<svg | ||
width="10px" | ||
height="10px" | ||
viewBox="0 0 24 24" | ||
className="size-5 flex-none rounded-full bg-green-600 fill-white p-1" | ||
> | ||
<div className="flex items-center gap-2"> | ||
{icon} | ||
<h5 className="m-0 font-bold">{advice[variant]}</h5> | ||
</div> | ||
<p className="m-0">{description}</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
<path d="M8.17368 16.6154L3.19528 11.637L1.5 13.3204L8.17368 19.994L22.5 5.66772L20.8167 3.98437L8.17368 16.6154Z"></path> | ||
</svg> | ||
<h5 className="m-0 font-bold uppercase">Do</h5> | ||
</Title> | ||
{children} | ||
</Container> | ||
); | ||
|
||
Do.Figure = Figure; | ||
Do.Description = Description; | ||
|
||
// Dont | ||
// --------------- | ||
export const Dont = ({ children }: PropsWithChildren) => ( | ||
<Container variant="dont"> | ||
<Title> | ||
<svg | ||
width="10px" | ||
height="10px" | ||
viewBox="0 0 24 24" | ||
className="size-5 flex-none rounded-full bg-red-600 fill-white p-1" | ||
> | ||
<path d="M19.8281 5.74868L18.2513 4.17188L12 10.4232L5.74868 4.17188L4.17188 5.74868L10.4232 12L4.17188 18.2513L5.74868 19.8281L12 13.5768L18.2513 19.8281L19.8281 18.2513L13.5768 12L19.8281 5.74868Z"></path> | ||
</svg> | ||
<h5 className="m-0 font-bold uppercase">Don't</h5> | ||
</Title> | ||
{children} | ||
</Container> | ||
); | ||
|
||
Dont.Figure = Figure; | ||
Dont.Description = Description; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters