doccupine 0.0.74 → 0.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,7 @@ import { calloutTemplate } from "../templates/components/layout/Callout.js";
27
27
  import { cardTemplate } from "../templates/components/layout/Card.js";
28
28
  import { cherryThemeProviderTemplate } from "../templates/components/layout/CherryThemeProvider.js";
29
29
  import { clientThemeProviderTemplate } from "../templates/components/layout/ClientThemeProvider.js";
30
+ import { colorSwatchTemplate } from "../templates/components/layout/ColorSwatch.js";
30
31
  import { codeTemplate } from "../templates/components/layout/Code.js";
31
32
  import { columnsTemplate } from "../templates/components/layout/Columns.js";
32
33
  import { demoThemeTemplate } from "../templates/components/layout/DemoTheme.js";
@@ -66,6 +67,7 @@ import { buttonsMdxTemplate } from "../templates/mdx/buttons.mdx.js";
66
67
  import { calloutsMdxTemplate } from "../templates/mdx/callouts.mdx.js";
67
68
  import { cardsMdxTemplate } from "../templates/mdx/cards.mdx.js";
68
69
  import { codeMdxTemplate } from "../templates/mdx/code.mdx.js";
70
+ import { colorSwatchesMdxTemplate } from "../templates/mdx/color-swatches.mdx.js";
69
71
  import { columnsMdxTemplate } from "../templates/mdx/columns.mdx.js";
70
72
  import { commandsMdxTemplate } from "../templates/mdx/commands.mdx.js";
71
73
  import { componentsMdxTemplate } from "../templates/mdx/components.mdx.js";
@@ -146,6 +148,7 @@ export const appStructure = {
146
148
  "components/layout/Card.tsx": cardTemplate,
147
149
  "components/layout/CherryThemeProvider.tsx": cherryThemeProviderTemplate,
148
150
  "components/layout/ClientThemeProvider.tsx": clientThemeProviderTemplate,
151
+ "components/layout/ColorSwatch.tsx": colorSwatchTemplate,
149
152
  "components/layout/Code.tsx": codeTemplate,
150
153
  "components/layout/Columns.tsx": columnsTemplate,
151
154
  "components/layout/DemoTheme.tsx": demoThemeTemplate,
@@ -174,6 +177,7 @@ export const startingDocsStructure = {
174
177
  "callouts.mdx": calloutsMdxTemplate,
175
178
  "cards.mdx": cardsMdxTemplate,
176
179
  "code.mdx": codeMdxTemplate,
180
+ "color-swatches.mdx": colorSwatchesMdxTemplate,
177
181
  "columns.mdx": columnsMdxTemplate,
178
182
  "commands.mdx": commandsMdxTemplate,
179
183
  "components.mdx": componentsMdxTemplate,
@@ -1 +1 @@
1
- export declare const mdxComponentsTemplate = "import React from \"react\";\nimport Link from \"next/link\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MDXComponents = Record<string, React.ComponentType<any>>;\nimport { Space } from \"cherry-styled-components\";\nimport { Code as CodeBlock } from \"@/components/layout/Code\";\nimport { Card } from \"@/components/layout/Card\";\nimport { Accordion } from \"@/components/layout/Accordion\";\nimport { Tabs, TabContent } from \"@/components/layout/Tabs\";\nimport { Callout } from \"@/components/layout/Callout\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { Columns } from \"@/components/layout/Columns\";\nimport { Field } from \"@/components/layout/Field\";\nimport { Update } from \"@/components/layout/Update\";\nimport { Steps, Step } from \"@/components/layout/Steps\";\nimport { Button } from \"@/components/layout/Button\";\nimport { DemoTheme } from \"@/components/layout/DemoTheme\";\n\ninterface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {\n children?: React.ReactNode;\n}\n\ninterface PreProps extends React.HTMLAttributes<HTMLPreElement> {\n children?: React.ReactNode;\n}\n\nfunction extractAllTextFromChildren(children: React.ReactNode): string {\n if (children == null) return \"\";\n if (typeof children === \"string\") return children;\n if (typeof children === \"number\") return String(children);\n if (typeof children === \"boolean\") return \"\";\n if (Array.isArray(children))\n return children.map(extractAllTextFromChildren).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractAllTextFromChildren(element.props.children);\n }\n return \"\";\n}\n\nfunction generateId(text: string): string {\n return text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\")\n .trim();\n}\n\n// Map <pre><code class=\"language-xyz\"> to our <Code /> component\nfunction Pre(props: PreProps) {\n const child = React.Children.only(props.children) as React.ReactElement<{\n className?: string;\n children?: React.ReactNode;\n }> | null;\n if (child && child.type === \"code\") {\n const className = child.props.className || \"\";\n const match = /language-(\\w+)/.exec(className);\n const language = match ? match[1] : undefined;\n const code = extractAllTextFromChildren(child.props.children).replace(\n /\\n$/,\n \"\",\n );\n if (language) {\n return (\n <CodeBlock className={className} code={code} language={language} />\n );\n }\n }\n return <pre {...props} />;\n}\n\nexport function useMDXComponents(components: MDXComponents): MDXComponents {\n return {\n // Headings with auto-generated ids for TOC and deep links\n h1: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h1 id={id} {...props}>\n {children}\n </h1>\n );\n },\n h2: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h2 id={id} {...props}>\n {children}\n </h2>\n );\n },\n h3: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h3 id={id} {...props}>\n {children}\n </h3>\n );\n },\n h4: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h4 id={id} {...props}>\n {children}\n </h4>\n );\n },\n h5: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h5 id={id} {...props}>\n {children}\n </h5>\n );\n },\n h6: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h6 id={id} {...props}>\n {children}\n </h6>\n );\n },\n\n // Links - use Next.js Link for internal paths\n a: ({\n href,\n children,\n ...props\n }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {\n if (href && href.startsWith(\"/\")) {\n return (\n <Link href={href} {...props}>\n {children}\n </Link>\n );\n }\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n );\n },\n\n // Tables - wrap in a div for responsive overflow\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"table-wrapper\">\n <table {...props} />\n </div>\n ),\n\n // Code blocks\n pre: Pre,\n\n // Expose your custom components for MDX usage\n Card,\n Accordion,\n Tabs,\n TabContent,\n Callout,\n Icon,\n Columns,\n Field,\n Update,\n Steps,\n Step,\n Button,\n DemoTheme,\n Space,\n ...components,\n };\n}\n";
1
+ export declare const mdxComponentsTemplate = "import React from \"react\";\nimport Link from \"next/link\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MDXComponents = Record<string, React.ComponentType<any>>;\nimport { Space } from \"cherry-styled-components\";\nimport { Code as CodeBlock } from \"@/components/layout/Code\";\nimport { Card } from \"@/components/layout/Card\";\nimport { Accordion } from \"@/components/layout/Accordion\";\nimport { Tabs, TabContent } from \"@/components/layout/Tabs\";\nimport { Callout } from \"@/components/layout/Callout\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { Columns } from \"@/components/layout/Columns\";\nimport { Field } from \"@/components/layout/Field\";\nimport { Update } from \"@/components/layout/Update\";\nimport { Steps, Step } from \"@/components/layout/Steps\";\nimport { Button } from \"@/components/layout/Button\";\nimport { ColorSwatch, ColorSwatchGroup } from \"@/components/layout/ColorSwatch\";\nimport { DemoTheme } from \"@/components/layout/DemoTheme\";\n\ninterface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {\n children?: React.ReactNode;\n}\n\ninterface PreProps extends React.HTMLAttributes<HTMLPreElement> {\n children?: React.ReactNode;\n}\n\nfunction extractAllTextFromChildren(children: React.ReactNode): string {\n if (children == null) return \"\";\n if (typeof children === \"string\") return children;\n if (typeof children === \"number\") return String(children);\n if (typeof children === \"boolean\") return \"\";\n if (Array.isArray(children))\n return children.map(extractAllTextFromChildren).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractAllTextFromChildren(element.props.children);\n }\n return \"\";\n}\n\nfunction generateId(text: string): string {\n return text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\")\n .trim();\n}\n\n// Map <pre><code class=\"language-xyz\"> to our <Code /> component\nfunction Pre(props: PreProps) {\n const child = React.Children.only(props.children) as React.ReactElement<{\n className?: string;\n children?: React.ReactNode;\n }> | null;\n if (child && child.type === \"code\") {\n const className = child.props.className || \"\";\n const match = /language-(\\w+)/.exec(className);\n const language = match ? match[1] : undefined;\n const code = extractAllTextFromChildren(child.props.children).replace(\n /\\n$/,\n \"\",\n );\n if (language) {\n return (\n <CodeBlock className={className} code={code} language={language} />\n );\n }\n }\n return <pre {...props} />;\n}\n\nexport function useMDXComponents(components: MDXComponents): MDXComponents {\n return {\n // Headings with auto-generated ids for TOC and deep links\n h1: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h1 id={id} {...props}>\n {children}\n </h1>\n );\n },\n h2: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h2 id={id} {...props}>\n {children}\n </h2>\n );\n },\n h3: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h3 id={id} {...props}>\n {children}\n </h3>\n );\n },\n h4: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h4 id={id} {...props}>\n {children}\n </h4>\n );\n },\n h5: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h5 id={id} {...props}>\n {children}\n </h5>\n );\n },\n h6: ({ children, ...props }: HeadingProps) => {\n const id = generateId(extractAllTextFromChildren(children));\n return (\n <h6 id={id} {...props}>\n {children}\n </h6>\n );\n },\n\n // Links - use Next.js Link for internal paths\n a: ({\n href,\n children,\n ...props\n }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {\n if (href && href.startsWith(\"/\")) {\n return (\n <Link href={href} {...props}>\n {children}\n </Link>\n );\n }\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n );\n },\n\n // Tables - wrap in a div for responsive overflow\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"table-wrapper\">\n <table {...props} />\n </div>\n ),\n\n // Code blocks\n pre: Pre,\n\n // Expose your custom components for MDX usage\n Card,\n Accordion,\n Tabs,\n TabContent,\n Callout,\n Icon,\n Columns,\n Field,\n Update,\n Steps,\n Step,\n Button,\n ColorSwatch,\n ColorSwatchGroup,\n DemoTheme,\n Space,\n ...components,\n };\n}\n";
@@ -15,6 +15,7 @@ import { Field } from "@/components/layout/Field";
15
15
  import { Update } from "@/components/layout/Update";
16
16
  import { Steps, Step } from "@/components/layout/Steps";
17
17
  import { Button } from "@/components/layout/Button";
18
+ import { ColorSwatch, ColorSwatchGroup } from "@/components/layout/ColorSwatch";
18
19
  import { DemoTheme } from "@/components/layout/DemoTheme";
19
20
 
20
21
  interface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {
@@ -167,6 +168,8 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
167
168
  Steps,
168
169
  Step,
169
170
  Button,
171
+ ColorSwatch,
172
+ ColorSwatchGroup,
170
173
  DemoTheme,
171
174
  Space,
172
175
  ...components,
@@ -1 +1 @@
1
- export declare const buttonTemplate = "\"use client\";\nimport Link from \"next/link\";\nimport styled from \"styled-components\";\nimport {\n theme as localTheme,\n ButtonProps,\n buttonStyles,\n} from \"cherry-styled-components\";\nimport { Icon } from \"@/components/layout/Icon\";\n\ninterface LinkButtonProps extends ButtonProps {\n href?: string;\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n variant?: \"primary\" | \"secondary\" | \"tertiary\";\n size?: \"default\" | \"big\";\n outline?: boolean;\n fullWidth?: boolean;\n icon?: string;\n iconPosition?: \"left\" | \"right\";\n theme?: typeof localTheme;\n}\n\nconst StyledLinkButton = styled(Link)<LinkButtonProps>`\n ${({ theme, $variant, $size, $outline, $fullWidth, disabled }) =>\n buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}\n\n & p {\n color: inherit;\n }\n\n & svg.lucide {\n margin: auto 0;\n min-width: min-content;\n color: inherit;\n }\n`;\n\nconst ButtonBase = styled.button<ButtonProps>`\n ${({ theme, $variant, $size, $outline, $fullWidth, disabled }) =>\n buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}\n\n & p {\n color: inherit;\n }\n\n & svg.lucide {\n margin: auto 0;\n min-width: min-content;\n color: inherit;\n }\n`;\n\nfunction Button({\n variant = \"primary\",\n size,\n outline,\n fullWidth,\n icon,\n iconPosition = \"left\",\n theme: _theme = localTheme,\n href,\n ...props\n}: LinkButtonProps) {\n return href ? (\n <div>\n <StyledLinkButton\n {...props}\n href={href}\n $variant={variant}\n $size={size}\n $outline={outline}\n $fullWidth={fullWidth}\n >\n {iconPosition === \"left\" && icon && <Icon name={icon} size={16} />}\n {props.children}\n {iconPosition === \"right\" && icon && <Icon name={icon} size={16} />}\n </StyledLinkButton>\n </div>\n ) : (\n <div>\n <ButtonBase\n {...props}\n $variant={variant}\n $size={size}\n $outline={outline}\n $fullWidth={fullWidth}\n >\n {iconPosition === \"left\" && icon && <Icon name={icon} size={16} />}\n {props.children}\n {iconPosition === \"right\" && icon && <Icon name={icon} size={16} />}\n </ButtonBase>\n </div>\n );\n}\n\nexport { Button };\n";
1
+ export declare const buttonTemplate = "\"use client\";\nimport Link from \"next/link\";\nimport styled from \"styled-components\";\nimport {\n theme as localTheme,\n ButtonProps,\n buttonStyles,\n} from \"cherry-styled-components\";\nimport { Icon } from \"@/components/layout/Icon\";\n\ninterface LinkButtonProps extends ButtonProps {\n href?: string;\n target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n variant?: \"primary\" | \"secondary\" | \"tertiary\";\n size?: \"default\" | \"big\";\n outline?: boolean;\n fullWidth?: boolean;\n icon?: string;\n iconPosition?: \"left\" | \"right\";\n theme?: typeof localTheme;\n}\n\nconst StyledLinkButton = styled(Link)<LinkButtonProps>`\n ${({ theme, $variant, $size, $outline, $fullWidth, disabled }) =>\n buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}\n\n & p {\n color: inherit !important;\n }\n\n & svg.lucide {\n margin: auto 0;\n min-width: min-content;\n color: inherit;\n }\n`;\n\nconst ButtonBase = styled.button<ButtonProps>`\n ${({ theme, $variant, $size, $outline, $fullWidth, disabled }) =>\n buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}\n\n & p {\n color: inherit !important;\n }\n\n & svg.lucide {\n margin: auto 0;\n min-width: min-content;\n color: inherit;\n }\n`;\n\nfunction Button({\n variant = \"primary\",\n size,\n outline,\n fullWidth,\n icon,\n iconPosition = \"left\",\n theme: _theme = localTheme,\n href,\n ...props\n}: LinkButtonProps) {\n return href ? (\n <div>\n <StyledLinkButton\n {...props}\n href={href}\n $variant={variant}\n $size={size}\n $outline={outline}\n $fullWidth={fullWidth}\n >\n {iconPosition === \"left\" && icon && <Icon name={icon} size={16} />}\n {props.children}\n {iconPosition === \"right\" && icon && <Icon name={icon} size={16} />}\n </StyledLinkButton>\n </div>\n ) : (\n <div>\n <ButtonBase\n {...props}\n $variant={variant}\n $size={size}\n $outline={outline}\n $fullWidth={fullWidth}\n >\n {iconPosition === \"left\" && icon && <Icon name={icon} size={16} />}\n {props.children}\n {iconPosition === \"right\" && icon && <Icon name={icon} size={16} />}\n </ButtonBase>\n </div>\n );\n}\n\nexport { Button };\n";
@@ -25,7 +25,7 @@ const StyledLinkButton = styled(Link)<LinkButtonProps>\`
25
25
  buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}
26
26
 
27
27
  & p {
28
- color: inherit;
28
+ color: inherit !important;
29
29
  }
30
30
 
31
31
  & svg.lucide {
@@ -40,7 +40,7 @@ const ButtonBase = styled.button<ButtonProps>\`
40
40
  buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}
41
41
 
42
42
  & p {
43
- color: inherit;
43
+ color: inherit !important;
44
44
  }
45
45
 
46
46
  & svg.lucide {
@@ -0,0 +1 @@
1
+ export declare const colorSwatchTemplate = "\"use client\";\nimport styled from \"styled-components\";\nimport { styledText, Theme } from \"cherry-styled-components\";\nimport { mq } from \"@/app/theme\";\n\nconst StyledSwatchGroup = styled.div<{ theme: Theme }>`\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n gap: ${({ theme }) => theme.spacing.gridGap.xs};\n\n ${mq(\"md\")} {\n grid-template-columns: repeat(3, 1fr);\n }\n`;\n\nconst StyledSwatch = styled.div<{ theme: Theme }>`\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n overflow: hidden;\n`;\n\nconst StyledColor = styled.div<{\n theme: Theme;\n $color: string;\n $lightText: boolean;\n}>`\n background: ${({ $color }) => $color};\n height: 80px;\n display: flex;\n align-items: flex-end;\n padding: 8px 12px;\n color: ${({ $lightText }) => ($lightText ? \"#FFFFFF\" : \"#000000\")};\n font-size: 12px;\n font-family: monospace;\n opacity: 0.8;\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n`;\n\nconst StyledLabel = styled.div<{ theme: Theme }>`\n padding: 10px 12px;\n background: ${({ theme }) => theme.colors.light};\n ${({ theme }) => styledText(theme)};\n font-size: 13px;\n color: ${({ theme }) => theme.colors.grayDark};\n\n code {\n color: ${({ theme }) => theme.colors.dark};\n font-weight: 600;\n font-size: 13px;\n }\n`;\n\nfunction luminance(hex: string): number {\n const rgb = hex\n .replace(\"#\", \"\")\n .match(/.{2}/g)!\n .map((c) => parseInt(c, 16) / 255);\n\n const [r, g, b] = rgb.map((c) =>\n c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4),\n );\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\ninterface ColorSwatchProps {\n token: string;\n value: string;\n}\n\nfunction ColorSwatch({ token, value }: ColorSwatchProps) {\n const useLightText = luminance(value) < 0.4;\n\n return (\n <StyledSwatch>\n <StyledColor $color={value} $lightText={useLightText}>\n {value}\n </StyledColor>\n <StyledLabel>\n <code className=\"token\">{token}</code>\n </StyledLabel>\n </StyledSwatch>\n );\n}\n\ninterface ColorSwatchGroupProps {\n children: React.ReactNode;\n}\n\nfunction ColorSwatchGroup({ children }: ColorSwatchGroupProps) {\n return <StyledSwatchGroup>{children}</StyledSwatchGroup>;\n}\n\nexport { ColorSwatch, ColorSwatchGroup };\n";
@@ -0,0 +1,95 @@
1
+ export const colorSwatchTemplate = `"use client";
2
+ import styled from "styled-components";
3
+ import { styledText, Theme } from "cherry-styled-components";
4
+ import { mq } from "@/app/theme";
5
+
6
+ const StyledSwatchGroup = styled.div<{ theme: Theme }>\`
7
+ display: grid;
8
+ grid-template-columns: repeat(2, 1fr);
9
+ gap: \${({ theme }) => theme.spacing.gridGap.xs};
10
+
11
+ \${mq("md")} {
12
+ grid-template-columns: repeat(3, 1fr);
13
+ }
14
+ \`;
15
+
16
+ const StyledSwatch = styled.div<{ theme: Theme }>\`
17
+ border: solid 1px \${({ theme }) => theme.colors.grayLight};
18
+ border-radius: \${({ theme }) => theme.spacing.radius.lg};
19
+ overflow: hidden;
20
+ \`;
21
+
22
+ const StyledColor = styled.div<{
23
+ theme: Theme;
24
+ $color: string;
25
+ $lightText: boolean;
26
+ }>\`
27
+ background: \${({ $color }) => $color};
28
+ height: 80px;
29
+ display: flex;
30
+ align-items: flex-end;
31
+ padding: 8px 12px;
32
+ color: \${({ $lightText }) => ($lightText ? "#FFFFFF" : "#000000")};
33
+ font-size: 12px;
34
+ font-family: monospace;
35
+ opacity: 0.8;
36
+ border-bottom: solid 1px \${({ theme }) => theme.colors.grayLight};
37
+ \`;
38
+
39
+ const StyledLabel = styled.div<{ theme: Theme }>\`
40
+ padding: 10px 12px;
41
+ background: \${({ theme }) => theme.colors.light};
42
+ \${({ theme }) => styledText(theme)};
43
+ font-size: 13px;
44
+ color: \${({ theme }) => theme.colors.grayDark};
45
+
46
+ code {
47
+ color: \${({ theme }) => theme.colors.dark};
48
+ font-weight: 600;
49
+ font-size: 13px;
50
+ }
51
+ \`;
52
+
53
+ function luminance(hex: string): number {
54
+ const rgb = hex
55
+ .replace("#", "")
56
+ .match(/.{2}/g)!
57
+ .map((c) => parseInt(c, 16) / 255);
58
+
59
+ const [r, g, b] = rgb.map((c) =>
60
+ c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4),
61
+ );
62
+
63
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
64
+ }
65
+
66
+ interface ColorSwatchProps {
67
+ token: string;
68
+ value: string;
69
+ }
70
+
71
+ function ColorSwatch({ token, value }: ColorSwatchProps) {
72
+ const useLightText = luminance(value) < 0.4;
73
+
74
+ return (
75
+ <StyledSwatch>
76
+ <StyledColor $color={value} $lightText={useLightText}>
77
+ {value}
78
+ </StyledColor>
79
+ <StyledLabel>
80
+ <code className="token">{token}</code>
81
+ </StyledLabel>
82
+ </StyledSwatch>
83
+ );
84
+ }
85
+
86
+ interface ColorSwatchGroupProps {
87
+ children: React.ReactNode;
88
+ }
89
+
90
+ function ColorSwatchGroup({ children }: ColorSwatchGroupProps) {
91
+ return <StyledSwatchGroup>{children}</StyledSwatchGroup>;
92
+ }
93
+
94
+ export { ColorSwatch, ColorSwatchGroup };
95
+ `;
@@ -1 +1 @@
1
- export declare const sharedStyledTemplate = "\"use client\";\nimport { mq, styledSmall, styledText, Theme } from \"cherry-styled-components\";\nimport styled, { css } from \"styled-components\";\n\nexport const interactiveStyles = css<{ theme: Theme }>`\n transition: all 0.3s ease;\n border: solid 1px transparent;\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n &:hover {\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n &:focus {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:active {\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const styledAnchor = css<{ theme: Theme }>`\n & a:not([class]) {\n color: inherit;\n transition: all 0.3s ease;\n text-decoration: none;\n box-shadow: 0 2px 0 0 ${({ theme }) => theme.colors.primary};\n\n &:hover {\n color: ${({ theme }) =>\n theme.isDark ? theme.colors.primaryLight : theme.colors.primaryDark};\n box-shadow: 0 1px 0 0 ${({ theme }) => theme.colors.primary};\n }\n }\n`;\n\nexport const stylesLists = css<{ theme: Theme }>`\n & ul,\n & ol {\n & li {\n & > .code-wrapper {\n margin: 10px 0;\n }\n }\n }\n\n & ul {\n list-style: none;\n padding: 0;\n margin: 0;\n\n & li {\n text-indent: 0;\n display: block;\n position: relative;\n padding: 0 0 0 15px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n min-height: 23px;\n\n ${mq(\"lg\")} {\n min-height: 27px;\n }\n\n &::before {\n content: \"\";\n display: block;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n position: absolute;\n top: 8px;\n left: 2px;\n\n ${mq(\"lg\")} {\n top: 10px;\n }\n }\n }\n }\n\n & ol {\n padding: 0;\n margin: 0;\n\n & ul {\n padding-left: 15px;\n }\n\n & > li {\n position: relative;\n padding: 0;\n counter-increment: item;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n\n &::before {\n content: counter(item) \".\";\n display: inline-block;\n margin: 0 4px 0 0;\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n min-width: max-content;\n }\n }\n }\n`;\n\nexport const styledTable = css<{ theme: Theme }>`\n & .table-wrapper {\n overflow-x: auto;\n width: 100%;\n }\n\n & table {\n margin: 0;\n padding: 0;\n border-collapse: collapse;\n width: 100%;\n text-align: left;\n\n & tr {\n margin: 0;\n padding: 0;\n }\n\n & th {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n ${({ theme }) => styledSmall(theme)};\n font-weight: 600;\n color: ${({ theme }) => theme.colors.dark};\n }\n\n & td {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledSmall(theme)};\n }\n }\n`;\n\nexport const StyledSmallButton = styled.button<{ theme: Theme }>`\n ${interactiveStyles};\n background: transparent;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.primary};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 6px 8px;\n font-size: 12px;\n font-family: inherit;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n display: flex;\n align-items: center;\n gap: 6px;\n margin-right: -6px;\n\n & svg.lucide {\n color: inherit;\n }\n`;\n";
1
+ export declare const sharedStyledTemplate = "\"use client\";\nimport { mq, styledSmall, styledText, Theme } from \"cherry-styled-components\";\nimport styled, { css } from \"styled-components\";\n\nexport const interactiveStyles = css<{ theme: Theme }>`\n transition: all 0.3s ease;\n border: solid 1px transparent;\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n &:hover {\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n &:focus {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:active {\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const styledAnchor = css<{ theme: Theme }>`\n & a:not([class]):not(:has(img)) {\n color: inherit;\n transition: all 0.3s ease;\n text-decoration: none;\n box-shadow: 0 2px 0 0 ${({ theme }) => theme.colors.primary};\n\n &:hover {\n color: ${({ theme }) =>\n theme.isDark ? theme.colors.primaryLight : theme.colors.primaryDark};\n box-shadow: 0 1px 0 0 ${({ theme }) => theme.colors.primary};\n }\n }\n`;\n\nexport const stylesLists = css<{ theme: Theme }>`\n & ul,\n & ol {\n & li {\n & > .code-wrapper {\n margin: 10px 0;\n }\n }\n }\n\n & ul {\n list-style: none;\n padding: 0;\n margin: 0;\n\n & li {\n text-indent: 0;\n display: block;\n position: relative;\n padding: 0 0 0 15px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n min-height: 23px;\n\n ${mq(\"lg\")} {\n min-height: 27px;\n }\n\n &::before {\n content: \"\";\n display: block;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n position: absolute;\n top: 8px;\n left: 2px;\n\n ${mq(\"lg\")} {\n top: 10px;\n }\n }\n }\n }\n\n & ol {\n padding: 0;\n margin: 0;\n\n & ul {\n padding-left: 15px;\n }\n\n & > li {\n position: relative;\n padding: 0;\n counter-increment: item;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n\n &::before {\n content: counter(item) \".\";\n display: inline-block;\n margin: 0 4px 0 0;\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n min-width: max-content;\n }\n }\n }\n`;\n\nexport const styledTable = css<{ theme: Theme }>`\n & .table-wrapper {\n overflow-x: auto;\n width: 100%;\n }\n\n & table {\n margin: 0;\n padding: 0;\n border-collapse: collapse;\n width: 100%;\n text-align: left;\n\n & tr {\n margin: 0;\n padding: 0;\n }\n\n & th {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n ${({ theme }) => styledSmall(theme)};\n font-weight: 600;\n color: ${({ theme }) => theme.colors.dark};\n }\n\n & td {\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n padding: 10px 10px 10px 0;\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledSmall(theme)};\n }\n }\n`;\n\nexport const StyledSmallButton = styled.button<{ theme: Theme }>`\n ${interactiveStyles};\n background: transparent;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.primary};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 6px 8px;\n font-size: 12px;\n font-family: inherit;\n font-weight: 600;\n cursor: pointer;\n transition: all 0.2s ease;\n display: flex;\n align-items: center;\n gap: 6px;\n margin-right: -6px;\n\n & svg.lucide {\n color: inherit;\n }\n`;\n";
@@ -22,7 +22,7 @@ export const interactiveStyles = css<{ theme: Theme }>\`
22
22
  \`;
23
23
 
24
24
  export const styledAnchor = css<{ theme: Theme }>\`
25
- & a:not([class]) {
25
+ & a:not([class]):not(:has(img)) {
26
26
  color: inherit;
27
27
  transition: all 0.3s ease;
28
28
  text-decoration: none;
@@ -0,0 +1 @@
1
+ export declare const colorSwatchesMdxTemplate = "---\ntitle: \"Color Swatches\"\ndescription: \"Display color palettes with labeled swatches to document your theme colors.\"\ndate: \"2026-02-19\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 8\n---\n# Color Swatches\nDisplay color palettes with labeled swatches to document your theme colors.\n\nThe `ColorSwatch` component renders a visual preview of a color alongside its token name, and `ColorSwatchGroup` arranges multiple swatches in a responsive grid.\n\n## Usage\nYou can use the ColorSwatch components directly within your MDX files without any import:\n\n~~~mdx\n<ColorSwatchGroup>\n <ColorSwatch token=\"primary\" value=\"#6366F1\" />\n <ColorSwatch token=\"secondary\" value=\"#EC4899\" />\n <ColorSwatch token=\"success\" value=\"#10B981\" />\n <ColorSwatch token=\"warning\" value=\"#F59E0B\" />\n <ColorSwatch token=\"danger\" value=\"#EF4444\" />\n <ColorSwatch token=\"info\" value=\"#3B82F6\" />\n</ColorSwatchGroup>\n~~~\n\n<ColorSwatchGroup>\n <ColorSwatch token=\"primary\" value=\"#6366F1\" />\n <ColorSwatch token=\"secondary\" value=\"#EC4899\" />\n <ColorSwatch token=\"success\" value=\"#10B981\" />\n <ColorSwatch token=\"warning\" value=\"#F59E0B\" />\n <ColorSwatch token=\"danger\" value=\"#EF4444\" />\n <ColorSwatch token=\"info\" value=\"#3B82F6\" />\n</ColorSwatchGroup>\n\n## Dark Colors\n\nText color automatically adapts based on the background luminance, so dark swatches display white text:\n\n~~~mdx\n<ColorSwatchGroup>\n <ColorSwatch token=\"dark\" value=\"#1E1E2E\" />\n <ColorSwatch token=\"grayDark\" value=\"#374151\" />\n <ColorSwatch token=\"gray\" value=\"#6B7280\" />\n <ColorSwatch token=\"grayLight\" value=\"#D1D5DB\" />\n <ColorSwatch token=\"light\" value=\"#F9FAFB\" />\n <ColorSwatch token=\"white\" value=\"#FFFFFF\" />\n</ColorSwatchGroup>\n~~~\n\n<ColorSwatchGroup>\n <ColorSwatch token=\"dark\" value=\"#1E1E2E\" />\n <ColorSwatch token=\"grayDark\" value=\"#374151\" />\n <ColorSwatch token=\"gray\" value=\"#6B7280\" />\n <ColorSwatch token=\"grayLight\" value=\"#D1D5DB\" />\n <ColorSwatch token=\"light\" value=\"#F9FAFB\" />\n <ColorSwatch token=\"white\" value=\"#FFFFFF\" />\n</ColorSwatchGroup>\n\n## ColorSwatch Properties\n\n<Field value=\"token\" type=\"string\" required>\n The name or label displayed below the color preview (e.g. a design token name).\n</Field>\n\n<Field value=\"value\" type=\"string\" required>\n A hex color value (e.g. `#6366F1`). Displayed inside the color preview and used as the background.\n</Field>\n\n## ColorSwatchGroup Properties\n\n<Field value=\"children\" type=\"node\" required>\n One or more `ColorSwatch` components to display in a responsive grid.\n</Field>";
@@ -0,0 +1,75 @@
1
+ export const colorSwatchesMdxTemplate = `---
2
+ title: "Color Swatches"
3
+ description: "Display color palettes with labeled swatches to document your theme colors."
4
+ date: "2026-02-19"
5
+ category: "Components"
6
+ categoryOrder: 1
7
+ order: 8
8
+ ---
9
+ # Color Swatches
10
+ Display color palettes with labeled swatches to document your theme colors.
11
+
12
+ The \`ColorSwatch\` component renders a visual preview of a color alongside its token name, and \`ColorSwatchGroup\` arranges multiple swatches in a responsive grid.
13
+
14
+ ## Usage
15
+ You can use the ColorSwatch components directly within your MDX files without any import:
16
+
17
+ ~~~mdx
18
+ <ColorSwatchGroup>
19
+ <ColorSwatch token="primary" value="#6366F1" />
20
+ <ColorSwatch token="secondary" value="#EC4899" />
21
+ <ColorSwatch token="success" value="#10B981" />
22
+ <ColorSwatch token="warning" value="#F59E0B" />
23
+ <ColorSwatch token="danger" value="#EF4444" />
24
+ <ColorSwatch token="info" value="#3B82F6" />
25
+ </ColorSwatchGroup>
26
+ ~~~
27
+
28
+ <ColorSwatchGroup>
29
+ <ColorSwatch token="primary" value="#6366F1" />
30
+ <ColorSwatch token="secondary" value="#EC4899" />
31
+ <ColorSwatch token="success" value="#10B981" />
32
+ <ColorSwatch token="warning" value="#F59E0B" />
33
+ <ColorSwatch token="danger" value="#EF4444" />
34
+ <ColorSwatch token="info" value="#3B82F6" />
35
+ </ColorSwatchGroup>
36
+
37
+ ## Dark Colors
38
+
39
+ Text color automatically adapts based on the background luminance, so dark swatches display white text:
40
+
41
+ ~~~mdx
42
+ <ColorSwatchGroup>
43
+ <ColorSwatch token="dark" value="#1E1E2E" />
44
+ <ColorSwatch token="grayDark" value="#374151" />
45
+ <ColorSwatch token="gray" value="#6B7280" />
46
+ <ColorSwatch token="grayLight" value="#D1D5DB" />
47
+ <ColorSwatch token="light" value="#F9FAFB" />
48
+ <ColorSwatch token="white" value="#FFFFFF" />
49
+ </ColorSwatchGroup>
50
+ ~~~
51
+
52
+ <ColorSwatchGroup>
53
+ <ColorSwatch token="dark" value="#1E1E2E" />
54
+ <ColorSwatch token="grayDark" value="#374151" />
55
+ <ColorSwatch token="gray" value="#6B7280" />
56
+ <ColorSwatch token="grayLight" value="#D1D5DB" />
57
+ <ColorSwatch token="light" value="#F9FAFB" />
58
+ <ColorSwatch token="white" value="#FFFFFF" />
59
+ </ColorSwatchGroup>
60
+
61
+ ## ColorSwatch Properties
62
+
63
+ <Field value="token" type="string" required>
64
+ The name or label displayed below the color preview (e.g. a design token name).
65
+ </Field>
66
+
67
+ <Field value="value" type="string" required>
68
+ A hex color value (e.g. \`#6366F1\`). Displayed inside the color preview and used as the background.
69
+ </Field>
70
+
71
+ ## ColorSwatchGroup Properties
72
+
73
+ <Field value="children" type="node" required>
74
+ One or more \`ColorSwatch\` components to display in a responsive grid.
75
+ </Field>`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doccupine",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {