-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
4,384 additions
and
5,546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# panda-vscode | ||
|
||
The official Panda CSS VSCode extension | ||
|
||
## Contributing | ||
|
||
### Setup | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
### Development | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
Then start the VSCode extension development host with [the `Run extension` launch config.](.vscode/launch.json) | ||
|
||
### Build | ||
|
||
```bash | ||
yarn build | ||
``` | ||
|
||
### Test | ||
|
||
```bash | ||
yarn test | ||
``` | ||
|
||
```bash | ||
yarn typecheck | ||
``` | ||
|
||
### Publishing | ||
|
||
Done automatically when the release PR (generated with | ||
[Changesets](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)) is merged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
packages/language-server/__tests__/fixtures/create-config-result.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { mergeConfigs } from '@pandacss/config' | ||
import { PandaContext } from '@pandacss/node' | ||
import presetBase from '@pandacss/preset-base' | ||
import presetPanda from '@pandacss/preset-panda' | ||
import { parseJson, stringifyJson } from '@pandacss/shared' | ||
import type { Config, LoadConfigResult, PresetCore, UserConfig } from '@pandacss/types' | ||
import { utils } from './utils' | ||
|
||
const buttonRecipe = { | ||
className: 'button', | ||
description: 'The styles for the Button component', | ||
base: { | ||
display: 'flex', | ||
cursor: 'pointer', | ||
fontWeight: 'bold', | ||
}, | ||
variants: { | ||
visual: { | ||
funky: { bg: 'red.200', color: 'slate.800' }, | ||
edgy: { border: '1px solid {colors.red.500}' }, | ||
}, | ||
size: { | ||
sm: { padding: '4', fontSize: '12px' }, | ||
lg: { padding: '8', fontSize: '40px' }, | ||
}, | ||
shape: { | ||
square: { borderRadius: '0' }, | ||
circle: { borderRadius: 'full' }, | ||
}, | ||
}, | ||
defaultVariants: { | ||
visual: 'funky', | ||
size: 'sm', | ||
shape: 'circle', | ||
}, | ||
} | ||
|
||
const fixturePreset: Omit<PresetCore, 'globalCss' | 'staticCss'> = { | ||
...presetBase, | ||
...presetPanda, | ||
theme: { | ||
...presetPanda.theme, | ||
recipes: { | ||
button: buttonRecipe, | ||
}, | ||
}, | ||
} | ||
|
||
const config: UserConfig = { | ||
...fixturePreset, | ||
optimize: true, | ||
cwd: '', | ||
outdir: 'styled-system', | ||
include: [], | ||
// | ||
cssVarRoot: ':where(html)', | ||
jsxFramework: 'react', | ||
} | ||
|
||
const fixtureDefaults = { | ||
dependencies: [], | ||
config, | ||
path: '', | ||
hooks: {}, | ||
serialized: stringifyJson(config), | ||
deserialize: () => parseJson(stringifyJson(config)), | ||
} as LoadConfigResult | ||
|
||
export const createConfigResult = (userConfig?: Config) => { | ||
const resolvedConfig = ( | ||
userConfig ? mergeConfigs([userConfig, fixtureDefaults.config]) : fixtureDefaults.config | ||
) as UserConfig | ||
|
||
return { ...fixtureDefaults, config: resolvedConfig } | ||
} | ||
|
||
export const createContext = (userConfig?: Config) => { | ||
let resolvedConfig = ( | ||
userConfig ? mergeConfigs([userConfig, fixtureDefaults.config]) : fixtureDefaults.config | ||
) as UserConfig | ||
|
||
const hooks = userConfig?.hooks ?? {} | ||
|
||
// This allows editing the config before the context is created | ||
// since this function is only used in tests, we only look at the user hooks | ||
// not the presets hooks, so that we can keep this fn sync | ||
if (hooks['config:resolved']) { | ||
const result = hooks['config:resolved']({ | ||
config: resolvedConfig, | ||
path: fixtureDefaults.path, | ||
dependencies: fixtureDefaults.dependencies, | ||
utils: utils, | ||
}) | ||
if (result) { | ||
resolvedConfig = result as UserConfig | ||
} | ||
} | ||
|
||
return new PandaContext({ | ||
...fixtureDefaults, | ||
hooks, | ||
config: resolvedConfig, | ||
tsconfig: { | ||
// @ts-expect-error | ||
useInMemoryFileSystem: true, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './create-config-result' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { traverse } from '@pandacss/shared' | ||
|
||
const omit = <T, K extends keyof T | (string & {})>(obj: T, paths: K[]): Omit<T, K> => { | ||
const result = { ...obj } | ||
|
||
traverse(result, ({ path, parent, key }) => { | ||
if (paths.includes(path as K)) { | ||
delete (parent as any)[key] | ||
} | ||
}) | ||
|
||
return result as Omit<T, K> | ||
} | ||
|
||
export const utils = { | ||
omit, | ||
traverse, | ||
} |
Oops, something went wrong.