doccupine 0.0.140 → 0.0.142

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.
Files changed (145) hide show
  1. package/README.md +14 -7
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +191 -0
  4. package/dist/index.d.ts +3 -7
  5. package/dist/index.js +5 -1894
  6. package/dist/lib/config-manager.d.ts +1 -0
  7. package/dist/lib/config-manager.js +63 -3
  8. package/dist/lib/generated-artifacts.d.ts +26 -0
  9. package/dist/lib/generated-artifacts.js +147 -0
  10. package/dist/lib/layout.js +30 -30
  11. package/dist/lib/metadata.js +58 -30
  12. package/dist/lib/openapi-types.d.ts +2 -2
  13. package/dist/lib/openapi.d.ts +6 -3
  14. package/dist/lib/openapi.js +330 -50
  15. package/dist/lib/output-safety.d.ts +15 -0
  16. package/dist/lib/output-safety.js +428 -0
  17. package/dist/lib/structures.js +11 -0
  18. package/dist/lib/utils.d.ts +10 -5
  19. package/dist/lib/utils.js +108 -5
  20. package/dist/mdx-to-nextjs-generator.d.ts +166 -0
  21. package/dist/mdx-to-nextjs-generator.js +2229 -0
  22. package/dist/templates/app/api/gate/route.d.ts +1 -1
  23. package/dist/templates/app/api/gate/route.js +18 -6
  24. package/dist/templates/app/api/mcp/route.d.ts +1 -1
  25. package/dist/templates/app/api/mcp/route.js +181 -111
  26. package/dist/templates/app/api/playground/route.d.ts +1 -1
  27. package/dist/templates/app/api/playground/route.js +45 -13
  28. package/dist/templates/app/api/rag/route.d.ts +1 -1
  29. package/dist/templates/app/api/rag/route.js +72 -20
  30. package/dist/templates/app/api/search/route.d.ts +1 -1
  31. package/dist/templates/app/api/search/route.js +5 -0
  32. package/dist/templates/app/robots.d.ts +1 -1
  33. package/dist/templates/app/robots.js +1 -26
  34. package/dist/templates/app/theme.d.ts +1 -1
  35. package/dist/templates/app/theme.js +31 -19
  36. package/dist/templates/components/Chat.d.ts +1 -1
  37. package/dist/templates/components/Chat.js +342 -34
  38. package/dist/templates/components/SearchDocs.d.ts +1 -1
  39. package/dist/templates/components/SearchDocs.js +63 -11
  40. package/dist/templates/components/SearchModalContent.d.ts +1 -1
  41. package/dist/templates/components/SearchModalContent.js +191 -49
  42. package/dist/templates/components/SideBar.d.ts +1 -1
  43. package/dist/templates/components/SideBar.js +8 -2
  44. package/dist/templates/components/layout/Accordion.d.ts +1 -1
  45. package/dist/templates/components/layout/Accordion.js +26 -3
  46. package/dist/templates/components/layout/Badge.d.ts +1 -1
  47. package/dist/templates/components/layout/Badge.js +1 -1
  48. package/dist/templates/components/layout/Button.d.ts +1 -1
  49. package/dist/templates/components/layout/Button.js +4 -4
  50. package/dist/templates/components/layout/Callout.d.ts +1 -1
  51. package/dist/templates/components/layout/Callout.js +6 -6
  52. package/dist/templates/components/layout/Card.d.ts +1 -1
  53. package/dist/templates/components/layout/Card.js +9 -4
  54. package/dist/templates/components/layout/CherryThemeProvider.d.ts +1 -1
  55. package/dist/templates/components/layout/CherryThemeProvider.js +63 -12
  56. package/dist/templates/components/layout/Code.d.ts +1 -1
  57. package/dist/templates/components/layout/Code.js +5 -5
  58. package/dist/templates/components/layout/CopyButton.d.ts +1 -1
  59. package/dist/templates/components/layout/CopyButton.js +1 -1
  60. package/dist/templates/components/layout/DemoTheme.d.ts +1 -1
  61. package/dist/templates/components/layout/DemoTheme.js +8 -28
  62. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  63. package/dist/templates/components/layout/DocsComponents.js +57 -6
  64. package/dist/templates/components/layout/GlobalStyles.d.ts +1 -1
  65. package/dist/templates/components/layout/GlobalStyles.js +15 -9
  66. package/dist/templates/components/layout/Prompt.d.ts +1 -1
  67. package/dist/templates/components/layout/Prompt.js +4 -7
  68. package/dist/templates/components/layout/Steps.d.ts +1 -1
  69. package/dist/templates/components/layout/Steps.js +7 -1
  70. package/dist/templates/components/layout/Tabs.d.ts +1 -1
  71. package/dist/templates/components/layout/Tabs.js +108 -19
  72. package/dist/templates/env.example.d.ts +1 -1
  73. package/dist/templates/env.example.js +11 -0
  74. package/dist/templates/eslint.config.d.ts +1 -1
  75. package/dist/templates/eslint.config.js +20 -0
  76. package/dist/templates/gitignore.d.ts +1 -1
  77. package/dist/templates/gitignore.js +4 -3
  78. package/dist/templates/lib/access.d.ts +1 -0
  79. package/dist/templates/lib/access.js +41 -0
  80. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  81. package/dist/templates/mdx/ai-assistant.mdx.js +17 -1
  82. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  83. package/dist/templates/mdx/api-playground.mdx.js +5 -3
  84. package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
  85. package/dist/templates/mdx/authentication.mdx.js +5 -3
  86. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  87. package/dist/templates/mdx/commands.mdx.js +20 -6
  88. package/dist/templates/mdx/components.mdx.d.ts +1 -1
  89. package/dist/templates/mdx/components.mdx.js +3 -0
  90. package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
  91. package/dist/templates/mdx/deployment-and-hosting.mdx.js +2 -2
  92. package/dist/templates/mdx/globals.mdx.d.ts +1 -1
  93. package/dist/templates/mdx/globals.mdx.js +14 -11
  94. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  95. package/dist/templates/mdx/model-context-protocol.mdx.js +22 -35
  96. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  97. package/dist/templates/mdx/platform/ai-assistant.mdx.js +23 -0
  98. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
  99. package/dist/templates/mdx/platform/api-playground.mdx.js +7 -0
  100. package/dist/templates/mdx/platform/authentication.mdx.d.ts +1 -0
  101. package/dist/templates/mdx/platform/authentication.mdx.js +63 -0
  102. package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -1
  103. package/dist/templates/mdx/platform/import-from-github.mdx.js +2 -2
  104. package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
  105. package/dist/templates/mdx/platform/index.mdx.js +1 -0
  106. package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
  107. package/dist/templates/mdx/platform/mcp.mdx.js +2 -1
  108. package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
  109. package/dist/templates/mdx/platform/navigation-settings.mdx.js +12 -1
  110. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  111. package/dist/templates/mdx/platform/publishing.mdx.js +43 -10
  112. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
  113. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +48 -9
  114. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  115. package/dist/templates/mdx/sections.mdx.js +4 -0
  116. package/dist/templates/mdx/space.mdx.d.ts +1 -0
  117. package/dist/templates/mdx/space.mdx.js +125 -0
  118. package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
  119. package/dist/templates/mdx/tabs.mdx.js +4 -0
  120. package/dist/templates/next.config.js +20 -8
  121. package/dist/templates/package.js +3 -3
  122. package/dist/templates/prettierignore.d.ts +1 -1
  123. package/dist/templates/prettierignore.js +1 -0
  124. package/dist/templates/proxy.js +47 -19
  125. package/dist/templates/scripts/build-docs-index.d.ts +1 -1
  126. package/dist/templates/scripts/build-docs-index.js +1 -0
  127. package/dist/templates/services/mcp/docsContentStub.d.ts +1 -0
  128. package/dist/templates/services/mcp/docsContentStub.js +1 -0
  129. package/dist/templates/services/mcp/server.d.ts +1 -1
  130. package/dist/templates/services/mcp/server.js +140 -83
  131. package/dist/templates/services/mcp/tools.d.ts +1 -1
  132. package/dist/templates/services/mcp/tools.js +65 -137
  133. package/dist/templates/utils/playgroundAllowlist.d.ts +1 -1
  134. package/dist/templates/utils/playgroundAllowlist.js +13 -4
  135. package/dist/templates/utils/rateLimit.d.ts +1 -1
  136. package/dist/templates/utils/rateLimit.js +40 -3
  137. package/dist/templates/utils/requestBody.d.ts +1 -0
  138. package/dist/templates/utils/requestBody.js +56 -0
  139. package/dist/templates/utils/ssrfGuard.d.ts +1 -1
  140. package/dist/templates/utils/ssrfGuard.js +138 -33
  141. package/package.json +13 -5
  142. package/dist/lib/mdxToMarkdown.d.ts +0 -1
  143. package/dist/lib/mdxToMarkdown.js +0 -134
  144. package/dist/templates/mdx/image-and-embeds.mdx.d.ts +0 -1
  145. package/dist/templates/mdx/image-and-embeds.mdx.js +0 -118
@@ -1 +1 @@
1
- export declare const accordionTemplate = "\"use client\";\nimport { useId, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\nconst StyledAccordion = styled.div<{ theme: Theme }>`\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n width: 100%;\n`;\n\nconst StyledAccordionTitle = styled.button<{ theme: Theme; $isOpen: boolean }>`\n appearance: none;\n display: block;\n width: 100%;\n border: none;\n background: none;\n text-align: left;\n font: inherit;\n cursor: pointer;\n margin: 0;\n padding: 0 40px 0 0;\n ${({ theme }) => styledText(theme)};\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n transition: color 0.3s ease;\n position: relative;\n\n &:hover {\n color: ${({ theme }) => theme.colors.primaryDark};\n }\n\n & .lucide-chevron-down {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n right: 0;\n transition: transform 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n transform: translateY(-50%) rotate(180deg);\n `}\n }\n`;\n\nconst StyledAccordionContent = styled.div<{ theme: Theme; $isOpen: boolean }>`\n ${({ theme }) => styledText(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n height: 0;\n overflow: clip;\n transition: all 0.3s ease;\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex-wrap: wrap;\n flex: 1;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n margin: 20px 0 0;\n height: auto;\n `}\n`;\n\ninterface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n title: string;\n defaultOpen?: boolean;\n}\n\nfunction Accordion({ children, title, defaultOpen = false }: AccordionProps) {\n const [isOpen, setIsOpen] = useState(defaultOpen);\n const contentId = useId();\n\n return (\n <StyledAccordion>\n <StyledAccordionTitle\n type=\"button\"\n onClick={() => setIsOpen(!isOpen)}\n $isOpen={isOpen}\n aria-expanded={isOpen}\n aria-controls={contentId}\n >\n {title} <Icon name=\"ChevronDown\" />\n </StyledAccordionTitle>\n <StyledAccordionContent id={contentId} role=\"region\" $isOpen={isOpen}>\n {children}\n </StyledAccordionContent>\n </StyledAccordion>\n );\n}\n\nexport { Accordion };\n";
1
+ export declare const accordionTemplate = "\"use client\";\nimport { useId, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { Button, resetButton, styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\nconst StyledAccordion = styled.div<{ theme: Theme }>`\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n width: 100%;\n`;\n\nconst StyledAccordionTitle = styled(Button)<{\n theme: Theme;\n $isOpen: boolean;\n}>`\n ${resetButton};\n appearance: none;\n display: block;\n width: 100%;\n border: none;\n background: none;\n text-align: left;\n font: inherit;\n cursor: pointer;\n margin: 0;\n padding: 0 40px 0 0;\n ${({ theme }) => styledText(theme)};\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n transition: color 0.3s ease;\n position: relative;\n\n &:hover {\n color: ${({ theme }) => theme.colors.primaryDark};\n }\n\n &:focus-visible {\n outline: none;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n\n & .lucide-chevron-down {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n right: 0;\n transition: transform 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n transform: translateY(-50%) rotate(180deg);\n `}\n }\n`;\n\nconst StyledAccordionContent = styled.div<{ theme: Theme; $isOpen: boolean }>`\n ${({ theme }) => styledText(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n height: 0;\n overflow: clip;\n transition: all 0.3s ease;\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex-wrap: wrap;\n flex: 1;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n margin: 20px 0 0;\n height: auto;\n `}\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n`;\n\ninterface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n title: string;\n defaultOpen?: boolean;\n}\n\nfunction Accordion({ children, title, defaultOpen = false }: AccordionProps) {\n const [isOpen, setIsOpen] = useState(defaultOpen);\n const contentId = useId();\n const titleId = useId();\n\n return (\n <StyledAccordion>\n <StyledAccordionTitle\n id={titleId}\n type=\"button\"\n onClick={() => setIsOpen(!isOpen)}\n $isOpen={isOpen}\n aria-expanded={isOpen}\n aria-controls={contentId}\n >\n {title} <Icon name=\"ChevronDown\" />\n </StyledAccordionTitle>\n <StyledAccordionContent\n id={contentId}\n role=\"region\"\n aria-labelledby={titleId}\n aria-hidden={!isOpen}\n inert={!isOpen}\n $isOpen={isOpen}\n >\n {children}\n </StyledAccordionContent>\n </StyledAccordion>\n );\n}\n\nexport { Accordion };\n";
@@ -1,7 +1,7 @@
1
1
  export const accordionTemplate = `"use client";
2
2
  import { useId, useState } from "react";
3
3
  import styled, { css } from "styled-components";
4
- import { styledText } from "cherry-styled-components";
4
+ import { Button, resetButton, styledText } from "cherry-styled-components";
5
5
  import { Theme } from "@/app/theme";
6
6
  import { Icon } from "@/components/layout/Icon";
7
7
 
@@ -15,7 +15,11 @@ const StyledAccordion = styled.div<{ theme: Theme }>\`
15
15
  width: 100%;
16
16
  \`;
17
17
 
18
- const StyledAccordionTitle = styled.button<{ theme: Theme; $isOpen: boolean }>\`
18
+ const StyledAccordionTitle = styled(Button)<{
19
+ theme: Theme;
20
+ $isOpen: boolean;
21
+ }>\`
22
+ \${resetButton};
19
23
  appearance: none;
20
24
  display: block;
21
25
  width: 100%;
@@ -36,6 +40,12 @@ const StyledAccordionTitle = styled.button<{ theme: Theme; $isOpen: boolean }>\`
36
40
  color: \${({ theme }) => theme.colors.primaryDark};
37
41
  }
38
42
 
43
+ &:focus-visible {
44
+ outline: none;
45
+ border-radius: \${({ theme }) => theme.spacing.radius.xs};
46
+ box-shadow: 0 0 0 2px \${({ theme }) => theme.colors.primaryLight};
47
+ }
48
+
39
49
  & .lucide-chevron-down {
40
50
  position: absolute;
41
51
  top: 50%;
@@ -69,6 +79,10 @@ const StyledAccordionContent = styled.div<{ theme: Theme; $isOpen: boolean }>\`
69
79
  margin: 20px 0 0;
70
80
  height: auto;
71
81
  \`}
82
+
83
+ @media (prefers-reduced-motion: reduce) {
84
+ transition: none;
85
+ }
72
86
  \`;
73
87
 
74
88
  interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -80,10 +94,12 @@ interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
80
94
  function Accordion({ children, title, defaultOpen = false }: AccordionProps) {
81
95
  const [isOpen, setIsOpen] = useState(defaultOpen);
82
96
  const contentId = useId();
97
+ const titleId = useId();
83
98
 
84
99
  return (
85
100
  <StyledAccordion>
86
101
  <StyledAccordionTitle
102
+ id={titleId}
87
103
  type="button"
88
104
  onClick={() => setIsOpen(!isOpen)}
89
105
  $isOpen={isOpen}
@@ -92,7 +108,14 @@ function Accordion({ children, title, defaultOpen = false }: AccordionProps) {
92
108
  >
93
109
  {title} <Icon name="ChevronDown" />
94
110
  </StyledAccordionTitle>
95
- <StyledAccordionContent id={contentId} role="region" $isOpen={isOpen}>
111
+ <StyledAccordionContent
112
+ id={contentId}
113
+ role="region"
114
+ aria-labelledby={titleId}
115
+ aria-hidden={!isOpen}
116
+ inert={!isOpen}
117
+ $isOpen={isOpen}
118
+ >
96
119
  {children}
97
120
  </StyledAccordionContent>
98
121
  </StyledAccordion>
@@ -1 +1 @@
1
- export declare const badgeTemplate = "\"use client\";\nimport styled, { css } from \"styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\ntype BadgeColor =\n | \"gray\"\n | \"blue\"\n | \"green\"\n | \"yellow\"\n | \"orange\"\n | \"red\"\n | \"purple\"\n | \"white\"\n | \"surface\"\n | \"white-destructive\"\n | \"surface-destructive\"\n | \"info\"\n | \"success\"\n | \"warning\"\n | \"error\";\n\ntype BadgeSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\ntype BadgeShape = \"rounded\" | \"pill\";\n\n// The semantic colors read theme tokens instead of the fixed palette, so\n// they follow theme.json and the light/dark toggle. They are also what the\n// HTTP method chips use.\nconst THEME_TOKEN_COLORS = [\"info\", \"success\", \"warning\", \"error\"] as const;\n\ntype ThemeTokenColor = (typeof THEME_TOKEN_COLORS)[number];\n\ntype HexBadgeColor = Exclude<BadgeColor, ThemeTokenColor>;\n\nfunction isThemeTokenColor(color: BadgeColor): color is ThemeTokenColor {\n return (THEME_TOKEN_COLORS as readonly string[]).includes(color);\n}\n\n// Single source for verb -> badge color, shared by the sidebar method tags\n// and the API playground so every surface colors HTTP verbs identically.\nconst HTTP_METHOD_COLORS: Record<string, BadgeColor> = {\n get: \"info\",\n post: \"success\",\n put: \"warning\",\n patch: \"warning\",\n delete: \"error\",\n head: \"gray\",\n options: \"gray\",\n trace: \"gray\",\n};\n\nfunction httpMethodBadgeColor(method: string): BadgeColor {\n return HTTP_METHOD_COLORS[method.toLowerCase()] ?? \"gray\";\n}\n\ninterface BadgePalette {\n background: string;\n text: string;\n border: string;\n darkBackground: string;\n darkText: string;\n darkBorder: string;\n}\n\n// Strong fills for the hex palette; the white and surface variants have no\n// distinct solid form and fall back to their filled palette.\nconst SOLID_ACCENTS: Partial<Record<HexBadgeColor, string>> = {\n gray: \"#71717a\",\n blue: \"#3b82f6\",\n green: \"#22c55e\",\n yellow: \"#eab308\",\n orange: \"#f97316\",\n red: \"#ef4444\",\n purple: \"#a855f7\",\n};\n\n// Color tints are label-semantic and intentionally independent of theme.json\n// (same rationale as Callout's alert tints); only the surface and semantic\n// token variants read theme tokens, so they follow the active theme on both\n// modes. When both are set, solid wins over stroke.\nfunction badgePalette(\n theme: Theme,\n color: BadgeColor,\n stroke: boolean,\n solid: boolean,\n): BadgePalette {\n if (isThemeTokenColor(color)) {\n const token = theme.colors[color];\n if (solid) {\n return {\n background: token,\n text: theme.colors.surface,\n border: \"transparent\",\n darkBackground: token,\n darkText: theme.colors.surface,\n darkBorder: \"transparent\",\n };\n }\n if (stroke) {\n return {\n background: \"transparent\",\n text: token,\n border: token,\n darkBackground: \"transparent\",\n darkText: token,\n darkBorder: token,\n };\n }\n const tint = `color-mix(in srgb, ${token} 15%, transparent)`;\n return {\n background: tint,\n text: token,\n border: \"transparent\",\n darkBackground: tint,\n darkText: token,\n darkBorder: \"transparent\",\n };\n }\n\n const solidAccent = SOLID_ACCENTS[color];\n if (solid && solidAccent) {\n return {\n background: solidAccent,\n text: \"#ffffff\",\n border: \"transparent\",\n darkBackground: solidAccent,\n darkText: \"#ffffff\",\n darkBorder: \"transparent\",\n };\n }\n\n // The \"surface\" variants sit on the page surface of the active theme: white\n // on light, black on dark. They read theme.colors.light (the html/body\n // background) rather than theme.colors.surface \u2014 that token is a foreground\n // color that stays white in both modes, so using it here left the chip white\n // on dark pages. The \"white\" variants below stay literally white by contract.\n const surface = {\n background: theme.colors.light,\n text: theme.colors.grayDark,\n border: theme.colors.grayLight,\n darkBackground: theme.colors.light,\n darkText: theme.colors.grayDark,\n darkBorder: theme.colors.gray,\n };\n\n if (stroke && !solid) {\n const strokes: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"transparent\",\n text: \"#52525b\",\n border: \"#a1a1aa\",\n darkBackground: \"transparent\",\n darkText: \"#d4d4d8\",\n darkBorder: \"#71717a\",\n },\n blue: {\n background: \"transparent\",\n text: \"#1d4ed8\",\n border: \"#3b82f6\",\n darkBackground: \"transparent\",\n darkText: \"#93c5fd\",\n darkBorder: \"#3b82f6\",\n },\n green: {\n background: \"transparent\",\n text: \"#15803d\",\n border: \"#22c55e\",\n darkBackground: \"transparent\",\n darkText: \"#86efac\",\n darkBorder: \"#22c55e\",\n },\n yellow: {\n background: \"transparent\",\n text: \"#a16207\",\n border: \"#eab308\",\n darkBackground: \"transparent\",\n darkText: \"#fde047\",\n darkBorder: \"#eab308\",\n },\n orange: {\n background: \"transparent\",\n text: \"#c2410c\",\n border: \"#f97316\",\n darkBackground: \"transparent\",\n darkText: \"#fdba74\",\n darkBorder: \"#f97316\",\n },\n red: {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n purple: {\n background: \"transparent\",\n text: \"#7e22ce\",\n border: \"#a855f7\",\n darkBackground: \"transparent\",\n darkText: \"#d8b4fe\",\n darkBorder: \"#a855f7\",\n },\n white: {\n background: \"transparent\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"transparent\",\n darkText: \"#fafafa\",\n darkBorder: \"#3f3f46\",\n },\n surface: {\n ...surface,\n background: \"transparent\",\n darkBackground: \"transparent\",\n },\n \"white-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n \"surface-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n };\n return strokes[color];\n }\n\n const filled: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"#f4f4f5\",\n text: \"#3f3f46\",\n border: \"transparent\",\n darkBackground: \"#71717a33\",\n darkText: \"#d4d4d8\",\n darkBorder: \"transparent\",\n },\n blue: {\n background: \"#dbeafe\",\n text: \"#1e40af\",\n border: \"transparent\",\n darkBackground: \"#3b82f633\",\n darkText: \"#93c5fd\",\n darkBorder: \"transparent\",\n },\n green: {\n background: \"#dcfce7\",\n text: \"#166534\",\n border: \"transparent\",\n darkBackground: \"#22c55e33\",\n darkText: \"#86efac\",\n darkBorder: \"transparent\",\n },\n yellow: {\n background: \"#fef9c3\",\n text: \"#854d0e\",\n border: \"transparent\",\n darkBackground: \"#eab30833\",\n darkText: \"#fde047\",\n darkBorder: \"transparent\",\n },\n orange: {\n background: \"#ffedd5\",\n text: \"#9a3412\",\n border: \"transparent\",\n darkBackground: \"#f9731633\",\n darkText: \"#fdba74\",\n darkBorder: \"transparent\",\n },\n red: {\n background: \"#fee2e2\",\n text: \"#991b1b\",\n border: \"transparent\",\n darkBackground: \"#ef444433\",\n darkText: \"#fca5a5\",\n darkBorder: \"transparent\",\n },\n purple: {\n background: \"#f3e8ff\",\n text: \"#6b21a8\",\n border: \"transparent\",\n darkBackground: \"#a855f733\",\n darkText: \"#d8b4fe\",\n darkBorder: \"transparent\",\n },\n // Literally white in both modes, so it stays legible on images, colored\n // frames, and hero areas. Use the surface variants for theme-aware chips.\n white: {\n background: \"#ffffff\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"#ffffff\",\n darkText: \"#18181b\",\n darkBorder: \"#e4e4e7\",\n },\n surface,\n \"white-destructive\": {\n background: \"#ffffff\",\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkBackground: \"#ffffff\",\n darkText: \"#b91c1c\",\n darkBorder: \"#fecaca\",\n },\n \"surface-destructive\": {\n ...surface,\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef444466\",\n },\n };\n return filled[color];\n}\n\nconst badgeSizes = {\n xs: css`\n font-size: 11px;\n line-height: 16px;\n padding: 1px 6px;\n gap: 3px;\n `,\n sm: css`\n font-size: 12px;\n line-height: 18px;\n padding: 2px 8px;\n gap: 4px;\n `,\n md: css`\n font-size: 13px;\n line-height: 20px;\n padding: 3px 10px;\n gap: 5px;\n `,\n lg: css`\n font-size: 14px;\n line-height: 22px;\n padding: 4px 12px;\n gap: 6px;\n `,\n};\n\nconst badgeIconSizes: Record<BadgeSize, number> = {\n xs: 10,\n sm: 12,\n md: 14,\n lg: 16,\n};\n\nconst StyledBadge = styled.span<{\n theme: Theme;\n $color: BadgeColor;\n $size: BadgeSize;\n $shape: BadgeShape;\n $stroke: boolean;\n $solid: boolean;\n $mono: boolean;\n $disabled: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n vertical-align: middle;\n max-width: max-content;\n font-family: inherit;\n font-weight: 600;\n white-space: nowrap;\n\n & svg.lucide {\n flex-shrink: 0;\n color: inherit;\n }\n\n ${({ $size }) => badgeSizes[$size]}\n\n ${({ theme, $mono }) =>\n $mono &&\n css`\n font-family: ${theme.fonts.mono};\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n `}\n\n ${({ theme, $shape }) =>\n $shape === \"pill\"\n ? css`\n border-radius: 999px;\n `\n : css`\n border-radius: ${theme.spacing.radius.xs};\n `}\n\n ${({ theme, $color, $stroke, $solid }) => {\n const palette = badgePalette(theme, $color, $stroke, $solid);\n return css`\n background: ${palette.background};\n color: ${palette.text};\n border: solid 1px ${palette.border};\n\n :root.dark & {\n background: ${palette.darkBackground};\n color: ${palette.darkText};\n border-color: ${palette.darkBorder};\n }\n `;\n }}\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n opacity: 0.5;\n `}\n`;\n\ninterface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n children: React.ReactNode;\n color?: BadgeColor;\n size?: BadgeSize;\n shape?: BadgeShape;\n icon?: string;\n stroke?: boolean;\n solid?: boolean;\n mono?: boolean;\n disabled?: boolean;\n}\n\nfunction Badge({\n children,\n color = \"gray\",\n size = \"md\",\n shape = \"rounded\",\n icon,\n stroke = false,\n solid = false,\n mono = false,\n disabled = false,\n className,\n}: BadgeProps) {\n return (\n <StyledBadge\n className={className}\n $color={color}\n $size={size}\n $shape={shape}\n $stroke={stroke}\n $solid={solid}\n $mono={mono}\n $disabled={disabled}\n >\n {icon ? <Icon name={icon} size={badgeIconSizes[size]} /> : null}\n {children}\n </StyledBadge>\n );\n}\n\nexport { Badge, httpMethodBadgeColor };\n";
1
+ export declare const badgeTemplate = "\"use client\";\nimport styled, { css } from \"styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\ntype BadgeColor =\n | \"gray\"\n | \"blue\"\n | \"green\"\n | \"yellow\"\n | \"orange\"\n | \"red\"\n | \"purple\"\n | \"white\"\n | \"surface\"\n | \"white-destructive\"\n | \"surface-destructive\"\n | \"info\"\n | \"success\"\n | \"warning\"\n | \"error\";\n\ntype BadgeSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\ntype BadgeShape = \"rounded\" | \"pill\";\n\n// The semantic colors read theme tokens instead of the fixed palette, so\n// they follow theme.json and the light/dark toggle. They are also what the\n// HTTP method chips use.\nconst THEME_TOKEN_COLORS = [\"info\", \"success\", \"warning\", \"error\"] as const;\n\ntype ThemeTokenColor = (typeof THEME_TOKEN_COLORS)[number];\n\ntype HexBadgeColor = Exclude<BadgeColor, ThemeTokenColor>;\n\nfunction isThemeTokenColor(color: BadgeColor): color is ThemeTokenColor {\n return (THEME_TOKEN_COLORS as readonly string[]).includes(color);\n}\n\n// Single source for verb -> badge color, shared by the sidebar method tags\n// and the API playground so every surface colors HTTP verbs identically.\nconst HTTP_METHOD_COLORS: Record<string, BadgeColor> = {\n get: \"info\",\n post: \"success\",\n put: \"warning\",\n patch: \"warning\",\n delete: \"error\",\n head: \"gray\",\n options: \"gray\",\n trace: \"gray\",\n};\n\nfunction httpMethodBadgeColor(method: string): BadgeColor {\n return HTTP_METHOD_COLORS[method.toLowerCase()] ?? \"gray\";\n}\n\ninterface BadgePalette {\n background: string;\n text: string;\n border: string;\n darkBackground: string;\n darkText: string;\n darkBorder: string;\n}\n\n// Strong fills for the hex palette; the white and surface variants have no\n// distinct solid form and fall back to their filled palette.\nconst SOLID_ACCENTS: Partial<Record<HexBadgeColor, string>> = {\n gray: \"#71717a\",\n blue: \"#3b82f6\",\n green: \"#22c55e\",\n yellow: \"#eab308\",\n orange: \"#f97316\",\n red: \"#ef4444\",\n purple: \"#a855f7\",\n};\n\n// Color tints are label-semantic and intentionally independent of theme.json\n// (same rationale as Callout's alert tints); only the surface and semantic\n// token variants read theme tokens, so they follow the active theme on both\n// modes. When both are set, solid wins over stroke.\nfunction badgePalette(\n theme: Theme,\n color: BadgeColor,\n stroke: boolean,\n solid: boolean,\n): BadgePalette {\n if (isThemeTokenColor(color)) {\n const token = theme.colors[color];\n if (solid) {\n return {\n background: token,\n text: theme.colors.surface,\n border: \"transparent\",\n darkBackground: token,\n darkText: theme.colors.surface,\n darkBorder: \"transparent\",\n };\n }\n if (stroke) {\n return {\n background: \"transparent\",\n text: token,\n border: token,\n darkBackground: \"transparent\",\n darkText: token,\n darkBorder: token,\n };\n }\n const tint = `color-mix(in srgb, ${token} 15%, transparent)`;\n return {\n background: tint,\n text: token,\n border: \"transparent\",\n darkBackground: tint,\n darkText: token,\n darkBorder: \"transparent\",\n };\n }\n\n const solidAccent = SOLID_ACCENTS[color];\n if (solid && solidAccent) {\n return {\n background: solidAccent,\n text: \"#ffffff\",\n border: \"transparent\",\n darkBackground: solidAccent,\n darkText: \"#ffffff\",\n darkBorder: \"transparent\",\n };\n }\n\n // The \"surface\" variants sit on the page surface of the active theme: white\n // on light, black on dark. They read theme.colors.light (the html/body\n // background) rather than theme.colors.surface \u2014 that token is a foreground\n // color that stays white in both modes, so using it here left the chip white\n // on dark pages. The \"white\" variants below stay literally white by contract.\n const surface = {\n background: theme.colors.light,\n text: theme.colors.grayDark,\n border: theme.colors.grayLight,\n darkBackground: theme.colors.light,\n darkText: theme.colors.grayDark,\n darkBorder: theme.colors.gray,\n };\n\n if (stroke && !solid) {\n const strokes: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"transparent\",\n text: \"#52525b\",\n border: \"#a1a1aa\",\n darkBackground: \"transparent\",\n darkText: \"#d4d4d8\",\n darkBorder: \"#71717a\",\n },\n blue: {\n background: \"transparent\",\n text: \"#1d4ed8\",\n border: \"#3b82f6\",\n darkBackground: \"transparent\",\n darkText: \"#93c5fd\",\n darkBorder: \"#3b82f6\",\n },\n green: {\n background: \"transparent\",\n text: \"#15803d\",\n border: \"#22c55e\",\n darkBackground: \"transparent\",\n darkText: \"#86efac\",\n darkBorder: \"#22c55e\",\n },\n yellow: {\n background: \"transparent\",\n text: \"#a16207\",\n border: \"#eab308\",\n darkBackground: \"transparent\",\n darkText: \"#fde047\",\n darkBorder: \"#eab308\",\n },\n orange: {\n background: \"transparent\",\n text: \"#c2410c\",\n border: \"#f97316\",\n darkBackground: \"transparent\",\n darkText: \"#fdba74\",\n darkBorder: \"#f97316\",\n },\n red: {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n purple: {\n background: \"transparent\",\n text: \"#7e22ce\",\n border: \"#a855f7\",\n darkBackground: \"transparent\",\n darkText: \"#d8b4fe\",\n darkBorder: \"#a855f7\",\n },\n white: {\n background: \"transparent\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"transparent\",\n darkText: \"#fafafa\",\n darkBorder: \"#3f3f46\",\n },\n surface: {\n ...surface,\n background: \"transparent\",\n darkBackground: \"transparent\",\n },\n \"white-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n \"surface-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n };\n return strokes[color];\n }\n\n const filled: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"#f4f4f5\",\n text: \"#3f3f46\",\n border: \"transparent\",\n darkBackground: \"#71717a33\",\n darkText: \"#d4d4d8\",\n darkBorder: \"transparent\",\n },\n blue: {\n background: \"#dbeafe\",\n text: \"#1e40af\",\n border: \"transparent\",\n darkBackground: \"#3b82f633\",\n darkText: \"#93c5fd\",\n darkBorder: \"transparent\",\n },\n green: {\n background: \"#dcfce7\",\n text: \"#166534\",\n border: \"transparent\",\n darkBackground: \"#22c55e33\",\n darkText: \"#86efac\",\n darkBorder: \"transparent\",\n },\n yellow: {\n background: \"#fef9c3\",\n text: \"#854d0e\",\n border: \"transparent\",\n darkBackground: \"#eab30833\",\n darkText: \"#fde047\",\n darkBorder: \"transparent\",\n },\n orange: {\n background: \"#ffedd5\",\n text: \"#9a3412\",\n border: \"transparent\",\n darkBackground: \"#f9731633\",\n darkText: \"#fdba74\",\n darkBorder: \"transparent\",\n },\n red: {\n background: \"#fee2e2\",\n text: \"#991b1b\",\n border: \"transparent\",\n darkBackground: \"#ef444433\",\n darkText: \"#fca5a5\",\n darkBorder: \"transparent\",\n },\n purple: {\n background: \"#f3e8ff\",\n text: \"#6b21a8\",\n border: \"transparent\",\n darkBackground: \"#a855f733\",\n darkText: \"#d8b4fe\",\n darkBorder: \"transparent\",\n },\n // Literally white in both modes, so it stays legible on images, colored\n // frames, and hero areas. Use the surface variants for theme-aware chips.\n white: {\n background: \"#ffffff\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"#ffffff\",\n darkText: \"#18181b\",\n darkBorder: \"#e4e4e7\",\n },\n surface,\n \"white-destructive\": {\n background: \"#ffffff\",\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkBackground: \"#ffffff\",\n darkText: \"#b91c1c\",\n darkBorder: \"#fecaca\",\n },\n \"surface-destructive\": {\n ...surface,\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef444466\",\n },\n };\n return filled[color];\n}\n\nconst badgeSizes = {\n xs: css`\n font-size: 11px;\n line-height: 16px;\n padding: 1px 6px;\n gap: 3px;\n `,\n sm: css`\n font-size: 12px;\n line-height: 18px;\n padding: 2px 8px;\n gap: 4px;\n `,\n md: css`\n font-size: 13px;\n line-height: 20px;\n padding: 3px 10px;\n gap: 5px;\n `,\n lg: css`\n font-size: 14px;\n line-height: 22px;\n padding: 4px 12px;\n gap: 6px;\n `,\n};\n\nconst badgeIconSizes: Record<BadgeSize, number> = {\n xs: 10,\n sm: 12,\n md: 14,\n lg: 16,\n};\n\nconst StyledBadge = styled.span<{\n theme: Theme;\n $color: BadgeColor;\n $size: BadgeSize;\n $shape: BadgeShape;\n $stroke: boolean;\n $solid: boolean;\n $mono: boolean;\n $disabled: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n vertical-align: middle;\n max-width: max-content;\n font-family: inherit;\n font-weight: 600;\n white-space: nowrap;\n\n & svg.lucide {\n flex-shrink: 0;\n color: inherit;\n }\n\n ${({ $size }) => badgeSizes[$size]}\n\n ${({ theme, $mono }) =>\n $mono &&\n css`\n font-family: ${theme.fonts.mono};\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n `}\n\n ${({ theme, $shape }) =>\n $shape === \"pill\"\n ? css`\n border-radius: 999px;\n `\n : css`\n border-radius: ${theme.spacing.radius.xs};\n `}\n\n ${({ theme, $color, $stroke, $solid }) => {\n const palette = badgePalette(theme, $color, $stroke, $solid);\n return css`\n background: ${palette.background};\n color: ${palette.text};\n border: solid 1px ${palette.border};\n\n :root[data-theme=\"dark\"] & {\n background: ${palette.darkBackground};\n color: ${palette.darkText};\n border-color: ${palette.darkBorder};\n }\n `;\n }}\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n opacity: 0.5;\n `}\n`;\n\ninterface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n children: React.ReactNode;\n color?: BadgeColor;\n size?: BadgeSize;\n shape?: BadgeShape;\n icon?: string;\n stroke?: boolean;\n solid?: boolean;\n mono?: boolean;\n disabled?: boolean;\n}\n\nfunction Badge({\n children,\n color = \"gray\",\n size = \"md\",\n shape = \"rounded\",\n icon,\n stroke = false,\n solid = false,\n mono = false,\n disabled = false,\n className,\n}: BadgeProps) {\n return (\n <StyledBadge\n className={className}\n $color={color}\n $size={size}\n $shape={shape}\n $stroke={stroke}\n $solid={solid}\n $mono={mono}\n $disabled={disabled}\n >\n {icon ? <Icon name={icon} size={badgeIconSizes[size]} /> : null}\n {children}\n </StyledBadge>\n );\n}\n\nexport { Badge, httpMethodBadgeColor };\n";
@@ -406,7 +406,7 @@ const StyledBadge = styled.span<{
406
406
  color: \${palette.text};
407
407
  border: solid 1px \${palette.border};
408
408
 
409
- :root.dark & {
409
+ :root[data-theme="dark"] & {
410
410
  background: \${palette.darkBackground};
411
411
  color: \${palette.darkText};
412
412
  border-color: \${palette.darkBorder};
@@ -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 rel?: string;\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\n// Cherry's buttonStyles picks filled-button text via `isDark ? colors.dark : colors.light`.\n// Our theme's isDark is a stub (false) because mode switching lives in CSS vars, so\n// the fallback resolves to --color-light (black in dark mode). Re-pin to `surface`,\n// which resolves to white in both modes, for the filled, non-disabled case.\n// The \"button-link\" class opts this anchor out of the global a:focus-visible\n// ring (see GlobalStyles) so Cherry's buttonStyles owns the button's focus look.\nconst StyledLinkButton = styled(Link).attrs({\n className: \"button-link\",\n})<LinkButtonProps>`\n ${({ theme, $variant, $size, $outline, $fullWidth, $error, disabled }) =>\n buttonStyles(\n theme,\n $variant,\n $size,\n $outline,\n $fullWidth,\n $error,\n disabled,\n )}\n\n ${({ theme, $outline, disabled }) =>\n !disabled && !$outline && `color: ${theme.colors.surface};`}\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, $error, disabled }) =>\n buttonStyles(\n theme,\n $variant,\n $size,\n $outline,\n $fullWidth,\n $error,\n disabled,\n )}\n\n ${({ theme, $outline, disabled }) =>\n !disabled && !$outline && `color: ${theme.colors.surface};`}\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 target,\n rel,\n ...props\n}: LinkButtonProps) {\n const isExternal = typeof href === \"string\" && /^(https?:)?\\/\\//i.test(href);\n const resolvedTarget = target ?? (isExternal ? \"_blank\" : undefined);\n const resolvedRel =\n rel ?? (resolvedTarget === \"_blank\" ? \"noopener noreferrer\" : undefined);\n return href ? (\n <div>\n <StyledLinkButton\n {...props}\n href={href}\n target={resolvedTarget}\n rel={resolvedRel}\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 rel?: string;\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\n// Cherry's buttonStyles picks filled-button text from the theme object, which\n// this app keeps on the light mode for static rendering, so pin it to\n// `surface` instead: that token resolves through a CSS variable and is the\n// readable-on-brand color in both modes. Filled, non-disabled case only.\n// The \"button-link\" class opts this anchor out of the global a:focus-visible\n// ring (see GlobalStyles) so Cherry's buttonStyles owns the button's focus look.\nconst StyledLinkButton = styled(Link).attrs({\n className: \"button-link\",\n})<LinkButtonProps>`\n ${({ theme, $variant, $size, $outline, $fullWidth, $error, disabled }) =>\n buttonStyles(\n theme,\n $variant,\n $size,\n $outline,\n $fullWidth,\n $error,\n disabled,\n )}\n\n ${({ theme, $outline, disabled }) =>\n !disabled && !$outline && `color: ${theme.colors.surface};`}\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, $error, disabled }) =>\n buttonStyles(\n theme,\n $variant,\n $size,\n $outline,\n $fullWidth,\n $error,\n disabled,\n )}\n\n ${({ theme, $outline, disabled }) =>\n !disabled && !$outline && `color: ${theme.colors.surface};`}\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 target,\n rel,\n ...props\n}: LinkButtonProps) {\n const isExternal = typeof href === \"string\" && /^(https?:)?\\/\\//i.test(href);\n const resolvedTarget = target ?? (isExternal ? \"_blank\" : undefined);\n const resolvedRel =\n rel ?? (resolvedTarget === \"_blank\" ? \"noopener noreferrer\" : undefined);\n return href ? (\n <div>\n <StyledLinkButton\n {...props}\n href={href}\n target={resolvedTarget}\n rel={resolvedRel}\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";
@@ -21,10 +21,10 @@ interface LinkButtonProps extends ButtonProps {
21
21
  theme?: typeof localTheme;
22
22
  }
23
23
 
24
- // Cherry's buttonStyles picks filled-button text via \`isDark ? colors.dark : colors.light\`.
25
- // Our theme's isDark is a stub (false) because mode switching lives in CSS vars, so
26
- // the fallback resolves to --color-light (black in dark mode). Re-pin to \`surface\`,
27
- // which resolves to white in both modes, for the filled, non-disabled case.
24
+ // Cherry's buttonStyles picks filled-button text from the theme object, which
25
+ // this app keeps on the light mode for static rendering, so pin it to
26
+ // \`surface\` instead: that token resolves through a CSS variable and is the
27
+ // readable-on-brand color in both modes. Filled, non-disabled case only.
28
28
  // The "button-link" class opts this anchor out of the global a:focus-visible
29
29
  // ring (see GlobalStyles) so Cherry's buttonStyles owns the button's focus look.
30
30
  const StyledLinkButton = styled(Link).attrs({
@@ -1 +1 @@
1
- export declare const calloutTemplate = "\"use client\";\nimport { Theme } from \"@/app/theme\";\nimport { styledSmall } from \"cherry-styled-components\";\nimport styled, { css } from \"styled-components\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\n\ntype CalloutType = \"note\" | \"info\" | \"warning\" | \"danger\" | \"success\";\n\nconst StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>`\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n max-width: 100%;\n ${({ theme }) => styledSmall(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n display: flex;\n\n & svg {\n vertical-align: middle;\n min-width: min-content;\n margin: 3px 10px 0 0;\n }\n\n /* Callout tints are alert-semantic (info-blue, warning-amber, danger-red,\n etc.) and intentionally independent of theme.json. Light-mode values are\n defined by default; dark-mode overrides live in :root.dark & blocks so\n the swap happens via the active <html> class with no re-render. */\n ${({ $type }) =>\n $type === \"note\" &&\n css`\n border-color: #0ea5e933;\n background: #f0f9ff80;\n\n & svg.lucide,\n & p {\n color: #0c4a6e;\n }\n\n :root.dark & {\n border-color: #0ea5e94d;\n background: #0ea5e91a;\n\n & svg.lucide,\n & p {\n color: #bae6fd;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"info\" &&\n css`\n border-color: #71717a33;\n background: #fafafa80;\n\n & svg.lucide,\n & .lucide,\n & p {\n color: #18181b;\n }\n\n :root.dark & {\n border-color: #71717a4d;\n background: #71717a1a;\n\n & svg.lucide,\n & .lucide,\n & p {\n color: #e4e4e7;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"warning\" &&\n css`\n border-color: #f59e0b33;\n background: #fffbeb80;\n\n & svg.lucide,\n & p {\n color: #78350f;\n }\n\n :root.dark & {\n border-color: #f59e0b4d;\n background: #f59e0b1a;\n\n & svg.lucide,\n & p {\n color: #fde68a;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"danger\" &&\n css`\n border-color: #ef444433;\n background: #fef2f280;\n\n & svg.lucide,\n & p {\n color: #7f1d1d;\n }\n\n :root.dark & {\n border-color: #ef44444d;\n background: #ef44441a;\n\n & svg.lucide,\n & p {\n color: #fecaca;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"success\" &&\n css`\n border-color: #10b98133;\n background: #ecfdf580;\n\n & svg.lucide,\n & p {\n color: #064e3b;\n }\n\n :root.dark & {\n border-color: #10b9814d;\n background: #10b9811a;\n\n & svg.lucide,\n & p {\n color: #a7f3d0;\n }\n }\n `}\n`;\n\nconst StyledChildren = styled.span`\n display: flex;\n flex-direction: column;\n gap: 10px;\n`;\n\ninterface CalloutProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n icon?: IconProps;\n type?: CalloutType;\n}\n\nfunction Callout({ children, type, icon }: CalloutProps) {\n const iconType =\n type === \"note\"\n ? \"CircleAlert\"\n : type === \"info\"\n ? \"Info\"\n : type === \"warning\"\n ? \"TriangleAlert\"\n : type === \"danger\"\n ? \"OctagonAlert\"\n : type === \"success\"\n ? \"Check\"\n : (icon as IconProps);\n return (\n <StyledCallout $type={type}>\n {iconType ? <Icon name={iconType} size={16} /> : null}\n <StyledChildren>{children}</StyledChildren>\n </StyledCallout>\n );\n}\n\nexport { Callout };\n";
1
+ export declare const calloutTemplate = "\"use client\";\nimport { Theme } from \"@/app/theme\";\nimport { styledSmall } from \"cherry-styled-components\";\nimport styled, { css } from \"styled-components\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\n\ntype CalloutType = \"note\" | \"info\" | \"warning\" | \"danger\" | \"success\";\n\nconst StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>`\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n max-width: 100%;\n ${({ theme }) => styledSmall(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n display: flex;\n\n & svg {\n vertical-align: middle;\n min-width: min-content;\n margin: 3px 10px 0 0;\n }\n\n /* Callout tints are alert-semantic (info-blue, warning-amber, danger-red,\n etc.) and intentionally independent of theme.json. Light-mode values are\n defined by default; dark-mode overrides live in :root[data-theme=\"dark\"] & blocks so\n the swap happens via the active <html> class with no re-render. */\n ${({ $type }) =>\n $type === \"note\" &&\n css`\n border-color: #0ea5e933;\n background: #f0f9ff80;\n\n & svg.lucide,\n & p {\n color: #0c4a6e;\n }\n\n :root[data-theme=\"dark\"] & {\n border-color: #0ea5e94d;\n background: #0ea5e91a;\n\n & svg.lucide,\n & p {\n color: #bae6fd;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"info\" &&\n css`\n border-color: #71717a33;\n background: #fafafa80;\n\n & svg.lucide,\n & .lucide,\n & p {\n color: #18181b;\n }\n\n :root[data-theme=\"dark\"] & {\n border-color: #71717a4d;\n background: #71717a1a;\n\n & svg.lucide,\n & .lucide,\n & p {\n color: #e4e4e7;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"warning\" &&\n css`\n border-color: #f59e0b33;\n background: #fffbeb80;\n\n & svg.lucide,\n & p {\n color: #78350f;\n }\n\n :root[data-theme=\"dark\"] & {\n border-color: #f59e0b4d;\n background: #f59e0b1a;\n\n & svg.lucide,\n & p {\n color: #fde68a;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"danger\" &&\n css`\n border-color: #ef444433;\n background: #fef2f280;\n\n & svg.lucide,\n & p {\n color: #7f1d1d;\n }\n\n :root[data-theme=\"dark\"] & {\n border-color: #ef44444d;\n background: #ef44441a;\n\n & svg.lucide,\n & p {\n color: #fecaca;\n }\n }\n `}\n\n ${({ $type }) =>\n $type === \"success\" &&\n css`\n border-color: #10b98133;\n background: #ecfdf580;\n\n & svg.lucide,\n & p {\n color: #064e3b;\n }\n\n :root[data-theme=\"dark\"] & {\n border-color: #10b9814d;\n background: #10b9811a;\n\n & svg.lucide,\n & p {\n color: #a7f3d0;\n }\n }\n `}\n`;\n\nconst StyledChildren = styled.span`\n display: flex;\n flex-direction: column;\n gap: 10px;\n`;\n\ninterface CalloutProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n icon?: IconProps;\n type?: CalloutType;\n}\n\nfunction Callout({ children, type, icon }: CalloutProps) {\n const iconType =\n type === \"note\"\n ? \"CircleAlert\"\n : type === \"info\"\n ? \"Info\"\n : type === \"warning\"\n ? \"TriangleAlert\"\n : type === \"danger\"\n ? \"OctagonAlert\"\n : type === \"success\"\n ? \"Check\"\n : (icon as IconProps);\n return (\n <StyledCallout $type={type}>\n {iconType ? <Icon name={iconType} size={16} /> : null}\n <StyledChildren>{children}</StyledChildren>\n </StyledCallout>\n );\n}\n\nexport { Callout };\n";
@@ -25,7 +25,7 @@ const StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>\`
25
25
 
26
26
  /* Callout tints are alert-semantic (info-blue, warning-amber, danger-red,
27
27
  etc.) and intentionally independent of theme.json. Light-mode values are
28
- defined by default; dark-mode overrides live in :root.dark & blocks so
28
+ defined by default; dark-mode overrides live in :root[data-theme="dark"] & blocks so
29
29
  the swap happens via the active <html> class with no re-render. */
30
30
  \${({ $type }) =>
31
31
  $type === "note" &&
@@ -38,7 +38,7 @@ const StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>\`
38
38
  color: #0c4a6e;
39
39
  }
40
40
 
41
- :root.dark & {
41
+ :root[data-theme="dark"] & {
42
42
  border-color: #0ea5e94d;
43
43
  background: #0ea5e91a;
44
44
 
@@ -61,7 +61,7 @@ const StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>\`
61
61
  color: #18181b;
62
62
  }
63
63
 
64
- :root.dark & {
64
+ :root[data-theme="dark"] & {
65
65
  border-color: #71717a4d;
66
66
  background: #71717a1a;
67
67
 
@@ -84,7 +84,7 @@ const StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>\`
84
84
  color: #78350f;
85
85
  }
86
86
 
87
- :root.dark & {
87
+ :root[data-theme="dark"] & {
88
88
  border-color: #f59e0b4d;
89
89
  background: #f59e0b1a;
90
90
 
@@ -106,7 +106,7 @@ const StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>\`
106
106
  color: #7f1d1d;
107
107
  }
108
108
 
109
- :root.dark & {
109
+ :root[data-theme="dark"] & {
110
110
  border-color: #ef44444d;
111
111
  background: #ef44441a;
112
112
 
@@ -128,7 +128,7 @@ const StyledCallout = styled.div<{ theme: Theme; $type?: CalloutType }>\`
128
128
  color: #064e3b;
129
129
  }
130
130
 
131
- :root.dark & {
131
+ :root[data-theme="dark"] & {
132
132
  border-color: #10b9814d;
133
133
  background: #10b9811a;
134
134
 
@@ -1 +1 @@
1
- export declare const cardTemplate = "\"use client\";\nimport Link from \"next/link\";\nimport styled, { css, useTheme } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\nimport { interactiveStyles } from \"@/components/layout/SharedStyled\";\n\nconst cardStyles = css<{ theme: Theme }>`\n display: flex;\n flex-direction: column;\n gap: 12px;\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\nconst StyledCard = styled.div<{ theme: Theme }>`\n ${cardStyles}\n`;\n\nconst StyledCardLink = styled(Link)<{ theme: Theme }>`\n ${interactiveStyles};\n ${cardStyles}\n text-decoration: none;\n`;\n\nconst StyledCardTitle = styled.p<{ theme: Theme }>`\n font-weight: bold;\n margin: 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n`;\n\ninterface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n title?: string;\n icon?: IconProps;\n href?: string;\n}\n\nfunction Card({ children, title, icon, href }: CardProps) {\n const theme = useTheme() as Theme;\n\n const content = (\n <>\n {icon && <Icon name={icon} color={theme.colors.primary} />}\n {title && <StyledCardTitle>{title}</StyledCardTitle>}\n {children}\n </>\n );\n\n if (href) {\n const isExternal = /^(https?:)?\\/\\//i.test(href);\n return (\n <StyledCardLink\n href={href}\n target={isExternal ? \"_blank\" : undefined}\n rel={isExternal ? \"noopener noreferrer\" : undefined}\n >\n {content}\n </StyledCardLink>\n );\n }\n\n return <StyledCard>{content}</StyledCard>;\n}\n\nexport { Card };\n";
1
+ export declare const cardTemplate = "\"use client\";\nimport Link from \"next/link\";\nimport styled, { css } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\nimport { interactiveStyles } from \"@/components/layout/SharedStyled\";\n\nconst cardStyles = css<{ theme: Theme }>`\n display: flex;\n flex-direction: column;\n gap: 12px;\n background: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n margin: 0;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n\n /* Tints the optional leading icon. Set here rather than through lucide's\n color prop, because that becomes an SVG presentation attribute and CSS\n custom properties do not resolve in those. */\n & > svg.lucide {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nconst StyledCard = styled.div<{ theme: Theme }>`\n ${cardStyles}\n`;\n\nconst StyledCardLink = styled(Link)<{ theme: Theme }>`\n ${interactiveStyles};\n ${cardStyles}\n text-decoration: none;\n`;\n\nconst StyledCardTitle = styled.p<{ theme: Theme }>`\n font-weight: bold;\n margin: 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n`;\n\ninterface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n title?: string;\n icon?: IconProps;\n href?: string;\n}\n\nfunction Card({ children, title, icon, href }: CardProps) {\n const content = (\n <>\n {icon && <Icon name={icon} />}\n {title && <StyledCardTitle>{title}</StyledCardTitle>}\n {children}\n </>\n );\n\n if (href) {\n const isExternal = /^(https?:)?\\/\\//i.test(href);\n return (\n <StyledCardLink\n href={href}\n target={isExternal ? \"_blank\" : undefined}\n rel={isExternal ? \"noopener noreferrer\" : undefined}\n >\n {content}\n </StyledCardLink>\n );\n }\n\n return <StyledCard>{content}</StyledCard>;\n}\n\nexport { Card };\n";
@@ -1,6 +1,6 @@
1
1
  export const cardTemplate = `"use client";
2
2
  import Link from "next/link";
3
- import styled, { css, useTheme } from "styled-components";
3
+ import styled, { css } from "styled-components";
4
4
  import { styledText } from "cherry-styled-components";
5
5
  import { Theme } from "@/app/theme";
6
6
  import { Icon, IconProps } from "@/components/layout/Icon";
@@ -17,6 +17,13 @@ const cardStyles = css<{ theme: Theme }>\`
17
17
  margin: 0;
18
18
  \${({ theme }) => styledText(theme)}
19
19
  color: \${({ theme }) => theme.colors.grayDark};
20
+
21
+ /* Tints the optional leading icon. Set here rather than through lucide's
22
+ color prop, because that becomes an SVG presentation attribute and CSS
23
+ custom properties do not resolve in those. */
24
+ & > svg.lucide {
25
+ color: \${({ theme }) => theme.colors.primary};
26
+ }
20
27
  \`;
21
28
 
22
29
  const StyledCard = styled.div<{ theme: Theme }>\`
@@ -44,11 +51,9 @@ interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
44
51
  }
45
52
 
46
53
  function Card({ children, title, icon, href }: CardProps) {
47
- const theme = useTheme() as Theme;
48
-
49
54
  const content = (
50
55
  <>
51
- {icon && <Icon name={icon} color={theme.colors.primary} />}
56
+ {icon && <Icon name={icon} />}
52
57
  {title && <StyledCardTitle>{title}</StyledCardTitle>}
53
58
  {children}
54
59
  </>
@@ -1 +1 @@
1
- export declare const cherryThemeProviderTemplate = "import React from \"react\";\nimport { ClientThemeProvider } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { GlobalStyles } from \"@/components/layout/GlobalStyles\";\n\n/**\n * Wraps Cherry's ClientThemeProvider, which swaps theme/themeDark on toggle,\n * persists the choice to the `theme` cookie + localStorage, and keeps the\n * \"dark\" class on <html> in sync. Deliberately reads NO request data\n * (cookies/headers) so pages stay statically renderable \u2014 the blocking\n * theme-init script in the root layout sets the \"dark\" class before paint\n * and hides the body on dark visits; the provider reconciles against the\n * cookie on mount and removes the hiding style. $globalStyles is off because\n * this app ships its own GlobalStyles; $themeColor tracks \"light\", the\n * html/body background.\n */\nfunction CherryThemeProvider({\n children,\n theme,\n themeDark,\n}: {\n children: React.ReactNode;\n theme: Theme;\n themeDark: Theme;\n}) {\n return (\n <ClientThemeProvider\n theme={theme}\n themeDark={themeDark}\n $globalStyles={false}\n $themeColor=\"light\"\n >\n <GlobalStyles />\n {children}\n </ClientThemeProvider>\n );\n}\n\nexport { CherryThemeProvider };\n";
1
+ export declare const cherryThemeProviderTemplate = "\"use client\";\nimport React, { useEffect, useRef } from \"react\";\nimport { useTheme } from \"styled-components\";\nimport { ClientThemeProvider } from \"cherry-styled-components\";\nimport { colorsDark, colorsLight, Theme } from \"@/app/theme\";\nimport { GlobalStyles } from \"@/components/layout/GlobalStyles\";\n\n/**\n * Mirrors the active mode onto the data-theme attribute that every themed\n * selector keys off (see GlobalStyles), and keeps the theme-color meta tag in\n * step so browser chrome (the iOS Safari status bar) matches the page.\n *\n * The attribute is already correct before the first paint - the blocking script\n * in the root layout sets it from the theme cookie - and the provider's first\n * client render still carries the light theme the server rendered, so the first\n * pass leaves it alone and only later changes are written: the provider's own\n * reconciliation against the cookie, and user toggles. Writing on the first\n * pass would flip the whole page to light for a frame on every dark load.\n */\nfunction ThemeModeAttribute() {\n const activeTheme = useTheme() as Theme;\n const settled = useRef(false);\n\n useEffect(() => {\n const root = document.documentElement;\n\n if (settled.current) {\n root.dataset.theme = activeTheme.isDark ? \"dark\" : \"light\";\n } else {\n settled.current = true;\n }\n\n // A meta tag cannot resolve a custom property, and every color on the theme\n // object is a var() reference, so read the palette that GlobalStyles built\n // its variables from. `light` is the page background in both modes.\n let meta = document.querySelector<HTMLMetaElement>(\n 'meta[name=\"theme-color\"]',\n );\n if (!meta) {\n meta = document.createElement(\"meta\");\n meta.name = \"theme-color\";\n document.head.appendChild(meta);\n }\n meta.content =\n root.dataset.theme === \"dark\" ? colorsDark.light : colorsLight.light;\n }, [activeTheme.isDark]);\n\n return null;\n}\n\n/**\n * Wraps Cherry's ClientThemeProvider, which swaps theme/themeDark on toggle and\n * persists the choice to the `theme` cookie + localStorage. Deliberately reads\n * NO request data (cookies/headers) so pages stay statically renderable.\n *\n * The two theme objects hold the same CSS-variable colors and differ only in\n * `isDark`, so the visible mode is decided entirely by the data-theme\n * attribute on <html>, which ThemeModeAttribute keeps in step. The provider\n * also maintains a \"dark\" class of its own; nothing here depends on it, because\n * it is briefly out of step on mount while the provider reconciles the\n * server-rendered light theme against the cookie.\n *\n * $globalStyles is off because this app ships its own GlobalStyles, and\n * $themeColor is off because ThemeModeAttribute writes that meta tag itself\n * from resolved colors.\n */\nfunction CherryThemeProvider({\n children,\n theme,\n themeDark,\n}: {\n children: React.ReactNode;\n theme: Theme;\n themeDark: Theme;\n}) {\n return (\n <ClientThemeProvider\n theme={theme}\n themeDark={themeDark}\n $globalStyles={false}\n $themeColor={false}\n >\n <GlobalStyles />\n <ThemeModeAttribute />\n {children}\n </ClientThemeProvider>\n );\n}\n\nexport { CherryThemeProvider };\n";
@@ -1,18 +1,68 @@
1
- export const cherryThemeProviderTemplate = `import React from "react";
1
+ export const cherryThemeProviderTemplate = `"use client";
2
+ import React, { useEffect, useRef } from "react";
3
+ import { useTheme } from "styled-components";
2
4
  import { ClientThemeProvider } from "cherry-styled-components";
3
- import { Theme } from "@/app/theme";
5
+ import { colorsDark, colorsLight, Theme } from "@/app/theme";
4
6
  import { GlobalStyles } from "@/components/layout/GlobalStyles";
5
7
 
6
8
  /**
7
- * Wraps Cherry's ClientThemeProvider, which swaps theme/themeDark on toggle,
8
- * persists the choice to the \`theme\` cookie + localStorage, and keeps the
9
- * "dark" class on <html> in sync. Deliberately reads NO request data
10
- * (cookies/headers) so pages stay statically renderable — the blocking
11
- * theme-init script in the root layout sets the "dark" class before paint
12
- * and hides the body on dark visits; the provider reconciles against the
13
- * cookie on mount and removes the hiding style. $globalStyles is off because
14
- * this app ships its own GlobalStyles; $themeColor tracks "light", the
15
- * html/body background.
9
+ * Mirrors the active mode onto the data-theme attribute that every themed
10
+ * selector keys off (see GlobalStyles), and keeps the theme-color meta tag in
11
+ * step so browser chrome (the iOS Safari status bar) matches the page.
12
+ *
13
+ * The attribute is already correct before the first paint - the blocking script
14
+ * in the root layout sets it from the theme cookie - and the provider's first
15
+ * client render still carries the light theme the server rendered, so the first
16
+ * pass leaves it alone and only later changes are written: the provider's own
17
+ * reconciliation against the cookie, and user toggles. Writing on the first
18
+ * pass would flip the whole page to light for a frame on every dark load.
19
+ */
20
+ function ThemeModeAttribute() {
21
+ const activeTheme = useTheme() as Theme;
22
+ const settled = useRef(false);
23
+
24
+ useEffect(() => {
25
+ const root = document.documentElement;
26
+
27
+ if (settled.current) {
28
+ root.dataset.theme = activeTheme.isDark ? "dark" : "light";
29
+ } else {
30
+ settled.current = true;
31
+ }
32
+
33
+ // A meta tag cannot resolve a custom property, and every color on the theme
34
+ // object is a var() reference, so read the palette that GlobalStyles built
35
+ // its variables from. \`light\` is the page background in both modes.
36
+ let meta = document.querySelector<HTMLMetaElement>(
37
+ 'meta[name="theme-color"]',
38
+ );
39
+ if (!meta) {
40
+ meta = document.createElement("meta");
41
+ meta.name = "theme-color";
42
+ document.head.appendChild(meta);
43
+ }
44
+ meta.content =
45
+ root.dataset.theme === "dark" ? colorsDark.light : colorsLight.light;
46
+ }, [activeTheme.isDark]);
47
+
48
+ return null;
49
+ }
50
+
51
+ /**
52
+ * Wraps Cherry's ClientThemeProvider, which swaps theme/themeDark on toggle and
53
+ * persists the choice to the \`theme\` cookie + localStorage. Deliberately reads
54
+ * NO request data (cookies/headers) so pages stay statically renderable.
55
+ *
56
+ * The two theme objects hold the same CSS-variable colors and differ only in
57
+ * \`isDark\`, so the visible mode is decided entirely by the data-theme
58
+ * attribute on <html>, which ThemeModeAttribute keeps in step. The provider
59
+ * also maintains a "dark" class of its own; nothing here depends on it, because
60
+ * it is briefly out of step on mount while the provider reconciles the
61
+ * server-rendered light theme against the cookie.
62
+ *
63
+ * $globalStyles is off because this app ships its own GlobalStyles, and
64
+ * $themeColor is off because ThemeModeAttribute writes that meta tag itself
65
+ * from resolved colors.
16
66
  */
17
67
  function CherryThemeProvider({
18
68
  children,
@@ -28,9 +78,10 @@ function CherryThemeProvider({
28
78
  theme={theme}
29
79
  themeDark={themeDark}
30
80
  $globalStyles={false}
31
- $themeColor="light"
81
+ $themeColor={false}
32
82
  >
33
83
  <GlobalStyles />
84
+ <ThemeModeAttribute />
34
85
  {children}
35
86
  </ClientThemeProvider>
36
87
  );
@@ -1 +1 @@
1
- export declare const codeTemplate = "\"use client\";\nimport { useState, useCallback, useMemo, useId } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n interactiveStyles,\n resetButton,\n styledCode,\n} from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { unified } from \"unified\";\nimport rehypeParse from \"rehype-parse\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeStringify from \"rehype-stringify\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { thinScrollbar } from \"@/components/layout/SharedStyled\";\n\ninterface CodeProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n code: string;\n language?: string;\n title?: string;\n theme?: Theme;\n}\n\ninterface CodeTab {\n label: string;\n code: string;\n language?: string;\n}\n\ninterface CodeTabsProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n tabs: CodeTab[];\n theme?: Theme;\n}\n\nconst CodeWrapper = styled.span<{ theme: Theme }>`\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) => theme.colors.light};\n`;\n\n/* Code block uses a fixed GitHub-style palette for the syntax tokens in both\n modes so highlighting stays legible regardless of brand colors. The dark-mode\n surface, however, matches the left sidebar's translucent brand tint\n (color-mix of theme.colors.primaryLight over the black page) instead of\n GitHub's #0d1117, so the window sits on the same background as the nav. Dark\n variants live in :root.dark & blocks so the swap happens via the active\n <html> class with no re-render. */\nconst TopBar = styled.div<{ theme: Theme }>`\n position: relative;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n border-top-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-top-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n height: 33px;\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 5px;\n padding: 0 10px;\n`;\n\nconst DotsContainer = styled.div`\n display: flex;\n gap: 5px;\n`;\n\nconst Dot = styled.span<{ theme: Theme }>`\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.1);\n\n :root.dark & {\n background: rgba(255, 255, 255, 0.1);\n }\n`;\n\n/* Icon-only copy button. interactiveStyles supplies the border highlight on\n hover plus the focus/active rings (no scale effect). Colors come from theme\n tokens (grayLight border, success/grayDark icon) that swap for dark mode via\n the theme prop, so no :root.dark & override is needed and the copied state\n reads consistently in both modes. */\nconst CopyButton = styled.button<{ theme: Theme; $copied: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-right: -6px;\n\n & svg.lucide {\n margin: 0;\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayDark};\n }\n`;\n\n/* Centered file name in the TopBar. Sits absolutely over the flex row so the\n dots and copy button keep their edge alignment. Monospace + a muted grayDark\n token that swaps for dark mode via the theme prop. pointer-events off so\n clicks fall through to nothing and never steal focus from the buttons. */\nconst TopBarTitle = styled.span<{ theme: Theme }>`\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n max-width: 60%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 2;\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\n/* Segmented control living in the TopBar for CodeTabs. Scrolls horizontally\n with the thin scrollbar when the labels overflow the 33px bar. */\nconst TabList = styled.div<{ theme: Theme }>`\n display: flex;\n align-items: center;\n gap: 2px;\n min-width: 0;\n overflow-x: auto;\n ${thinScrollbar};\n padding: 2px;\n margin-left: -8px;\n`;\n\nconst CodeTab = styled.button<{ theme: Theme; $active: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n flex: 0 0 auto;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 1;\n padding: 5px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n cursor: pointer;\n white-space: nowrap;\n transition: all 0.3s ease;\n border: solid 1px\n ${({ theme, $active }) =>\n $active ? theme.colors.grayLight : \"transparent\"};\n background: ${({ theme, $active }) =>\n $active ? theme.colors.light : \"transparent\"};\n color: ${({ theme, $active }) =>\n $active ? theme.colors.dark : theme.colors.grayDark};\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n &:hover {\n color: ${({ theme }) => theme.colors.dark};\n background: ${({ theme, $active }) =>\n $active\n ? theme.colors.light\n : `color-mix(in srgb, ${theme.colors.dark} 4%, transparent)`};\n }\n\n &:focus {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:active {\n box-shadow: 0 0 0 1px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\n/* GitHub Light syntax highlighting by default; GitHub Dark in :root.dark.\n Browser resolves which rule wins based on the active <html> class with no\n JS or React re-render involved. */\nconst lightSyntaxHighlight = css`\n & .hljs {\n color: #24292f;\n background: #ffffff;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #cf222e;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #8250df;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #0550ae;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #0a3069;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #953800;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #6e7781;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #116329;\n }\n & .hljs-subst {\n color: #24292f;\n }\n & .hljs-section {\n color: #0550ae;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #953800;\n }\n & .hljs-emphasis {\n color: #24292f;\n font-style: italic;\n }\n & .hljs-strong {\n color: #24292f;\n font-weight: 700;\n }\n`;\n\nconst darkSyntaxHighlight = css`\n & .hljs {\n color: #c9d1d9;\n background: transparent;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #ff7b72;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #d2a8ff;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #79c0ff;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #a5d6ff;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #ffa657;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #8b949e;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #7ee787;\n }\n & .hljs-subst {\n color: #c9d1d9;\n }\n & .hljs-section {\n color: #1f6feb;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #f2cc60;\n }\n & .hljs-emphasis {\n color: #c9d1d9;\n font-style: italic;\n }\n & .hljs-strong {\n color: #c9d1d9;\n font-weight: 700;\n }\n`;\n\nconst Body = styled.div<{ theme: Theme }>`\n background: #ffffff;\n border-bottom-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n color: #24292f;\n padding: 20px 0;\n font-family: ${({ theme }) => theme.fonts.mono};\n text-align: left;\n overflow-x: auto;\n overflow-y: auto;\n max-height: calc(100dvh - 400px);\n ${thinScrollbar};\n ${({ theme }) => styledCode(theme)};\n ${lightSyntaxHighlight};\n\n /* The 20px side gutter sits on the <code> element instead of the Body so it\n scrolls with the content: the right gutter survives a scroll to the end of\n a long line, and diff rows can bleed back through it to the window edge. */\n & .hljs {\n display: block;\n width: 100%;\n min-width: min-content;\n padding: 0 20px;\n }\n\n /* Diff rows: highlight.js wraps each +/- line in its own span, so tinting it\n edge to edge reads like a GitHub diff. inline-table keeps the trailing\n newline as the line break instead of adding an empty row, and the negative\n margin pulls the row back through the gutter so the accent bar sits flush\n against the window edge. border-left + padding-left add up to the same\n 20px, keeping the code itself aligned with the untouched lines. The tints\n are the success/error tokens at low alpha, so a custom theme.json palette\n carries through and the syntax colors underneath stay legible. */\n & .hljs-addition,\n & .hljs-deletion {\n display: inline-table;\n width: calc(100% + 40px);\n margin: 0 -20px;\n padding: 0 20px 0 17px;\n border-left: solid 3px transparent;\n }\n\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.success};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.error};\n }\n\n :root.dark & {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n color: #ffffff;\n ${darkSyntaxHighlight};\n\n /* The tints sit on a near-black surface in dark mode, so they need a few\n more points of alpha to read at the same strength as in light. */\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 16%, transparent)`};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 16%, transparent)`};\n }\n }\n`;\n\nconst escapeHtml = (unsafe: string): string => {\n return unsafe\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n};\n\nconst sanitizeLanguage = (lang: string): string =>\n lang.replace(/[^a-zA-Z0-9_-]/g, \"\");\n\nconst highlightCode = (code: string, language: string): string => {\n const escapedCode = escapeHtml(code);\n const safeLang = sanitizeLanguage(language);\n const result = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeHighlight, {\n detect: true,\n ignoreMissing: true,\n })\n .use(rehypeStringify)\n .processSync(\n `<pre><code class=\"language-${safeLang}\">${escapedCode}</code></pre>`,\n );\n\n return String(result);\n};\n\nfunction Code({\n code,\n language = \"javascript\",\n title,\n theme,\n className,\n}: CodeProps) {\n const [copied, setCopied] = useState(false);\n const highlightedCode = useMemo(\n () => highlightCode(code, language),\n [code, language],\n );\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [code]);\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <DotsContainer>\n <Dot theme={theme} />\n <Dot theme={theme} />\n <Dot theme={theme} />\n </DotsContainer>\n {title ? <TopBarTitle theme={theme}>{title}</TopBarTitle> : null}\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\n/* Multi-variant code block (npm / pnpm / yarn, etc). Tabs replace the macOS\n dots in the TopBar as a keyboard-accessible tablist; the copy button copies\n whichever tab is active and resets its copied state when the tab changes. */\nfunction CodeTabs({ tabs, theme, className }: CodeTabsProps) {\n const baseId = useId();\n const [active, setActive] = useState(0);\n const [copied, setCopied] = useState(false);\n\n const safeActive = active < tabs.length ? active : 0;\n const activeTab = tabs[safeActive];\n\n const highlightedCode = useMemo(\n () =>\n activeTab\n ? highlightCode(activeTab.code, activeTab.language ?? \"bash\")\n : \"\",\n [activeTab],\n );\n\n const handleSelect = useCallback((index: number) => {\n setActive(index);\n setCopied(false);\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (!activeTab) return;\n try {\n await navigator.clipboard.writeText(activeTab.code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [activeTab]);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n let next = safeActive;\n if (event.key === \"ArrowRight\" || event.key === \"ArrowDown\") {\n next = (safeActive + 1) % tabs.length;\n } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowUp\") {\n next = (safeActive - 1 + tabs.length) % tabs.length;\n } else if (event.key === \"Home\") {\n next = 0;\n } else if (event.key === \"End\") {\n next = tabs.length - 1;\n } else {\n return;\n }\n event.preventDefault();\n handleSelect(next);\n const target = document.getElementById(`${baseId}-tab-${next}`);\n if (target) target.focus();\n },\n [baseId, handleSelect, safeActive, tabs.length],\n );\n\n if (!tabs || tabs.length === 0) return null;\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <TabList role=\"tablist\" aria-label=\"Code variants\">\n {tabs.map((tab, index) => (\n <CodeTab\n key={`${tab.label}-${index}`}\n type=\"button\"\n role=\"tab\"\n id={`${baseId}-tab-${index}`}\n aria-selected={index === safeActive}\n aria-controls={`${baseId}-panel`}\n tabIndex={index === safeActive ? 0 : -1}\n onClick={() => handleSelect(index)}\n onKeyDown={handleKeyDown}\n $active={index === safeActive}\n theme={theme}\n >\n {tab.label}\n </CodeTab>\n ))}\n </TabList>\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n id={`${baseId}-panel`}\n role=\"tabpanel\"\n aria-labelledby={`${baseId}-tab-${safeActive}`}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\nexport { Code, CodeTabs };\n";
1
+ export declare const codeTemplate = "\"use client\";\nimport { useState, useCallback, useMemo, useId } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n interactiveStyles,\n resetButton,\n styledCode,\n} from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { unified } from \"unified\";\nimport rehypeParse from \"rehype-parse\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeStringify from \"rehype-stringify\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { thinScrollbar } from \"@/components/layout/SharedStyled\";\n\ninterface CodeProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n code: string;\n language?: string;\n title?: string;\n theme?: Theme;\n}\n\ninterface CodeTab {\n label: string;\n code: string;\n language?: string;\n}\n\ninterface CodeTabsProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"theme\"\n> {\n tabs: CodeTab[];\n theme?: Theme;\n}\n\nconst CodeWrapper = styled.span<{ theme: Theme }>`\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) => theme.colors.light};\n`;\n\n/* Code block uses a fixed GitHub-style palette for the syntax tokens in both\n modes so highlighting stays legible regardless of brand colors. The dark-mode\n surface, however, matches the left sidebar's translucent brand tint\n (color-mix of theme.colors.primaryLight over the black page) instead of\n GitHub's #0d1117, so the window sits on the same background as the nav. Dark\n variants live in :root[data-theme=\"dark\"] & blocks so the swap happens via the active\n <html> class with no re-render. */\nconst TopBar = styled.div<{ theme: Theme }>`\n position: relative;\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n border-top-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-top-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom: solid 1px ${({ theme }) => theme.colors.grayLight};\n height: 33px;\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 5px;\n padding: 0 10px;\n`;\n\nconst DotsContainer = styled.div`\n display: flex;\n gap: 5px;\n`;\n\nconst Dot = styled.span<{ theme: Theme }>`\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.1);\n\n :root[data-theme=\"dark\"] & {\n background: rgba(255, 255, 255, 0.1);\n }\n`;\n\n/* Icon-only copy button. interactiveStyles supplies the border highlight on\n hover plus the focus/active rings (no scale effect). Colors come from theme\n tokens (grayLight border, success/grayDark icon) that swap for dark mode via\n the theme prop, so no :root[data-theme=\"dark\"] & override is needed and the copied state\n reads consistently in both modes. */\nconst CopyButton = styled.button<{ theme: Theme; $copied: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-right: -6px;\n\n & svg.lucide {\n margin: 0;\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayDark};\n }\n`;\n\n/* Centered file name in the TopBar. Sits absolutely over the flex row so the\n dots and copy button keep their edge alignment. Monospace + a muted grayDark\n token that swaps for dark mode via the theme prop. pointer-events off so\n clicks fall through to nothing and never steal focus from the buttons. */\nconst TopBarTitle = styled.span<{ theme: Theme }>`\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n max-width: 60%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n pointer-events: none;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 2;\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\n/* Segmented control living in the TopBar for CodeTabs. Scrolls horizontally\n with the thin scrollbar when the labels overflow the 33px bar. */\nconst TabList = styled.div<{ theme: Theme }>`\n display: flex;\n align-items: center;\n gap: 2px;\n min-width: 0;\n overflow-x: auto;\n ${thinScrollbar};\n padding: 2px;\n margin-left: -8px;\n`;\n\nconst CodeTab = styled.button<{ theme: Theme; $active: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n flex: 0 0 auto;\n font-family: ${({ theme }) => theme.fonts.mono};\n font-size: 12px;\n line-height: 1;\n padding: 5px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n cursor: pointer;\n white-space: nowrap;\n transition: all 0.3s ease;\n border: solid 1px\n ${({ theme, $active }) =>\n $active ? theme.colors.grayLight : \"transparent\"};\n background: ${({ theme, $active }) =>\n $active ? theme.colors.light : \"transparent\"};\n color: ${({ theme, $active }) =>\n $active ? theme.colors.dark : theme.colors.grayDark};\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n &:hover {\n color: ${({ theme }) => theme.colors.dark};\n background: ${({ theme, $active }) =>\n $active\n ? theme.colors.light\n : `color-mix(in srgb, ${theme.colors.dark} 4%, transparent)`};\n }\n\n &:focus {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:active {\n box-shadow: 0 0 0 1px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\n/* GitHub Light syntax highlighting by default; GitHub Dark in :root[data-theme=\"dark\"].\n Browser resolves which rule wins based on the active <html> class with no\n JS or React re-render involved. */\nconst lightSyntaxHighlight = css`\n & .hljs {\n color: #24292f;\n background: #ffffff;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #cf222e;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #8250df;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #0550ae;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #0a3069;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #953800;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #6e7781;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #116329;\n }\n & .hljs-subst {\n color: #24292f;\n }\n & .hljs-section {\n color: #0550ae;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #953800;\n }\n & .hljs-emphasis {\n color: #24292f;\n font-style: italic;\n }\n & .hljs-strong {\n color: #24292f;\n font-weight: 700;\n }\n`;\n\nconst darkSyntaxHighlight = css`\n & .hljs {\n color: #c9d1d9;\n background: transparent;\n }\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #ff7b72;\n }\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #d2a8ff;\n }\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #79c0ff;\n }\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #a5d6ff;\n }\n & .hljs-built_in,\n & .hljs-symbol {\n color: #ffa657;\n }\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #8b949e;\n }\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #7ee787;\n }\n & .hljs-subst {\n color: #c9d1d9;\n }\n & .hljs-section {\n color: #1f6feb;\n font-weight: 700;\n }\n & .hljs-bullet {\n color: #f2cc60;\n }\n & .hljs-emphasis {\n color: #c9d1d9;\n font-style: italic;\n }\n & .hljs-strong {\n color: #c9d1d9;\n font-weight: 700;\n }\n`;\n\nconst Body = styled.div<{ theme: Theme }>`\n background: #ffffff;\n border-bottom-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n color: #24292f;\n padding: 20px 0;\n font-family: ${({ theme }) => theme.fonts.mono};\n text-align: left;\n overflow-x: auto;\n overflow-y: auto;\n max-height: calc(100dvh - 400px);\n ${thinScrollbar};\n ${({ theme }) => styledCode(theme)};\n ${lightSyntaxHighlight};\n\n /* The 20px side gutter sits on the <code> element instead of the Body so it\n scrolls with the content: the right gutter survives a scroll to the end of\n a long line, and diff rows can bleed back through it to the window edge. */\n & .hljs {\n display: block;\n width: 100%;\n min-width: min-content;\n padding: 0 20px;\n }\n\n /* Diff rows: highlight.js wraps each +/- line in its own span, so tinting it\n edge to edge reads like a GitHub diff. inline-table keeps the trailing\n newline as the line break instead of adding an empty row, and the negative\n margin pulls the row back through the gutter so the accent bar sits flush\n against the window edge. border-left + padding-left add up to the same\n 20px, keeping the code itself aligned with the untouched lines. The tints\n are the success/error tokens at low alpha, so a custom theme.json palette\n carries through and the syntax colors underneath stay legible. */\n & .hljs-addition,\n & .hljs-deletion {\n display: inline-table;\n width: calc(100% + 40px);\n margin: 0 -20px;\n padding: 0 20px 0 17px;\n border-left: solid 3px transparent;\n }\n\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.success};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 12%, transparent)`};\n border-left-color: ${({ theme }) => theme.colors.error};\n }\n\n :root[data-theme=\"dark\"] & {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n color: #ffffff;\n ${darkSyntaxHighlight};\n\n /* The tints sit on a near-black surface in dark mode, so they need a few\n more points of alpha to read at the same strength as in light. */\n & .hljs-addition {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.success} 16%, transparent)`};\n }\n\n & .hljs-deletion {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.error} 16%, transparent)`};\n }\n }\n`;\n\nconst escapeHtml = (unsafe: string): string => {\n return unsafe\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n};\n\nconst sanitizeLanguage = (lang: string): string =>\n lang.replace(/[^a-zA-Z0-9_-]/g, \"\");\n\nconst highlightCode = (code: string, language: string): string => {\n const escapedCode = escapeHtml(code);\n const safeLang = sanitizeLanguage(language);\n const result = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeHighlight, {\n detect: true,\n ignoreMissing: true,\n })\n .use(rehypeStringify)\n .processSync(\n `<pre><code class=\"language-${safeLang}\">${escapedCode}</code></pre>`,\n );\n\n return String(result);\n};\n\nfunction Code({\n code,\n language = \"javascript\",\n title,\n theme,\n className,\n}: CodeProps) {\n const [copied, setCopied] = useState(false);\n const highlightedCode = useMemo(\n () => highlightCode(code, language),\n [code, language],\n );\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [code]);\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <DotsContainer>\n <Dot theme={theme} />\n <Dot theme={theme} />\n <Dot theme={theme} />\n </DotsContainer>\n {title ? <TopBarTitle theme={theme}>{title}</TopBarTitle> : null}\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\n/* Multi-variant code block (npm / pnpm / yarn, etc). Tabs replace the macOS\n dots in the TopBar as a keyboard-accessible tablist; the copy button copies\n whichever tab is active and resets its copied state when the tab changes. */\nfunction CodeTabs({ tabs, theme, className }: CodeTabsProps) {\n const baseId = useId();\n const [active, setActive] = useState(0);\n const [copied, setCopied] = useState(false);\n\n const safeActive = active < tabs.length ? active : 0;\n const activeTab = tabs[safeActive];\n\n const highlightedCode = useMemo(\n () =>\n activeTab\n ? highlightCode(activeTab.code, activeTab.language ?? \"bash\")\n : \"\",\n [activeTab],\n );\n\n const handleSelect = useCallback((index: number) => {\n setActive(index);\n setCopied(false);\n }, []);\n\n const handleCopy = useCallback(async () => {\n if (!activeTab) return;\n try {\n await navigator.clipboard.writeText(activeTab.code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy code:\", err);\n }\n }, [activeTab]);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n let next = safeActive;\n if (event.key === \"ArrowRight\" || event.key === \"ArrowDown\") {\n next = (safeActive + 1) % tabs.length;\n } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowUp\") {\n next = (safeActive - 1 + tabs.length) % tabs.length;\n } else if (event.key === \"Home\") {\n next = 0;\n } else if (event.key === \"End\") {\n next = tabs.length - 1;\n } else {\n return;\n }\n event.preventDefault();\n handleSelect(next);\n const target = document.getElementById(`${baseId}-tab-${next}`);\n if (target) target.focus();\n },\n [baseId, handleSelect, safeActive, tabs.length],\n );\n\n if (!tabs || tabs.length === 0) return null;\n\n return (\n <CodeWrapper\n className={`${className ?? \"\"} code-wrapper`.trim()}\n theme={theme}\n >\n <TopBar theme={theme}>\n <TabList role=\"tablist\" aria-label=\"Code variants\">\n {tabs.map((tab, index) => (\n <CodeTab\n key={`${tab.label}-${index}`}\n type=\"button\"\n role=\"tab\"\n id={`${baseId}-tab-${index}`}\n aria-selected={index === safeActive}\n aria-controls={`${baseId}-panel`}\n tabIndex={index === safeActive ? 0 : -1}\n onClick={() => handleSelect(index)}\n onKeyDown={handleKeyDown}\n $active={index === safeActive}\n theme={theme}\n >\n {tab.label}\n </CodeTab>\n ))}\n </TabList>\n <CopyButton\n onClick={handleCopy}\n $copied={copied}\n theme={theme}\n aria-label={copied ? \"Copied\" : \"Copy code\"}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={12} />\n </CopyButton>\n </TopBar>\n <Body\n id={`${baseId}-panel`}\n role=\"tabpanel\"\n aria-labelledby={`${baseId}-tab-${safeActive}`}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n theme={theme}\n className=\"code-wrapper-body\"\n />\n </CodeWrapper>\n );\n}\n\nexport { Code, CodeTabs };\n";
@@ -53,7 +53,7 @@ const CodeWrapper = styled.span<{ theme: Theme }>\`
53
53
  surface, however, matches the left sidebar's translucent brand tint
54
54
  (color-mix of theme.colors.primaryLight over the black page) instead of
55
55
  GitHub's #0d1117, so the window sits on the same background as the nav. Dark
56
- variants live in :root.dark & blocks so the swap happens via the active
56
+ variants live in :root[data-theme="dark"] & blocks so the swap happens via the active
57
57
  <html> class with no re-render. */
58
58
  const TopBar = styled.div<{ theme: Theme }>\`
59
59
  position: relative;
@@ -82,7 +82,7 @@ const Dot = styled.span<{ theme: Theme }>\`
82
82
  border-radius: 50%;
83
83
  background: rgba(0, 0, 0, 0.1);
84
84
 
85
- :root.dark & {
85
+ :root[data-theme="dark"] & {
86
86
  background: rgba(255, 255, 255, 0.1);
87
87
  }
88
88
  \`;
@@ -90,7 +90,7 @@ const Dot = styled.span<{ theme: Theme }>\`
90
90
  /* Icon-only copy button. interactiveStyles supplies the border highlight on
91
91
  hover plus the focus/active rings (no scale effect). Colors come from theme
92
92
  tokens (grayLight border, success/grayDark icon) that swap for dark mode via
93
- the theme prop, so no :root.dark & override is needed and the copied state
93
+ the theme prop, so no :root[data-theme="dark"] & override is needed and the copied state
94
94
  reads consistently in both modes. */
95
95
  const CopyButton = styled.button<{ theme: Theme; $copied: boolean }>\`
96
96
  \${resetButton}
@@ -182,7 +182,7 @@ const CodeTab = styled.button<{ theme: Theme; $active: boolean }>\`
182
182
  }
183
183
  \`;
184
184
 
185
- /* GitHub Light syntax highlighting by default; GitHub Dark in :root.dark.
185
+ /* GitHub Light syntax highlighting by default; GitHub Dark in :root[data-theme="dark"].
186
186
  Browser resolves which rule wins based on the active <html> class with no
187
187
  JS or React re-render involved. */
188
188
  const lightSyntaxHighlight = css\`
@@ -383,7 +383,7 @@ const Body = styled.div<{ theme: Theme }>\`
383
383
  border-left-color: \${({ theme }) => theme.colors.error};
384
384
  }
385
385
 
386
- :root.dark & {
386
+ :root[data-theme="dark"] & {
387
387
  background: \${({ theme }) =>
388
388
  \`color-mix(in srgb, \${theme.colors.primaryLight} 5%, transparent)\`};
389
389
  color: #ffffff;
@@ -1 +1 @@
1
- export declare const copyButtonTemplate = "\"use client\";\nimport { useCallback, useState } from \"react\";\nimport styled from \"styled-components\";\nimport { resetButton, interactiveStyles } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\n/* Icon-only copy-to-clipboard button. Same look/behaviour as the copy button in\n the code block: interactiveStyles supplies the border highlight on hover plus\n the focus/active rings, and the icon swaps to a check in success green for two\n seconds after a successful copy. Theme tokens swap for dark mode on their own,\n so no :root.dark override is needed. */\nconst StyledCopyButton = styled.button<{ theme: Theme; $copied: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n & svg.lucide {\n margin: 0;\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayDark};\n }\n`;\n\ninterface CopyButtonProps {\n text: string;\n size?: number;\n label?: string;\n className?: string;\n}\n\nexport function CopyButton({\n text,\n size = 12,\n label = \"Copy\",\n className,\n}: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(text);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy:\", err);\n }\n }, [text]);\n\n return (\n <StyledCopyButton\n type=\"button\"\n onClick={handleCopy}\n $copied={copied}\n aria-label={copied ? \"Copied\" : label}\n className={className}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={size} />\n </StyledCopyButton>\n );\n}\n";
1
+ export declare const copyButtonTemplate = "\"use client\";\nimport { useCallback, useState } from \"react\";\nimport styled from \"styled-components\";\nimport { resetButton, interactiveStyles } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\n/* Icon-only copy-to-clipboard button. Same look/behaviour as the copy button in\n the code block: interactiveStyles supplies the border highlight on hover plus\n the focus/active rings, and the icon swaps to a check in success green for two\n seconds after a successful copy. Theme tokens swap for dark mode on their own,\n so no :root[data-theme=\"dark\"] override is needed. */\nconst StyledCopyButton = styled.button<{ theme: Theme; $copied: boolean }>`\n ${resetButton}\n ${interactiveStyles}\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n & svg.lucide {\n margin: 0;\n color: ${({ theme, $copied }) =>\n $copied ? theme.colors.success : theme.colors.grayDark};\n }\n`;\n\ninterface CopyButtonProps {\n text: string;\n size?: number;\n label?: string;\n className?: string;\n}\n\nexport function CopyButton({\n text,\n size = 12,\n label = \"Copy\",\n className,\n}: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n\n const handleCopy = useCallback(async () => {\n try {\n await navigator.clipboard.writeText(text);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error(\"Failed to copy:\", err);\n }\n }, [text]);\n\n return (\n <StyledCopyButton\n type=\"button\"\n onClick={handleCopy}\n $copied={copied}\n aria-label={copied ? \"Copied\" : label}\n className={className}\n >\n <Icon name={copied ? \"check\" : \"copy\"} size={size} />\n </StyledCopyButton>\n );\n}\n";
@@ -9,7 +9,7 @@ import { Icon } from "@/components/layout/Icon";
9
9
  the code block: interactiveStyles supplies the border highlight on hover plus
10
10
  the focus/active rings, and the icon swaps to a check in success green for two
11
11
  seconds after a successful copy. Theme tokens swap for dark mode on their own,
12
- so no :root.dark override is needed. */
12
+ so no :root[data-theme="dark"] override is needed. */
13
13
  const StyledCopyButton = styled.button<{ theme: Theme; $copied: boolean }>\`
14
14
  \${resetButton}
15
15
  \${interactiveStyles}