@pandacss/studio 0.0.0-dev-20250414214914 → 0.0.0-dev-20250416095209

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/studio",
3
- "version": "0.0.0-dev-20250414214914",
3
+ "version": "0.0.0-dev-20250416095209",
4
4
  "description": "The automated token documentation for Panda CSS",
5
5
  "main": "dist/studio.js",
6
6
  "module": "dist/studio.mjs",
@@ -48,16 +48,17 @@
48
48
  "react": "18.2.0",
49
49
  "react-dom": "18.2.0",
50
50
  "vite": "6.2.5",
51
- "@pandacss/config": "0.0.0-dev-20250414214914",
52
- "@pandacss/logger": "0.0.0-dev-20250414214914",
53
- "@pandacss/shared": "0.0.0-dev-20250414214914",
54
- "@pandacss/token-dictionary": "0.0.0-dev-20250414214914",
55
- "@pandacss/types": "0.0.0-dev-20250414214914",
56
- "@pandacss/astro-plugin-studio": "0.0.0-dev-20250414214914"
51
+ "@pandacss/logger": "0.0.0-dev-20250416095209",
52
+ "@pandacss/config": "0.0.0-dev-20250416095209",
53
+ "@pandacss/shared": "0.0.0-dev-20250416095209",
54
+ "@pandacss/token-dictionary": "0.0.0-dev-20250416095209",
55
+ "@pandacss/astro-plugin-studio": "0.0.0-dev-20250416095209",
56
+ "@pandacss/types": "0.0.0-dev-20250416095209"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/react": "18.2.55",
60
- "@types/react-dom": "18.2.19"
60
+ "@types/react-dom": "18.2.19",
61
+ "@testing-library/react": "14.2.2"
61
62
  },
62
63
  "scripts": {
63
64
  "panda": "node ../cli/bin.js",
@@ -1,10 +1,10 @@
1
- import type { Token } from '@pandacss/token-dictionary'
1
+ import type { Token, TokenExtensions } from '@pandacss/token-dictionary'
2
2
  import * as React from 'react'
3
3
  import { Grid, HStack, Stack, panda } from '../../styled-system/jsx'
4
4
  import { ColorWrapper } from '../components/color-wrapper'
5
5
  import { TokenContent } from '../components/token-content'
6
6
  import { TokenGroup } from '../components/token-group'
7
- import { useColorDocs } from '../lib/use-color-docs'
7
+ import { useColorDocs, type ColorToken } from '../lib/use-color-docs'
8
8
  import { Input } from './input'
9
9
  import { SemanticColorDisplay } from './semantic-color'
10
10
  import { StickyTop } from './sticky-top'
@@ -15,33 +15,56 @@ function getColorFromReference(reference: string) {
15
15
  return reference.match(/{colors\.(.*?)}/)?.[1]
16
16
  }
17
17
 
18
+ const SEMANTIC_TOKEN_PRIORITY = ['base', 'light', '_light', 'dark', '_dark']
19
+
20
+ export function sortSemanticTokens(tokens: string[]) {
21
+ const ret = tokens.slice()
22
+ ret.sort((a, b) => {
23
+ const _a = SEMANTIC_TOKEN_PRIORITY.indexOf(a)
24
+ const _b = SEMANTIC_TOKEN_PRIORITY.indexOf(b)
25
+ if (_a !== -1 && _b !== -1) return _a - _b
26
+ if (_a !== -1) return -1
27
+ if (_b !== -1) return 1
28
+ return a.localeCompare(b)
29
+ })
30
+
31
+ return ret
32
+ }
33
+
34
+ export interface SemanticTokenProps {
35
+ name: string
36
+ tokens: Record<string, ColorToken>
37
+ }
38
+
39
+ export function SemanticToken(props: SemanticTokenProps) {
40
+ const { name, tokens } = props
41
+
42
+ const conditions: string[] = []
43
+ if (tokens.extensions.conditions) {
44
+ conditions.push(...sortSemanticTokens(Object.keys(tokens.extensions.conditions)))
45
+ }
46
+
47
+ return (
48
+ <Stack gap="2" width="full">
49
+ <HStack gap="1">
50
+ {conditions.map((cond) => (
51
+ <SemanticColorDisplay
52
+ key={cond}
53
+ value={tokens[cond].value}
54
+ condition={cond}
55
+ token={getColorFromReference(tokens.extensions.conditions![cond])}
56
+ />
57
+ ))}
58
+ </HStack>
59
+ <panda.span fontWeight="semibold">{name}</panda.span>
60
+ </Stack>
61
+ )
62
+ }
63
+
18
64
  export default function Colors() {
19
65
  const { filterQuery, setFilterQuery, semanticTokens, hasResults, uncategorizedColors, categorizedColors } =
20
66
  useColorDocs()
21
67
 
22
- const renderSemanticTokens = () => {
23
- return semanticTokens.map(([name, colors], i) => {
24
- return (
25
- <Stack gap="2" key={i} width="full">
26
- <HStack gap="1">
27
- <SemanticColorDisplay
28
- value={colors.base.value}
29
- condition="base"
30
- token={getColorFromReference(colors.extensions.conditions!.base)}
31
- />
32
- <SemanticColorDisplay
33
- value={colors[colors.extensions.condition!].value}
34
- condition={colors.extensions.condition!}
35
- token={getColorFromReference(colors.extensions.conditions![colors.extensions.condition!])}
36
- />
37
- </HStack>
38
-
39
- <panda.span fontWeight="semibold">{name}</panda.span>
40
- </Stack>
41
- )
42
- })
43
- }
44
-
45
68
  return (
46
69
  <TokenGroup>
47
70
  <StickyTop>
@@ -60,7 +83,13 @@ export default function Colors() {
60
83
 
61
84
  <ColorGroup title={UNCATEGORIZED_ID} colors={uncategorizedColors} />
62
85
 
63
- {!!semanticTokens.length && <ColorGroup title="Semantic Tokens">{renderSemanticTokens()}</ColorGroup>}
86
+ {!!semanticTokens.length && (
87
+ <ColorGroup title="Semantic Tokens">
88
+ {semanticTokens.map(([name, colors], i) => (
89
+ <SemanticToken key={i} name={name} tokens={colors} />
90
+ ))}
91
+ </ColorGroup>
92
+ )}
64
93
 
65
94
  {!hasResults && <div>No result found! 🐼</div>}
66
95
  </Stack>
@@ -10,7 +10,7 @@ interface Color {
10
10
  path: string[]
11
11
  }
12
12
 
13
- type ColorToken = Token & Color & TokenExtensions
13
+ export type ColorToken = Token & Color & TokenExtensions
14
14
 
15
15
  const UNCATEGORIZED_ID = 'uncategorized' as const
16
16
 
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "extends": "astro/tsconfigs/strict",
3
- "include": ["src"],
3
+ "include": ["src", "__tests__"],
4
4
  "compilerOptions": {
5
5
  "jsx": "preserve",
6
6
  "customConditions": ["source"]