Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updates #44

Merged
merged 13 commits into from
May 20, 2024
38 changes: 38 additions & 0 deletions README.md
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.
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,27 @@
"author": "Segun Adebayo <[email protected]>",
"license": "MIT",
"dependencies": {
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.2",
"@types/node": "20.4.5",
"@typescript-eslint/eslint-plugin": "6.2.1",
"@typescript-eslint/parser": "6.2.1",
"prettier": "^2.8.8",
"tsup": "7.1.0",
"typescript": "5.2.2",
"vitest": "0.33.0"
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.1",
"@types/node": "20.11.30",
"@typescript-eslint/eslint-plugin": "7.3.1",
"@typescript-eslint/parser": "7.3.1",
"prettier": "^3.2.5",
"tsup": "8.0.2",
"typescript": "5.4.2",
"vitest": "1.4.0"
},
"resolutions": {
"panda-css-vscode/esbuild": "npm:[email protected]"
"panda-css-vscode/esbuild": "npm:[email protected]",
"panda-css-vscode/lightningcss": "npm:[email protected]"
},
"packageManager": "[email protected]",
"workspaces": [
"packages/*",
"sandbox/**"
],
"devDependencies": {
"@types/eslint": "^8",
"eslint": "^8.52.0"
"@types/eslint": "^8.56.6",
"eslint": "^8.57.0"
}
}
108 changes: 108 additions & 0 deletions packages/language-server/__tests__/fixtures/create-config-result.ts
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,
},
})
}
1 change: 1 addition & 0 deletions packages/language-server/__tests__/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './create-config-result'
18 changes: 18 additions & 0 deletions packages/language-server/__tests__/fixtures/utils.ts
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,
}