@pandacss/studio 0.0.0-dev-20230613163214

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 (250) hide show
  1. package/LICENSE.md +21 -0
  2. package/astro.config.ts +14 -0
  3. package/dist/studio.d.ts +13 -0
  4. package/dist/studio.js +2089 -0
  5. package/dist/studio.mjs +2087 -0
  6. package/index.ts +1 -0
  7. package/package.json +59 -0
  8. package/panda.config.ts +110 -0
  9. package/public/favicon.svg +13 -0
  10. package/src/components/analyzer/category-utilities.tsx +146 -0
  11. package/src/components/analyzer/data-combobox.tsx +125 -0
  12. package/src/components/analyzer/data-table.tsx +43 -0
  13. package/src/components/analyzer/external-icon.tsx +8 -0
  14. package/src/components/analyzer/file-details.tsx +101 -0
  15. package/src/components/analyzer/get-report-infos-from.ts +80 -0
  16. package/src/components/analyzer/quick-tooltip.tsx +15 -0
  17. package/src/components/analyzer/report-item-columns.tsx +52 -0
  18. package/src/components/analyzer/report-item-link.tsx +98 -0
  19. package/src/components/analyzer/section.tsx +24 -0
  20. package/src/components/analyzer/sort-icon.tsx +7 -0
  21. package/src/components/analyzer/text-with-count.tsx +28 -0
  22. package/src/components/analyzer/token-search-combobox.tsx +39 -0
  23. package/src/components/analyzer/truncated-text.tsx +26 -0
  24. package/src/components/analyzer/utility-details.tsx +312 -0
  25. package/src/components/color-constrast.tsx +131 -0
  26. package/src/components/color-item.tsx +37 -0
  27. package/src/components/color-wrapper.tsx +25 -0
  28. package/src/components/colors.tsx +96 -0
  29. package/src/components/empty-state.tsx +19 -0
  30. package/src/components/font-family.tsx +55 -0
  31. package/src/components/font-tokens.tsx +69 -0
  32. package/src/components/head.astro +35 -0
  33. package/src/components/icons.tsx +207 -0
  34. package/src/components/input.tsx +27 -0
  35. package/src/components/layer-styles.tsx +38 -0
  36. package/src/components/logo.tsx +34 -0
  37. package/src/components/nav-item.tsx +39 -0
  38. package/src/components/overview.tsx +65 -0
  39. package/src/components/radii.tsx +34 -0
  40. package/src/components/semantic-color.tsx +27 -0
  41. package/src/components/side-nav-item.astro +25 -0
  42. package/src/components/side-nav.astro +30 -0
  43. package/src/components/sizes.tsx +53 -0
  44. package/src/components/text-styles.tsx +33 -0
  45. package/src/components/theme-toggle.astro +56 -0
  46. package/src/components/token-analyzer.tsx +390 -0
  47. package/src/components/token-content.tsx +5 -0
  48. package/src/components/token-group.tsx +6 -0
  49. package/src/components/typography-playground.tsx +83 -0
  50. package/src/env.d.ts +1 -0
  51. package/src/icons/moon.tsx +15 -0
  52. package/src/icons/sun.tsx +19 -0
  53. package/src/layouts/Layout.astro +19 -0
  54. package/src/layouts/Sidebar.astro +35 -0
  55. package/src/lib/analysis-data.ts +17 -0
  56. package/src/lib/color-contrast-checker.ts +218 -0
  57. package/src/lib/color.ts +40 -0
  58. package/src/lib/constants.ts +140 -0
  59. package/src/lib/create-context.ts +27 -0
  60. package/src/lib/get-report-item.tsx +41 -0
  61. package/src/lib/group-in.ts +35 -0
  62. package/src/lib/panda.context.ts +23 -0
  63. package/src/lib/pick.ts +24 -0
  64. package/src/lib/sizes-sort.ts +10 -0
  65. package/src/lib/truncate.tsx +7 -0
  66. package/src/lib/use-color-docs.ts +101 -0
  67. package/src/pages/colors.astro +11 -0
  68. package/src/pages/font-sizes.astro +15 -0
  69. package/src/pages/font-weights.astro +15 -0
  70. package/src/pages/fonts.astro +11 -0
  71. package/src/pages/index.astro +8 -0
  72. package/src/pages/layer-styles.astro +11 -0
  73. package/src/pages/letter-spacings.astro +20 -0
  74. package/src/pages/line-heights.astro +21 -0
  75. package/src/pages/playground/contrast-checker.astro +11 -0
  76. package/src/pages/playground/typography.astro +11 -0
  77. package/src/pages/radii.astro +11 -0
  78. package/src/pages/sizes.astro +14 -0
  79. package/src/pages/spacing.astro +14 -0
  80. package/src/pages/text-styles.astro +11 -0
  81. package/src/pages/token-analyzer/file.astro +11 -0
  82. package/src/pages/token-analyzer/index.astro +11 -0
  83. package/src/pages/token-analyzer/utility.astro +11 -0
  84. package/styled-system/chunks/..__core____tests____composition.test.css +2 -0
  85. package/styled-system/chunks/src__components__analyzer__category-utilities.css +97 -0
  86. package/styled-system/chunks/src__components__analyzer__data-combobox.css +77 -0
  87. package/styled-system/chunks/src__components__analyzer__data-table.css +37 -0
  88. package/styled-system/chunks/src__components__analyzer__file-details.css +103 -0
  89. package/styled-system/chunks/src__components__analyzer__quick-tooltip.css +2 -0
  90. package/styled-system/chunks/src__components__analyzer__report-item-columns.css +29 -0
  91. package/styled-system/chunks/src__components__analyzer__report-item-link.css +109 -0
  92. package/styled-system/chunks/src__components__analyzer__section.css +29 -0
  93. package/styled-system/chunks/src__components__analyzer__text-with-count.css +33 -0
  94. package/styled-system/chunks/src__components__analyzer__truncated-text.css +13 -0
  95. package/styled-system/chunks/src__components__analyzer__utility-details.css +125 -0
  96. package/styled-system/chunks/src__components__color-constrast.css +114 -0
  97. package/styled-system/chunks/src__components__color-item.css +21 -0
  98. package/styled-system/chunks/src__components__color-wrapper.css +73 -0
  99. package/styled-system/chunks/src__components__colors.css +97 -0
  100. package/styled-system/chunks/src__components__empty-state.css +45 -0
  101. package/styled-system/chunks/src__components__font-family.css +85 -0
  102. package/styled-system/chunks/src__components__font-tokens.css +61 -0
  103. package/styled-system/chunks/src__components__input.css +68 -0
  104. package/styled-system/chunks/src__components__layer-styles.css +66 -0
  105. package/styled-system/chunks/src__components__nav-item.css +73 -0
  106. package/styled-system/chunks/src__components__overview.css +125 -0
  107. package/styled-system/chunks/src__components__radii.css +49 -0
  108. package/styled-system/chunks/src__components__semantic-color.css +45 -0
  109. package/styled-system/chunks/src__components__side-nav-item.css +33 -0
  110. package/styled-system/chunks/src__components__side-nav.css +49 -0
  111. package/styled-system/chunks/src__components__sizes.css +41 -0
  112. package/styled-system/chunks/src__components__text-styles.css +31 -0
  113. package/styled-system/chunks/src__components__theme-toggle.css +63 -0
  114. package/styled-system/chunks/src__components__token-analyzer.css +227 -0
  115. package/styled-system/chunks/src__components__token-content.css +13 -0
  116. package/styled-system/chunks/src__components__token-group.css +21 -0
  117. package/styled-system/chunks/src__components__token-search-combobox.css +2 -0
  118. package/styled-system/chunks/src__components__typography-playground.css +61 -0
  119. package/styled-system/chunks/src__layouts__Layout.css +2 -0
  120. package/styled-system/chunks/src__layouts__Sidebar.css +113 -0
  121. package/styled-system/chunks/src__pages__colors.css +2 -0
  122. package/styled-system/chunks/src__pages__font-sizes.css +2 -0
  123. package/styled-system/chunks/src__pages__font-weights.css +2 -0
  124. package/styled-system/chunks/src__pages__fonts.css +2 -0
  125. package/styled-system/chunks/src__pages__index.css +2 -0
  126. package/styled-system/chunks/src__pages__layer-styles.css +2 -0
  127. package/styled-system/chunks/src__pages__letter-spacings.css +2 -0
  128. package/styled-system/chunks/src__pages__line-heights.css +2 -0
  129. package/styled-system/chunks/src__pages__playground__contrast-checker.css +2 -0
  130. package/styled-system/chunks/src__pages__playground__typography.css +2 -0
  131. package/styled-system/chunks/src__pages__radii.css +2 -0
  132. package/styled-system/chunks/src__pages__sizes.css +2 -0
  133. package/styled-system/chunks/src__pages__spacing.css +2 -0
  134. package/styled-system/chunks/src__pages__text-styles.css +2 -0
  135. package/styled-system/chunks/src__pages__token-analyzer__file.css +2 -0
  136. package/styled-system/chunks/src__pages__token-analyzer__index.css +2 -0
  137. package/styled-system/chunks/src__pages__token-analyzer__utility.css +2 -0
  138. package/styled-system/css/conditions.mjs +147 -0
  139. package/styled-system/css/css.d.ts +2 -0
  140. package/styled-system/css/css.mjs +391 -0
  141. package/styled-system/css/cva.d.ts +5 -0
  142. package/styled-system/css/cva.mjs +63 -0
  143. package/styled-system/css/cx.d.ts +4 -0
  144. package/styled-system/css/cx.mjs +15 -0
  145. package/styled-system/css/index.d.ts +3 -0
  146. package/styled-system/css/index.mjs +3 -0
  147. package/styled-system/global.css +61 -0
  148. package/styled-system/helpers.mjs +251 -0
  149. package/styled-system/jsx/absolute-center.d.ts +8 -0
  150. package/styled-system/jsx/absolute-center.mjs +9 -0
  151. package/styled-system/jsx/aspect-ratio.d.ts +8 -0
  152. package/styled-system/jsx/aspect-ratio.mjs +9 -0
  153. package/styled-system/jsx/box.d.ts +8 -0
  154. package/styled-system/jsx/box.mjs +8 -0
  155. package/styled-system/jsx/center.d.ts +8 -0
  156. package/styled-system/jsx/center.mjs +9 -0
  157. package/styled-system/jsx/circle.d.ts +8 -0
  158. package/styled-system/jsx/circle.mjs +9 -0
  159. package/styled-system/jsx/container.d.ts +8 -0
  160. package/styled-system/jsx/container.mjs +8 -0
  161. package/styled-system/jsx/divider.d.ts +8 -0
  162. package/styled-system/jsx/divider.mjs +9 -0
  163. package/styled-system/jsx/factory.d.ts +2 -0
  164. package/styled-system/jsx/factory.mjs +59 -0
  165. package/styled-system/jsx/flex.d.ts +8 -0
  166. package/styled-system/jsx/flex.mjs +9 -0
  167. package/styled-system/jsx/float.d.ts +8 -0
  168. package/styled-system/jsx/float.mjs +9 -0
  169. package/styled-system/jsx/grid-item.d.ts +8 -0
  170. package/styled-system/jsx/grid-item.mjs +9 -0
  171. package/styled-system/jsx/grid.d.ts +8 -0
  172. package/styled-system/jsx/grid.mjs +9 -0
  173. package/styled-system/jsx/hstack.d.ts +8 -0
  174. package/styled-system/jsx/hstack.mjs +9 -0
  175. package/styled-system/jsx/index.d.ts +20 -0
  176. package/styled-system/jsx/index.mjs +19 -0
  177. package/styled-system/jsx/is-valid-prop.mjs +1010 -0
  178. package/styled-system/jsx/spacer.d.ts +8 -0
  179. package/styled-system/jsx/spacer.mjs +9 -0
  180. package/styled-system/jsx/square.d.ts +8 -0
  181. package/styled-system/jsx/square.mjs +9 -0
  182. package/styled-system/jsx/stack.d.ts +8 -0
  183. package/styled-system/jsx/stack.mjs +9 -0
  184. package/styled-system/jsx/styled-link.d.ts +8 -0
  185. package/styled-system/jsx/styled-link.mjs +8 -0
  186. package/styled-system/jsx/vstack.d.ts +8 -0
  187. package/styled-system/jsx/vstack.mjs +9 -0
  188. package/styled-system/jsx/wrap.d.ts +8 -0
  189. package/styled-system/jsx/wrap.mjs +9 -0
  190. package/styled-system/patterns/absolute-center.d.ts +14 -0
  191. package/styled-system/patterns/absolute-center.mjs +23 -0
  192. package/styled-system/patterns/aspect-ratio.d.ts +14 -0
  193. package/styled-system/patterns/aspect-ratio.mjs +25 -0
  194. package/styled-system/patterns/box.d.ts +14 -0
  195. package/styled-system/patterns/box.mjs +12 -0
  196. package/styled-system/patterns/center.d.ts +14 -0
  197. package/styled-system/patterns/center.mjs +18 -0
  198. package/styled-system/patterns/circle.d.ts +14 -0
  199. package/styled-system/patterns/circle.mjs +22 -0
  200. package/styled-system/patterns/container.d.ts +14 -0
  201. package/styled-system/patterns/container.mjs +18 -0
  202. package/styled-system/patterns/divider.d.ts +16 -0
  203. package/styled-system/patterns/divider.mjs +21 -0
  204. package/styled-system/patterns/flex.d.ts +20 -0
  205. package/styled-system/patterns/flex.mjs +23 -0
  206. package/styled-system/patterns/float.d.ts +17 -0
  207. package/styled-system/patterns/float.mjs +45 -0
  208. package/styled-system/patterns/grid-item.d.ts +19 -0
  209. package/styled-system/patterns/grid-item.mjs +20 -0
  210. package/styled-system/patterns/grid.d.ts +18 -0
  211. package/styled-system/patterns/grid.mjs +25 -0
  212. package/styled-system/patterns/hstack.d.ts +15 -0
  213. package/styled-system/patterns/hstack.mjs +20 -0
  214. package/styled-system/patterns/index.d.ts +18 -0
  215. package/styled-system/patterns/index.mjs +18 -0
  216. package/styled-system/patterns/spacer.d.ts +14 -0
  217. package/styled-system/patterns/spacer.mjs +18 -0
  218. package/styled-system/patterns/square.d.ts +14 -0
  219. package/styled-system/patterns/square.mjs +21 -0
  220. package/styled-system/patterns/stack.d.ts +17 -0
  221. package/styled-system/patterns/stack.mjs +20 -0
  222. package/styled-system/patterns/styled-link.d.ts +14 -0
  223. package/styled-system/patterns/styled-link.mjs +18 -0
  224. package/styled-system/patterns/vstack.d.ts +15 -0
  225. package/styled-system/patterns/vstack.mjs +20 -0
  226. package/styled-system/patterns/wrap.d.ts +18 -0
  227. package/styled-system/patterns/wrap.mjs +22 -0
  228. package/styled-system/reset.css +190 -0
  229. package/styled-system/static.css +5 -0
  230. package/styled-system/styles.css +938 -0
  231. package/styled-system/tokens/index.css +374 -0
  232. package/styled-system/tokens/index.d.ts +8 -0
  233. package/styled-system/tokens/index.mjs +1590 -0
  234. package/styled-system/tokens/keyframes.css +30 -0
  235. package/styled-system/tokens/tokens.d.ts +56 -0
  236. package/styled-system/types/composition.d.ts +110 -0
  237. package/styled-system/types/conditions.d.ts +135 -0
  238. package/styled-system/types/csstype.d.ts +20748 -0
  239. package/styled-system/types/global.d.ts +15 -0
  240. package/styled-system/types/helpers.d.ts +1 -0
  241. package/styled-system/types/index.d.ts +3 -0
  242. package/styled-system/types/jsx.d.ts +27 -0
  243. package/styled-system/types/parts.d.ts +5 -0
  244. package/styled-system/types/pattern.d.ts +52 -0
  245. package/styled-system/types/prop-type.d.ts +300 -0
  246. package/styled-system/types/recipe.d.ts +79 -0
  247. package/styled-system/types/selectors.d.ts +56 -0
  248. package/styled-system/types/style-props.d.ts +688 -0
  249. package/styled-system/types/system-types.d.ts +76 -0
  250. package/virtual-panda.ts +72 -0
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './scripts/studio'
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@pandacss/studio",
3
+ "version": "0.0.0-dev-20230613163214",
4
+ "description": "The automated token documentation for Panda CSS",
5
+ "main": "dist/studio.js",
6
+ "module": "dist/studio.mjs",
7
+ "types": "dist/studio.d.ts",
8
+ "sideEffects": false,
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "src",
15
+ "public",
16
+ "styled-system",
17
+ "*.ts"
18
+ ],
19
+ "keywords": [
20
+ "panda",
21
+ "studio",
22
+ "design tokens",
23
+ "documentation"
24
+ ],
25
+ "author": "Segun Adebayo <joseshegs@gmail.com>",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "@ark-ui/react": "0.6.0",
29
+ "@astrojs/react": "2.2.1",
30
+ "astro": "2.6.3",
31
+ "javascript-stringify": "2.1.0",
32
+ "react": "18.2.0",
33
+ "react-dom": "18.2.0",
34
+ "vite": "4.3.9",
35
+ "@pandacss/types": "0.0.0-dev-20230613163214",
36
+ "@pandacss/config": "0.0.0-dev-20230613163214",
37
+ "@pandacss/shared": "0.0.0-dev-20230613163214",
38
+ "@pandacss/token-dictionary": "0.0.0-dev-20230613163214",
39
+ "@pandacss/logger": "0.0.0-dev-20230613163214",
40
+ "@pandacss/node": "0.0.0-dev-20230613163214"
41
+ },
42
+ "devDependencies": {
43
+ "@types/react": "18.2.12",
44
+ "@types/react-dom": "18.2.5",
45
+ "@vitejs/plugin-react": "4.0.0",
46
+ "execa": "7.1.1",
47
+ "@pandacss/dev": "0.0.0-dev-20230613163214"
48
+ },
49
+ "scripts": {
50
+ "codegen": "panda",
51
+ "build": "tsup scripts --format=esm,cjs --dts --no-splitting --shims",
52
+ "postbuild": "panda",
53
+ "build-fast": "tsup scripts --format=esm,cjs --no-dts --no-splitting --shims",
54
+ "dev": "pnpm build-fast --watch scripts",
55
+ "dev:panda": "panda --clean --watch",
56
+ "dev:astro": "astro dev",
57
+ "start": "concurrently \"pnpm dev:panda\" \"pnpm dev:astro\""
58
+ }
59
+ }
@@ -0,0 +1,110 @@
1
+ import { defineConfig } from '@pandacss/dev'
2
+
3
+ export default defineConfig({
4
+ gitignore: false,
5
+ preflight: true,
6
+ include: ['./src/**/*.{tsx,jsx,astro}'],
7
+ exclude: [],
8
+ outdir: 'styled-system',
9
+ jsxFactory: 'panda',
10
+ jsxFramework: 'react',
11
+ theme: {
12
+ extend: {
13
+ tokens: {
14
+ colors: {
15
+ neutral: {
16
+ 50: { value: '#fafafa' },
17
+ 100: { value: '#f5f5f5' },
18
+ 200: { value: '#e5e5e5' },
19
+ 300: { value: '#d4d4d4' },
20
+ 400: { value: '#a3a3a3' },
21
+ 500: { value: '#737373' },
22
+ 600: { value: '#525252' },
23
+ 700: { value: '#404040' },
24
+ 800: { value: '#262626' },
25
+ 900: { value: '#171717' },
26
+ 950: { value: '#0a0a0a' },
27
+ },
28
+ },
29
+ assets: {
30
+ check: {
31
+ value: {
32
+ type: 'url',
33
+ value:
34
+ 'data:image/svg+xml;utf8,%3Csvg%20width%3D%226%22%20height%3D%226%22%20viewBox%3D%220%200%206%206%22%20fill%3D%22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20d%3D%22M0%200H3V3H0V0Z%22%20fill%3D%22%23E1E1E1%22/%3E%3Cpath%20d%3D%22M3%200H6V3H3V0Z%22%20fill%3D%22white%22/%3E%3Cpath%20d%3D%22M3%203H6V6H3V3Z%22%20fill%3D%22%23E1E1E1%22/%3E%3Cpath%20d%3D%22M0%203H3V6H0V3Z%22%20fill%3D%22white%22/%3E%3C/svg%3E%0A',
35
+ },
36
+ },
37
+ },
38
+ },
39
+ semanticTokens: {
40
+ shadows: {
41
+ inset: {
42
+ value: { base: 'inset 0 0 0 1px rgba(0,0,0,0.1)', _dark: 'inset 0 0 0 1px rgba(255,255,255,0.2)' },
43
+ },
44
+ },
45
+ colors: {
46
+ text: {
47
+ value: { base: '{colors.black}', _dark: '{colors.neutral.200}' },
48
+ },
49
+ bg: {
50
+ value: { base: '{colors.white}', _dark: '{colors.neutral.900}' },
51
+ },
52
+ card: {
53
+ value: { base: '{colors.neutral.200}', _dark: '{colors.neutral.800}' },
54
+ },
55
+ border: {
56
+ value: { base: '{colors.neutral.300}', _dark: '{colors.neutral.700}' },
57
+ },
58
+ },
59
+ },
60
+ },
61
+ },
62
+ patterns: {
63
+ extend: {
64
+ styledLink: {
65
+ properties: {},
66
+ transform: (props: any) => ({
67
+ display: 'inline-flex',
68
+ alignItems: 'center',
69
+ opacity: '0.5',
70
+ borderBottom: '1px solid transparent',
71
+ cursor: 'pointer',
72
+ _hover: { opacity: 1, borderBottomColor: 'black' },
73
+ ...props,
74
+ }),
75
+ },
76
+ },
77
+ },
78
+ staticCss: {
79
+ css: [
80
+ {
81
+ properties: {
82
+ color: ['red.400'],
83
+ },
84
+ },
85
+ ],
86
+ },
87
+ globalCss: {
88
+ ':root': {
89
+ '--global-color-border': 'colors.border',
90
+ '--global-color-placeholder': 'colors.neutral.500',
91
+ fontFamily: 'Inter, Avenir, Helvetica, Arial, sans-serif',
92
+ fontSize: 'md',
93
+ lineHeight: 'normal',
94
+ fontWeight: 'normal',
95
+ colorScheme: 'light dark',
96
+ color: 'text',
97
+ background: 'bg',
98
+ },
99
+
100
+ a: {
101
+ color: 'unset',
102
+ textDecoration: 'none',
103
+ },
104
+
105
+ body: {
106
+ margin: 0,
107
+ minHeight: '100vh',
108
+ },
109
+ },
110
+ })
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 36 36">
2
+ <path fill="#000" d="M22.25 4h-8.5a1 1 0 0 0-.96.73l-5.54 19.4a.5.5 0 0 0 .62.62l5.05-1.44a2 2 0 0 0 1.38-1.4l3.22-11.66a.5.5 0 0 1 .96 0l3.22 11.67a2 2 0 0 0 1.38 1.39l5.05 1.44a.5.5 0 0 0 .62-.62l-5.54-19.4a1 1 0 0 0-.96-.73Z"/>
3
+ <path fill="url(#gradient)" d="M18 28a7.63 7.63 0 0 1-5-2c-1.4 2.1-.35 4.35.6 5.55.14.17.41.07.47-.15.44-1.8 2.93-1.22 2.93.6 0 2.28.87 3.4 1.72 3.81.34.16.59-.2.49-.56-.31-1.05-.29-2.46 1.29-3.25 3-1.5 3.17-4.83 2.5-6-.67.67-2.6 2-5 2Z"/>
4
+ <defs>
5
+ <linearGradient id="gradient" x1="16" x2="16" y1="32" y2="24" gradientUnits="userSpaceOnUse">
6
+ <stop stop-color="#000"/>
7
+ <stop offset="1" stop-color="#000" stop-opacity="0"/>
8
+ </linearGradient>
9
+ </defs>
10
+ <style>
11
+ @media (prefers-color-scheme:dark){:root{filter:invert(100%)}}
12
+ </style>
13
+ </svg>
@@ -0,0 +1,146 @@
1
+ import { Grid, panda, Wrap } from '../../../styled-system/jsx'
2
+ import { gridItem, styledLink } from '../../../styled-system/patterns'
3
+ import { getReportItem, getUtilityLink } from '../../lib/get-report-item'
4
+ import { groupBy } from '../../lib/group-in'
5
+ import { Section } from './section'
6
+ import { TextWithCount } from './text-with-count'
7
+ import { TruncatedText } from './truncated-text'
8
+
9
+ import { Portal, Select, SelectContent, SelectOption, SelectPositioner, SelectTrigger } from '@ark-ui/react'
10
+ import { useState } from 'react'
11
+ import { css, cx } from '../../../styled-system/css'
12
+ import { ReportItemLink } from './report-item-link'
13
+ import { SortIcon } from './sort-icon'
14
+
15
+ const selectOptionClass = css({ padding: '4px 8px', bg: 'white' })
16
+
17
+ type SortBy = 'property name' | 'tokens count'
18
+ const defaultOption = { label: 'tokens count', value: 'tokens count' as SortBy }
19
+
20
+ export const ByCategory = ({ byCategory }: { byCategory: Record<string, number[]> }) => {
21
+ const { unknown, ...rest } = byCategory
22
+ const keys = Object.keys(rest)
23
+ const [sortedBy, setSortedBy] = useState<SortBy>('tokens count')
24
+
25
+ return (
26
+ <Section
27
+ p="0"
28
+ title={
29
+ <span>
30
+ <TextWithCount count={keys.length + 1}>Category </TextWithCount>
31
+ <panda.span ml="2">utilities</panda.span>
32
+ </span>
33
+ }
34
+ subTitle={
35
+ <panda.div ml="auto">
36
+ <Select
37
+ onChange={(option) => setSortedBy((option?.value as SortBy) ?? 'tokens count')}
38
+ defaultValue={defaultOption}
39
+ >
40
+ {({ selectedOption }) => (
41
+ <>
42
+ <SelectTrigger>
43
+ <panda.button display="flex" alignItems="center">
44
+ Sort by {selectedOption?.label}
45
+ <panda.div w="26px" ml="2">
46
+ <SortIcon />
47
+ </panda.div>
48
+ </panda.button>
49
+ </SelectTrigger>
50
+ <Portal>
51
+ <SelectPositioner>
52
+ <SelectContent className={cx(selectOptionClass, css({ listStyle: 'none' }))}>
53
+ <SelectOption
54
+ className={selectOptionClass}
55
+ value={defaultOption.value}
56
+ label={defaultOption.label}
57
+ />
58
+ <SelectOption className={selectOptionClass} value="property name" label="property name" />
59
+ </SelectContent>
60
+ </SelectPositioner>
61
+ </Portal>
62
+ </>
63
+ )}
64
+ </Select>
65
+ </panda.div>
66
+ }
67
+ >
68
+ <Grid gap="4" columns={2}>
69
+ {/* TODO filter out variants from recipes ? */}
70
+ {keys.map((category) => (
71
+ <CategoryUtilities key={category} category={category} byCategory={byCategory} sortedBy={sortedBy} />
72
+ ))}
73
+ <CategoryUtilities
74
+ className={gridItem({ colSpan: 2 })}
75
+ category="unknown"
76
+ byCategory={byCategory}
77
+ sortedBy={sortedBy}
78
+ />
79
+ </Grid>
80
+ </Section>
81
+ )
82
+ }
83
+
84
+ const CategoryUtilities = ({
85
+ category,
86
+ byCategory,
87
+ className,
88
+ sortedBy,
89
+ }: {
90
+ category: string
91
+ byCategory: Record<string, number[]>
92
+ className?: string
93
+ sortedBy: SortBy
94
+ }) => {
95
+ const reportItemIdList = byCategory[category as keyof typeof byCategory]
96
+
97
+ const categoryTokens = reportItemIdList.map(getReportItem)
98
+ const grouped = groupBy(categoryTokens, 'value')
99
+ const values = Object.entries(grouped)
100
+ const flattened = values.flatMap(([_value, reportItemList]) => reportItemList)
101
+
102
+ const sorted = flattened
103
+ .filter((item) => {
104
+ return item === grouped[String(item.value)][0]
105
+ })
106
+ .sort((a, b) => {
107
+ if (sortedBy === 'property name') {
108
+ const result = a.propName.localeCompare(b.propName)
109
+ if (result !== 0) {
110
+ return result
111
+ }
112
+
113
+ return String(a.value).localeCompare(String(b.value))
114
+ }
115
+
116
+ if (sortedBy === 'tokens count') {
117
+ return grouped[String(b.value)].length - grouped[String(a.value)].length
118
+ }
119
+
120
+ return 0
121
+ })
122
+
123
+ return (
124
+ <panda.div key={category} p="4" bg="gray.50" className={className}>
125
+ <panda.h4>
126
+ <panda.a className={styledLink({})} href={getUtilityLink({ category })}>
127
+ <TextWithCount count={values.length}>
128
+ <TruncatedText text={category} />
129
+ </TextWithCount>
130
+ </panda.a>
131
+ </panda.h4>
132
+ <Wrap gap="2">
133
+ {sorted.map((reportItem) => {
134
+ return (
135
+ <ReportItemLink
136
+ key={reportItem.id}
137
+ value={reportItem.value}
138
+ category={reportItem.category}
139
+ propName={reportItem.propName}
140
+ />
141
+ )
142
+ })}
143
+ </Wrap>
144
+ </panda.div>
145
+ )
146
+ }
@@ -0,0 +1,125 @@
1
+ import {
2
+ Combobox,
3
+ ComboboxContent,
4
+ ComboboxControl,
5
+ ComboboxInput,
6
+ ComboboxLabel,
7
+ ComboboxOption,
8
+ ComboboxPositioner,
9
+ ComboboxTrigger,
10
+ Portal,
11
+ } from '@ark-ui/react'
12
+ import { useEffect, useState } from 'react'
13
+ import { css } from '../../../styled-system/css'
14
+ import { panda } from '../../../styled-system/jsx'
15
+
16
+ export type DataComboboxOption = {
17
+ value: string
18
+ label: string
19
+ }
20
+
21
+ export type DataComboboxProps = {
22
+ options: DataComboboxOption[]
23
+ label?: React.ReactNode
24
+ placeholder?: string
25
+ filterFn?: (value: string) => DataComboboxOption[]
26
+ defaultValue?: string
27
+ onSelect?: (option: any) => void
28
+ }
29
+
30
+ export const DataCombobox = ({ options: allOptions, label, ...props }: DataComboboxProps) => {
31
+ const [options, setOptions] = useState(allOptions)
32
+ const filterFn =
33
+ props.filterFn ||
34
+ ((value: string) => allOptions.filter((item) => item.label.toLowerCase().includes(value.toLowerCase())))
35
+
36
+ // sync available options from parent
37
+ useEffect(() => {
38
+ setOptions(allOptions)
39
+ }, [allOptions])
40
+
41
+ return (
42
+ <Combobox openOnClick {...props}>
43
+ {(state: any) => {
44
+ return (
45
+ <>
46
+ <ComboboxControl>
47
+ <panda.div display="flex" flexDirection="column">
48
+ {label && (
49
+ <ComboboxLabel>
50
+ <panda.span fontWeight="bold">{label}</panda.span>
51
+ </ComboboxLabel>
52
+ )}
53
+ <panda.div display="flex" border="1px solid token(colors.blue.400, blue)">
54
+ <ComboboxInput
55
+ defaultValue={props.defaultValue}
56
+ placeholder={props.placeholder ?? 'Search...'}
57
+ className={css({ width: 'full' })}
58
+ onChange={(e) => {
59
+ const value = e.target.value
60
+ if (!value) {
61
+ props?.onSelect?.({ relatedTarget: null })
62
+ setOptions(allOptions)
63
+ state.clearValue()
64
+ return
65
+ }
66
+
67
+ setOptions(filterFn(value))
68
+ }}
69
+ />
70
+ {state.selectedValue && (
71
+ <panda.span
72
+ px="2"
73
+ mr="-2"
74
+ cursor="pointer"
75
+ userSelect="none"
76
+ fontSize="lg"
77
+ fontWeight="bold"
78
+ onClick={() => state.clearValue()}
79
+ >
80
+ X
81
+ </panda.span>
82
+ )}
83
+ <ComboboxTrigger>
84
+ <panda.span ml="auto" px="2" cursor="pointer">
85
+ {state.isOpen ? '▲' : '▼'}
86
+ </panda.span>
87
+ </ComboboxTrigger>
88
+ </panda.div>
89
+ </panda.div>
90
+ </ComboboxControl>
91
+ <Portal>
92
+ <ComboboxPositioner>
93
+ <ComboboxContent
94
+ className={css({
95
+ maxHeight: '300px',
96
+ overflow: 'auto',
97
+ padding: '4px 8px',
98
+ bg: 'white',
99
+ listStyle: 'none',
100
+ border: '1px solid token(colors.blue.400, blue)',
101
+ })}
102
+ >
103
+ {/* TODO virtualization */}
104
+ {options.map((option) => (
105
+ <ComboboxOption
106
+ key={option.label + '-' + option.value}
107
+ value={option.value}
108
+ label={option.label}
109
+ className={css({
110
+ padding: '4px 8px',
111
+ _highlighted: {
112
+ outline: '1px solid token(colors.blue.400, blue)',
113
+ },
114
+ })}
115
+ />
116
+ ))}
117
+ </ComboboxContent>
118
+ </ComboboxPositioner>
119
+ </Portal>
120
+ </>
121
+ )
122
+ }}
123
+ </Combobox>
124
+ )
125
+ }
@@ -0,0 +1,43 @@
1
+ import type { ReactNode } from 'react'
2
+ import { Grid, panda } from '../../../styled-system/jsx'
3
+ import { flex } from '../../../styled-system/patterns'
4
+
5
+ export type Column<T> = { header: string; accessor: string; cell?: (item: T) => ReactNode }
6
+
7
+ // TODO tanstack/table ? hide/show columns + sort
8
+ export function DataTable<T>({ list, columns }: { list: T[]; columns: ReadonlyArray<Column<T>> }) {
9
+ return (
10
+ <panda.div>
11
+ <Grid
12
+ style={{ gridTemplateColumns: `80px repeat(auto-fit, minmax(30px, 1fr))` }}
13
+ // gridTemplateColumns="repeat(auto-fit, minmax(30px, 1fr))"
14
+ w="full"
15
+ fontWeight="bold"
16
+ fontSize="lg"
17
+ mb="2"
18
+ >
19
+ {columns.map((column) => {
20
+ return <panda.div key={column.header}>{column.header}</panda.div>
21
+ })}
22
+ </Grid>
23
+ <panda.div className={flex({ direction: 'column', gap: '2' })}>
24
+ {list.map((item, index) => {
25
+ return (
26
+ <Grid
27
+ style={{ gridTemplateColumns: `80px repeat(auto-fit, minmax(30px, 1fr))` }}
28
+ // gridTemplateColumns="repeat(auto-fit, minmax(30px, 1fr))"
29
+ w="full"
30
+ key={index}
31
+ >
32
+ {columns.map((column) => {
33
+ return (
34
+ <panda.div key={column.accessor}>{column.cell?.(item) ?? (item as any)[column.accessor]}</panda.div>
35
+ )
36
+ })}
37
+ </Grid>
38
+ )
39
+ })}
40
+ </panda.div>
41
+ </panda.div>
42
+ )
43
+ }
@@ -0,0 +1,8 @@
1
+ /** @see https://iconmonstr.com/share-11-svg/ */
2
+ export const ExternalIcon = () => {
3
+ return (
4
+ <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100%" viewBox="0 0 24 24">
5
+ <path d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z" />
6
+ </svg>
7
+ )
8
+ }
@@ -0,0 +1,101 @@
1
+ import type { ReportItemJSON } from '@pandacss/types'
2
+ import { panda, Wrap } from '../../../styled-system/jsx'
3
+ import { styledLink } from '../../../styled-system/patterns'
4
+ import { createContext } from '../../lib/create-context'
5
+ import { analysisData } from '../../lib/analysis-data'
6
+ import { getReportItem, getUtilityLink, getReportRelativeFilePath } from '../../lib/get-report-item'
7
+ import { ByCategory } from './category-utilities'
8
+ import { ColorItem } from '../color-item'
9
+ import { TokenSearchCombobox } from './token-search-combobox'
10
+ import { TextWithCount } from './text-with-count'
11
+ import { TruncatedText } from './truncated-text'
12
+
13
+ export const FileDetails = () => {
14
+ const search = new URLSearchParams(window.location.search)
15
+ const filepath = search.get('filepath')
16
+
17
+ const byFilepath = analysisData.details.byFilepath[filepath as keyof typeof analysisData.details.byFilepath] ?? []
18
+ const reportItemList = byFilepath.map(getReportItem)
19
+
20
+ return (
21
+ <panda.div>
22
+ <panda.div display="flex">
23
+ <panda.a href="/token-analyzer">
24
+ <panda.span fontWeight="bold">{'<'} </panda.span>Back
25
+ </panda.a>
26
+ <panda.div ml="auto">
27
+ <TokenSearchCombobox placeholder="Global search" />
28
+ </panda.div>
29
+ </panda.div>
30
+ <panda.div p="4" mt="4">
31
+ {!filepath ? (
32
+ <panda.div display="flex" justifyContent="center" fontSize="xl" p="16" fontWeight="bold">
33
+ No file selected
34
+ </panda.div>
35
+ ) : reportItemList.length > 0 ? (
36
+ <FileProvider value={{ filepath, localMaps: analysisData.details.byFilePathMaps[filepath], reportItemList }}>
37
+ <FileDetailsContent />
38
+ </FileProvider>
39
+ ) : (
40
+ <panda.div display="flex" justifyContent="center" fontSize="xl" p="16" fontWeight="bold">
41
+ No results
42
+ </panda.div>
43
+ )}
44
+ </panda.div>
45
+ </panda.div>
46
+ )
47
+ }
48
+
49
+ const [FileProvider, useFileContext] = createContext<{
50
+ filepath: string
51
+ localMaps: (typeof analysisData.details.byFilePathMaps)[string]
52
+ reportItemList: Array<ReportItemJSON>
53
+ }>({
54
+ name: 'UtilityFileContext',
55
+ })
56
+
57
+ const FileDetailsContent = () => {
58
+ const { filepath, localMaps, reportItemList } = useFileContext()
59
+ const colors = Object.entries(localMaps.colorsUsed)
60
+
61
+ return (
62
+ <>
63
+ <panda.h3 mb="4">
64
+ Usage in file :{' '}
65
+ <panda.a
66
+ mt="1"
67
+ key={filepath}
68
+ className={styledLink({})}
69
+ href={getUtilityLink({ filepath })}
70
+ onClick={(e) => e.stopPropagation()}
71
+ >
72
+ <TextWithCount count={reportItemList.length}>{getReportRelativeFilePath(filepath)}</TextWithCount>
73
+ </panda.a>
74
+ </panda.h3>
75
+ <ByCategory byCategory={localMaps.byCategory} />
76
+ {colors.length ? (
77
+ <panda.div mt="8">
78
+ <panda.h3>
79
+ <TextWithCount count={colors.length}>Color palette</TextWithCount>
80
+ </panda.h3>
81
+ <Wrap gap="2" mt="4">
82
+ {colors.map(([key]) => {
83
+ return (
84
+ <ColorItem
85
+ tokenName={key}
86
+ key={key}
87
+ py="2"
88
+ px="4"
89
+ transition="all 0.2s ease"
90
+ _hover={{ bgColor: 'gray.100' }}
91
+ >
92
+ <TruncatedText text={key} />
93
+ </ColorItem>
94
+ )
95
+ })}
96
+ </Wrap>
97
+ </panda.div>
98
+ ) : null}
99
+ </>
100
+ )
101
+ }