-
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([DST-485]): Create reusable component for Do's and Don'ts (#3968)
Co-authored-by: Sebastian Sebald <[email protected]>
- Loading branch information
1 parent
dd0ec90
commit 9f491e3
Showing
4 changed files
with
101 additions
and
1 deletion.
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': minor | ||
--- | ||
|
||
Adding AdviceCard component |
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,58 @@ | ||
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" | ||
> | ||
<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> | ||
); | ||
|
||
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" | ||
> | ||
<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> | ||
); | ||
|
||
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', | ||
})} | ||
> | ||
<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> | ||
); | ||
}; |
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
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