@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.
- package/LICENSE.md +21 -0
- package/astro.config.ts +14 -0
- package/dist/studio.d.ts +13 -0
- package/dist/studio.js +2089 -0
- package/dist/studio.mjs +2087 -0
- package/index.ts +1 -0
- package/package.json +59 -0
- package/panda.config.ts +110 -0
- package/public/favicon.svg +13 -0
- package/src/components/analyzer/category-utilities.tsx +146 -0
- package/src/components/analyzer/data-combobox.tsx +125 -0
- package/src/components/analyzer/data-table.tsx +43 -0
- package/src/components/analyzer/external-icon.tsx +8 -0
- package/src/components/analyzer/file-details.tsx +101 -0
- package/src/components/analyzer/get-report-infos-from.ts +80 -0
- package/src/components/analyzer/quick-tooltip.tsx +15 -0
- package/src/components/analyzer/report-item-columns.tsx +52 -0
- package/src/components/analyzer/report-item-link.tsx +98 -0
- package/src/components/analyzer/section.tsx +24 -0
- package/src/components/analyzer/sort-icon.tsx +7 -0
- package/src/components/analyzer/text-with-count.tsx +28 -0
- package/src/components/analyzer/token-search-combobox.tsx +39 -0
- package/src/components/analyzer/truncated-text.tsx +26 -0
- package/src/components/analyzer/utility-details.tsx +312 -0
- package/src/components/color-constrast.tsx +131 -0
- package/src/components/color-item.tsx +37 -0
- package/src/components/color-wrapper.tsx +25 -0
- package/src/components/colors.tsx +96 -0
- package/src/components/empty-state.tsx +19 -0
- package/src/components/font-family.tsx +55 -0
- package/src/components/font-tokens.tsx +69 -0
- package/src/components/head.astro +35 -0
- package/src/components/icons.tsx +207 -0
- package/src/components/input.tsx +27 -0
- package/src/components/layer-styles.tsx +38 -0
- package/src/components/logo.tsx +34 -0
- package/src/components/nav-item.tsx +39 -0
- package/src/components/overview.tsx +65 -0
- package/src/components/radii.tsx +34 -0
- package/src/components/semantic-color.tsx +27 -0
- package/src/components/side-nav-item.astro +25 -0
- package/src/components/side-nav.astro +30 -0
- package/src/components/sizes.tsx +53 -0
- package/src/components/text-styles.tsx +33 -0
- package/src/components/theme-toggle.astro +56 -0
- package/src/components/token-analyzer.tsx +390 -0
- package/src/components/token-content.tsx +5 -0
- package/src/components/token-group.tsx +6 -0
- package/src/components/typography-playground.tsx +83 -0
- package/src/env.d.ts +1 -0
- package/src/icons/moon.tsx +15 -0
- package/src/icons/sun.tsx +19 -0
- package/src/layouts/Layout.astro +19 -0
- package/src/layouts/Sidebar.astro +35 -0
- package/src/lib/analysis-data.ts +17 -0
- package/src/lib/color-contrast-checker.ts +218 -0
- package/src/lib/color.ts +40 -0
- package/src/lib/constants.ts +140 -0
- package/src/lib/create-context.ts +27 -0
- package/src/lib/get-report-item.tsx +41 -0
- package/src/lib/group-in.ts +35 -0
- package/src/lib/panda.context.ts +23 -0
- package/src/lib/pick.ts +24 -0
- package/src/lib/sizes-sort.ts +10 -0
- package/src/lib/truncate.tsx +7 -0
- package/src/lib/use-color-docs.ts +101 -0
- package/src/pages/colors.astro +11 -0
- package/src/pages/font-sizes.astro +15 -0
- package/src/pages/font-weights.astro +15 -0
- package/src/pages/fonts.astro +11 -0
- package/src/pages/index.astro +8 -0
- package/src/pages/layer-styles.astro +11 -0
- package/src/pages/letter-spacings.astro +20 -0
- package/src/pages/line-heights.astro +21 -0
- package/src/pages/playground/contrast-checker.astro +11 -0
- package/src/pages/playground/typography.astro +11 -0
- package/src/pages/radii.astro +11 -0
- package/src/pages/sizes.astro +14 -0
- package/src/pages/spacing.astro +14 -0
- package/src/pages/text-styles.astro +11 -0
- package/src/pages/token-analyzer/file.astro +11 -0
- package/src/pages/token-analyzer/index.astro +11 -0
- package/src/pages/token-analyzer/utility.astro +11 -0
- package/styled-system/chunks/..__core____tests____composition.test.css +2 -0
- package/styled-system/chunks/src__components__analyzer__category-utilities.css +97 -0
- package/styled-system/chunks/src__components__analyzer__data-combobox.css +77 -0
- package/styled-system/chunks/src__components__analyzer__data-table.css +37 -0
- package/styled-system/chunks/src__components__analyzer__file-details.css +103 -0
- package/styled-system/chunks/src__components__analyzer__quick-tooltip.css +2 -0
- package/styled-system/chunks/src__components__analyzer__report-item-columns.css +29 -0
- package/styled-system/chunks/src__components__analyzer__report-item-link.css +109 -0
- package/styled-system/chunks/src__components__analyzer__section.css +29 -0
- package/styled-system/chunks/src__components__analyzer__text-with-count.css +33 -0
- package/styled-system/chunks/src__components__analyzer__truncated-text.css +13 -0
- package/styled-system/chunks/src__components__analyzer__utility-details.css +125 -0
- package/styled-system/chunks/src__components__color-constrast.css +114 -0
- package/styled-system/chunks/src__components__color-item.css +21 -0
- package/styled-system/chunks/src__components__color-wrapper.css +73 -0
- package/styled-system/chunks/src__components__colors.css +97 -0
- package/styled-system/chunks/src__components__empty-state.css +45 -0
- package/styled-system/chunks/src__components__font-family.css +85 -0
- package/styled-system/chunks/src__components__font-tokens.css +61 -0
- package/styled-system/chunks/src__components__input.css +68 -0
- package/styled-system/chunks/src__components__layer-styles.css +66 -0
- package/styled-system/chunks/src__components__nav-item.css +73 -0
- package/styled-system/chunks/src__components__overview.css +125 -0
- package/styled-system/chunks/src__components__radii.css +49 -0
- package/styled-system/chunks/src__components__semantic-color.css +45 -0
- package/styled-system/chunks/src__components__side-nav-item.css +33 -0
- package/styled-system/chunks/src__components__side-nav.css +49 -0
- package/styled-system/chunks/src__components__sizes.css +41 -0
- package/styled-system/chunks/src__components__text-styles.css +31 -0
- package/styled-system/chunks/src__components__theme-toggle.css +63 -0
- package/styled-system/chunks/src__components__token-analyzer.css +227 -0
- package/styled-system/chunks/src__components__token-content.css +13 -0
- package/styled-system/chunks/src__components__token-group.css +21 -0
- package/styled-system/chunks/src__components__token-search-combobox.css +2 -0
- package/styled-system/chunks/src__components__typography-playground.css +61 -0
- package/styled-system/chunks/src__layouts__Layout.css +2 -0
- package/styled-system/chunks/src__layouts__Sidebar.css +113 -0
- package/styled-system/chunks/src__pages__colors.css +2 -0
- package/styled-system/chunks/src__pages__font-sizes.css +2 -0
- package/styled-system/chunks/src__pages__font-weights.css +2 -0
- package/styled-system/chunks/src__pages__fonts.css +2 -0
- package/styled-system/chunks/src__pages__index.css +2 -0
- package/styled-system/chunks/src__pages__layer-styles.css +2 -0
- package/styled-system/chunks/src__pages__letter-spacings.css +2 -0
- package/styled-system/chunks/src__pages__line-heights.css +2 -0
- package/styled-system/chunks/src__pages__playground__contrast-checker.css +2 -0
- package/styled-system/chunks/src__pages__playground__typography.css +2 -0
- package/styled-system/chunks/src__pages__radii.css +2 -0
- package/styled-system/chunks/src__pages__sizes.css +2 -0
- package/styled-system/chunks/src__pages__spacing.css +2 -0
- package/styled-system/chunks/src__pages__text-styles.css +2 -0
- package/styled-system/chunks/src__pages__token-analyzer__file.css +2 -0
- package/styled-system/chunks/src__pages__token-analyzer__index.css +2 -0
- package/styled-system/chunks/src__pages__token-analyzer__utility.css +2 -0
- package/styled-system/css/conditions.mjs +147 -0
- package/styled-system/css/css.d.ts +2 -0
- package/styled-system/css/css.mjs +391 -0
- package/styled-system/css/cva.d.ts +5 -0
- package/styled-system/css/cva.mjs +63 -0
- package/styled-system/css/cx.d.ts +4 -0
- package/styled-system/css/cx.mjs +15 -0
- package/styled-system/css/index.d.ts +3 -0
- package/styled-system/css/index.mjs +3 -0
- package/styled-system/global.css +61 -0
- package/styled-system/helpers.mjs +251 -0
- package/styled-system/jsx/absolute-center.d.ts +8 -0
- package/styled-system/jsx/absolute-center.mjs +9 -0
- package/styled-system/jsx/aspect-ratio.d.ts +8 -0
- package/styled-system/jsx/aspect-ratio.mjs +9 -0
- package/styled-system/jsx/box.d.ts +8 -0
- package/styled-system/jsx/box.mjs +8 -0
- package/styled-system/jsx/center.d.ts +8 -0
- package/styled-system/jsx/center.mjs +9 -0
- package/styled-system/jsx/circle.d.ts +8 -0
- package/styled-system/jsx/circle.mjs +9 -0
- package/styled-system/jsx/container.d.ts +8 -0
- package/styled-system/jsx/container.mjs +8 -0
- package/styled-system/jsx/divider.d.ts +8 -0
- package/styled-system/jsx/divider.mjs +9 -0
- package/styled-system/jsx/factory.d.ts +2 -0
- package/styled-system/jsx/factory.mjs +59 -0
- package/styled-system/jsx/flex.d.ts +8 -0
- package/styled-system/jsx/flex.mjs +9 -0
- package/styled-system/jsx/float.d.ts +8 -0
- package/styled-system/jsx/float.mjs +9 -0
- package/styled-system/jsx/grid-item.d.ts +8 -0
- package/styled-system/jsx/grid-item.mjs +9 -0
- package/styled-system/jsx/grid.d.ts +8 -0
- package/styled-system/jsx/grid.mjs +9 -0
- package/styled-system/jsx/hstack.d.ts +8 -0
- package/styled-system/jsx/hstack.mjs +9 -0
- package/styled-system/jsx/index.d.ts +20 -0
- package/styled-system/jsx/index.mjs +19 -0
- package/styled-system/jsx/is-valid-prop.mjs +1010 -0
- package/styled-system/jsx/spacer.d.ts +8 -0
- package/styled-system/jsx/spacer.mjs +9 -0
- package/styled-system/jsx/square.d.ts +8 -0
- package/styled-system/jsx/square.mjs +9 -0
- package/styled-system/jsx/stack.d.ts +8 -0
- package/styled-system/jsx/stack.mjs +9 -0
- package/styled-system/jsx/styled-link.d.ts +8 -0
- package/styled-system/jsx/styled-link.mjs +8 -0
- package/styled-system/jsx/vstack.d.ts +8 -0
- package/styled-system/jsx/vstack.mjs +9 -0
- package/styled-system/jsx/wrap.d.ts +8 -0
- package/styled-system/jsx/wrap.mjs +9 -0
- package/styled-system/patterns/absolute-center.d.ts +14 -0
- package/styled-system/patterns/absolute-center.mjs +23 -0
- package/styled-system/patterns/aspect-ratio.d.ts +14 -0
- package/styled-system/patterns/aspect-ratio.mjs +25 -0
- package/styled-system/patterns/box.d.ts +14 -0
- package/styled-system/patterns/box.mjs +12 -0
- package/styled-system/patterns/center.d.ts +14 -0
- package/styled-system/patterns/center.mjs +18 -0
- package/styled-system/patterns/circle.d.ts +14 -0
- package/styled-system/patterns/circle.mjs +22 -0
- package/styled-system/patterns/container.d.ts +14 -0
- package/styled-system/patterns/container.mjs +18 -0
- package/styled-system/patterns/divider.d.ts +16 -0
- package/styled-system/patterns/divider.mjs +21 -0
- package/styled-system/patterns/flex.d.ts +20 -0
- package/styled-system/patterns/flex.mjs +23 -0
- package/styled-system/patterns/float.d.ts +17 -0
- package/styled-system/patterns/float.mjs +45 -0
- package/styled-system/patterns/grid-item.d.ts +19 -0
- package/styled-system/patterns/grid-item.mjs +20 -0
- package/styled-system/patterns/grid.d.ts +18 -0
- package/styled-system/patterns/grid.mjs +25 -0
- package/styled-system/patterns/hstack.d.ts +15 -0
- package/styled-system/patterns/hstack.mjs +20 -0
- package/styled-system/patterns/index.d.ts +18 -0
- package/styled-system/patterns/index.mjs +18 -0
- package/styled-system/patterns/spacer.d.ts +14 -0
- package/styled-system/patterns/spacer.mjs +18 -0
- package/styled-system/patterns/square.d.ts +14 -0
- package/styled-system/patterns/square.mjs +21 -0
- package/styled-system/patterns/stack.d.ts +17 -0
- package/styled-system/patterns/stack.mjs +20 -0
- package/styled-system/patterns/styled-link.d.ts +14 -0
- package/styled-system/patterns/styled-link.mjs +18 -0
- package/styled-system/patterns/vstack.d.ts +15 -0
- package/styled-system/patterns/vstack.mjs +20 -0
- package/styled-system/patterns/wrap.d.ts +18 -0
- package/styled-system/patterns/wrap.mjs +22 -0
- package/styled-system/reset.css +190 -0
- package/styled-system/static.css +5 -0
- package/styled-system/styles.css +938 -0
- package/styled-system/tokens/index.css +374 -0
- package/styled-system/tokens/index.d.ts +8 -0
- package/styled-system/tokens/index.mjs +1590 -0
- package/styled-system/tokens/keyframes.css +30 -0
- package/styled-system/tokens/tokens.d.ts +56 -0
- package/styled-system/types/composition.d.ts +110 -0
- package/styled-system/types/conditions.d.ts +135 -0
- package/styled-system/types/csstype.d.ts +20748 -0
- package/styled-system/types/global.d.ts +15 -0
- package/styled-system/types/helpers.d.ts +1 -0
- package/styled-system/types/index.d.ts +3 -0
- package/styled-system/types/jsx.d.ts +27 -0
- package/styled-system/types/parts.d.ts +5 -0
- package/styled-system/types/pattern.d.ts +52 -0
- package/styled-system/types/prop-type.d.ts +300 -0
- package/styled-system/types/recipe.d.ts +79 -0
- package/styled-system/types/selectors.d.ts +56 -0
- package/styled-system/types/style-props.d.ts +688 -0
- package/styled-system/types/system-types.d.ts +76 -0
- package/virtual-panda.ts +72 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { css, cx } from '../../styled-system/css'
|
|
2
|
+
import { panda, Stack, Wrap } from '../../styled-system/jsx'
|
|
3
|
+
import { analysisData } from '../lib/analysis-data'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Portal,
|
|
7
|
+
Select,
|
|
8
|
+
SelectContent,
|
|
9
|
+
SelectLabel,
|
|
10
|
+
SelectOption,
|
|
11
|
+
SelectPositioner,
|
|
12
|
+
SelectTrigger,
|
|
13
|
+
Tooltip,
|
|
14
|
+
TooltipContent,
|
|
15
|
+
TooltipPositioner,
|
|
16
|
+
TooltipTrigger,
|
|
17
|
+
} from '@ark-ui/react'
|
|
18
|
+
|
|
19
|
+
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@ark-ui/react'
|
|
20
|
+
import { stack } from '../../styled-system/patterns/stack'
|
|
21
|
+
|
|
22
|
+
import { styledLink } from '../../styled-system/patterns'
|
|
23
|
+
import { getReportItem, getUtilityLink, getReportRelativeFilePath, getFileLink } from '../lib/get-report-item'
|
|
24
|
+
import { pick } from '../lib/pick'
|
|
25
|
+
import { ReportItemLink } from './analyzer/report-item-link'
|
|
26
|
+
import { Section } from './analyzer/section'
|
|
27
|
+
import { TextWithCount } from './analyzer/text-with-count'
|
|
28
|
+
import { TruncatedText } from './analyzer/truncated-text'
|
|
29
|
+
import { ByCategory } from './analyzer/category-utilities'
|
|
30
|
+
import { ColorItem } from './color-item'
|
|
31
|
+
import { TokenSearchCombobox } from './analyzer/token-search-combobox'
|
|
32
|
+
import { useState } from 'react'
|
|
33
|
+
import { SortIcon } from './analyzer/sort-icon'
|
|
34
|
+
|
|
35
|
+
export function TokenAnalyzer() {
|
|
36
|
+
// console.log(tokenDictionary)
|
|
37
|
+
// console.log(analysisData)
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className={css({ width: '100%', py: '20px', debug: false })}>
|
|
41
|
+
<panda.div px="24" w="100%">
|
|
42
|
+
<HeadlineSummary />
|
|
43
|
+
<TokenSearchCombobox />
|
|
44
|
+
<MostUsedList />
|
|
45
|
+
<ColorPalette />
|
|
46
|
+
<ByCategory byCategory={analysisData.details.globalMaps.byCategory} />
|
|
47
|
+
<FilesAccordionList />
|
|
48
|
+
</panda.div>
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const [topKind, secondKind] = analysisData.stats.mostUseds.instanceOfKinds
|
|
54
|
+
|
|
55
|
+
const values = Object.values(analysisData.details.byId)
|
|
56
|
+
const withImportant = values.filter((reportItem) => String(reportItem.value).endsWith('!'))
|
|
57
|
+
|
|
58
|
+
const knownValues = values.filter((reportItem) => reportItem.isKnown)
|
|
59
|
+
const unknownValuesCount = values.length - knownValues.length
|
|
60
|
+
const formater = new Intl.NumberFormat('en-US', {
|
|
61
|
+
maximumFractionDigits: 2,
|
|
62
|
+
minimumFractionDigits: 2,
|
|
63
|
+
style: 'percent',
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const HeadlineSummary = () => {
|
|
67
|
+
return (
|
|
68
|
+
<Stack mb="4" direction="column" align="center" p="20px" fontSize="lg">
|
|
69
|
+
<div>
|
|
70
|
+
<panda.span fontSize="xl" fontWeight="bold">
|
|
71
|
+
{Object.keys(analysisData.details.byId).length}
|
|
72
|
+
</panda.span>{' '}
|
|
73
|
+
token usage including{' '}
|
|
74
|
+
<panda.span fontSize="xl" fontWeight="bold">
|
|
75
|
+
<panda.a className={styledLink({})} href={getUtilityLink({ category: 'colors' })}>
|
|
76
|
+
{analysisData.counts.colorsUsed}
|
|
77
|
+
</panda.a>
|
|
78
|
+
</panda.span>{' '}
|
|
79
|
+
colors found in{' '}
|
|
80
|
+
<panda.span fontSize="xl" fontWeight="bold">
|
|
81
|
+
{analysisData.counts.filesWithTokens}
|
|
82
|
+
</panda.span>{' '}
|
|
83
|
+
files
|
|
84
|
+
</div>
|
|
85
|
+
<panda.div fontSize="md">
|
|
86
|
+
with{' '}
|
|
87
|
+
<Tooltip openDelay={0} closeDelay={100} positioning={{ placement: 'bottom-start', gutter: 20 }}>
|
|
88
|
+
<TooltipTrigger>
|
|
89
|
+
<span>
|
|
90
|
+
<panda.span fontSize="lg" fontWeight="bold">
|
|
91
|
+
{analysisData.fileSizes.gzip.minified}
|
|
92
|
+
</panda.span>{' '}
|
|
93
|
+
KB corresponding CSS generated (min+gzip)
|
|
94
|
+
</span>
|
|
95
|
+
</TooltipTrigger>
|
|
96
|
+
<Portal>
|
|
97
|
+
<TooltipPositioner>
|
|
98
|
+
<TooltipContent>
|
|
99
|
+
<panda.span p="2" bg="gray.100" border="1px solid rgba(0, 0, 0, 0.1)" rounded="md">
|
|
100
|
+
<panda.span fontSize="lg" fontWeight="bold">
|
|
101
|
+
{analysisData.fileSizes.normal}
|
|
102
|
+
</panda.span>{' '}
|
|
103
|
+
(unmin+uncompressed)
|
|
104
|
+
</panda.span>
|
|
105
|
+
</TooltipContent>
|
|
106
|
+
</TooltipPositioner>
|
|
107
|
+
</Portal>
|
|
108
|
+
</Tooltip>
|
|
109
|
+
</panda.div>
|
|
110
|
+
{topKind && (
|
|
111
|
+
<panda.div fontSize="md">
|
|
112
|
+
<span>Mostly </span>
|
|
113
|
+
{
|
|
114
|
+
<TextWithCount display="inline-block" count={topKind.count}>
|
|
115
|
+
{topKind.key === 'function' ? 'using functions' : 'using style props'}
|
|
116
|
+
</TextWithCount>
|
|
117
|
+
}
|
|
118
|
+
{secondKind && (
|
|
119
|
+
<>
|
|
120
|
+
, and others{' '}
|
|
121
|
+
<TextWithCount display="inline-block" count={secondKind.count}>
|
|
122
|
+
{secondKind.key === 'function' ? 'using functions' : 'using style props'}.
|
|
123
|
+
</TextWithCount>
|
|
124
|
+
</>
|
|
125
|
+
)}
|
|
126
|
+
</panda.div>
|
|
127
|
+
)}
|
|
128
|
+
<panda.div fontSize="sm">
|
|
129
|
+
<span>
|
|
130
|
+
With{' '}
|
|
131
|
+
<panda.span fontSize="md" fontWeight="bold">
|
|
132
|
+
{unknownValuesCount}
|
|
133
|
+
</panda.span>{' '}
|
|
134
|
+
unknown token values (
|
|
135
|
+
<panda.span fontSize="md" fontWeight="bold">
|
|
136
|
+
{formater.format(unknownValuesCount / values.length)}
|
|
137
|
+
</panda.span>
|
|
138
|
+
) and{' '}
|
|
139
|
+
<panda.span fontSize="md" fontWeight="bold">
|
|
140
|
+
{withImportant.length}
|
|
141
|
+
</panda.span>{' '}
|
|
142
|
+
values marked as important (
|
|
143
|
+
<panda.span fontSize="md" fontWeight="bold">
|
|
144
|
+
{formater.format(withImportant.length / values.length)}
|
|
145
|
+
</panda.span>
|
|
146
|
+
)
|
|
147
|
+
</span>
|
|
148
|
+
</panda.div>
|
|
149
|
+
</Stack>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const selectOptionClass = css({
|
|
154
|
+
padding: '4px 8px',
|
|
155
|
+
bg: 'white',
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
const MostUsedList = () => {
|
|
159
|
+
return (
|
|
160
|
+
<>
|
|
161
|
+
<Select defaultValue={{ label: 'tokens', value: 'tokens' }}>
|
|
162
|
+
{({ selectedOption }) => (
|
|
163
|
+
<Section
|
|
164
|
+
title={
|
|
165
|
+
<>
|
|
166
|
+
<SelectLabel>Top 10 </SelectLabel>
|
|
167
|
+
<SelectTrigger>
|
|
168
|
+
<button>{selectedOption?.label}</button>
|
|
169
|
+
</SelectTrigger>
|
|
170
|
+
</>
|
|
171
|
+
}
|
|
172
|
+
bg="gray.50"
|
|
173
|
+
>
|
|
174
|
+
{mostUsedByName[selectedOption?.value as keyof typeof mostUsedByName]}
|
|
175
|
+
<>
|
|
176
|
+
<Portal>
|
|
177
|
+
<SelectPositioner>
|
|
178
|
+
<SelectContent className={cx(selectOptionClass, css({ listStyle: 'none' }))}>
|
|
179
|
+
<SelectOption className={selectOptionClass} value="tokens" label="tokens" />
|
|
180
|
+
<SelectOption className={selectOptionClass} value="properties" label="properties" />
|
|
181
|
+
<SelectOption className={selectOptionClass} value="categories" label="categories" />
|
|
182
|
+
<SelectOption className={selectOptionClass} value="conditions" label="conditions" />
|
|
183
|
+
<SelectOption className={selectOptionClass} value="propertyPaths" label="property paths" />
|
|
184
|
+
<SelectOption className={selectOptionClass} value="shorthands" label="shorthands" />
|
|
185
|
+
<SelectOption className={selectOptionClass} value="instances" label="instances" />
|
|
186
|
+
<SelectOption className={selectOptionClass} value="types" label="types" />
|
|
187
|
+
</SelectContent>
|
|
188
|
+
</SelectPositioner>
|
|
189
|
+
</Portal>
|
|
190
|
+
</>
|
|
191
|
+
</Section>
|
|
192
|
+
)}
|
|
193
|
+
</Select>
|
|
194
|
+
</>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const MostUsedItem = ({
|
|
199
|
+
entries,
|
|
200
|
+
}: {
|
|
201
|
+
entries: Array<{
|
|
202
|
+
key: string
|
|
203
|
+
count: number
|
|
204
|
+
}>
|
|
205
|
+
}) => {
|
|
206
|
+
return (
|
|
207
|
+
<Wrap gap="4" fontSize="sm">
|
|
208
|
+
{entries.map(({ key, count }) => {
|
|
209
|
+
return (
|
|
210
|
+
<panda.a className={styledLink({})} key={key} href={getUtilityLink({ value: key })}>
|
|
211
|
+
<TextWithCount count={count}>{key}</TextWithCount>
|
|
212
|
+
</panda.a>
|
|
213
|
+
)
|
|
214
|
+
})}
|
|
215
|
+
</Wrap>
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const mostUsedByName = {
|
|
220
|
+
tokens: <MostUsedItem entries={analysisData.stats.mostUseds.tokens} />,
|
|
221
|
+
properties: <MostUsedItem entries={analysisData.stats.mostUseds.propNames} />,
|
|
222
|
+
shorthands: <MostUsedItem entries={analysisData.stats.mostUseds.shorthands} />,
|
|
223
|
+
categories: <MostUsedItem entries={analysisData.stats.mostUseds.categories} />,
|
|
224
|
+
conditions: <MostUsedItem entries={analysisData.stats.mostUseds.conditions} />,
|
|
225
|
+
propertyPaths: <MostUsedItem entries={analysisData.stats.mostUseds.propertyPaths} />,
|
|
226
|
+
instances: <MostUsedItem entries={analysisData.stats.mostUseds.instanceNames} />,
|
|
227
|
+
types: <MostUsedItem entries={analysisData.stats.mostUseds.types} />,
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const ColorPalette = () => {
|
|
231
|
+
return (
|
|
232
|
+
<Section
|
|
233
|
+
title={<TextWithCount count={analysisData.stats.mostUseds.colors.length}>Color palette</TextWithCount>}
|
|
234
|
+
bg="gray.50"
|
|
235
|
+
>
|
|
236
|
+
<Wrap gap="2" fontSize="sm">
|
|
237
|
+
{analysisData.stats.mostUseds.colors.map(({ key, count }) => (
|
|
238
|
+
<ColorItem
|
|
239
|
+
tokenName={key}
|
|
240
|
+
key={key}
|
|
241
|
+
py="2"
|
|
242
|
+
px="4"
|
|
243
|
+
transition="all 0.2s ease"
|
|
244
|
+
_hover={{ bgColor: 'gray.100' }}
|
|
245
|
+
>
|
|
246
|
+
<TextWithCount count={count}>
|
|
247
|
+
<TruncatedText text={key} />
|
|
248
|
+
</TextWithCount>
|
|
249
|
+
</ColorItem>
|
|
250
|
+
))}
|
|
251
|
+
</Wrap>
|
|
252
|
+
</Section>
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const FilesAccordionList = () => {
|
|
257
|
+
const entries = Object.entries(analysisData.details.byFilepath)
|
|
258
|
+
|
|
259
|
+
const [sortedBy, setSortedBy] = useState<'name' | 'tokens count' | 'file path'>('file path')
|
|
260
|
+
const sorted = entries.sort((a, b) => {
|
|
261
|
+
if (sortedBy === 'name') {
|
|
262
|
+
return a[0].localeCompare(b[0])
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (sortedBy === 'tokens count') {
|
|
266
|
+
return b[1].length - a[1].length
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return 0
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<Section
|
|
274
|
+
p="0"
|
|
275
|
+
title={<TextWithCount count={sorted.length}>Files</TextWithCount>}
|
|
276
|
+
subTitle={
|
|
277
|
+
<panda.div ml="auto">
|
|
278
|
+
<Select onChange={(option) => setSortedBy((option?.value as any) ?? 'file path')}>
|
|
279
|
+
{({ selectedOption }) => (
|
|
280
|
+
<>
|
|
281
|
+
<SelectTrigger>
|
|
282
|
+
<panda.button display="flex" alignItems="center">
|
|
283
|
+
Sort by {selectedOption?.label}
|
|
284
|
+
<panda.div w="26px" ml="2">
|
|
285
|
+
<SortIcon />
|
|
286
|
+
</panda.div>
|
|
287
|
+
</panda.button>
|
|
288
|
+
</SelectTrigger>
|
|
289
|
+
<Portal>
|
|
290
|
+
<SelectPositioner>
|
|
291
|
+
<SelectContent className={cx(selectOptionClass, css({ listStyle: 'none' }))}>
|
|
292
|
+
<SelectOption className={selectOptionClass} value="name" label="name" />
|
|
293
|
+
<SelectOption className={selectOptionClass} value="tokens count" label="tokens count" />
|
|
294
|
+
<SelectOption className={selectOptionClass} value="file path" label="file path" />
|
|
295
|
+
</SelectContent>
|
|
296
|
+
</SelectPositioner>
|
|
297
|
+
</Portal>
|
|
298
|
+
</>
|
|
299
|
+
)}
|
|
300
|
+
</Select>
|
|
301
|
+
</panda.div>
|
|
302
|
+
}
|
|
303
|
+
>
|
|
304
|
+
<Accordion className={stack({ gap: '2', px: '2', fontSize: 'sm', width: 'full', debug: false })} multiple>
|
|
305
|
+
{sorted.map(([filepath, reportItemIdList]) => {
|
|
306
|
+
const values = reportItemIdList.map(getReportItem)
|
|
307
|
+
const localMaps =
|
|
308
|
+
analysisData.details.byFilePathMaps[filepath as keyof typeof analysisData.details.byFilePathMaps]
|
|
309
|
+
const colors = Object.entries(localMaps.colorsUsed)
|
|
310
|
+
// console.log(localMaps, values)
|
|
311
|
+
|
|
312
|
+
return (
|
|
313
|
+
<AccordionItem
|
|
314
|
+
key={filepath}
|
|
315
|
+
value={filepath}
|
|
316
|
+
className={css({
|
|
317
|
+
p: '4',
|
|
318
|
+
width: 'full',
|
|
319
|
+
rounded: 'md',
|
|
320
|
+
_hover: { bgColor: 'gray.50' },
|
|
321
|
+
cursor: 'pointer',
|
|
322
|
+
})}
|
|
323
|
+
>
|
|
324
|
+
{(props) => (
|
|
325
|
+
<>
|
|
326
|
+
<AccordionTrigger>
|
|
327
|
+
<panda.button display="flex" bg="none" w="full" p="2" cursor="pointer">
|
|
328
|
+
<panda.a
|
|
329
|
+
className={styledLink({})}
|
|
330
|
+
href={getFileLink({ filepath })}
|
|
331
|
+
onClick={(e) => e.stopPropagation()}
|
|
332
|
+
>
|
|
333
|
+
<TextWithCount key={filepath} count={reportItemIdList.length}>
|
|
334
|
+
{getReportRelativeFilePath(filepath)}
|
|
335
|
+
</TextWithCount>
|
|
336
|
+
</panda.a>
|
|
337
|
+
<panda.div ml="auto" mb="4">
|
|
338
|
+
<panda.span fontWeight="bold">{values.length}</panda.span> utilities and{' '}
|
|
339
|
+
<panda.span fontWeight="bold">{Object.keys(localMaps.colorsUsed).length}</panda.span> colors
|
|
340
|
+
used
|
|
341
|
+
</panda.div>
|
|
342
|
+
<panda.span ml="2">{props.isOpen ? '▲' : '▼'}</panda.span>
|
|
343
|
+
</panda.button>
|
|
344
|
+
</AccordionTrigger>
|
|
345
|
+
<AccordionContent className={css({ p: '2' })}>
|
|
346
|
+
<panda.div>
|
|
347
|
+
<panda.h5>Utilities</panda.h5>
|
|
348
|
+
<Wrap gap="2" mt="4">
|
|
349
|
+
{values.map((reportItem) => (
|
|
350
|
+
<ReportItemLink
|
|
351
|
+
key={reportItem.id}
|
|
352
|
+
{...pick(reportItem, ['value', 'propName', 'filepath'])}
|
|
353
|
+
/>
|
|
354
|
+
))}
|
|
355
|
+
</Wrap>
|
|
356
|
+
</panda.div>
|
|
357
|
+
|
|
358
|
+
{colors.length ? (
|
|
359
|
+
<panda.div mt="8">
|
|
360
|
+
<panda.h5>
|
|
361
|
+
<TextWithCount count={colors.length}>Color palette</TextWithCount>
|
|
362
|
+
</panda.h5>
|
|
363
|
+
<Wrap gap="2" mt="4">
|
|
364
|
+
{colors.map(([key]) => {
|
|
365
|
+
return (
|
|
366
|
+
<ColorItem
|
|
367
|
+
tokenName={key}
|
|
368
|
+
key={key}
|
|
369
|
+
py="2"
|
|
370
|
+
px="4"
|
|
371
|
+
transition="all 0.2s ease"
|
|
372
|
+
_hover={{ bg: 'gray.100' }}
|
|
373
|
+
>
|
|
374
|
+
<TruncatedText text={key} />
|
|
375
|
+
</ColorItem>
|
|
376
|
+
)
|
|
377
|
+
})}
|
|
378
|
+
</Wrap>
|
|
379
|
+
</panda.div>
|
|
380
|
+
) : null}
|
|
381
|
+
</AccordionContent>
|
|
382
|
+
</>
|
|
383
|
+
)}
|
|
384
|
+
</AccordionItem>
|
|
385
|
+
)
|
|
386
|
+
})}
|
|
387
|
+
</Accordion>
|
|
388
|
+
</Section>
|
|
389
|
+
)
|
|
390
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HTMLPandaProps } from '../../styled-system/jsx'
|
|
2
|
+
import { panda } from '../../styled-system/jsx'
|
|
3
|
+
|
|
4
|
+
export function TokenGroup(props: HTMLPandaProps<'div'>) {
|
|
5
|
+
return <panda.div display="flex" flexDir="column" gap="3" width="full" marginTop="5" {...props} />
|
|
6
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Stack, panda } from '../../styled-system/jsx'
|
|
3
|
+
import context from '../lib/panda.context'
|
|
4
|
+
import { TokenContent } from './token-content'
|
|
5
|
+
import { TokenGroup } from './token-group'
|
|
6
|
+
|
|
7
|
+
const getFirstToken = <T extends Map<string, any>>(token: T) => Array.from(token.values())[0].extensions.prop
|
|
8
|
+
const tokens = Object.fromEntries(context.tokens.categoryMap)
|
|
9
|
+
|
|
10
|
+
const defaultConfig = {
|
|
11
|
+
fontSize: getFirstToken(tokens.fontSizes),
|
|
12
|
+
letterSpacing: getFirstToken(tokens.letterSpacings),
|
|
13
|
+
fontWeight: getFirstToken(tokens.fontWeights),
|
|
14
|
+
lineHeight: getFirstToken(tokens.lineHeights),
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function TypographyPlayground() {
|
|
18
|
+
const [config, setConfig] = useState(defaultConfig)
|
|
19
|
+
const configValues = Object.entries(config).reduce(
|
|
20
|
+
(acc, [token, label]) => ({
|
|
21
|
+
...acc,
|
|
22
|
+
[token]: tokens[`${token}s`].get(label)?.value,
|
|
23
|
+
}),
|
|
24
|
+
{},
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const updateConfig = (key: string, value: string) => {
|
|
28
|
+
setConfig((prev) => ({
|
|
29
|
+
...prev,
|
|
30
|
+
[key]: value,
|
|
31
|
+
}))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const onChangeConfig = (e: Event | React.FormEvent<HTMLElement>, key: string) => {
|
|
35
|
+
const event = e as React.FormEvent<HTMLInputElement>
|
|
36
|
+
updateConfig(key, event.currentTarget.value)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const renderTokenSwitch = (token: keyof typeof defaultConfig) => {
|
|
40
|
+
const values = Array.from(tokens[`${token}s`].values())
|
|
41
|
+
return (
|
|
42
|
+
<panda.select background="card" value={config[token]} onChange={(e) => onChangeConfig(e, token)}>
|
|
43
|
+
{values.map((token) => (
|
|
44
|
+
<option key={token.value} value={token.extensions.prop}>
|
|
45
|
+
{`${token.extensions.prop} (${token.value})`}
|
|
46
|
+
</option>
|
|
47
|
+
))}
|
|
48
|
+
</panda.select>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<TokenGroup>
|
|
54
|
+
<TokenContent>
|
|
55
|
+
<div>
|
|
56
|
+
<panda.div
|
|
57
|
+
contentEditable
|
|
58
|
+
outline="0"
|
|
59
|
+
pt="28"
|
|
60
|
+
pb="28"
|
|
61
|
+
mx="auto"
|
|
62
|
+
suppressContentEditableWarning={true}
|
|
63
|
+
width="fit-content"
|
|
64
|
+
style={configValues}
|
|
65
|
+
>
|
|
66
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
67
|
+
</panda.div>
|
|
68
|
+
|
|
69
|
+
<Stack gap="4">
|
|
70
|
+
{Object.keys(config).map((tokenKey) => (
|
|
71
|
+
<panda.div display="flex" alignItems="center" gap="1.5" key={tokenKey}>
|
|
72
|
+
<panda.span whiteSpace="nowrap" width="48" textTransform="capitalize" mr="2">
|
|
73
|
+
{tokenKey.replace(/([a-z0-9])([A-Z])/g, '$1 $2')}
|
|
74
|
+
</panda.span>
|
|
75
|
+
{renderTokenSwitch(tokenKey as keyof typeof defaultConfig)}
|
|
76
|
+
</panda.div>
|
|
77
|
+
))}
|
|
78
|
+
</Stack>
|
|
79
|
+
</div>
|
|
80
|
+
</TokenContent>
|
|
81
|
+
</TokenGroup>
|
|
82
|
+
)
|
|
83
|
+
}
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="astro/client" />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react'
|
|
2
|
+
|
|
3
|
+
export const MoonIcon = (props: ComponentProps<'svg'>) => (
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
width="20"
|
|
7
|
+
height="20"
|
|
8
|
+
viewBox="0 0 20 20"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
aria-hidden="true"
|
|
11
|
+
{...props}
|
|
12
|
+
>
|
|
13
|
+
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path>
|
|
14
|
+
</svg>
|
|
15
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react'
|
|
2
|
+
|
|
3
|
+
export const SunIcon = (props: ComponentProps<'svg'>) => (
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
width="20"
|
|
7
|
+
height="20"
|
|
8
|
+
viewBox="0 0 20 20"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
aria-hidden="true"
|
|
11
|
+
{...props}
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z"
|
|
15
|
+
fillRule="evenodd"
|
|
16
|
+
clipRule="evenodd"
|
|
17
|
+
></path>
|
|
18
|
+
</svg>
|
|
19
|
+
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
import '../../styled-system/styles.css'
|
|
3
|
+
import Head from '../components/head.astro'
|
|
4
|
+
import context from '../lib/panda.context'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<!DOCTYPE html>
|
|
8
|
+
<html lang="en">
|
|
9
|
+
<head>
|
|
10
|
+
<Head />
|
|
11
|
+
<Fragment set:html={context.inject.head} />
|
|
12
|
+
<meta name="generator" content={Astro.generator} />
|
|
13
|
+
<title>Panda Playground</title>
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<Fragment set:html={context.inject.body} />
|
|
17
|
+
<slot />
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Container, panda, Stack } from '../../styled-system/jsx'
|
|
3
|
+
import '../../styled-system/styles.css'
|
|
4
|
+
import { Logo } from '../components/logo'
|
|
5
|
+
import SideNav from '../components/side-nav.astro'
|
|
6
|
+
import ThemeToggle from '../components/theme-toggle.astro'
|
|
7
|
+
import context from '../lib/panda.context'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
title: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { title } = Astro.props
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<panda.main display="flex" height="calc(100vh - env(safe-area-inset-bottom))">
|
|
17
|
+
<Stack height="full" minW="60" overflow="auto" px="12" py="8">
|
|
18
|
+
<panda.a title="Token documentation" fontWeight="bold" fontSize="2xl" href="/" display="flex" gap="2">
|
|
19
|
+
{context.logo ? <panda.img src={context.logo} width="16" alt="logo" /> : <Logo />}
|
|
20
|
+
</panda.a>
|
|
21
|
+
<panda.div mt="4">
|
|
22
|
+
<ThemeToggle />
|
|
23
|
+
</panda.div>
|
|
24
|
+
<SideNav />
|
|
25
|
+
</Stack>
|
|
26
|
+
|
|
27
|
+
<Container width="full">
|
|
28
|
+
<panda.div overflow="auto" px="4" pt="14" pb="8">
|
|
29
|
+
<panda.h1 fontSize="3xl" fontWeight="semibold" mb="8" letterSpacing="tight">
|
|
30
|
+
{title}
|
|
31
|
+
</panda.h1>
|
|
32
|
+
<slot />
|
|
33
|
+
</panda.div>
|
|
34
|
+
</Container>
|
|
35
|
+
</panda.main>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TokenDictionary } from '@pandacss/token-dictionary'
|
|
2
|
+
import type { AnalysisReportJSON } from '@pandacss/types'
|
|
3
|
+
|
|
4
|
+
//@ts-ignore
|
|
5
|
+
import analysisData from './analysis.json' assert { type: 'json' }
|
|
6
|
+
|
|
7
|
+
const typedData = analysisData as any as AnalysisReportJSON
|
|
8
|
+
export { typedData as analysisData }
|
|
9
|
+
|
|
10
|
+
export const tokenDictionary = new TokenDictionary(analysisData.theme)
|
|
11
|
+
|
|
12
|
+
if (typeof window !== 'undefined') {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
window.PANDA_TOKEN_DICTIONNARY = tokenDictionary
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
window.PANDA_ANALYSIS_DATA = analysisData
|
|
17
|
+
}
|