Skip to content

Commit

Permalink
fix: several pseudo class and combinator compat (#11)
Browse files Browse the repository at this point in the history
* chore(deps): upgrade panda css to 0.9

* fix: replace :root :host to page tag selector

* fix: expand universal selector

* fix: raw :root and :host without where

* chore: taro demo update

* feat: expand is pseudo

* fix: ~ combinator compat

* chore: upgrade taro demo

* chore: commit uni-app case

* docs: update
  • Loading branch information
sonofmagic authored Jul 29, 2023
1 parent a97415b commit f584e91
Show file tree
Hide file tree
Showing 19 changed files with 1,477 additions and 1,286 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"name": "[uni-app] dev:mp-weixin",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceRoot}/examples/taro-app"
"cwd": "${workspaceRoot}/examples/uni-app-vue3"
},
{
"command": "npm run test:dev",
Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
- [panda css 安装和配置](#panda-css-安装和配置)
- [weapp-pandacss 配置](#weapp-pandacss-配置)
- [跨平台注意事项](#跨平台注意事项)
- [小程序预览事项](#小程序预览事项)
- [配置项](#配置项)
- [参考项目](#参考项目)
- [参考示例](#参考示例)
- [Bugs \& Issues](#bugs--issues)

## 介绍
Expand All @@ -29,7 +30,7 @@ npm install -D @pandacss/dev weapp-pandacss # 或者 yarn / pnpm
npx panda init
```

接着你按照 `panda css` 的安装教程,按照你不同的框架走一遍: <https://panda-css.com/docs/installation/postcss>
接着你按照 `panda css` 的安装教程,按照你不同的框架注册方式走一遍: <https://panda-css.com/docs/installation/postcss>

配置好了之后,此时 `h5` 平台已经生效了,接下来进入 `weapp-pandacss` 的插件配置,不用担心,也非常简单。

Expand Down Expand Up @@ -59,7 +60,13 @@ module.exports = {

> 注意这里必须用 `&&` 而不能用 `&``&` 任务执行会并行不会等待,而 `&&` 会等待前一个执行完成再执行后一条命令
然后,你再手动执行一下 `npm run prepare`, 重新生成 `styled-system``panda css` 就兼容小程序平台啦,是不是很简单?
然后,你再手动执行一下

```bash
npm run prepare
```

重新生成 `styled-system`,这样 `weapp-pandacss` 相关的转义代码就被注入进去了,此时 `panda css` 生成的类就兼容小程序平台啦,是不是很简单?

## 跨平台注意事项

Expand All @@ -73,11 +80,17 @@ module.exports = {

当然你恢复到小程序版本也只需要 `weapp-panda codegen`

## 小程序预览事项

当小程序预览时会出现 `Error: 非法的文件,错误信息:invalid file: pages/index/index.js, 565:24, SyntaxError: Unexpected token . if (variants[key]?.[value])` 错误。

这是因为 `panda` 生成的文件 `cva.mjs` 使用了 [`Optional chaining (?.)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining)语法,这个语法小程序原生不支持,这时候可以开启勾选 `将JS编译成ES5` 功能再进行预览,或者使用 `babel` 预先进行转义再上传预览。

## 配置项

详见 [types](./src//types.ts)
详见 [types](./src/types.ts)

## 参考项目
## 参考示例

[Taro-app](./examples/taro-app)

Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "ISC",
"devDependencies": {
"@csstools/postcss-cascade-layers": "^4.0.0",
"@pandacss/dev": "^0.8.0",
"@pandacss/dev": "^0.9.0",
"weapp-ide-cli": "^1.0.1"
},
"dependencies": {
Expand Down
Loading

0 comments on commit f584e91

Please sign in to comment.