doccupine 0.0.1-1

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 (62) hide show
  1. package/README.md +65 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +532 -0
  4. package/dist/templates/click-outside.d.ts +1 -0
  5. package/dist/templates/click-outside.js +28 -0
  6. package/dist/templates/code.d.ts +1 -0
  7. package/dist/templates/code.js +192 -0
  8. package/dist/templates/components/ClickOutside.d.ts +1 -0
  9. package/dist/templates/components/ClickOutside.js +27 -0
  10. package/dist/templates/components/Docs.d.ts +1 -0
  11. package/dist/templates/components/Docs.js +52 -0
  12. package/dist/templates/components/SideBar.d.ts +1 -0
  13. package/dist/templates/components/SideBar.js +80 -0
  14. package/dist/templates/components/layout/Code.d.ts +1 -0
  15. package/dist/templates/components/layout/Code.js +192 -0
  16. package/dist/templates/components/layout/DocsComponents.d.ts +1 -0
  17. package/dist/templates/components/layout/DocsComponents.js +444 -0
  18. package/dist/templates/components/layout/Footer.d.ts +1 -0
  19. package/dist/templates/components/layout/Footer.js +8 -0
  20. package/dist/templates/components/layout/Header.d.ts +1 -0
  21. package/dist/templates/components/layout/Header.js +280 -0
  22. package/dist/templates/components/layout/Icon.d.ts +1 -0
  23. package/dist/templates/components/layout/Icon.js +19 -0
  24. package/dist/templates/components/layout/Pictograms.d.ts +1 -0
  25. package/dist/templates/components/layout/Pictograms.js +66 -0
  26. package/dist/templates/components/layout/SharedStyles.d.ts +1 -0
  27. package/dist/templates/components/layout/SharedStyles.js +791 -0
  28. package/dist/templates/components/layout/ThemeToggle.d.ts +1 -0
  29. package/dist/templates/components/layout/ThemeToggle.js +123 -0
  30. package/dist/templates/components/layout/Typography.d.ts +1 -0
  31. package/dist/templates/components/layout/Typography.js +51 -0
  32. package/dist/templates/docs-components.d.ts +1 -0
  33. package/dist/templates/docs-components.js +441 -0
  34. package/dist/templates/docs.d.ts +1 -0
  35. package/dist/templates/docs.js +48 -0
  36. package/dist/templates/footer.d.ts +1 -0
  37. package/dist/templates/footer.js +9 -0
  38. package/dist/templates/gitignore.d.ts +1 -0
  39. package/dist/templates/gitignore.js +41 -0
  40. package/dist/templates/header.d.ts +1 -0
  41. package/dist/templates/header.js +275 -0
  42. package/dist/templates/home.d.ts +1 -0
  43. package/dist/templates/home.js +79 -0
  44. package/dist/templates/icon.d.ts +1 -0
  45. package/dist/templates/icon.js +20 -0
  46. package/dist/templates/layout.d.ts +1 -0
  47. package/dist/templates/layout.js +66 -0
  48. package/dist/templates/not-found.d.ts +1 -0
  49. package/dist/templates/not-found.js +22 -0
  50. package/dist/templates/pictograms.d.ts +1 -0
  51. package/dist/templates/pictograms.js +67 -0
  52. package/dist/templates/shared-styles.d.ts +1 -0
  53. package/dist/templates/shared-styles.js +792 -0
  54. package/dist/templates/theme-toggle.d.ts +1 -0
  55. package/dist/templates/theme-toggle.js +111 -0
  56. package/dist/templates/theme.d.ts +1 -0
  57. package/dist/templates/theme.js +291 -0
  58. package/dist/templates/typography.d.ts +1 -0
  59. package/dist/templates/typography.js +52 -0
  60. package/dist/templates/utils/orderNavItems.d.ts +1 -0
  61. package/dist/templates/utils/orderNavItems.js +45 -0
  62. package/package.json +44 -0
@@ -0,0 +1,192 @@
1
+ export const codeTemplate = `"use client";
2
+ "use client";
3
+ import styled from "styled-components";
4
+ import { Theme, styledCode } from "cherry-styled-components/src/lib";
5
+ import { rgba } from "polished";
6
+ import { unified } from "unified";
7
+ import rehypeParse from "rehype-parse";
8
+ import rehypeHighlight from "rehype-highlight";
9
+ import rehypeStringify from "rehype-stringify";
10
+ import { editableContent } from "@/app/components/layout/SharedStyled";
11
+
12
+ interface CodeProps extends React.HTMLAttributes<HTMLDivElement> {
13
+ code: string;
14
+ language?: string;
15
+ theme?: Theme;
16
+ }
17
+
18
+ const CodeWrapper = styled.span<{ theme: Theme }>\`
19
+ position: relative;
20
+ z-index: 2;
21
+ display: block;
22
+ width: 100%;
23
+ border-radius: \${({ theme }) => theme.spacing.radius.lg};
24
+ border: solid 1px
25
+ \${({ theme }) =>
26
+ theme.isDark ? rgba(theme.colors.dark, 0.2) : rgba(theme.colors.dark, 0)};
27
+ \`;
28
+
29
+ const TopBar = styled.div<{ theme: Theme }>\`
30
+ background: #0d1117;
31
+ border-top-left-radius: \${({ theme }) => theme.spacing.radius.lg};
32
+ border-top-right-radius: \${({ theme }) => theme.spacing.radius.lg};
33
+ border-bottom: solid 1px \${rgba("#ffffff", 0.1)};
34
+ height: 33px;
35
+ width: 100%;
36
+ display: flex;
37
+ justify-content: flex-start;
38
+ gap: 5px;
39
+ padding: 10px;
40
+ \`;
41
+
42
+ const Dot = styled.span<{ theme: Theme }>\`
43
+ margin: auto 0;
44
+ width: 10px;
45
+ height: 10px;
46
+ border-radius: 50%;
47
+ background: \${rgba("#ffffff", 0.1)};
48
+ \`;
49
+
50
+ const Body = styled.div<{ theme: Theme }>\`
51
+ background: #0d1117;
52
+ border-bottom-left-radius: \${({ theme }) => theme.spacing.radius.lg};
53
+ border-bottom-right-radius: \${({ theme }) => theme.spacing.radius.lg};
54
+ color: #ffffff;
55
+ padding: 20px;
56
+ font-family: \${({ theme }) => theme.fonts.mono};
57
+ text-align: left;
58
+ overflow-x: auto;
59
+ overflow-y: auto;
60
+ max-height: calc(100svh - 400px);
61
+ \${({ theme }) => styledCode(theme)};
62
+
63
+ &[contenteditable="true"] {
64
+ \${editableContent};
65
+ border-top-left-radius: 0;
66
+ border-top-right-radius: 0;
67
+ }
68
+
69
+ & .hljs {
70
+ color: #c9d1d9;
71
+ background: #0d1117;
72
+ }
73
+
74
+ & .hljs-doctag,
75
+ & .hljs-keyword,
76
+ & .hljs-meta .hljs-keyword,
77
+ & .hljs-template-tag,
78
+ & .hljs-template-variable,
79
+ & .hljs-type,
80
+ & .hljs-variable.language_ {
81
+ color: #ff7b72;
82
+ }
83
+
84
+ & .hljs-title,
85
+ & .hljs-title.class_,
86
+ & .hljs-title.class_.inherited__,
87
+ & .hljs-title.function_ {
88
+ color: #d2a8ff;
89
+ }
90
+
91
+ & .hljs-attr,
92
+ & .hljs-attribute,
93
+ & .hljs-literal,
94
+ & .hljs-meta,
95
+ & .hljs-number,
96
+ & .hljs-operator,
97
+ & .hljs-selector-attr,
98
+ & .hljs-selector-class,
99
+ & .hljs-selector-id,
100
+ & .hljs-variable {
101
+ color: #79c0ff;
102
+ }
103
+
104
+ & .hljs-meta .hljs-string,
105
+ & .hljs-regexp,
106
+ & .hljs-string {
107
+ color: #a5d6ff;
108
+ }
109
+
110
+ & .hljs-built_in,
111
+ & .hljs-symbol {
112
+ color: #ffa657;
113
+ }
114
+
115
+ & .hljs-code,
116
+ & .hljs-comment,
117
+ & .hljs-formula {
118
+ color: #8b949e;
119
+ }
120
+
121
+ & .hljs-name,
122
+ & .hljs-quote,
123
+ & .hljs-selector-pseudo,
124
+ & .hljs-selector-tag {
125
+ color: #7ee787;
126
+ }
127
+
128
+ & .hljs-subst {
129
+ color: #c9d1d9;
130
+ }
131
+
132
+ & .hljs-section {
133
+ color: #1f6feb;
134
+ font-weight: 700;
135
+ }
136
+
137
+ & .hljs-bullet {
138
+ color: #f2cc60;
139
+ }
140
+
141
+ & .hljs-emphasis {
142
+ color: #c9d1d9;
143
+ font-style: italic;
144
+ }
145
+
146
+ & .hljs-strong {
147
+ color: #c9d1d9;
148
+ font-weight: 700;
149
+ }
150
+
151
+ & .hljs-addition {
152
+ color: #aff5b4;
153
+ background-color: #033a16;
154
+ }
155
+
156
+ & .hljs-deletion {
157
+ color: #ffdcd7;
158
+ background-color: #67060c;
159
+ }
160
+ \`;
161
+
162
+ const highlightCode = (code: string, language: string): string => {
163
+ const result = unified()
164
+ .use(rehypeParse, { fragment: true })
165
+ .use(rehypeHighlight, {
166
+ detect: true,
167
+ ignoreMissing: true,
168
+ })
169
+ .use(rehypeStringify)
170
+ .processSync(
171
+ \`<pre><code class="language-\${language}">\${code}</code></pre>\`,
172
+ );
173
+
174
+ return String(result);
175
+ };
176
+
177
+ function Code({ code, language = "javascript", ...props }: CodeProps) {
178
+ const highlightedCode = highlightCode(code, language);
179
+ return (
180
+ <CodeWrapper>
181
+ <TopBar>
182
+ <Dot />
183
+ <Dot />
184
+ <Dot />
185
+ </TopBar>
186
+ <Body dangerouslySetInnerHTML={{ __html: highlightedCode }} {...props} />
187
+ </CodeWrapper>
188
+ );
189
+ }
190
+
191
+ export { Code };
192
+ `;
@@ -0,0 +1 @@
1
+ export declare const clickOutsideTemplate = "import { RefObject, useEffect } from \"react\";\n\nexport function useOnClickOutside(\n refs: RefObject<HTMLElement | null>[],\n cb: () => void,\n) {\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (\n refs &&\n refs\n .map(\n (ref) =>\n ref && ref.current && ref.current.contains(event.target as Node),\n )\n .every((i) => i === false)\n ) {\n cb();\n }\n }\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [refs, cb]);\n}\n";
@@ -0,0 +1,27 @@
1
+ export const clickOutsideTemplate = `import { RefObject, useEffect } from "react";
2
+
3
+ export function useOnClickOutside(
4
+ refs: RefObject<HTMLElement | null>[],
5
+ cb: () => void,
6
+ ) {
7
+ useEffect(() => {
8
+ function handleClickOutside(event: MouseEvent) {
9
+ if (
10
+ refs &&
11
+ refs
12
+ .map(
13
+ (ref) =>
14
+ ref && ref.current && ref.current.contains(event.target as Node),
15
+ )
16
+ .every((i) => i === false)
17
+ ) {
18
+ cb();
19
+ }
20
+ }
21
+ document.addEventListener("mousedown", handleClickOutside);
22
+ return () => {
23
+ document.removeEventListener("mousedown", handleClickOutside);
24
+ };
25
+ }, [refs, cb]);
26
+ }
27
+ `;
@@ -0,0 +1 @@
1
+ export declare const docsTemplate = "\"use client\";\nimport { Flex } from \"cherry-styled-components/src/lib\";\nimport Markdown from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport { Code } from \"@/components/layout/Code\";\nimport { \n DocsContainer,\n StyledMarkdownContainer,\n} from \"@/components/layout/DocsComponents\";\n\ninterface DocsProps {\n content: string;\n}\n \nfunction Docs({ content }: DocsProps) {\n return (\n <DocsContainer>\n <Flex $gap={20}>\n <StyledMarkdownContainer>\n {content && (\n <Markdown\n remarkPlugins={[remarkGfm]}\n components={{\n code(props) {\n const { children, className, node, ...rest } = props;\n const match = /language-(\\w+)/.exec(className || \"\");\n return match ? (\n <Code\n {...rest}\n className={className}\n code={String(children).replace(/\\n$/, \"\")}\n language={match[1]}\n />\n ) : (\n <code {...rest} className={className}>\n {children}\n </code>\n );\n },\n }}\n >\n {content}\n </Markdown>\n )}\n </StyledMarkdownContainer>\n </Flex>\n </DocsContainer>\n );\n}\n\nexport { Docs };\n";
@@ -0,0 +1,52 @@
1
+ export const docsTemplate = `"use client";
2
+ import { Flex } from "cherry-styled-components/src/lib";
3
+ import Markdown from "react-markdown";
4
+ import remarkGfm from "remark-gfm";
5
+ import { Code } from "@/components/layout/Code";
6
+ import {
7
+ DocsContainer,
8
+ StyledMarkdownContainer,
9
+ } from "@/components/layout/DocsComponents";
10
+
11
+ interface DocsProps {
12
+ content: string;
13
+ }
14
+
15
+ function Docs({ content }: DocsProps) {
16
+ return (
17
+ <DocsContainer>
18
+ <Flex $gap={20}>
19
+ <StyledMarkdownContainer>
20
+ {content && (
21
+ <Markdown
22
+ remarkPlugins={[remarkGfm]}
23
+ components={{
24
+ code(props) {
25
+ const { children, className, node, ...rest } = props;
26
+ const match = /language-(\\w+)/.exec(className || "");
27
+ return match ? (
28
+ <Code
29
+ {...rest}
30
+ className={className}
31
+ code={String(children).replace(/\\n\$/, "")}
32
+ language={match[1]}
33
+ />
34
+ ) : (
35
+ <code {...rest} className={className}>
36
+ {children}
37
+ </code>
38
+ );
39
+ },
40
+ }}
41
+ >
42
+ {content}
43
+ </Markdown>
44
+ )}
45
+ </StyledMarkdownContainer>
46
+ </Flex>
47
+ </DocsContainer>
48
+ );
49
+ }
50
+
51
+ export { Docs };
52
+ `;
@@ -0,0 +1 @@
1
+ export declare const sideBarTemplate = "\"use client\";\nimport { useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { Space } from \"cherry-styled-components/src/lib\";\nimport { \n DocsSidebar,\n StyledSidebar,\n StyledSidebarList,\n StyledSidebarListItem,\n StyledStrong,\n StyledSidebarListItemLink,\n StyleMobileBar,\n StyledMobileBurger\n} from \"@/components/layout/DocsComponents\";\n\ntype NavItem = {\n label: string;\n links: NavItemLink[];\n};\n\ntype NavItemLink = {\n slug: string;\n title: string;\n};\n\ninterface SideBarProps {\n result: NavItem[];\n}\n\nfunction SideBar({ result }: SideBarProps) {\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n const pathname = usePathname();\n\n return (\n <DocsSidebar>\n <StyleMobileBar\n onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}\n $isActive={isMobileMenuOpen}\n >\n <StyledMobileBurger $isActive={isMobileMenuOpen} />\n </StyleMobileBar>\n\n <StyledSidebar $isActive={isMobileMenuOpen}>\n {result && result.map((item: any, index: number) => {\n return (\n <StyledSidebarList key={index}>\n <StyledSidebarListItem>\n <StyledStrong>{item.label}</StyledStrong>{\" \"}\n </StyledSidebarListItem>\n <li>\n <Space $size={20} />\n </li>\n {item.links &&\n item.links.map((link: any, indexChild: number) => {\n return (\n <StyledSidebarListItem key={indexChild}>\n <StyledSidebarListItemLink\n href={`/${link.slug}`}\n $isActive={\n pathname ===\n `/${link.slug}`\n }\n onClick={() => setIsMobileMenuOpen(false)}\n >\n {link.title}\n </StyledSidebarListItemLink>\n </StyledSidebarListItem>\n );\n })}\n <Space $size={20} />\n </StyledSidebarList>\n );\n })}\n </StyledSidebar>\n </DocsSidebar>\n );\n}\n\nexport { SideBar };\n";
@@ -0,0 +1,80 @@
1
+ export const sideBarTemplate = `"use client";
2
+ import { useState } from "react";
3
+ import { usePathname } from "next/navigation";
4
+ import { Space } from "cherry-styled-components/src/lib";
5
+ import {
6
+ DocsSidebar,
7
+ StyledSidebar,
8
+ StyledSidebarList,
9
+ StyledSidebarListItem,
10
+ StyledStrong,
11
+ StyledSidebarListItemLink,
12
+ StyleMobileBar,
13
+ StyledMobileBurger
14
+ } from "@/components/layout/DocsComponents";
15
+
16
+ type NavItem = {
17
+ label: string;
18
+ links: NavItemLink[];
19
+ };
20
+
21
+ type NavItemLink = {
22
+ slug: string;
23
+ title: string;
24
+ };
25
+
26
+ interface SideBarProps {
27
+ result: NavItem[];
28
+ }
29
+
30
+ function SideBar({ result }: SideBarProps) {
31
+ const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
32
+ const pathname = usePathname();
33
+
34
+ return (
35
+ <DocsSidebar>
36
+ <StyleMobileBar
37
+ onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
38
+ $isActive={isMobileMenuOpen}
39
+ >
40
+ <StyledMobileBurger $isActive={isMobileMenuOpen} />
41
+ </StyleMobileBar>
42
+
43
+ <StyledSidebar $isActive={isMobileMenuOpen}>
44
+ {result && result.map((item: any, index: number) => {
45
+ return (
46
+ <StyledSidebarList key={index}>
47
+ <StyledSidebarListItem>
48
+ <StyledStrong>{item.label}</StyledStrong>{" "}
49
+ </StyledSidebarListItem>
50
+ <li>
51
+ <Space $size={20} />
52
+ </li>
53
+ {item.links &&
54
+ item.links.map((link: any, indexChild: number) => {
55
+ return (
56
+ <StyledSidebarListItem key={indexChild}>
57
+ <StyledSidebarListItemLink
58
+ href={\`/\${link.slug}\`}
59
+ $isActive={
60
+ pathname ===
61
+ \`/\${link.slug}\`
62
+ }
63
+ onClick={() => setIsMobileMenuOpen(false)}
64
+ >
65
+ {link.title}
66
+ </StyledSidebarListItemLink>
67
+ </StyledSidebarListItem>
68
+ );
69
+ })}
70
+ <Space $size={20} />
71
+ </StyledSidebarList>
72
+ );
73
+ })}
74
+ </StyledSidebar>
75
+ </DocsSidebar>
76
+ );
77
+ }
78
+
79
+ export { SideBar };
80
+ `;
@@ -0,0 +1 @@
1
+ export declare const codeTemplate = "\"use client\";\n\"use client\";\nimport styled from \"styled-components\";\nimport { Theme, styledCode } from \"cherry-styled-components/src/lib\";\nimport { rgba } from \"polished\";\nimport { unified } from \"unified\";\nimport rehypeParse from \"rehype-parse\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeStringify from \"rehype-stringify\";\nimport { editableContent } from \"@/components/layout/SharedStyled\";\n\ninterface CodeProps extends React.HTMLAttributes<HTMLDivElement> {\n code: string;\n language?: string;\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\n ${({ theme }) =>\n theme.isDark ? rgba(theme.colors.dark, 0.2) : rgba(theme.colors.dark, 0)};\n`;\n\nconst TopBar = styled.div<{ theme: Theme }>`\n background: #0d1117;\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 ${rgba(\"#ffffff\", 0.1)};\n height: 33px;\n width: 100%;\n display: flex;\n justify-content: flex-start;\n gap: 5px;\n padding: 10px;\n`;\n\nconst Dot = styled.span<{ theme: Theme }>`\n margin: auto 0;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: ${rgba(\"#ffffff\", 0.1)};\n`;\n\nconst Body = styled.div<{ theme: Theme }>`\n background: #0d1117;\n border-bottom-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n color: #ffffff;\n padding: 20px;\n font-family: ${({ theme }) => theme.fonts.mono};\n text-align: left;\n overflow-x: auto;\n overflow-y: auto;\n max-height: calc(100svh - 400px);\n ${({ theme }) => styledCode(theme)};\n\n &[contenteditable=\"true\"] {\n ${editableContent};\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n\n & .hljs {\n color: #c9d1d9;\n background: #0d1117;\n }\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\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #d2a8ff;\n }\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\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #a5d6ff;\n }\n\n & .hljs-built_in,\n & .hljs-symbol {\n color: #ffa657;\n }\n\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #8b949e;\n }\n\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #7ee787;\n }\n\n & .hljs-subst {\n color: #c9d1d9;\n }\n\n & .hljs-section {\n color: #1f6feb;\n font-weight: 700;\n }\n\n & .hljs-bullet {\n color: #f2cc60;\n }\n\n & .hljs-emphasis {\n color: #c9d1d9;\n font-style: italic;\n }\n\n & .hljs-strong {\n color: #c9d1d9;\n font-weight: 700;\n }\n\n & .hljs-addition {\n color: #aff5b4;\n background-color: #033a16;\n }\n\n & .hljs-deletion {\n color: #ffdcd7;\n background-color: #67060c;\n }\n`;\n\nconst highlightCode = (code: string, language: string): string => {\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-${language}\">${code}</code></pre>`,\n );\n\n return String(result);\n};\n\nfunction Code({ code, language = \"javascript\", ...props }: CodeProps) {\n const highlightedCode = highlightCode(code, language);\n return (\n <CodeWrapper>\n <TopBar>\n <Dot />\n <Dot />\n <Dot />\n </TopBar>\n <Body dangerouslySetInnerHTML={{ __html: highlightedCode }} {...props} />\n </CodeWrapper>\n );\n}\n\nexport { Code };\n";
@@ -0,0 +1,192 @@
1
+ export const codeTemplate = `"use client";
2
+ "use client";
3
+ import styled from "styled-components";
4
+ import { Theme, styledCode } from "cherry-styled-components/src/lib";
5
+ import { rgba } from "polished";
6
+ import { unified } from "unified";
7
+ import rehypeParse from "rehype-parse";
8
+ import rehypeHighlight from "rehype-highlight";
9
+ import rehypeStringify from "rehype-stringify";
10
+ import { editableContent } from "@/components/layout/SharedStyled";
11
+
12
+ interface CodeProps extends React.HTMLAttributes<HTMLDivElement> {
13
+ code: string;
14
+ language?: string;
15
+ theme?: Theme;
16
+ }
17
+
18
+ const CodeWrapper = styled.span<{ theme: Theme }>\`
19
+ position: relative;
20
+ z-index: 2;
21
+ display: block;
22
+ width: 100%;
23
+ border-radius: \${({ theme }) => theme.spacing.radius.lg};
24
+ border: solid 1px
25
+ \${({ theme }) =>
26
+ theme.isDark ? rgba(theme.colors.dark, 0.2) : rgba(theme.colors.dark, 0)};
27
+ \`;
28
+
29
+ const TopBar = styled.div<{ theme: Theme }>\`
30
+ background: #0d1117;
31
+ border-top-left-radius: \${({ theme }) => theme.spacing.radius.lg};
32
+ border-top-right-radius: \${({ theme }) => theme.spacing.radius.lg};
33
+ border-bottom: solid 1px \${rgba("#ffffff", 0.1)};
34
+ height: 33px;
35
+ width: 100%;
36
+ display: flex;
37
+ justify-content: flex-start;
38
+ gap: 5px;
39
+ padding: 10px;
40
+ \`;
41
+
42
+ const Dot = styled.span<{ theme: Theme }>\`
43
+ margin: auto 0;
44
+ width: 10px;
45
+ height: 10px;
46
+ border-radius: 50%;
47
+ background: \${rgba("#ffffff", 0.1)};
48
+ \`;
49
+
50
+ const Body = styled.div<{ theme: Theme }>\`
51
+ background: #0d1117;
52
+ border-bottom-left-radius: \${({ theme }) => theme.spacing.radius.lg};
53
+ border-bottom-right-radius: \${({ theme }) => theme.spacing.radius.lg};
54
+ color: #ffffff;
55
+ padding: 20px;
56
+ font-family: \${({ theme }) => theme.fonts.mono};
57
+ text-align: left;
58
+ overflow-x: auto;
59
+ overflow-y: auto;
60
+ max-height: calc(100svh - 400px);
61
+ \${({ theme }) => styledCode(theme)};
62
+
63
+ &[contenteditable="true"] {
64
+ \${editableContent};
65
+ border-top-left-radius: 0;
66
+ border-top-right-radius: 0;
67
+ }
68
+
69
+ & .hljs {
70
+ color: #c9d1d9;
71
+ background: #0d1117;
72
+ }
73
+
74
+ & .hljs-doctag,
75
+ & .hljs-keyword,
76
+ & .hljs-meta .hljs-keyword,
77
+ & .hljs-template-tag,
78
+ & .hljs-template-variable,
79
+ & .hljs-type,
80
+ & .hljs-variable.language_ {
81
+ color: #ff7b72;
82
+ }
83
+
84
+ & .hljs-title,
85
+ & .hljs-title.class_,
86
+ & .hljs-title.class_.inherited__,
87
+ & .hljs-title.function_ {
88
+ color: #d2a8ff;
89
+ }
90
+
91
+ & .hljs-attr,
92
+ & .hljs-attribute,
93
+ & .hljs-literal,
94
+ & .hljs-meta,
95
+ & .hljs-number,
96
+ & .hljs-operator,
97
+ & .hljs-selector-attr,
98
+ & .hljs-selector-class,
99
+ & .hljs-selector-id,
100
+ & .hljs-variable {
101
+ color: #79c0ff;
102
+ }
103
+
104
+ & .hljs-meta .hljs-string,
105
+ & .hljs-regexp,
106
+ & .hljs-string {
107
+ color: #a5d6ff;
108
+ }
109
+
110
+ & .hljs-built_in,
111
+ & .hljs-symbol {
112
+ color: #ffa657;
113
+ }
114
+
115
+ & .hljs-code,
116
+ & .hljs-comment,
117
+ & .hljs-formula {
118
+ color: #8b949e;
119
+ }
120
+
121
+ & .hljs-name,
122
+ & .hljs-quote,
123
+ & .hljs-selector-pseudo,
124
+ & .hljs-selector-tag {
125
+ color: #7ee787;
126
+ }
127
+
128
+ & .hljs-subst {
129
+ color: #c9d1d9;
130
+ }
131
+
132
+ & .hljs-section {
133
+ color: #1f6feb;
134
+ font-weight: 700;
135
+ }
136
+
137
+ & .hljs-bullet {
138
+ color: #f2cc60;
139
+ }
140
+
141
+ & .hljs-emphasis {
142
+ color: #c9d1d9;
143
+ font-style: italic;
144
+ }
145
+
146
+ & .hljs-strong {
147
+ color: #c9d1d9;
148
+ font-weight: 700;
149
+ }
150
+
151
+ & .hljs-addition {
152
+ color: #aff5b4;
153
+ background-color: #033a16;
154
+ }
155
+
156
+ & .hljs-deletion {
157
+ color: #ffdcd7;
158
+ background-color: #67060c;
159
+ }
160
+ \`;
161
+
162
+ const highlightCode = (code: string, language: string): string => {
163
+ const result = unified()
164
+ .use(rehypeParse, { fragment: true })
165
+ .use(rehypeHighlight, {
166
+ detect: true,
167
+ ignoreMissing: true,
168
+ })
169
+ .use(rehypeStringify)
170
+ .processSync(
171
+ \`<pre><code class="language-\${language}">\${code}</code></pre>\`,
172
+ );
173
+
174
+ return String(result);
175
+ };
176
+
177
+ function Code({ code, language = "javascript", ...props }: CodeProps) {
178
+ const highlightedCode = highlightCode(code, language);
179
+ return (
180
+ <CodeWrapper>
181
+ <TopBar>
182
+ <Dot />
183
+ <Dot />
184
+ <Dot />
185
+ </TopBar>
186
+ <Body dangerouslySetInnerHTML={{ __html: highlightedCode }} {...props} />
187
+ </CodeWrapper>
188
+ );
189
+ }
190
+
191
+ export { Code };
192
+ `;
@@ -0,0 +1 @@
1
+ export declare const docsComponentsTemplate = "\"use client\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n resetButton,\n styledStrong,\n styledText,\n} from \"cherry-styled-components/src/lib\";\nimport Link from \"next/link\";\nimport { rgba } from \"polished\";\nimport React from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { interactiveStyles } from \"./SharedStyled\";\n\ninterface DocsProps {\n children: React.ReactNode;\n}\n\nconst StyledDocsWrapper = styled.div<{ theme: Theme }>`\n position: relative;\n`;\n\nconst StyledDocsSidebar = styled.div<{ theme: Theme }>`\n position: sticky;\n top: 90px;\n min-width: 200px;\n float: left;\n z-index: 999;\n\n ${mq(\"lg\")} {\n z-index: 2;\n }\n`;\n\nconst StyledDocsContainer = styled.div<{ theme: Theme }>`\n position: relative;\n padding: 0;\n width: 100%;\n\n & pre {\n max-width: 100%;\n }\n\n ${mq(\"lg\")} {\n padding-left: 230px;\n }\n\n & ul {\n list-style: none;\n padding: 0;\n margin: 0;\n\n & li {\n text-indent: 0;\n display: block;\n position: relative;\n padding: 0 0 0 15px;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n min-height: 23px;\n\n $mq: \"lg\" {\n min-height: 27px;\n }\n\n &::before {\n content: \"\";\n display: block;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n position: absolute;\n top: 8px;\n left: 2px;\n\n ${mq(\"lg\")} {\n top: 10px;\n }\n }\n }\n }\n\n & ol {\n padding: 0;\n margin: 0;\n\n & > li {\n position: relative;\n padding: 0;\n counter-increment: item;\n padding: 0;\n margin: 0;\n ${({ theme }) => styledText(theme)};\n\n &::before {\n content: counter(item) \".\";\n display: inline-block;\n margin: 0 4px 0 0;\n font-weight: 700;\n color: ${({ theme }) => theme.colors.primary};\n min-width: max-content;\n }\n }\n }\n`;\n\nexport const StyledMarkdownContainer = styled.div`\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex-wrap: wrap;\n flex: 1;\n`;\n\ninterface Props {\n theme?: Theme;\n $isActive?: boolean;\n}\n\nexport const StyledSidebar = styled.nav<Props>`\n position: fixed;\n overflow-y: auto;\n max-height: calc(100svh - 70px);\n width: 100%;\n background: ${({ theme }) => theme.colors.light};\n z-index: 99;\n top: 70px;\n height: 100%;\n padding: 20px;\n opacity: 0;\n pointer-events: none;\n transition: all 0.3s ease;\n transform: translateY(30px);\n left: 0;\n\n ${mq(\"lg\")} {\n width: 220px;\n left: 20px;\n background: transparent;\n padding: 20px 20px 20px 0;\n opacity: 1;\n pointer-events: all;\n transform: translateY(0);\n }\n\n ${mq(\"xl\")} {\n width: 220px;\n left: calc(50% - 610px);\n }\n\n ${mq(\"xxl\")} {\n width: 220px;\n left: calc(50% - 690px);\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n transform: translateY(0);\n opacity: 1;\n pointer-events: all;\n `}\n`;\n\nexport const StyledSidebarList = styled.ul`\n list-style: none;\n margin: 0;\n padding: 0;\n`;\n\nexport const StyledStrong = styled.strong<{ theme: Theme }>`\n font-weight: 600;\n ${({ theme }) => styledStrong(theme)};\n`;\n\nexport const StyledSidebarListItem = styled.li`\n display: flex;\n gap: 10px;\n clear: both;\n`;\n\nexport const StyledSidebarListItemLink = styled(Link)<Props>`\n text-decoration: none;\n font-size: ${({ theme }) => theme.fontSizes.strong.xs};\n line-height: 1.6;\n color: ${({ theme }) =>\n theme.isDark ? theme.colors.grayDark : theme.colors.primary};\n padding: 5px 0 5px 20px;\n display: flex;\n transition: all 0.3s ease;\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n\n ${mq(\"lg\")} {\n font-size: ${({ theme }) => theme.fontSizes.strong.lg};\n }\n\n @media (hover: hover) {\n &:hover {\n color: ${({ theme }) =>\n theme.isDark ? theme.colors.primaryLight : theme.colors.primaryDark};\n border-color: ${({ theme }) => theme.colors.info};\n }\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n `\n\t\t\tcolor: ${theme.colors.dark};\n\t\t\tborder-color: ${theme.colors.info};\n\t\t\tfont-weight: 600;\n\t`};\n`;\n\nexport const StyleMobileBar = styled.button<Props>`\n ${resetButton};\n position: fixed;\n z-index: 1000;\n bottom: 0;\n right: 20px;\n font-size: ${({ theme }) => theme.fontSizes.strong.lg};\n line-height: ${({ theme }) => theme.fontSizes.strong.lg};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n background: ${({ theme }) =>\n theme.isDark\n ? rgba(theme.colors.grayLight, 0.7)\n : rgba(theme.colors.light, 0.7)};\n color: ${({ theme }) =>\n theme.isDark ? theme.colors.dark : theme.colors.primary};\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n padding: 30px;\n border-radius: 100px;\n margin: 0 0 20px 0;\n font-weight: 600;\n display: flex;\n justify-content: flex-start;\n width: auto;\n\n ${mq(\"lg\")} {\n display: none;\n }\n\n ${({ $isActive }) => $isActive && `position: fixed; `};\n`;\n\nexport const StyledMobileBurger = styled.span<Props>`\n display: block;\n margin: auto 0;\n width: 18px;\n height: 18px;\n position: relative;\n overflow: hidden;\n background: transparent;\n position: relative;\n\n &::before,\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n width: 18px;\n height: 3px;\n border-radius: 3px;\n background: ${({ theme }) =>\n theme.isDark ? theme.colors.dark : theme.colors.primary};\n transition: all 0.3s ease;\n }\n\n &::before {\n top: 3px;\n }\n\n &::after {\n bottom: 3px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n &::before {\n transform: translateY(5px) rotate(45deg);\n }\n\n &::after {\n transform: translateY(-4px) rotate(-45deg);\n }\n `};\n`;\n\nexport const StyledInlineButton = styled.button<{ theme: Theme }>`\n ${resetButton};\n ${interactiveStyles};\n color: ${({ theme }) => theme.colors.primary};\n vertical-align: middle;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n padding: 0;\n width: 18px;\n height: 18px;\n display: flex;\n margin: auto 0;\n transition: all 0.3s ease;\n\n @media (hover: hover) {\n &:hover {\n color: ${({ theme }) => theme.colors.light};\n background: ${({ theme }) => theme.colors.primary};\n border-color: ${({ theme }) => theme.colors.primary};\n }\n }\n\n & svg {\n vertical-align: middle;\n width: 12px;\n height: 12px;\n margin: auto;\n }\n`;\n\nexport const StyledPlusButton = styled.button<{ theme: Theme }>`\n ${resetButton};\n color: ${({ theme }) => theme.colors.primary};\n vertical-align: middle;\n padding: 0;\n width: 100%;\n height: 18px;\n display: flex;\n margin: auto 0;\n transition: all 0.3s ease;\n position: relative;\n margin: 20px 0 0 0;\n\n &::before {\n content: \"\";\n display: block;\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n width: 100%;\n height: 1px;\n border-radius: 3px;\n background: ${({ theme }) => theme.colors.grayLight};\n transition: all 0.3s ease;\n z-index: -1;\n }\n\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n width: 18px;\n height: 18px;\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n background: ${({ theme }) => theme.colors.light};\n transition: all 0.3s ease;\n z-index: -1;\n }\n\n box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primary};\n\n @media (hover: hover) {\n &:hover {\n &::after {\n border-color: ${({ theme }) => theme.colors.primary};\n }\n }\n }\n\n &:focus {\n &::after {\n border-color: ${({ theme }) => theme.colors.primary};\n box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};\n }\n }\n\n &:active {\n &::after {\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n }\n\n @media (hover: hover) {\n &:hover {\n color: ${({ theme }) => theme.colors.light};\n\n &::after {\n background: ${({ theme }) => theme.colors.primary};\n border-color: ${({ theme }) => theme.colors.primary};\n }\n }\n }\n\n & svg {\n vertical-align: middle;\n width: 14px;\n height: 14px;\n margin: auto;\n }\n`;\n\nexport const StyledFullHeightInput = styled.div`\n height: 100%;\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex: 1;\n\n & > span {\n height: 100%;\n width: 100%;\n }\n\n & textarea {\n height: 100%;\n }\n`;\n\nexport const StyledEditorWrapper = styled.div`\n flex: 1;\n\n &:empty {\n display: none;\n }\n`;\n\nfunction DocsWrapper({ children }: DocsProps) {\n return <StyledDocsWrapper>{children}</StyledDocsWrapper>;\n}\n\nfunction DocsSidebar({ children }: DocsProps) {\n return <StyledDocsSidebar>{children}</StyledDocsSidebar>;\n}\n\nfunction DocsContainer({ children }: DocsProps) {\n return <StyledDocsContainer>{children}</StyledDocsContainer>;\n}\n\nexport { DocsWrapper, DocsSidebar, DocsContainer };\n";