From 9f491e3a80d07150d8c239a37269ae889549c4fe Mon Sep 17 00:00:00 2001 From: Osama Abdul Latif <62595605+OsamaAbdellateef@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:36:43 +0300 Subject: [PATCH] docs([DST-485]): Create reusable component for Do's and Don'ts (#3968) Co-authored-by: Sebastian Sebald --- .changeset/thin-suits-complain.md | 5 +++ docs/ui/DosAndDonts.tsx | 58 +++++++++++++++++++++++++++++++ docs/ui/mdx.tsx | 3 ++ themes/theme-docs/src/tokens.ts | 36 ++++++++++++++++++- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 .changeset/thin-suits-complain.md create mode 100644 docs/ui/DosAndDonts.tsx diff --git a/.changeset/thin-suits-complain.md b/.changeset/thin-suits-complain.md new file mode 100644 index 0000000000..8e5db6c38c --- /dev/null +++ b/.changeset/thin-suits-complain.md @@ -0,0 +1,5 @@ +--- +'@marigold/docs': minor +--- + +Adding AdviceCard component diff --git a/docs/ui/DosAndDonts.tsx b/docs/ui/DosAndDonts.tsx new file mode 100644 index 0000000000..0272da1048 --- /dev/null +++ b/docs/ui/DosAndDonts.tsx @@ -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 = ( + + + +); + +const warningIcon = ( + + + +); + +export const DosAndDonts = ({ description, variant, children }: Props) => { + const icon = variant === 'do' ? checkIcon : warningIcon; + + return ( +
+ {children} +
+
+ {icon} +
{advice[variant]}
+
+

{description}

+
+
+ ); +}; diff --git a/docs/ui/mdx.tsx b/docs/ui/mdx.tsx index c4e594a52b..f755622bc7 100644 --- a/docs/ui/mdx.tsx +++ b/docs/ui/mdx.tsx @@ -24,6 +24,7 @@ import { AppearanceTable } from './AppearanceTable'; import { ColorTokenTable } from './ColorTokens'; import { ComponentDemo } from './ComponentDemo'; import { CopyButton } from './CopyButton'; +import { DosAndDonts } from './DosAndDonts'; import { FullsizeView } from './FullsizeViewDemo'; import { Image } from './Image'; import { PropsTable } from './PropsTable'; @@ -130,6 +131,8 @@ const typography = { const components = { ...typography, Image, + DosAndDonts, + Link, // Docs Components AlignmentsX, AlignmentsY, diff --git a/themes/theme-docs/src/tokens.ts b/themes/theme-docs/src/tokens.ts index 9bc72d6837..6c3cc634ad 100644 --- a/themes/theme-docs/src/tokens.ts +++ b/themes/theme-docs/src/tokens.ts @@ -34,6 +34,20 @@ const blue = { 950: '#172554', }; +const green = { + 50: '#f0fdf4', + 100: '#ecfccb', + 200: '#d9f99d', + 300: '#bef264', + 400: '#a3e635', + 500: '#84cc16', + 600: '#65a30d', + 700: '#4d7c0f', + 800: '#3f6212', + 900: '#365314', + 950: '#1a2e05', +}; + const neutral = { 50: '#fafafa', 100: '#f5f5f5', @@ -48,6 +62,20 @@ const neutral = { 950: '#0a0a0a', }; +const red = { + 50: '#fef2f2', + 100: '#fee2e2', + 200: '#fecaca', + 300: '#fca5a5', + 400: '#f87171', + 500: '#ef4444', + 600: '#dc2626', + 700: '#b91c1c', + 800: '#991b1b', + 900: '#7f1d1d', + 950: '#450a0a', +}; + const slate = { 50: '#f8fafc', 100: '#f1f5f9', @@ -132,7 +160,9 @@ export const colors = { }, // Status - info: blue[100], + success: green[100], + error: red[50], + info: blue[50], warning: amber[50], }, @@ -141,5 +171,9 @@ export const colors = { border: { DEFAULT: slate[300], primary: slate[950], + + // status + success: green[600], + error: red[600], }, };