Skip to content

Commit a8b5fb8

Browse files
committed
chore(style-context): initial tests
1 parent e0fca65 commit a8b5fb8

File tree

10 files changed

+680
-224
lines changed

10 files changed

+680
-224
lines changed

packages/core/__tests__/static-css.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,11 @@ describe('static-css', () => {
19111911
background: red.300;
19121912
border-radius: var(--radii-sm);
19131913
}
1914+
1915+
.popover__content {
1916+
background: white;
1917+
box-shadow: var(--shadows-md);
1918+
}
19141919
}
19151920
19161921
.checkbox__control--size_sm {
@@ -1953,6 +1958,24 @@ describe('static-css', () => {
19531958
.badge__title--raised_true {
19541959
box-shadow: var(--shadows-md);
19551960
}
1961+
1962+
.popover__content--size_sm {
1963+
padding: 2px;
1964+
font-size: var(--font-sizes-sm);
1965+
max-width: 200px;
1966+
}
1967+
1968+
.popover__content--size_md {
1969+
padding: 4px;
1970+
font-size: var(--font-sizes-md);
1971+
max-width: 300px;
1972+
}
1973+
1974+
.popover__content--size_lg {
1975+
padding: 6px;
1976+
font-size: var(--font-sizes-lg);
1977+
max-width: 400px;
1978+
}
19561979
}
19571980
19581981
@layer utilities {
@@ -2046,6 +2069,24 @@ describe('static-css', () => {
20462069
"raised": "true",
20472070
},
20482071
},
2072+
{
2073+
"popover": {},
2074+
},
2075+
{
2076+
"popover": {
2077+
"size": "sm",
2078+
},
2079+
},
2080+
{
2081+
"popover": {
2082+
"size": "md",
2083+
},
2084+
},
2085+
{
2086+
"popover": {
2087+
"size": "lg",
2088+
},
2089+
},
20492090
],
20502091
},
20512092
}

packages/core/__tests__/style-encoder.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ describe('style encoder', () => {
767767
"size]___[value:md]___[recipe:checkbox",
768768
"size]___[value:lg]___[recipe:checkbox",
769769
],
770+
"popover": [
771+
"size]___[value:sm]___[recipe:popover",
772+
"size]___[value:md]___[recipe:popover",
773+
"size]___[value:lg]___[recipe:popover",
774+
],
770775
"textStyle": [
771776
"size]___[value:h1]___[recipe:textStyle",
772777
"size]___[value:h2]___[recipe:textStyle",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@pandacss/shared": "workspace:*",
4444
"@pandacss/token-dictionary": "workspace:*",
4545
"@pandacss/types": "workspace:*",
46-
"browserslist": "4.23.3",
46+
"browserslist": "4.26.0",
4747
"hookable": "5.5.3",
4848
"lightningcss": "1.25.1",
4949
"lodash.merge": "4.6.2",

packages/fixture/src/slot-recipes.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,39 @@ export const slotRecipes: Record<string, SlotRecipeConfig> = {
5858
},
5959
],
6060
},
61+
popover: {
62+
className: 'popover',
63+
slots: ['root', 'content'],
64+
base: {
65+
content: {
66+
bg: 'white',
67+
boxShadow: 'md',
68+
},
69+
},
70+
variants: {
71+
size: {
72+
sm: {
73+
content: {
74+
padding: '2',
75+
fontSize: 'sm',
76+
maxWidth: '200px',
77+
},
78+
},
79+
md: {
80+
content: {
81+
padding: '4',
82+
fontSize: 'md',
83+
maxWidth: '300px',
84+
},
85+
},
86+
lg: {
87+
content: {
88+
padding: '6',
89+
fontSize: 'lg',
90+
maxWidth: '400px',
91+
},
92+
},
93+
},
94+
},
95+
},
6196
}

packages/generator/__tests__/generate-recipe.test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,84 @@ describe('generate recipes', () => {
542542
})",
543543
"name": "badge",
544544
},
545+
{
546+
"dts": "import type { ConditionalValue } from '../types/index';
547+
import type { DistributiveOmit, Pretty } from '../types/system-types';
548+
549+
interface PopoverVariant {
550+
size: "sm" | "md" | "lg"
551+
}
552+
553+
type PopoverVariantMap = {
554+
[key in keyof PopoverVariant]: Array<PopoverVariant[key]>
555+
}
556+
557+
type PopoverSlot = "root" | "content"
558+
559+
export type PopoverVariantProps = {
560+
[key in keyof PopoverVariant]?: ConditionalValue<PopoverVariant[key]> | undefined
561+
}
562+
563+
export interface PopoverRecipe {
564+
__slot: PopoverSlot
565+
__type: PopoverVariantProps
566+
(props?: PopoverVariantProps): Pretty<Record<PopoverSlot, string>>
567+
raw: (props?: PopoverVariantProps) => PopoverVariantProps
568+
variantMap: PopoverVariantMap
569+
variantKeys: Array<keyof PopoverVariant>
570+
splitVariantProps<Props extends PopoverVariantProps>(props: Props): [PopoverVariantProps, Pretty<DistributiveOmit<Props, keyof PopoverVariantProps>>]
571+
getVariantProps: (props?: PopoverVariantProps) => PopoverVariantProps
572+
}
573+
574+
575+
export declare const popover: PopoverRecipe",
576+
"js": "import { compact, getSlotCompoundVariant, memo, splitProps } from '../helpers.mjs';
577+
import { createRecipe } from './create-recipe.mjs';
578+
579+
const popoverDefaultVariants = {}
580+
const popoverCompoundVariants = []
581+
582+
const popoverSlotNames = [
583+
[
584+
"root",
585+
"popover__root"
586+
],
587+
[
588+
"content",
589+
"popover__content"
590+
]
591+
]
592+
const popoverSlotFns = /* @__PURE__ */ popoverSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, popoverDefaultVariants, getSlotCompoundVariant(popoverCompoundVariants, slotName))])
593+
594+
const popoverFn = memo((props = {}) => {
595+
return Object.fromEntries(popoverSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]))
596+
})
597+
598+
const popoverVariantKeys = [
599+
"size"
600+
]
601+
const getVariantProps = (variants) => ({ ...popoverDefaultVariants, ...compact(variants) })
602+
603+
export const popover = /* @__PURE__ */ Object.assign(popoverFn, {
604+
__recipe__: false,
605+
__name__: 'popover',
606+
raw: (props) => props,
607+
classNameMap: {},
608+
variantKeys: popoverVariantKeys,
609+
variantMap: {
610+
"size": [
611+
"sm",
612+
"md",
613+
"lg"
614+
]
615+
},
616+
splitVariantProps(props) {
617+
return splitProps(props, popoverVariantKeys)
618+
},
619+
getVariantProps
620+
})",
621+
"name": "popover",
622+
},
545623
]
546624
`)
547625
})

packages/generator/__tests__/setup-artifacts.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ describe('setup-artifacts', () => {
4646
"recipes/checkbox.d.ts",
4747
"recipes/badge.mjs",
4848
"recipes/badge.d.ts",
49+
"recipes/popover.mjs",
50+
"recipes/popover.d.ts",
4951
],
5052
]
5153
`)
@@ -201,6 +203,8 @@ describe('setup-artifacts', () => {
201203
"recipes/checkbox.d.ts",
202204
"recipes/badge.mjs",
203205
"recipes/badge.d.ts",
206+
"recipes/popover.mjs",
207+
"recipes/popover.d.ts",
204208
],
205209
[
206210
"patterns/index.mjs",

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"@pandacss/shared": "workspace:*",
4747
"@pandacss/token-dictionary": "workspace:*",
4848
"@pandacss/types": "workspace:*",
49-
"browserslist": "4.23.3",
49+
"browserslist": "4.26.0",
5050
"chokidar": "4.0.3",
5151
"fast-glob": "3.3.3",
5252
"fs-extra": "11.2.0",

0 commit comments

Comments
 (0)