├── examples
├── taro4_vite_vue3
│ ├── src
│ │ ├── app.less
│ │ ├── pages
│ │ │ ├── index
│ │ │ │ └── index.config.ts
│ │ │ ├── bg
│ │ │ │ └── logo.png
│ │ │ ├── icon
│ │ │ │ └── index.vue
│ │ │ ├── shortcuts
│ │ │ │ └── index.vue
│ │ │ ├── font
│ │ │ │ ├── components
│ │ │ │ │ ├── TextAlign.vue
│ │ │ │ │ ├── TextDecoration.vue
│ │ │ │ │ ├── LineHeight.vue
│ │ │ │ │ ├── TextShadow.vue
│ │ │ │ │ ├── TextDecorationStyle.vue
│ │ │ │ │ ├── LetterSpacing.vue
│ │ │ │ │ ├── FontBold.vue
│ │ │ │ │ ├── FontSize.vue
│ │ │ │ │ └── TextIndent.vue
│ │ │ │ └── index.vue
│ │ │ ├── border
│ │ │ │ ├── index.vue
│ │ │ │ └── components
│ │ │ │ │ └── BorderStyle.vue
│ │ │ ├── odd-even
│ │ │ │ └── index.vue
│ │ │ ├── color
│ │ │ │ └── index.vue
│ │ │ └── first-last
│ │ │ │ └── index.vue
│ │ ├── app.ts
│ │ ├── index.html
│ │ └── app.config.ts
│ ├── .env.test
│ ├── .env.production
│ ├── .env.development
│ ├── .gitignore
│ ├── .eslintrc
│ ├── config
│ │ └── dev.ts
│ ├── .editorconfig
│ ├── babel.config.js
│ ├── types
│ │ ├── vue.d.ts
│ │ └── global.d.ts
│ ├── project.config.json
│ ├── tsconfig.json
│ └── unocss.config.ts
├── taro4_webpack5_vue3
│ ├── src
│ │ ├── app.less
│ │ ├── pages
│ │ │ ├── index
│ │ │ │ └── index.config.ts
│ │ │ ├── bg
│ │ │ │ └── logo.png
│ │ │ ├── icon
│ │ │ │ └── index.vue
│ │ │ ├── shortcuts
│ │ │ │ └── index.vue
│ │ │ ├── font
│ │ │ │ ├── components
│ │ │ │ │ ├── TextAlign.vue
│ │ │ │ │ ├── TextDecoration.vue
│ │ │ │ │ ├── LineHeight.vue
│ │ │ │ │ ├── TextShadow.vue
│ │ │ │ │ ├── TextDecorationStyle.vue
│ │ │ │ │ ├── LetterSpacing.vue
│ │ │ │ │ ├── FontBold.vue
│ │ │ │ │ ├── FontSize.vue
│ │ │ │ │ └── TextIndent.vue
│ │ │ │ └── index.vue
│ │ │ ├── border
│ │ │ │ ├── index.vue
│ │ │ │ └── components
│ │ │ │ │ └── BorderStyle.vue
│ │ │ ├── odd-even
│ │ │ │ └── index.vue
│ │ │ ├── color
│ │ │ │ └── index.vue
│ │ │ └── first-last
│ │ │ │ └── index.vue
│ │ ├── app.ts
│ │ ├── index.html
│ │ └── app.config.ts
│ ├── .env.test
│ ├── .env.production
│ ├── .env.development
│ ├── .gitignore
│ ├── .eslintrc
│ ├── config
│ │ └── dev.ts
│ ├── .editorconfig
│ ├── babel.config.js
│ ├── types
│ │ ├── vue.d.ts
│ │ └── global.d.ts
│ ├── project.config.json
│ └── tsconfig.json
├── taro_webpack4_vue3
│ ├── src
│ │ ├── app.css
│ │ ├── pages
│ │ │ ├── bg
│ │ │ │ └── logo.png
│ │ │ ├── icon
│ │ │ │ └── index.vue
│ │ │ ├── shortcuts
│ │ │ │ └── index.vue
│ │ │ ├── font
│ │ │ │ ├── components
│ │ │ │ │ ├── TextAlign.vue
│ │ │ │ │ ├── TextDecoration.vue
│ │ │ │ │ ├── LineHeight.vue
│ │ │ │ │ ├── TextShadow.vue
│ │ │ │ │ ├── TextDecorationStyle.vue
│ │ │ │ │ ├── LetterSpacing.vue
│ │ │ │ │ ├── FontBold.vue
│ │ │ │ │ ├── FontSize.vue
│ │ │ │ │ └── TextIndent.vue
│ │ │ │ └── index.vue
│ │ │ ├── border
│ │ │ │ ├── index.vue
│ │ │ │ └── components
│ │ │ │ │ └── BorderStyle.vue
│ │ │ ├── odd-even
│ │ │ │ └── index.vue
│ │ │ ├── rpxTranform
│ │ │ │ └── index.vue
│ │ │ ├── color
│ │ │ │ └── index.vue
│ │ │ ├── first-last
│ │ │ │ └── index.vue
│ │ │ ├── shadow
│ │ │ │ └── index.vue
│ │ │ └── attributify-mode
│ │ │ │ └── index.vue
│ │ ├── app.ts
│ │ ├── app.config.ts
│ │ └── index.html
│ ├── .gitignore
│ ├── .eslintrc
│ ├── config
│ │ ├── dev.js
│ │ └── prod.js
│ ├── .editorconfig
│ ├── babel.config.js
│ ├── project.config.json
│ ├── global.d.ts
│ ├── tsconfig.json
│ └── unocss.config.ts
├── taro_webpack5_react
│ ├── src
│ │ ├── pages
│ │ │ ├── index
│ │ │ │ ├── index.css
│ │ │ │ ├── index.config.ts
│ │ │ │ └── index.tsx
│ │ │ ├── directives
│ │ │ │ └── index.tsx
│ │ │ ├── shortcuts
│ │ │ │ └── index.tsx
│ │ │ ├── border
│ │ │ │ ├── index.tsx
│ │ │ │ └── components
│ │ │ │ │ └── BorderStyle.tsx
│ │ │ ├── font
│ │ │ │ ├── components
│ │ │ │ │ ├── TextAlign.tsx
│ │ │ │ │ ├── TextDecoration.tsx
│ │ │ │ │ ├── LineHeight.tsx
│ │ │ │ │ ├── TextShadow.tsx
│ │ │ │ │ ├── TextDecorationStyle.tsx
│ │ │ │ │ ├── LetterSpacing.tsx
│ │ │ │ │ ├── FontBold.tsx
│ │ │ │ │ ├── FontSize.tsx
│ │ │ │ │ └── TextIndent.tsx
│ │ │ │ └── index.tsx
│ │ │ └── shadow
│ │ │ │ └── index.tsx
│ │ ├── app.css
│ │ ├── app.ts
│ │ ├── app.config.ts
│ │ └── index.html
│ ├── .gitignore
│ ├── .eslintrc
│ ├── config
│ │ ├── dev.js
│ │ └── prod.js
│ ├── project.tt.json
│ ├── .editorconfig
│ ├── babel.config.js
│ ├── project.config.json
│ ├── types
│ │ └── global.d.ts
│ ├── tsconfig.json
│ └── unocss.config.ts
├── uniapp_vue3
│ ├── .npmrc
│ ├── .eslintrc
│ ├── src
│ │ ├── static
│ │ │ └── logo.png
│ │ ├── main.ts
│ │ ├── pages
│ │ │ ├── bg
│ │ │ │ └── components
│ │ │ │ │ └── xxClass.vue
│ │ │ ├── icon
│ │ │ │ └── index.vue
│ │ │ ├── shortcuts
│ │ │ │ └── index.vue
│ │ │ ├── font
│ │ │ │ └── components
│ │ │ │ │ ├── TextAlign.vue
│ │ │ │ │ ├── TextDecoration.vue
│ │ │ │ │ ├── LineHeight.vue
│ │ │ │ │ ├── TextShadow.vue
│ │ │ │ │ ├── TextDecorationStyle.vue
│ │ │ │ │ ├── LetterSpacing.vue
│ │ │ │ │ ├── FontBold.vue
│ │ │ │ │ ├── TextIndent.vue
│ │ │ │ │ └── FontSize.vue
│ │ │ ├── border
│ │ │ │ ├── index.vue
│ │ │ │ └── components
│ │ │ │ │ └── BorderStyle.vue
│ │ │ ├── odd-even
│ │ │ │ └── index.vue
│ │ │ ├── apply
│ │ │ │ └── index.vue
│ │ │ ├── first-last
│ │ │ │ └── index.vue
│ │ │ └── color
│ │ │ │ └── index.vue
│ │ ├── env.d.ts
│ │ └── App.vue
│ ├── vite.config.ts
│ ├── tsconfig.json
│ ├── .hbuilderx
│ │ └── launch.json
│ └── index.html
├── taro_webpack5_vue3
│ ├── .npmrc
│ ├── .gitignore
│ ├── src
│ │ ├── pages
│ │ │ ├── index
│ │ │ │ └── index.config.ts
│ │ │ ├── bg
│ │ │ │ └── logo.png
│ │ │ ├── icon
│ │ │ │ └── index.vue
│ │ │ ├── shortcuts
│ │ │ │ └── index.vue
│ │ │ ├── font
│ │ │ │ ├── components
│ │ │ │ │ ├── TextAlign.vue
│ │ │ │ │ ├── TextDecoration.vue
│ │ │ │ │ ├── LineHeight.vue
│ │ │ │ │ ├── TextShadow.vue
│ │ │ │ │ ├── TextDecorationStyle.vue
│ │ │ │ │ ├── LetterSpacing.vue
│ │ │ │ │ ├── FontBold.vue
│ │ │ │ │ ├── FontSize.vue
│ │ │ │ │ └── TextIndent.vue
│ │ │ │ └── index.vue
│ │ │ ├── border
│ │ │ │ ├── index.vue
│ │ │ │ └── components
│ │ │ │ │ └── BorderStyle.vue
│ │ │ ├── odd-even
│ │ │ │ └── index.vue
│ │ │ ├── color
│ │ │ │ └── index.vue
│ │ │ ├── first-last
│ │ │ │ └── index.vue
│ │ │ ├── attributify-mode
│ │ │ │ └── index.vue
│ │ │ └── rpxTranform
│ │ │ │ └── index.vue
│ │ ├── app.css
│ │ ├── app.ts
│ │ ├── index.html
│ │ └── app.config.ts
│ ├── config
│ │ ├── dev.js
│ │ └── prod.js
│ ├── project.tt.json
│ ├── project.config.json
│ ├── README.md
│ ├── babel.config.js
│ ├── types
│ │ └── global.d.ts
│ └── tsconfig.json
├── uniapp_vue2
│ ├── src
│ │ ├── static
│ │ │ └── logo.png
│ │ ├── main.js
│ │ ├── pages
│ │ │ ├── shortcuts
│ │ │ │ └── index.vue
│ │ │ ├── font
│ │ │ │ └── components
│ │ │ │ │ ├── TextAlign.vue
│ │ │ │ │ ├── TextDecoration.vue
│ │ │ │ │ ├── LineHeight.vue
│ │ │ │ │ ├── TextShadow.vue
│ │ │ │ │ ├── TextDecorationStyle.vue
│ │ │ │ │ ├── LetterSpacing.vue
│ │ │ │ │ ├── FontBold.vue
│ │ │ │ │ ├── FontSize.vue
│ │ │ │ │ └── TextIndent.vue
│ │ │ ├── border
│ │ │ │ ├── index.vue
│ │ │ │ └── components
│ │ │ │ │ └── BorderStyle.vue
│ │ │ ├── odd-even
│ │ │ │ └── index.vue
│ │ │ ├── first-last
│ │ │ │ └── index.vue
│ │ │ ├── attributify-mode
│ │ │ │ └── index.vue
│ │ │ └── color
│ │ │ │ └── index.vue
│ │ └── App.vue
│ ├── jsconfig.json
│ ├── sfc.d.ts
│ ├── vue.config.js
│ ├── .gitignore
│ ├── .hbuilderx
│ │ └── launch.json
│ ├── postcss.config.js
│ ├── public
│ │ └── index.html
│ └── unocss.config.js
└── vue2_example
│ ├── src
│ ├── static
│ │ └── logo.png
│ ├── main.js
│ ├── App.vue
│ ├── pages.json
│ └── pages
│ │ └── index
│ │ └── index.vue
│ ├── jsconfig.json
│ ├── vue.config.js
│ ├── sfc.d.ts
│ ├── .gitignore
│ ├── unocss.config.js
│ ├── postcss.config.js
│ └── public
│ └── index.html
├── rules.d.ts
├── theme.d.ts
├── utils.d.ts
├── colors.d.ts
├── src
├── colors.ts
├── rules.ts
├── theme.ts
├── utils.ts
├── variants.ts
├── transformer.ts
├── rules
│ ├── constant.ts
│ ├── container.ts
│ ├── safe-area.ts
│ ├── question-mark.ts
│ ├── layout.ts
│ ├── line-clamp.ts
│ ├── index.ts
│ └── gap.ts
├── utils
│ ├── index.ts
│ └── handlers
│ │ ├── index.ts
│ │ └── regex.ts
├── variants
│ ├── children.ts
│ ├── directions.ts
│ ├── startingstyle.ts
│ ├── index.ts
│ ├── supports.ts
│ ├── dark.ts
│ ├── media.ts
│ └── important.ts
├── shorthands.ts
├── theme
│ ├── preflight.ts
│ ├── index.ts
│ ├── aria.ts
│ ├── filters.ts
│ └── transition.ts
├── transformer
│ ├── transformerAttributify
│ │ ├── index.ts
│ │ └── transformer.ts
│ └── index.ts
└── rpxTranform
│ ├── uniapp.ts
│ └── index.ts
├── variants.d.ts
├── transformer.d.ts
├── .npmrc
├── test
├── assets
│ ├── output
│ │ ├── preset-mini-font-weight-theme.css
│ │ ├── preset-mini
│ │ │ ├── font-weight-theme.css
│ │ │ ├── font-size-theme.css
│ │ │ ├── dark-class.css
│ │ │ ├── nested-theme-colors.css
│ │ │ ├── active-pseudo.css
│ │ │ ├── non-nested-theme-colors.css
│ │ │ ├── empty-prefix.css
│ │ │ ├── custom-var-prefix.css
│ │ │ ├── dark-customizing-selector.css
│ │ │ ├── group-data.css
│ │ │ └── targets-2.css
│ │ ├── preset-mini、font-weight-theme.css
│ │ ├── transformer-class
│ │ │ └── base.tsx
│ │ ├── transformer-attributify
│ │ │ └── base.vue
│ │ └── preset-weapp
│ │ │ └── targets-2.css
│ └── preset-weapp-targets.ts
├── setup.ts
├── __snapshots__
│ └── parser.test.ts.snap
├── debug.test.ts
└── wh-rpx.test.ts
├── assets
└── Snipaste_2023-06-17_19-53-21.png
├── vitest.config.ts
├── .vscode
└── settings.json
├── .gitignore
├── .github
└── workflows
│ └── release.yml
├── tsconfig.json
└── LICENSE
/examples/taro4_vite_vue3/src/app.less:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/app.less:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/rules.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/rules'
2 |
--------------------------------------------------------------------------------
/theme.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/theme'
2 |
--------------------------------------------------------------------------------
/utils.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/utils'
2 |
--------------------------------------------------------------------------------
/colors.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/colors'
2 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/app.css:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/colors.ts:
--------------------------------------------------------------------------------
1 | export * from './theme/colors'
2 |
--------------------------------------------------------------------------------
/src/rules.ts:
--------------------------------------------------------------------------------
1 | export * from './rules/index'
2 |
--------------------------------------------------------------------------------
/src/theme.ts:
--------------------------------------------------------------------------------
1 | export * from './theme/index'
2 |
--------------------------------------------------------------------------------
/src/utils.ts:
--------------------------------------------------------------------------------
1 | export * from './utils/index'
2 |
--------------------------------------------------------------------------------
/src/variants.ts:
--------------------------------------------------------------------------------
1 | export * from './variants/index'
2 |
--------------------------------------------------------------------------------
/variants.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/variants'
2 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/index/index.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/transformer.ts:
--------------------------------------------------------------------------------
1 | export * from './transformer/index'
2 |
--------------------------------------------------------------------------------
/transformer.d.ts:
--------------------------------------------------------------------------------
1 | export * from './dist/transformer'
2 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | # 使用淘宝镜像
2 | # registry=https://registry.npmmirror.com
3 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/.env.test:
--------------------------------------------------------------------------------
1 | # TARO_APP_ID="测试环境下的小程序 AppID"
2 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/.npmrc:
--------------------------------------------------------------------------------
1 | # registry=https://registry.npmmirror.com
2 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/.env.production:
--------------------------------------------------------------------------------
1 | # TARO_APP_ID="生产环境下的小程序 AppID"
2 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/.env.test:
--------------------------------------------------------------------------------
1 | # TARO_APP_ID="测试环境下的小程序 AppID"
2 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/.env.production:
--------------------------------------------------------------------------------
1 | # TARO_APP_ID="生产环境下的小程序 AppID"
2 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/.npmrc:
--------------------------------------------------------------------------------
1 | # registry=https://registry.npmmirror.com
2 |
--------------------------------------------------------------------------------
/src/rules/constant.ts:
--------------------------------------------------------------------------------
1 | export const varEmpty = 'var(--un-empty,/*!*/ /*!*/)'
2 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "@unocss"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | deploy_versions/
3 | .temp/
4 | .rn_temp/
5 | node_modules/
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | deploy_versions/
3 | .temp/
4 | .rn_temp/
5 | node_modules/
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/app.css:
--------------------------------------------------------------------------------
1 | .uno-bg{
2 | @apply: bg-#e33 text-center my-0 font-medium text-base c-#fff;
3 | }
4 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | deploy_versions/
3 | .temp/
4 | .rn_temp/
5 | node_modules/
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/index/index.config.ts:
--------------------------------------------------------------------------------
1 | export default definePageConfig({
2 | navigationBarTitleText: '首页',
3 | })
4 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini-font-weight-theme.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .font-foot{font-weight:100;}
3 | .font-head{font-weight:900;}
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/font-weight-theme.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .font-foot{font-weight:100;}
3 | .font-head{font-weight:900;}
--------------------------------------------------------------------------------
/test/assets/output/preset-mini、font-weight-theme.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .font-foot{font-weight:100;}
3 | .font-head{font-weight:900;}
--------------------------------------------------------------------------------
/assets/Snipaste_2023-06-17_19-53-21.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/assets/Snipaste_2023-06-17_19-53-21.png
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/.env.development:
--------------------------------------------------------------------------------
1 | # 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config
2 | # TARO_APP_ID="开发环境下的小程序 AppID"
3 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/index/index.config.ts:
--------------------------------------------------------------------------------
1 | export default definePageConfig({
2 | navigationBarTitleText: '首页',
3 | })
4 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/index/index.config.ts:
--------------------------------------------------------------------------------
1 | export default definePageConfig({
2 | navigationBarTitleText: '首页'
3 | })
4 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/index/index.config.ts:
--------------------------------------------------------------------------------
1 | export default definePageConfig({
2 | navigationBarTitleText: '首页',
3 | })
4 |
--------------------------------------------------------------------------------
/src/utils/index.ts:
--------------------------------------------------------------------------------
1 | export * from './handlers'
2 | export * from './mappings'
3 | export * from './utilities'
4 | export * from './variants'
5 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | deploy_versions/
3 | .temp/
4 | .rn_temp/
5 | node_modules/
6 | .DS_Store
7 | .swc
8 | *.local
9 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/.env.development:
--------------------------------------------------------------------------------
1 | # 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config
2 | # TARO_APP_ID="开发环境下的小程序 AppID"
3 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | deploy_versions/
3 | .temp/
4 | .rn_temp/
5 | node_modules/
6 | .DS_Store
7 | .swc
8 | *.local
9 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/examples/uniapp_vue2/src/static/logo.png
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/examples/uniapp_vue3/src/static/logo.png
--------------------------------------------------------------------------------
/examples/vue2_example/src/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/examples/vue2_example/src/static/logo.png
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/bg/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/examples/taro4_vite_vue3/src/pages/bg/logo.png
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/bg/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/examples/taro_webpack4_vue3/src/pages/bg/logo.png
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/app.css:
--------------------------------------------------------------------------------
1 | view,
2 | :before,
3 | :after {
4 | border-width: 0;
5 | border-style: solid;
6 | border-color: #e5e7eb;
7 | }
8 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/bg/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/examples/taro_webpack5_vue3/src/pages/bg/logo.png
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/bg/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MellowCo/unocss-preset-weapp/HEAD/examples/taro4_webpack5_vue3/src/pages/bg/logo.png
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/.eslintrc:
--------------------------------------------------------------------------------
1 | // ESLint 检查 .vue 文件需要单独配置编辑器:
2 | // https://eslint.vuejs.org/user-guide/#editor-integrations
3 | {
4 | "extends": ["taro/vue3"]
5 | }
6 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/.eslintrc:
--------------------------------------------------------------------------------
1 | // ESLint 检查 .vue 文件需要单独配置编辑器:
2 | // https://eslint.vuejs.org/user-guide/#editor-integrations
3 | {
4 | "extends": ["taro/vue3"]
5 | }
6 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/.eslintrc:
--------------------------------------------------------------------------------
1 | // ESLint 检查 .vue 文件需要单独配置编辑器:
2 | // https://eslint.vuejs.org/user-guide/#editor-integrations
3 | {
4 | "extends": ["taro/vue3"]
5 | }
6 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["taro/react"],
3 | "rules": {
4 | "react/jsx-uses-react": "off",
5 | "react/react-in-jsx-scope": "off"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/config/dev.ts:
--------------------------------------------------------------------------------
1 | import type { UserConfigExport } from "@tarojs/cli"
2 |
3 | export default {
4 |
5 | mini: {},
6 | h5: {}
7 | } satisfies UserConfigExport<'vite'>
8 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/config/dev.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"development"'
4 | },
5 | defineConstants: {
6 | },
7 | mini: {},
8 | h5: {}
9 | }
10 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/config/dev.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"development"'
4 | },
5 | defineConstants: {
6 | },
7 | mini: {},
8 | h5: {}
9 | }
10 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/config/dev.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"development"',
4 | },
5 | defineConstants: {
6 | },
7 | mini: {},
8 | h5: {},
9 | }
10 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "types": [
4 | "@dcloudio/types",
5 | "miniprogram-api-typings",
6 | "mini-types"
7 | ]
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/vue2_example/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "types": [
4 | "@dcloudio/types",
5 | "miniprogram-api-typings",
6 | "mini-types"
7 | ]
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/vue2_example/vue.config.js:
--------------------------------------------------------------------------------
1 | const UnoCSS = require('unocss/webpack').default
2 |
3 | module.exports = {
4 | configureWebpack: {
5 | plugins: [
6 | UnoCSS(),
7 | ],
8 | },
9 | }
10 |
--------------------------------------------------------------------------------
/test/assets/preset-weapp-targets.ts:
--------------------------------------------------------------------------------
1 | export const presetWeappTargets: string[] = [
2 | // preset-weapp
3 | 'dark_cl_bg-white',
4 | 'dark_cl_hover_cl_rounded',
5 | 'left-[calc(-1*var(--td-badge-basic-height)+1rpx)]',
6 | ]
7 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/project.tt.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./",
3 | "projectname": "taro_webpack5_react",
4 | "appid": "testAppId",
5 | "setting": {
6 | "es6": false,
7 | "minified": false
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/variants/children.ts:
--------------------------------------------------------------------------------
1 | import type { Variant } from '@unocss/core'
2 | import { variantMatcher } from '../utils'
3 |
4 | export const variantChildren: Variant[] = [
5 | variantMatcher('*', input => ({ selector: `${input.selector} > *` })),
6 | ]
7 |
--------------------------------------------------------------------------------
/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | optimizeDeps: {
5 | entries: [],
6 | },
7 | test: {
8 | isolate: false,
9 | setupFiles: ['./test/setup.ts'],
10 | },
11 | })
12 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/font-size-theme.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .text-lg{font-size:3rem;line-height:1.5em;}
3 | .text-medium{font-size:2rem;line-height:1.5em;}
4 | .text-small{font-size:1rem;line-height:1;}
5 | .text-xs{font-size:2rem;line-height:1;}
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "attributify",
4 | "isolations",
5 | "Postprocessor",
6 | "preflights",
7 | "Smoothings",
8 | "uniapp",
9 | "unocss",
10 | "Weapp",
11 | "whitespaces"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/src/utils/handlers/index.ts:
--------------------------------------------------------------------------------
1 | import { createValueHandler } from '@unocss/rule-utils'
2 | import * as valueHandlers from './handlers'
3 |
4 | export const handler = createValueHandler(valueHandlers)
5 | export const h = handler
6 |
7 | export { valueHandlers }
8 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/app.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import 'uno.css'
3 | import './app.css'
4 |
5 | const App = createApp({
6 | onShow (options) {},
7 | // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
8 | })
9 |
10 | export default App
11 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/main.ts:
--------------------------------------------------------------------------------
1 | import { createSSRApp } from 'vue'
2 | import App from './App.vue'
3 |
4 | import 'uno.css'
5 |
6 | export function createApp() {
7 | const app = createSSRApp(App)
8 | return {
9 | app,
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/vue2_example/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App'
3 | import 'uno.css'
4 |
5 | Vue.config.productionTip = false
6 |
7 | App.mpType = 'app'
8 |
9 | const app = new Vue({
10 | ...App,
11 | })
12 | app.$mount()
13 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/config/dev.ts:
--------------------------------------------------------------------------------
1 | import type { UserConfigExport } from "@tarojs/cli"
2 |
3 | export default {
4 | logger: {
5 | quiet: false,
6 | stats: true
7 | },
8 | mini: {},
9 | h5: {}
10 | } satisfies UserConfigExport<'webpack5'>
11 |
--------------------------------------------------------------------------------
/src/shorthands.ts:
--------------------------------------------------------------------------------
1 | import { globalKeywords } from './utils'
2 |
3 | export const shorthands = {
4 | position: [
5 | 'relative',
6 | 'absolute',
7 | 'fixed',
8 | 'sticky',
9 | 'static',
10 | ],
11 | globalKeyword: globalKeywords,
12 | }
13 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/dark-class.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .dark .hello .dark_cl_scope-_lfl__dl_hello_lfr__cl_text-1_sl_2{font-size:8rpx;line-height:16rpx;}
3 | .light [world] .scope-_lfl__lfl_world_lfr__lfr__cl_light_cl_text-1_sl_3{font-size:8rpx;line-height:24rpx;}
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/bg/components/xxClass.vue:
--------------------------------------------------------------------------------
1 |
2 | 11111111
3 |
4 |
5 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App'
3 | // 不再需要导入 uno.css
4 | // import 'uno.css'
5 |
6 | Vue.config.productionTip = false
7 |
8 | App.mpType = 'app'
9 |
10 | const app = new Vue({
11 | ...App,
12 | })
13 | app.$mount()
14 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/src/theme/preflight.ts:
--------------------------------------------------------------------------------
1 | import { backdropFilterBase, boxShadowsBase, filterBase, ringBase, transformBase } from '../rules'
2 |
3 | export const preflightBase = {
4 | ...transformBase,
5 | ...boxShadowsBase,
6 | ...ringBase,
7 | ...filterBase,
8 | ...backdropFilterBase,
9 | }
10 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/babel.config.js:
--------------------------------------------------------------------------------
1 | // babel-preset-taro 更多选项和默认值:
2 | // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3 | module.exports = {
4 | presets: [
5 | ['taro', {
6 | framework: 'vue3',
7 | ts: true
8 | }]
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/babel.config.js:
--------------------------------------------------------------------------------
1 | // babel-preset-taro 更多选项和默认值:
2 | // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3 | module.exports = {
4 | presets: [
5 | ['taro', {
6 | framework: 'react',
7 | ts: true
8 | }]
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/directives/index.tsx:
--------------------------------------------------------------------------------
1 | import { Button, View } from '@tarojs/components'
2 |
3 | export default function () {
4 | return (
5 |
6 | 222222
7 |
8 |
9 | )
10 | }
11 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/sfc.d.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | declare module "vue/types/options" {
4 | type Hooks = App.AppInstance & Page.PageInstance;
5 | interface ComponentOptions extends Hooks {
6 | /**
7 | * 组件类型
8 | */
9 | mpType?: string;
10 | }
11 | }
--------------------------------------------------------------------------------
/examples/vue2_example/sfc.d.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | declare module "vue/types/options" {
4 | type Hooks = App.AppInstance & Page.PageInstance;
5 | interface ComponentOptions extends Hooks {
6 | /**
7 | * 组件类型
8 | */
9 | mpType?: string;
10 | }
11 | }
--------------------------------------------------------------------------------
/src/theme/index.ts:
--------------------------------------------------------------------------------
1 | /* @export-submodules */
2 | export * from './animation'
3 | export * from './colors'
4 | export * from './default'
5 | export * from './filters'
6 | export * from './font'
7 | export * from './misc'
8 | export * from './preflight'
9 | export * from './size'
10 | export * from './types'
11 |
--------------------------------------------------------------------------------
/src/rules/container.ts:
--------------------------------------------------------------------------------
1 | import type { Rule } from '@unocss/core'
2 |
3 | export const containerParent: Rule[] = [
4 | [/^@container(?:\/(\w+))?(?:-(normal|inline-size|size))?$/, ([, l, v]) => {
5 | return {
6 | 'container-type': v ?? 'inline-size',
7 | 'container-name': l,
8 | }
9 | }],
10 | ]
11 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/app.ts:
--------------------------------------------------------------------------------
1 |
2 | import { createApp } from 'vue'
3 |
4 | import './app.less'
5 |
6 | import 'uno.css'
7 |
8 | const App = createApp({
9 | onShow (options) {
10 | console.log('App onShow.')
11 | },
12 | // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
13 | })
14 |
15 | export default App
16 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.vue' {
4 | import { DefineComponent } from 'vue'
5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6 | const component: DefineComponent<{}, {}, any>
7 | export default component
8 | }
9 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/nested-theme-colors.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .bg-a-b-c{--licl-bg-opacity:1;background-color:rgb(81 69 67 / var(--licl-bg-opacity));}
3 | .text-a-b-c{--licl-text-opacity:1;color:rgb(81 69 67 / var(--licl-text-opacity));}
4 | .text-a-camel-case{--licl-text-opacity:1;color:rgb(34 51 68 / var(--licl-text-opacity));}
--------------------------------------------------------------------------------
/examples/vue2_example/src/App.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
18 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/app.ts:
--------------------------------------------------------------------------------
1 |
2 | import { createApp } from 'vue'
3 |
4 | import './app.less'
5 | // import 'uno.css'
6 | import 'virtual:uno.css'
7 |
8 | const App = createApp({
9 | onShow (options) {
10 | console.log('App onShow.')
11 | },
12 | // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
13 | })
14 |
15 | export default App
16 |
--------------------------------------------------------------------------------
/src/theme/aria.ts:
--------------------------------------------------------------------------------
1 | export const aria = {
2 | busy: 'busy="true"',
3 | checked: 'checked="true"',
4 | disabled: 'disabled="true"',
5 | expanded: 'expanded="true"',
6 | hidden: 'hidden="true"',
7 | pressed: 'pressed="true"',
8 | readonly: 'readonly="true"',
9 | required: 'required="true"',
10 | selected: 'selected="true"',
11 | }
12 |
--------------------------------------------------------------------------------
/src/variants/directions.ts:
--------------------------------------------------------------------------------
1 | import type { Variant } from '@unocss/core'
2 | import { variantMatcher } from '../utils'
3 |
4 | export const variantLanguageDirections: Variant[] = [
5 | variantMatcher('rtl', input => ({ prefix: `[dir="rtl"] $$ ${input.prefix}` })),
6 | variantMatcher('ltr', input => ({ prefix: `[dir="ltr"] $$ ${input.prefix}` })),
7 | ]
8 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/vue.config.js:
--------------------------------------------------------------------------------
1 | // 兼容 app
2 | // 解决 App平台 v3 模式暂不支持在 js 文件中引用"uno.css" 请改在 style 内引用
3 | const UnoCSS = require('unocss-webpack-uniapp2').default
4 |
5 | module.exports = {
6 | configureWebpack: {
7 | plugins: [
8 | // https://github.com/MellowCo/unocss-webpack-uniapp2
9 | UnoCSS(),
10 | ],
11 | },
12 | }
13 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/babel.config.js:
--------------------------------------------------------------------------------
1 | // babel-preset-taro 更多选项和默认值:
2 | // https://docs.taro.zone/docs/next/babel-config
3 | module.exports = {
4 | presets: [
5 | ['taro', {
6 | framework: 'vue3',
7 | ts: true,
8 | compiler: 'vite',
9 | useBuiltIns: process.env.TARO_ENV === 'h5' ? 'usage' : false
10 | }]
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/icon/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/icon/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/app.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import { Button, Toast } from '@nutui/nutui-taro'
3 |
4 | import './app.css'
5 | import 'uno.css'
6 |
7 | const App = createApp({
8 | onShow(options) {},
9 | // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
10 | })
11 |
12 | App.use(Button).use(Toast)
13 |
14 | export default App
15 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/icon/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/babel.config.js:
--------------------------------------------------------------------------------
1 | // babel-preset-taro 更多选项和默认值:
2 | // https://docs.taro.zone/docs/next/babel-config
3 | module.exports = {
4 | presets: [
5 | ['taro', {
6 | framework: 'vue3',
7 | ts: true,
8 | compiler: 'webpack5',
9 | useBuiltIns: process.env.TARO_ENV === 'h5' ? 'usage' : false
10 | }]
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/project.tt.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./",
3 | "projectname": "taro_webpack5_vue3",
4 | "description": "taro_webpack5_vue3",
5 | "appid": "touristappid",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "postcss": false,
10 | "minified": false
11 | },
12 | "compileType": "miniprogram"
13 | }
14 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | unpackage/
4 | dist/
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 |
15 | # Editor directories and files
16 | .project
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw*
24 |
--------------------------------------------------------------------------------
/examples/vue2_example/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | unpackage/
4 | dist/
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 |
15 | # Editor directories and files
16 | .project
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw*
24 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./dist",
3 | "projectname": "taro_webpack4_vue3",
4 | "description": "taro_webpack4_vue3",
5 | "appid": "touristappid",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "postcss": false,
10 | "minified": false
11 | },
12 | "compileType": "miniprogram"
13 | }
14 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/types/vue.d.ts:
--------------------------------------------------------------------------------
1 | export {}
2 |
3 | declare module 'vue' {
4 | export interface GlobalComponents extends JSX.IntrinsicElements {
5 | /** Note: Vue 在 runtime 中将 JSX.IntrinsicElements 通过 index signature 重复声明标签
6 | * 这会导致插件无法正常跳转类型,可以手动覆盖声明标签活得更好的体验,参考如下:
7 | * 'scroll-view': JSX.IntrinsicElements['scroll-view']
8 | */
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/icon/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/active-pseudo.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .hover_cl_bg-blue-3:hover{--un-bg-opacity:1;background-color:rgb(147 197 253 / var(--un-bg-opacity));}
3 | .focus_cl_bg-blue-3:focus{--un-bg-opacity:1;background-color:rgb(147 197 253 / var(--un-bg-opacity));}
4 | .active_cl_bg-blue-3:active{--un-bg-opacity:1;background-color:rgb(147 197 253 / var(--un-bg-opacity));}
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/types/vue.d.ts:
--------------------------------------------------------------------------------
1 | export {}
2 |
3 | declare module 'vue' {
4 | export interface GlobalComponents extends JSX.IntrinsicElements {
5 | /** Note: Vue 在 runtime 中将 JSX.IntrinsicElements 通过 index signature 重复声明标签
6 | * 这会导致插件无法正常跳转类型,可以手动覆盖声明标签活得更好的体验,参考如下:
7 | * 'scroll-view': JSX.IntrinsicElements['scroll-view']
8 | */
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/shortcuts/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | center
5 |
6 |
7 |
8 | border-base
9 |
10 |
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/icon/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/shortcuts/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | center
5 |
6 |
7 |
8 | border-base
9 |
10 |
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/shortcuts/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | center
5 |
6 |
7 |
8 | border-base
9 |
10 |
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/shortcuts/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | center
5 |
6 |
7 |
8 | border-base
9 |
10 |
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/shortcuts/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | center
5 |
6 |
7 |
8 | border-base
9 |
10 |
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/shortcuts/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | center
5 |
6 |
7 |
8 | border-base
9 |
10 |
11 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./dist",
3 | "projectname": "taro4_vite_vue3",
4 | "description": "",
5 | "appid": "touristappid",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "enhance": false,
10 | "compileHotReLoad": false,
11 | "postcss": false,
12 | "minified": false
13 | },
14 | "compileType": "miniprogram"
15 | }
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .cache
2 | .DS_Store
3 | .idea
4 | .nuxt
5 | .output
6 | .temp
7 | *.local
8 | *.log
9 | *.vsix
10 | bench/source/gen*.js
11 | coverage
12 | dist
13 | node_modules
14 | packages/runtime/*.global.js
15 | packages/unocss/README.md
16 | packages/vscode/LICENSE
17 | result.json
18 | interactive/guides/vendor/*.md
19 | interactive/data/guides.ts
20 | interactive/public/play
21 | interactive/public/shiki
22 | .swc
23 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./dist",
3 | "projectname": "taro4_webpack5_vue3",
4 | "description": "",
5 | "appid": "touristappid",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "enhance": false,
10 | "compileHotReLoad": false,
11 | "postcss": false,
12 | "minified": false
13 | },
14 | "compileType": "miniprogram"
15 | }
16 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/shortcuts/index.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function() {
4 | return (
5 |
6 |
7 | center
8 |
9 |
10 |
11 | border-base
12 |
13 |
14 | )
15 | }
16 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./dist",
3 | "projectname": "taro_webpack5_vue3",
4 | "description": "taro_webpack5_vue3",
5 | "appid": "touristappid",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "enhance": false,
10 | "compileHotReLoad": false,
11 | "postcss": false,
12 | "minified": false
13 | },
14 | "compileType": "miniprogram"
15 | }
16 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./dist",
3 | "projectname": "taro_webpack5_react",
4 | "description": "taro webpack5 react",
5 | "appid": "touristappid",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "enhance": false,
10 | "compileHotReLoad": false,
11 | "postcss": false,
12 | "minified": false
13 | },
14 | "compileType": "miniprogram"
15 | }
16 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import uni from '@dcloudio/vite-plugin-uni'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig(async ()=>{
6 | const UnoCss = await import('unocss/vite').then(i => i.default)
7 |
8 | return {
9 | plugins: [
10 |
11 | uni(),
12 |
13 | // https://github.com/unocss/unocss
14 | UnoCss(),
15 | ],
16 | }
17 | })
18 |
--------------------------------------------------------------------------------
/src/variants/startingstyle.ts:
--------------------------------------------------------------------------------
1 | import type { Variant } from '@unocss/core'
2 |
3 | export const variantStartingStyle: Variant = {
4 | name: 'starting',
5 | match(matcher) {
6 | if (!matcher.startsWith('starting:'))
7 | return
8 |
9 | return {
10 | matcher: matcher.slice(9),
11 | handle: (input, next) => next({
12 | ...input,
13 | parent: `@starting-style`,
14 | }),
15 | }
16 | },
17 | }
18 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/non-nested-theme-colors.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .bg-numbered321{--licl-bg-opacity:1;background-color:rgb(51 34 17 / var(--licl-bg-opacity));}
3 | .bg-with-hyphen{--licl-bg-opacity:1;background-color:rgb(18 52 86 / var(--licl-bg-opacity));}
4 | .text-numbered-123{--licl-text-opacity:1;color:rgb(17 34 51 / var(--licl-text-opacity));}
5 | .text-with-hyphen{--licl-text-opacity:1;color:rgb(18 52 86 / var(--licl-text-opacity));}
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/TextAlign.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-align
5 |
6 |
7 |
8 | text-left
9 |
10 |
11 |
12 | text-center
13 |
14 |
15 |
16 | text-right
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/app.ts:
--------------------------------------------------------------------------------
1 | import 'uno.css'
2 | import { Component, PropsWithChildren } from 'react'
3 | import './app.css'
4 |
5 | class App extends Component> {
6 |
7 | componentDidMount () {}
8 |
9 | componentDidShow () {}
10 |
11 | componentDidHide () {}
12 |
13 | render () {
14 | // this.props.children 是将要会渲染的页面
15 | return this.props.children
16 | }
17 | }
18 |
19 | export default App
20 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/TextAlign.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-align
5 |
6 |
7 |
8 | text-left
9 |
10 |
11 |
12 | text-center
13 |
14 |
15 |
16 | text-right
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/TextAlign.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-align
5 |
6 |
7 |
8 | text-left
9 |
10 |
11 |
12 | text-center
13 |
14 |
15 |
16 | text-right
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/TextAlign.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-align
5 |
6 |
7 |
8 | text-left
9 |
10 |
11 |
12 | text-center
13 |
14 |
15 |
16 | text-right
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/TextAlign.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-align
5 |
6 |
7 |
8 | text-left
9 |
10 |
11 |
12 | text-center
13 |
14 |
15 |
16 | text-right
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/TextAlign.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-align
5 |
6 |
7 |
8 | text-left
9 |
10 |
11 |
12 | text-center
13 |
14 |
15 |
16 | text-right
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/vue2_example/src/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
3 | {
4 | "path": "pages/index/index",
5 | "style": {
6 | "navigationBarTitleText": "uni-app"
7 | }
8 | }
9 | ],
10 | "globalStyle": {
11 | "navigationBarTextStyle": "black",
12 | "navigationBarTitleText": "uni-app",
13 | "navigationBarBackgroundColor": "#F8F8F8",
14 | "backgroundColor": "#F8F8F8"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'v*'
7 |
8 | jobs:
9 | release:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | with:
14 | fetch-depth: 0
15 |
16 | - uses: actions/setup-node@v3
17 | with:
18 | node-version: lts/*
19 |
20 | - run: npx changelogithub
21 | env:
22 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
23 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/App.vue:
--------------------------------------------------------------------------------
1 |
13 |
14 |
22 |
--------------------------------------------------------------------------------
/src/transformer/transformerAttributify/index.ts:
--------------------------------------------------------------------------------
1 | import type { Options } from 'unplugin-attributify-to-class/types'
2 | import { presetWeappAttributify as preset } from './autocomplete'
3 | import transformer from './transformer'
4 |
5 | export function extractorAttributify(options: Options = {}) {
6 | return {
7 | transformerAttributify: () => transformer(options),
8 | presetWeappAttributify: () => preset(options),
9 | }
10 | }
11 |
12 | export const transformerAttributify = transformer
13 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/border/index.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/border/index.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/border/index.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/border/index.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "useDefineForClassFields": true,
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "jsx": "preserve",
9 | "sourceMap": true,
10 | "resolveJsonModule": true,
11 | "esModuleInterop": true,
12 | "lib": ["esnext", "dom"],
13 | "types": ["@dcloudio/types"]
14 | },
15 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
16 | }
17 |
--------------------------------------------------------------------------------
/examples/vue2_example/unocss.config.js:
--------------------------------------------------------------------------------
1 | import presetWeapp from 'unocss-preset-weapp'
2 | import { transformerClass } from 'unocss-preset-weapp/transformer'
3 | import { defineConfig } from 'unocss'
4 |
5 | export default defineConfig({
6 | presets: [
7 | presetWeapp(),
8 | ],
9 | shortcuts: [
10 | {
11 | 'border-base': 'border border-gray-500_10',
12 | 'center': 'flex justify-center items-center',
13 | },
14 | ],
15 | transformers: [
16 | transformerClass(),
17 | ],
18 | })
19 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/border/index.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/.hbuilderx/launch.json:
--------------------------------------------------------------------------------
1 | { // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
2 | // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
3 | "version": "0.0",
4 | "configurations": [{
5 | "app-plus" :
6 | {
7 | "launchtype" : "local"
8 | },
9 | "default" :
10 | {
11 | "launchtype" : "local"
12 | },
13 | "type" : "uniCloud"
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/.hbuilderx/launch.json:
--------------------------------------------------------------------------------
1 | { // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
2 | // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
3 | "version": "0.0",
4 | "configurations": [{
5 | "app-plus" :
6 | {
7 | "launchtype" : "local"
8 | },
9 | "default" :
10 | {
11 | "launchtype" : "local"
12 | },
13 | "type" : "uniCloud"
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/README.md:
--------------------------------------------------------------------------------
1 | # taro webpack5 vue3
2 |
3 | [文档地址](https://github.com/MellowCo/unocss-preset-weapp/blob/main/examples/taro_webpack4_vue3/README.md)
4 |
5 | ## DEMO
6 |
7 | [taro_webpack4_vue3](https://github.com/MellowCo/unocss-preset-weapp/tree/main/examples/taro_webpack4_vue3)
8 |
9 | [taro_webpack4_vue2](https://github.com/MellowCo/unocss-preset-weapp/tree/main/examples/taro_vue2)
10 |
11 | [taro_react](https://github.com/MellowCo/unocss-preset-weapp/tree/main/examples/taro_webpack5_react)
12 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/empty-prefix.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .scale-100{--scale-x:1;--scale-y:1;transform:translateX(var(--translate-x)) translateY(var(--translate-y)) translateZ(var(--translate-z)) rotate(var(--rotate)) rotateX(var(--rotate-x)) rotateY(var(--rotate-y)) rotateZ(var(--rotate-z)) skewX(var(--skew-x)) skewY(var(--skew-y)) scaleX(var(--scale-x)) scaleY(var(--scale-y)) scaleZ(var(--scale-z));}
3 | .text-red{--text-opacity:1;color:rgb(248 113 113 / var(--text-opacity));}
4 | .text-opacity-50{--text-opacity:0.5;}
--------------------------------------------------------------------------------
/test/setup.ts:
--------------------------------------------------------------------------------
1 | import { rest } from 'msw'
2 | import { setupServer } from 'msw/node'
3 | import { afterAll, afterEach, beforeAll } from 'vitest'
4 |
5 | export const restHandlers = [
6 | rest.get(/google/, (req, res, ctx) => {
7 | return res(ctx.status(200), ctx.text('@font-face mocked {}'))
8 | }),
9 | ]
10 |
11 | const server = setupServer(...restHandlers)
12 |
13 | beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))
14 | afterAll(() => server.close())
15 | afterEach(() => server.resetHandlers())
16 |
--------------------------------------------------------------------------------
/src/transformer/index.ts:
--------------------------------------------------------------------------------
1 | import { defaultAttributes, defaultIgnoreNonValuedAttributes } from 'unplugin-attributify-to-class/utils'
2 | import { defaultRules } from 'unplugin-transform-class/utils'
3 | import { extractorAttributify, transformerAttributify } from './transformerAttributify'
4 | import transformerClass from './transformerClass'
5 |
6 | export {
7 | defaultAttributes,
8 | defaultIgnoreNonValuedAttributes,
9 | defaultRules,
10 | extractorAttributify,
11 | transformerAttributify,
12 | transformerClass,
13 | }
14 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/border/index.tsx:
--------------------------------------------------------------------------------
1 |
2 | import BorderRadius from './components/BorderRadius'
3 | import BorderWidth from './components/BorderWidth'
4 | import BorderStyle from './components/BorderStyle'
5 | import BorderColor from './components/BorderColor'
6 | import {View} from '@tarojs/components'
7 |
8 | export default function() {
9 | return (
10 |
11 |
12 |
13 |
14 |
15 |
16 | )
17 | }
18 |
--------------------------------------------------------------------------------
/src/variants/index.ts:
--------------------------------------------------------------------------------
1 | /* @export-submodules */
2 | export * from './aria'
3 | export * from './breakpoints'
4 | export * from './children'
5 | export * from './combinators'
6 | export * from './container'
7 | export * from './dark'
8 | export * from './data'
9 | export * from './default'
10 | export * from './directions'
11 | export * from './important'
12 | export * from './media'
13 | export * from './misc'
14 | export * from './negative'
15 | export * from './pseudo'
16 | export * from './startingstyle'
17 | export * from './supports'
18 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.png';
4 | declare module '*.gif';
5 | declare module '*.jpg';
6 | declare module '*.jpeg';
7 | declare module '*.svg';
8 | declare module '*.css';
9 | declare module '*.less';
10 | declare module '*.scss';
11 | declare module '*.sass';
12 | declare module '*.styl';
13 |
14 | declare namespace NodeJS {
15 | interface ProcessEnv {
16 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/App.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
30 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/types/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.png';
4 | declare module '*.gif';
5 | declare module '*.jpg';
6 | declare module '*.jpeg';
7 | declare module '*.svg';
8 | declare module '*.css';
9 | declare module '*.less';
10 | declare module '*.scss';
11 | declare module '*.sass';
12 | declare module '*.styl';
13 |
14 | declare namespace NodeJS {
15 | interface ProcessEnv {
16 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/TextAlign.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function TextAlign() {
4 | return (
5 |
6 |
7 | text-align
8 |
9 |
10 |
11 | text-left
12 |
13 |
14 |
15 | text-center
16 |
17 |
18 |
19 | text-right
20 |
21 |
22 | )
23 | }
24 |
--------------------------------------------------------------------------------
/src/rules/safe-area.ts:
--------------------------------------------------------------------------------
1 | import type { Rule } from '@unocss/core'
2 | import type { Theme } from '../theme'
3 |
4 | export const safeArea: Rule[] = [
5 | ['p-safe', { padding: 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)' }],
6 | ['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
7 | ['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
8 | ['pl-safe', { 'padding-left': 'env(safe-area-inset-left)' }],
9 | ['pr-safe', { 'padding-right': 'env(safe-area-inset-right)' }],
10 | ]
11 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/custom-var-prefix.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .scale-100{--hi-scale-x:1;--hi-scale-y:1;transform:translateX(var(--hi-translate-x)) translateY(var(--hi-translate-y)) translateZ(var(--hi-translate-z)) rotate(var(--hi-rotate)) rotateX(var(--hi-rotate-x)) rotateY(var(--hi-rotate-y)) rotateZ(var(--hi-rotate-z)) skewX(var(--hi-skew-x)) skewY(var(--hi-skew-y)) scaleX(var(--hi-scale-x)) scaleY(var(--hi-scale-y)) scaleZ(var(--hi-scale-z));}
3 | .text-red{--hi-text-opacity:1;color:rgb(248 113 113 / var(--hi-text-opacity));}
4 | .text-opacity-50{--hi-text-opacity:0.5;}
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/app.config.ts:
--------------------------------------------------------------------------------
1 | export default defineAppConfig({
2 | pages: [
3 | 'pages/index/index',
4 | 'pages/font/index' ,
5 | 'pages/size/index' ,
6 | 'pages/shadow/index' ,
7 | 'pages/border/index' ,
8 | 'pages/spacing/index' ,
9 | 'pages/shortcuts/index',
10 | 'pages/color/index',
11 | 'pages/directives/index',
12 | ],
13 | window: {
14 | backgroundTextStyle: 'light',
15 | navigationBarBackgroundColor: '#fff',
16 | navigationBarTitleText: 'WeChat',
17 | navigationBarTextStyle: 'black'
18 | }
19 | })
20 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/dark-customizing-selector.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | [data-mode="light"] .light\:disabled\:w-full:disabled{width:100%;}
3 | [data-mode="dark"] .dark\:hover\:rounded:hover{border-radius:8rpx;}
4 | [data-mode="dark"] .dark\:bg-white{--un-bg-opacity:1;background-color:rgb(255 255 255 / var(--un-bg-opacity));}
5 | [data-mode="light"] .light\:bg-black{--un-bg-opacity:1;background-color:rgb(0 0 0 / var(--un-bg-opacity));}
6 | [data-mode="dark"] .dark\:text-lg{font-size:36rpx;line-height:56rpx;}
7 | [data-mode="light"] .light\:text-sm{font-size:28rpx;line-height:40rpx;}
--------------------------------------------------------------------------------
/src/utils/handlers/regex.ts:
--------------------------------------------------------------------------------
1 | export const numberWithUnitRE = /^(-?\d*(?:\.\d+)?)(px|pt|pc|%|r?(?:em|ex|lh|cap|ch|ic)|(?:[sld]?v|cq)(?:[whib]|min|max)|in|cm|mm|rpx)?$/i
2 | export const numberRE = /^(-?\d*(?:\.\d+)?)$/
3 | export const unitOnlyRE = /^(px|[sld]?v[wh])$/i
4 | export const unitOnlyMap: Record = {
5 | px: 1,
6 | vw: 100,
7 | vh: 100,
8 | svw: 100,
9 | svh: 100,
10 | dvw: 100,
11 | dvh: 100,
12 | lvh: 100,
13 | lvw: 100,
14 | }
15 | export const bracketTypeRe = /^\[(color|image|length|size|position|quoted|string):/i
16 | export const splitComma = /,(?![^()]*\))/g
17 |
--------------------------------------------------------------------------------
/src/rpxTranform/uniapp.ts:
--------------------------------------------------------------------------------
1 | import type { UtilObject } from '@unocss/core'
2 | import { cssRpxTransform, rpxRE } from '.'
3 |
4 | /**
5 | * uniapp vue2 postcss rpx 转换规则
6 | * pkg: @dcloudio/vue-cli-plugin-uni/packages/postcss 37行
7 | * @param size
8 | */
9 | export function uniAppRpxTransform(size: string) {
10 | return `%?${size}?%`
11 | }
12 |
13 | /**
14 | * uniapp vue2 webpack: h5 rpx 处理
15 | * @param css
16 | */
17 | export function uniAppVue2CssRpxTransform(css: UtilObject) {
18 | cssRpxTransform(css, rpxRE, (value) => {
19 | return uniAppRpxTransform(value.slice(0, -3))
20 | })
21 | }
22 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/TextDecoration.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration
5 |
6 |
7 |
8 | overline
9 |
10 |
11 |
12 | underline
13 |
14 |
15 |
16 | line-through
17 |
18 |
19 |
20 | no-underline
21 |
22 |
23 |
24 | decoration-solid
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/TextDecoration.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration
5 |
6 |
7 |
8 | overline
9 |
10 |
11 |
12 | underline
13 |
14 |
15 |
16 | line-through
17 |
18 |
19 |
20 | no-underline
21 |
22 |
23 |
24 | decoration-solid
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/TextDecoration.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration
5 |
6 |
7 |
8 | overline
9 |
10 |
11 |
12 | underline
13 |
14 |
15 |
16 | line-through
17 |
18 |
19 |
20 | no-underline
21 |
22 |
23 |
24 | decoration-solid
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/rules/question-mark.ts:
--------------------------------------------------------------------------------
1 | import type { Rule } from '@unocss/core'
2 |
3 | /**
4 | * Used for debugging, only avaliable in development mode.
5 | *
6 | * @example `?` / `where`
7 | */
8 | export const questionMark: Rule[] = [
9 | [
10 | /^(where|\?)$/,
11 | (_, { constructCSS, generator }) => {
12 | if (generator.userConfig.envMode === 'dev')
13 | return `@keyframes __un_qm{0%{box-shadow:inset 4px 4px #ff1e90, inset -4px -4px #ff1e90}100%{box-shadow:inset 8px 8px #3399ff, inset -8px -8px #3399ff}} ${constructCSS({ animation: '__un_qm 0.5s ease-in-out alternate infinite' })}`
14 | },
15 | ],
16 | ]
17 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/TextDecoration.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration
5 |
6 |
7 |
8 | overline
9 |
10 |
11 |
12 | underline
13 |
14 |
15 |
16 | line-through
17 |
18 |
19 |
20 | no-underline
21 |
22 |
23 |
24 | decoration-solid
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/TextDecoration.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration
5 |
6 |
7 |
8 | overline
9 |
10 |
11 |
12 | underline
13 |
14 |
15 |
16 | line-through
17 |
18 |
19 |
20 | no-underline
21 |
22 |
23 |
24 | decoration-solid
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/TextDecoration.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration
5 |
6 |
7 |
8 | overline
9 |
10 |
11 |
12 | underline
13 |
14 |
15 |
16 | line-through
17 |
18 |
19 |
20 | no-underline
21 |
22 |
23 |
24 | decoration-solid
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/border/index.vue:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/babel.config.js:
--------------------------------------------------------------------------------
1 | // babel-preset-taro 更多选项和默认值:
2 | // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3 | module.exports = {
4 | presets: [
5 | ['taro', {
6 | framework: 'vue3',
7 | ts: true
8 | }]
9 | ],
10 | plugins: [
11 | [
12 | "import",
13 | {
14 | "libraryName": "@nutui/nutui-taro",
15 | "libraryDirectory": "dist/packages/_es",
16 | "style": (name, file) => name.toLowerCase().replace('_es/', '') + '/index.scss',
17 | "camel2DashComponentName": false
18 | },
19 | 'nutui3-taro'
20 | ]
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/types/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.png';
4 | declare module '*.gif';
5 | declare module '*.jpg';
6 | declare module '*.jpeg';
7 | declare module '*.svg';
8 | declare module '*.css';
9 | declare module '*.less';
10 | declare module '*.scss';
11 | declare module '*.sass';
12 | declare module '*.styl';
13 |
14 | declare namespace NodeJS {
15 | interface ProcessEnv {
16 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
17 | }
18 | }
19 |
20 | declare module '@tarojs/components' {
21 | export * from '@tarojs/components/types/index.vue3'
22 | }
--------------------------------------------------------------------------------
/src/rules/layout.ts:
--------------------------------------------------------------------------------
1 | import type { Rule } from '@unocss/core'
2 | import { globalKeywords } from '../utils'
3 |
4 | const overflowValues = [
5 | 'auto',
6 | 'hidden',
7 | 'clip',
8 | 'visible',
9 | 'scroll',
10 | 'overlay',
11 | ...globalKeywords,
12 | ]
13 |
14 | export const overflows: Rule[] = [
15 | [/^(?:overflow|of)-(.+)$/, ([, v]) => overflowValues.includes(v) ? { overflow: v } : undefined, { autocomplete: [`(overflow|of)-(${overflowValues.join('|')})`, `(overflow|of)-(x|y)-(${overflowValues.join('|')})`] }],
16 | [/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : undefined],
17 | ]
18 |
--------------------------------------------------------------------------------
/examples/vue2_example/src/pages/index/index.vue:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 | {{ title }}
22 |
23 |
24 |
25 | c-[#157666]
26 |
27 |
28 |
29 | c-blue
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/theme/filters.ts:
--------------------------------------------------------------------------------
1 | export const blur = {
2 | 'DEFAULT': '16rpx',
3 | '0': '0',
4 | 'sm': '8rpx',
5 | 'md': '24rpx',
6 | 'lg': '32rpx',
7 | 'xl': '48rpx',
8 | '2xl': '80rpx',
9 | '3xl': '128rpx',
10 | }
11 |
12 | export const dropShadow = {
13 | 'DEFAULT': ['0 1px 2px rgb(0 0 0 / 0.1)', '0 1px 1px rgb(0 0 0 / 0.06)'],
14 | 'sm': '0 1px 1px rgb(0 0 0 / 0.05)',
15 | 'md': ['0 4px 3px rgb(0 0 0 / 0.07)', '0 2px 2px rgb(0 0 0 / 0.06)'],
16 | 'lg': ['0 10px 8px rgb(0 0 0 / 0.04)', '0 4px 3px rgb(0 0 0 / 0.1)'],
17 | 'xl': ['0 20px 13px rgb(0 0 0 / 0.03)', '0 8px 5px rgb(0 0 0 / 0.08)'],
18 | '2xl': '0 25px 25px rgb(0 0 0 / 0.15)',
19 | 'none': '0 0 rgb(0 0 0 / 0)',
20 | }
21 |
--------------------------------------------------------------------------------
/test/assets/output/transformer-class/base.tsx:
--------------------------------------------------------------------------------
1 | /* tracking-[2/5] bg-teal-200:55 c-#e67e22 */
2 |
3 | export default function(){
4 | const day = 10
5 |
6 | const classnames = (p:any) => {
7 | return p
8 | }
9 |
10 | return (
11 | <>
12 | 剩余 {day} 天
13 |
14 |
20 |
21 | tracking-[2/5]
22 | >
23 | )
24 | }
25 |
--------------------------------------------------------------------------------
/src/rules/line-clamp.ts:
--------------------------------------------------------------------------------
1 | import type { Rule } from '@unocss/core'
2 | import { globalKeywords } from '../utils'
3 |
4 | export const lineClamps: Rule[] = [
5 | [/^line-clamp-(\d+)$/, ([, v]) => ({
6 | 'overflow': 'hidden',
7 | 'display': '-webkit-box',
8 | '-webkit-box-orient': 'vertical',
9 | '-webkit-line-clamp': v,
10 | 'line-clamp': v,
11 | }), { autocomplete: ['line-clamp', 'line-clamp-'] }],
12 |
13 | ...['none', ...globalKeywords].map(keyword => [`line-clamp-${keyword}`, {
14 | 'overflow': 'visible',
15 | 'display': 'block',
16 | '-webkit-box-orient': 'horizontal',
17 | '-webkit-line-clamp': keyword,
18 | 'line-clamp': keyword,
19 | }] as Rule),
20 | ]
21 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/LineHeight.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | line-height
5 |
6 |
7 |
8 | leading-none
9 |
10 |
11 |
12 | leading-tight
13 |
14 |
15 |
16 | leading-snug
17 |
18 |
19 |
20 | leading-normal
21 |
22 |
23 |
24 | leading-relaxed
25 |
26 |
27 |
28 | leading-loose
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/LineHeight.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | line-height
5 |
6 |
7 |
8 | leading-none
9 |
10 |
11 |
12 | leading-tight
13 |
14 |
15 |
16 | leading-snug
17 |
18 |
19 |
20 | leading-normal
21 |
22 |
23 |
24 | leading-relaxed
25 |
26 |
27 |
28 | leading-loose
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/LineHeight.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | line-height
5 |
6 |
7 |
8 | leading-none
9 |
10 |
11 |
12 | leading-tight
13 |
14 |
15 |
16 | leading-snug
17 |
18 |
19 |
20 | leading-normal
21 |
22 |
23 |
24 | leading-relaxed
25 |
26 |
27 |
28 | leading-loose
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/LineHeight.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | line-height
5 |
6 |
7 |
8 | leading-none
9 |
10 |
11 |
12 | leading-tight
13 |
14 |
15 |
16 | leading-snug
17 |
18 |
19 |
20 | leading-normal
21 |
22 |
23 |
24 | leading-relaxed
25 |
26 |
27 |
28 | leading-loose
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/LineHeight.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | line-height
5 |
6 |
7 |
8 | leading-none
9 |
10 |
11 |
12 | leading-tight
13 |
14 |
15 |
16 | leading-snug
17 |
18 |
19 |
20 | leading-normal
21 |
22 |
23 |
24 | leading-relaxed
25 |
26 |
27 |
28 | leading-loose
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/LineHeight.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | line-height
5 |
6 |
7 |
8 | leading-none
9 |
10 |
11 |
12 | leading-tight
13 |
14 |
15 |
16 | leading-snug
17 |
18 |
19 |
20 | leading-normal
21 |
22 |
23 |
24 | leading-relaxed
25 |
26 |
27 |
28 | leading-loose
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/TextShadow.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-shadow
5 |
6 |
7 |
8 | text-shadow
9 |
10 |
11 |
12 | text-shadow-sm
13 |
14 |
15 |
16 | text-shadow-md
17 |
18 |
19 |
20 | text-shadow-lg
21 |
22 |
23 |
24 | text-shadow-xl
25 |
26 |
27 |
28 | text-shadow-none
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/TextShadow.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-shadow
5 |
6 |
7 |
8 | text-shadow
9 |
10 |
11 |
12 | text-shadow-sm
13 |
14 |
15 |
16 | text-shadow-md
17 |
18 |
19 |
20 | text-shadow-lg
21 |
22 |
23 |
24 | text-shadow-xl
25 |
26 |
27 |
28 | text-shadow-none
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/TextShadow.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-shadow
5 |
6 |
7 |
8 | text-shadow
9 |
10 |
11 |
12 | text-shadow-sm
13 |
14 |
15 |
16 | text-shadow-md
17 |
18 |
19 |
20 | text-shadow-lg
21 |
22 |
23 |
24 | text-shadow-xl
25 |
26 |
27 |
28 | text-shadow-none
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/TextShadow.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-shadow
5 |
6 |
7 |
8 | text-shadow
9 |
10 |
11 |
12 | text-shadow-sm
13 |
14 |
15 |
16 | text-shadow-md
17 |
18 |
19 |
20 | text-shadow-lg
21 |
22 |
23 |
24 | text-shadow-xl
25 |
26 |
27 |
28 | text-shadow-none
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/TextShadow.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-shadow
5 |
6 |
7 |
8 | text-shadow
9 |
10 |
11 |
12 | text-shadow-sm
13 |
14 |
15 |
16 | text-shadow-md
17 |
18 |
19 |
20 | text-shadow-lg
21 |
22 |
23 |
24 | text-shadow-xl
25 |
26 |
27 |
28 | text-shadow-none
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/TextShadow.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-shadow
5 |
6 |
7 |
8 | text-shadow
9 |
10 |
11 |
12 | text-shadow-sm
13 |
14 |
15 |
16 | text-shadow-md
17 |
18 |
19 |
20 | text-shadow-lg
21 |
22 |
23 |
24 | text-shadow-xl
25 |
26 |
27 |
28 | text-shadow-none
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2018",
4 | "module": "esnext",
5 | "lib": [
6 | "esnext"
7 | ],
8 | "types": [
9 | "node",
10 | "vite/client",
11 | "vitest/importMeta"
12 | ],
13 | "moduleResolution": "node",
14 | "esModuleInterop": true,
15 | "strict": true,
16 | "strictNullChecks": true,
17 | "resolveJsonModule": true,
18 | "skipDefaultLibCheck": true,
19 | "skipLibCheck": true,
20 | "jsx": "preserve"
21 | },
22 | "exclude": [
23 | "**/dist/**",
24 | "**/node_modules/**",
25 | "**/client/**",
26 | "**/playground/**",
27 | "**/examples/**",
28 | "**/interactive/**",
29 | "**/test/dts/**"
30 | ]
31 | }
32 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | taro4_vite_vue3
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/TextDecoration.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function TextDecoration() {
4 | return (
5 |
6 |
7 | text-decoration
8 |
9 |
10 |
11 | overline
12 |
13 |
14 |
15 | underline
16 |
17 |
18 |
19 | line-through
20 |
21 |
22 |
23 | no-underline
24 |
25 |
26 |
27 | decoration-solid
28 |
29 |
30 | )
31 | }
32 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/odd-even/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | odd:class even:class
5 |
6 |
7 |
8 |
9 | odd:class 奇数为 bg-green
10 |
11 |
12 |
13 | even:class 偶数为 bg-red
14 |
15 |
16 |
17 |
18 |
19 | 1
20 |
21 |
22 | 2
23 |
24 |
25 | 3
26 |
27 |
28 | 4
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/odd-even/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | odd:class even:class
5 |
6 |
7 |
8 |
9 | odd:class 奇数为 bg-green
10 |
11 |
12 |
13 | even:class 偶数为 bg-red
14 |
15 |
16 |
17 |
18 |
19 | 1
20 |
21 |
22 | 2
23 |
24 |
25 | 3
26 |
27 |
28 | 4
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/odd-even/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | odd:class even:class
5 |
6 |
7 |
8 |
9 | odd:class 奇数为 bg-green
10 |
11 |
12 |
13 | even:class 偶数为 bg-red
14 |
15 |
16 |
17 |
18 |
19 | 1
20 |
21 |
22 | 2
23 |
24 |
25 | 3
26 |
27 |
28 | 4
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/odd-even/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | odd:class even:class
5 |
6 |
7 |
8 |
9 | odd:class 奇数为 bg-green
10 |
11 |
12 |
13 | even:class 偶数为 bg-red
14 |
15 |
16 |
17 |
18 |
19 | 1
20 |
21 |
22 | 2
23 |
24 |
25 | 3
26 |
27 |
28 | 4
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/odd-even/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | odd:class even:class
5 |
6 |
7 |
8 |
9 | odd:class 奇数为 bg-green
10 |
11 |
12 |
13 | even:class 偶数为 bg-red
14 |
15 |
16 |
17 |
18 |
19 | 1
20 |
21 |
22 | 2
23 |
24 |
25 | 3
26 |
27 |
28 | 4
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/odd-even/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | odd:class even:class
5 |
6 |
7 |
8 |
9 | odd:class 奇数为 bg-green
10 |
11 |
12 |
13 | even:class 偶数为 bg-red
14 |
15 |
16 |
17 |
18 |
19 | 1
20 |
21 |
22 | 2
23 |
24 |
25 | 3
26 |
27 |
28 | 4
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | taro_webpack5_react
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/TextDecorationStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration-style
5 |
6 |
7 |
8 | underline decoration-solid
9 |
10 |
11 |
12 | underline decoration-double
13 |
14 |
15 |
16 | underline decoration-dotted
17 |
18 |
19 |
20 | underline decoration-dashed
21 |
22 |
23 |
24 | underline decoration-wavy
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/TextDecorationStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration-style
5 |
6 |
7 |
8 | underline decoration-solid
9 |
10 |
11 |
12 | underline decoration-double
13 |
14 |
15 |
16 | underline decoration-dotted
17 |
18 |
19 |
20 | underline decoration-dashed
21 |
22 |
23 |
24 | underline decoration-wavy
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/TextDecorationStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration-style
5 |
6 |
7 |
8 | underline decoration-solid
9 |
10 |
11 |
12 | underline decoration-double
13 |
14 |
15 |
16 | underline decoration-dotted
17 |
18 |
19 |
20 | underline decoration-dashed
21 |
22 |
23 |
24 | underline decoration-wavy
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | taro4_webpack5_vue3
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/TextDecorationStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration-style
5 |
6 |
7 |
8 | underline decoration-solid
9 |
10 |
11 |
12 | underline decoration-double
13 |
14 |
15 |
16 | underline decoration-dotted
17 |
18 |
19 |
20 | underline decoration-dashed
21 |
22 |
23 |
24 | underline decoration-wavy
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/TextDecorationStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration-style
5 |
6 |
7 |
8 | underline decoration-solid
9 |
10 |
11 |
12 | underline decoration-double
13 |
14 |
15 |
16 | underline decoration-dotted
17 |
18 |
19 |
20 | underline decoration-dashed
21 |
22 |
23 |
24 | underline decoration-wavy
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | taro_webpack5_vue3
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/TextDecorationStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-decoration-style
5 |
6 |
7 |
8 | underline decoration-solid
9 |
10 |
11 |
12 | underline decoration-double
13 |
14 |
15 |
16 | underline decoration-dotted
17 |
18 |
19 |
20 | underline decoration-dashed
21 |
22 |
23 |
24 | underline decoration-wavy
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/test/assets/output/transformer-attributify/base.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 | xx
11 |
12 |
13 |
14 | xxx
15 |
16 |
17 |
18 |
19 | 1
20 |
21 |
22 |
23 | 1
24 |
25 |
26 |
27 | 1
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "module": "commonjs",
5 | "removeComments": false,
6 | "preserveConstEnums": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "noImplicitAny": false,
10 | "allowSyntheticDefaultImports": true,
11 | "outDir": "lib",
12 | "noUnusedLocals": true,
13 | "noUnusedParameters": true,
14 | "strictNullChecks": true,
15 | "sourceMap": true,
16 | "baseUrl": ".",
17 | "rootDir": ".",
18 | "jsx": "react-jsx",
19 | "allowJs": true,
20 | "resolveJsonModule": true,
21 | "typeRoots": [
22 | "node_modules/@types"
23 | ]
24 | },
25 | "include": ["./src", "./types"],
26 | "compileOnSave": false
27 | }
28 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "module": "commonjs",
5 | "removeComments": false,
6 | "preserveConstEnums": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "noImplicitAny": false,
10 | "allowSyntheticDefaultImports": true,
11 | "outDir": "lib",
12 | "noUnusedLocals": true,
13 | "noUnusedParameters": true,
14 | "strictNullChecks": true,
15 | "sourceMap": true,
16 | "baseUrl": ".",
17 | "rootDir": ".",
18 | "jsx": "preserve",
19 | "allowJs": true,
20 | "resolveJsonModule": true,
21 | "typeRoots": [
22 | "node_modules/@types"
23 | ]
24 | },
25 | "include": ["./src", "./types"],
26 | "compileOnSave": false
27 | }
28 |
--------------------------------------------------------------------------------
/src/theme/transition.ts:
--------------------------------------------------------------------------------
1 | import type { Theme } from './types'
2 |
3 | export const easing = {
4 | 'DEFAULT': 'cubic-bezier(0.4, 0, 0.2, 1)',
5 | 'linear': 'linear',
6 | 'in': 'cubic-bezier(0.4, 0, 1, 1)',
7 | 'out': 'cubic-bezier(0, 0, 0.2, 1)',
8 | 'in-out': 'cubic-bezier(0.4, 0, 0.2, 1)',
9 | } satisfies Theme['easing']
10 |
11 | export const transitionProperty = {
12 | none: 'none',
13 | all: 'all',
14 | colors: ['color', 'background-color', 'border-color', 'text-decoration-color', 'fill', 'stroke'].join(','),
15 | opacity: 'opacity',
16 | shadow: 'box-shadow',
17 | transform: 'transform',
18 | get DEFAULT() {
19 | return [this.colors, 'opacity', 'box-shadow', 'transform', 'filter', 'backdrop-filter'].join(',')
20 | },
21 | } satisfies Theme['transitionProperty']
22 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "module": "commonjs",
5 | "removeComments": false,
6 | "preserveConstEnums": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "noImplicitAny": false,
10 | "allowSyntheticDefaultImports": true,
11 | "outDir": "lib",
12 | "noUnusedLocals": true,
13 | "noUnusedParameters": true,
14 | "strictNullChecks": true,
15 | "sourceMap": true,
16 | "baseUrl": ".",
17 | "rootDir": ".",
18 | "jsx": "preserve",
19 | "allowJs": true,
20 | "resolveJsonModule": true,
21 | "typeRoots": [
22 | "node_modules/@types"
23 | ]
24 | },
25 | "include": ["./src", "global.d.ts"],
26 | "compileOnSave": false
27 | }
28 |
--------------------------------------------------------------------------------
/src/rpxTranform/index.ts:
--------------------------------------------------------------------------------
1 | import type { UtilObject } from '@unocss/core'
2 |
3 | export * from './taro'
4 | export * from './uniapp'
5 |
6 | export const pxRE = /-?[.\d]+px/g
7 | export const rpxRE = /-?[.\d]+rpx/g
8 | export const rpxOrPxRE = /-?[.\d]+r?px/g
9 |
10 | export function cssRpxTransform(css: UtilObject, regex: RegExp, transform: (val: string) => string) {
11 | css.entries.forEach((i) => {
12 | let value = i[1]
13 |
14 | if (value && typeof value === 'string') {
15 | const matchs = Array.from(value.matchAll(regex))
16 |
17 | if (matchs.length !== 0) {
18 | matchs.forEach((m) => {
19 | const size = m[0]
20 | value = (value as string).replace(size, transform(size))
21 | })
22 |
23 | i[1] = value
24 | }
25 | }
26 | })
27 | }
28 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/app.config.ts:
--------------------------------------------------------------------------------
1 | export default defineAppConfig({
2 | pages: [
3 | 'pages/index/index',
4 | 'pages/font/index',
5 | 'pages/size/index',
6 | 'pages/shadow/index',
7 | 'pages/border/index',
8 | 'pages/spacing/index',
9 | 'pages/shortcuts/index',
10 | 'pages/class/index',
11 | 'pages/color/index',
12 | 'pages/attributify-mode/index',
13 | 'pages/animation/index',
14 | 'pages/rpxTranform/index',
15 | 'pages/bg/index',
16 | 'pages/odd-even/index',
17 | 'pages/first-last/index',
18 | 'pages/divide/index',
19 | 'pages/space/index',
20 | 'pages/icon/index',
21 | ],
22 | window: {
23 | backgroundTextStyle: 'light',
24 | navigationBarBackgroundColor: '#fff',
25 | navigationBarTitleText: 'WeChat',
26 | navigationBarTextStyle: 'black'
27 | }
28 | })
29 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/LineHeight.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function LineHeight() {
4 | return (
5 |
6 |
7 | line-height
8 |
9 |
10 |
11 | leading-none
12 |
13 |
14 |
15 | leading-tight
16 |
17 |
18 |
19 | leading-snug
20 |
21 |
22 |
23 | leading-normal
24 |
25 |
26 |
27 | leading-relaxed
28 |
29 |
30 |
31 | leading-loose
32 |
33 |
34 | )
35 | }
36 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/app.config.ts:
--------------------------------------------------------------------------------
1 | export default defineAppConfig({
2 | pages: [
3 | 'pages/index/index',
4 | 'pages/font/index',
5 | 'pages/size/index',
6 | 'pages/shadow/index',
7 | 'pages/border/index',
8 | 'pages/spacing/index',
9 | 'pages/shortcuts/index',
10 | 'pages/class/index',
11 | 'pages/color/index',
12 | 'pages/attributify-mode/index',
13 | 'pages/animation/index',
14 | 'pages/rpxTranform/index',
15 | 'pages/bg/index',
16 | 'pages/odd-even/index',
17 | 'pages/first-last/index',
18 | 'pages/divide/index',
19 | 'pages/space/index',
20 | 'pages/icon/index',
21 | ],
22 | window: {
23 | backgroundTextStyle: 'light',
24 | navigationBarBackgroundColor: '#fff',
25 | navigationBarTitleText: 'WeChat',
26 | navigationBarTextStyle: 'black'
27 | }
28 | })
29 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/TextShadow.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function TextShadow() {
4 | return (
5 |
6 |
7 | text-shadow
8 |
9 |
10 |
11 | text-shadow
12 |
13 |
14 |
15 | text-shadow-sm
16 |
17 |
18 |
19 | text-shadow-md
20 |
21 |
22 |
23 | text-shadow-lg
24 |
25 |
26 |
27 | text-shadow-xl
28 |
29 |
30 |
31 | text-shadow-none
32 |
33 |
34 | )
35 | }
36 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/app.config.ts:
--------------------------------------------------------------------------------
1 | export default defineAppConfig({
2 | pages: [
3 | 'pages/index/index',
4 | 'pages/font/index' ,
5 | 'pages/size/index' ,
6 | 'pages/shadow/index' ,
7 | 'pages/border/index' ,
8 | 'pages/spacing/index' ,
9 | 'pages/shortcuts/index',
10 | 'pages/class/index',
11 | 'pages/color/index',
12 | 'pages/attributify-mode/index',
13 | 'pages/animation/index',
14 | 'pages/rpxTranform/index',
15 | 'pages/bg/index',
16 | 'pages/odd-even/index',
17 | 'pages/first-last/index',
18 | 'pages/divide/index',
19 | 'pages/space/index',
20 | 'pages/icon/index',
21 | ],
22 | window: {
23 | backgroundTextStyle: 'light',
24 | navigationBarBackgroundColor: '#fff',
25 | navigationBarTitleText: 'WeChat',
26 | navigationBarTextStyle: 'black'
27 | }
28 | })
29 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/app.config.ts:
--------------------------------------------------------------------------------
1 | export default defineAppConfig({
2 | pages: [
3 | 'pages/index/index',
4 | 'pages/font/index',
5 | 'pages/size/index',
6 | 'pages/shadow/index',
7 | 'pages/border/index',
8 | 'pages/spacing/index',
9 | 'pages/shortcuts/index',
10 | 'pages/class/index',
11 | 'pages/color/index',
12 | 'pages/attributify-mode/index',
13 | 'pages/animation/index',
14 | 'pages/rpxTranform/index',
15 | 'pages/bg/index',
16 | 'pages/odd-even/index',
17 | 'pages/first-last/index',
18 | 'pages/divide/index',
19 | 'pages/space/index',
20 | // 'pages/icon/index',
21 | ],
22 | window: {
23 | backgroundTextStyle: 'light',
24 | navigationBarBackgroundColor: '#fff',
25 | navigationBarTitleText: 'WeChat',
26 | navigationBarTextStyle: 'black',
27 | },
28 | })
29 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/postcss.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 | module.exports = {
3 | parser: require('postcss-comment'),
4 | plugins: [
5 | require('postcss-import')({
6 | resolve(id, basedir, importOptions) {
7 | if (id.startsWith('~@/'))
8 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
9 |
10 | else if (id.startsWith('@/'))
11 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
12 |
13 | else if (id.startsWith('/') && !id.startsWith('//'))
14 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
15 |
16 | return id
17 | },
18 | }),
19 | require('autoprefixer')({
20 | remove: process.env.UNI_PLATFORM !== 'h5',
21 | }),
22 | require('@dcloudio/vue-cli-plugin-uni/packages/postcss'),
23 | ],
24 | }
25 |
--------------------------------------------------------------------------------
/examples/vue2_example/postcss.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 | module.exports = {
3 | parser: require('postcss-comment'),
4 | plugins: [
5 | require('postcss-import')({
6 | resolve (id, basedir, importOptions) {
7 | if (id.startsWith('~@/')) {
8 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
9 | } else if (id.startsWith('@/')) {
10 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
11 | } else if (id.startsWith('/') && !id.startsWith('//')) {
12 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
13 | }
14 | return id
15 | }
16 | }),
17 | require('autoprefixer')({
18 | remove: process.env.UNI_PLATFORM !== 'h5'
19 | }),
20 | require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/group-data.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .group[data-state=open] .group-data-_lfl_state_eqe_open_lfr__cl_text-black{--un-text-opacity:1;color:rgba(0,0,0,var(--un-text-opacity));}
3 | .data-_lfl_state_eqe_open_lfr__cl_text-red[data-state=open]{--un-text-opacity:1;color:rgba(248,113,113,var(--un-text-opacity));}
4 | .group:hover .group-hover_cl_font-bold{font-weight:700;}
5 | .group[data-state=open] .group-data-_lfl_state_eqe_open_lfr__cl_rotate-180{--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-rotate:180deg;transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));}
--------------------------------------------------------------------------------
/test/assets/output/preset-weapp/targets-2.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .dark .body_main{--un-bg-opacity:1;background-color:rgb(255 255 255 / var(--un-bg-opacity));}
3 | .cls.multi,
4 | section{--un-text-opacity:1;color:rgb(156 163 175 / var(--un-text-opacity));}
5 | @media (max-width: 500px){
6 | .max-_lfl_500px_lfr__cl_bg-red-100{--un-bg-opacity:1;background-color:rgb(254 226 226 / var(--un-bg-opacity));}
7 | }
8 | @media (min-width: 300px){
9 | .dark .dark_cl_min-_lfl_300px_lfr__cl_bg-red-100{--un-bg-opacity:1;background-color:rgb(254 226 226 / var(--un-bg-opacity));}
10 | }
11 | @media (min-width: 768px){
12 | aside{--un-shadow:var(--un-shadow-inset) 0 20px 25px -5px var(--un-shadow-color, rgb(0 0 0 / 0.1)),var(--un-shadow-inset) 0 8px 10px -6px var(--un-shadow-color, rgb(0 0 0 / 0.1));box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}
13 | }
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "module": "commonjs",
5 | "removeComments": false,
6 | "preserveConstEnums": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "noImplicitAny": false,
10 | "allowSyntheticDefaultImports": true,
11 | "outDir": "lib",
12 | "noUnusedLocals": true,
13 | "noUnusedParameters": true,
14 | "strictNullChecks": true,
15 | "sourceMap": true,
16 | "rootDir": ".",
17 | "jsx": "preserve",
18 | "allowJs": true,
19 | "resolveJsonModule": true,
20 | "typeRoots": [
21 | "node_modules/@types"
22 | ],
23 | "paths": {
24 | // TS5090 leading './'
25 | "@/*": ["./src/*"]
26 | }
27 | },
28 | "include": ["./src", "./types", "./config"],
29 | "compileOnSave": false
30 | }
31 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "module": "commonjs",
5 | "removeComments": false,
6 | "preserveConstEnums": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "noImplicitAny": false,
10 | "allowSyntheticDefaultImports": true,
11 | "outDir": "lib",
12 | "noUnusedLocals": true,
13 | "noUnusedParameters": true,
14 | "strictNullChecks": true,
15 | "sourceMap": true,
16 | "rootDir": ".",
17 | "jsx": "preserve",
18 | "allowJs": true,
19 | "resolveJsonModule": true,
20 | "typeRoots": [
21 | "node_modules/@types"
22 | ],
23 | "paths": {
24 | // TS5090 leading './'
25 | "@/*": ["./src/*"]
26 | }
27 | },
28 | "include": ["./src", "./types", "./config"],
29 | "compileOnSave": false
30 | }
31 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/apply/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | apply bg-to-t
4 |
5 |
6 |
7 |
8 |
9 | apply bg-to-r
10 |
11 |
12 |
13 | apply bg-to-r
14 |
15 |
16 |
17 |
34 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/rpxTranform/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | p-24px m-32px text-16px w-100px h-200px
5 |
6 |
7 |
8 | p-48rpx m-64rpx text-32rpx w-200rpx h-400rpx
9 |
10 |
11 |
12 | px
13 |
14 |
15 |
16 | rpx
17 |
18 |
19 |
20 |
21 |
22 |
42 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/LetterSpacing.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | letter-spacing
5 |
6 |
7 | tracking-tighter
8 |
9 |
10 |
11 | tracking-tight
12 |
13 |
14 |
15 | tracking-normal
16 |
17 |
18 |
19 | tracking-wide
20 |
21 |
22 |
23 | tracking-wider
24 |
25 |
26 |
27 | tracking-widest
28 |
29 |
30 |
31 | tracking-5px
32 |
33 |
34 |
35 | tracking-5rpx
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/LetterSpacing.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | letter-spacing
5 |
6 |
7 | tracking-tighter
8 |
9 |
10 |
11 | tracking-tight
12 |
13 |
14 |
15 | tracking-normal
16 |
17 |
18 |
19 | tracking-wide
20 |
21 |
22 |
23 | tracking-wider
24 |
25 |
26 |
27 | tracking-widest
28 |
29 |
30 |
31 | tracking-5px
32 |
33 |
34 |
35 | tracking-5rpx
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/transformer/transformerAttributify/transformer.ts:
--------------------------------------------------------------------------------
1 | import type { SourceCodeTransformer } from '@unocss/core'
2 | import type { Options } from 'unplugin-attributify-to-class/types'
3 | import { createFilter } from '@rollup/pluginutils'
4 | import { extractorAttributify } from 'unplugin-attributify-to-class/utils'
5 |
6 | export default function (options: Options = {}): SourceCodeTransformer {
7 | const idFilter = createFilter(
8 | options.include || [/\.vue$/, /\.vue\?vue/],
9 | options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/],
10 | )
11 |
12 | const extractor = extractorAttributify(options)
13 |
14 | return {
15 | name: 'transformer-weapp-attributify',
16 | idFilter,
17 | enforce: 'pre',
18 | transform(code) {
19 | const newCode = extractor(code.toString())
20 | code.overwrite(0, code.original.length, newCode)
21 | },
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/color/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | bg-[#3498db]
4 | bg-[#3498db]/80
5 |
6 | bg-[#3498db]:60
7 |
8 | bg-[#3498db]_40
9 |
10 | bg-hex-e74c3c
11 |
12 | text-hex-8e44ad
13 |
14 | text-hex-8e44ad/80
15 |
16 | text-hex-8e44ad:60
17 |
18 | text-hex-8e44ad_40
19 |
20 |
21 | bg-hex-000/80 text-hex-fff:60
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/LetterSpacing.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | letter-spacing
5 |
6 |
7 | tracking-tighter
8 |
9 |
10 |
11 | tracking-tight
12 |
13 |
14 |
15 | tracking-normal
16 |
17 |
18 |
19 | tracking-wide
20 |
21 |
22 |
23 | tracking-wider
24 |
25 |
26 |
27 | tracking-widest
28 |
29 |
30 |
31 | tracking-5px
32 |
33 |
34 |
35 | tracking-5rpx
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/LetterSpacing.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | letter-spacing
5 |
6 |
7 | tracking-tighter
8 |
9 |
10 |
11 | tracking-tight
12 |
13 |
14 |
15 | tracking-normal
16 |
17 |
18 |
19 | tracking-wide
20 |
21 |
22 |
23 | tracking-wider
24 |
25 |
26 |
27 | tracking-widest
28 |
29 |
30 |
31 | tracking-5px
32 |
33 |
34 |
35 | tracking-5rpx
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/LetterSpacing.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | letter-spacing
5 |
6 |
7 | tracking-tighter
8 |
9 |
10 |
11 | tracking-tight
12 |
13 |
14 |
15 | tracking-normal
16 |
17 |
18 |
19 | tracking-wide
20 |
21 |
22 |
23 | tracking-wider
24 |
25 |
26 |
27 | tracking-widest
28 |
29 |
30 |
31 | tracking-5px
32 |
33 |
34 |
35 | tracking-5rpx
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/LetterSpacing.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | letter-spacing
5 |
6 |
7 | tracking-tighter
8 |
9 |
10 |
11 | tracking-tight
12 |
13 |
14 |
15 | tracking-normal
16 |
17 |
18 |
19 | tracking-wide
20 |
21 |
22 |
23 | tracking-wider
24 |
25 |
26 |
27 | tracking-widest
28 |
29 |
30 |
31 | tracking-5px
32 |
33 |
34 |
35 | tracking-5rpx
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/color/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | bg-[#3498db]
4 | bg-[#3498db]/80
5 |
6 | bg-[#3498db]:60
7 |
8 | bg-[#3498db]_40
9 |
10 | bg-hex-e74c3c
11 |
12 | text-hex-8e44ad
13 |
14 | text-hex-8e44ad/80
15 |
16 | text-hex-8e44ad:60
17 |
18 | text-hex-8e44ad_40
19 |
20 |
21 | bg-hex-000/80 text-hex-fff:60
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/color/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | bg-[#3498db]
4 | bg-[#3498db]/80
5 |
6 | bg-[#3498db]:60
7 |
8 | bg-[#3498db]_40
9 |
10 | bg-hex-e74c3c
11 |
12 | text-hex-8e44ad
13 |
14 | text-hex-8e44ad/80
15 |
16 | text-hex-8e44ad:60
17 |
18 | text-hex-8e44ad_40
19 |
20 |
21 | bg-hex-000/80 text-hex-fff:60
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/unocss.config.ts:
--------------------------------------------------------------------------------
1 | import presetWeapp from 'unocss-preset-weapp'
2 | import { transformerClass, extractorAttributify } from 'unocss-preset-weapp/transformer';
3 | import { defineConfig, presetIcons } from 'unocss'
4 |
5 | const {presetWeappAttributify,transformerAttributify} = extractorAttributify()
6 |
7 | export default defineConfig({
8 | presets: [
9 | // https://github.com/MellowCo/unocss-preset-weapp
10 | presetWeapp({
11 | isH5: process.env.TARO_ENV === 'h5',
12 | platform: 'taro',
13 | }),
14 | // attributify autocomplete
15 | presetWeappAttributify(),
16 | presetIcons()
17 | ],
18 | shortcuts: [
19 | {
20 | 'border-base': 'border border-gray-500_10',
21 | 'center': 'flex justify-center items-center',
22 | },
23 | ],
24 | transformers: [
25 | transformerAttributify(),
26 | transformerClass()
27 | ]
28 | })
29 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/color/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | bg-[#3498db]
4 | bg-[#3498db]/80
5 |
6 | bg-[#3498db]:60
7 |
8 | bg-[#3498db]_40
9 |
10 | bg-hex-e74c3c
11 |
12 | text-hex-8e44ad
13 |
14 | text-hex-8e44ad/80
15 |
16 | text-hex-8e44ad:60
17 |
18 | text-hex-8e44ad_40
19 |
20 |
21 | bg-hex-000/80 text-hex-fff:60
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/TextDecorationStyle.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function TextDecorationStyle() {
4 | return (
5 |
6 |
7 | text-decoration-style
8 |
9 |
10 |
11 | underline decoration-solid
12 |
13 |
14 |
15 | underline decoration-double
16 |
17 |
18 |
19 | underline decoration-dotted
20 |
21 |
22 |
23 | underline decoration-dashed
24 |
25 |
26 |
27 | underline decoration-wavy
28 |
29 |
30 | )
31 | }
32 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/unocss.config.ts:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-named-as-default
2 | import presetWeapp from 'unocss-preset-weapp'
3 | import {transformerClass} from 'unocss-preset-weapp/transformer';
4 | import {defineConfig,transformerDirectives} from 'unocss';
5 |
6 | export default defineConfig({
7 | presets: [
8 | presetWeapp({
9 | // h5兼容
10 | isH5: process.env.TARO_ENV === 'h5',
11 | platform: 'taro',
12 | taroWebpack:'webpack5'
13 | }),
14 | ],
15 | shortcuts: [
16 | {
17 | 'border-base': 'border border-gray-500/10',
18 | 'center': 'flex justify-center items-center',
19 | },
20 | ],
21 | transformers:[
22 | transformerClass(),
23 | transformerDirectives({
24 | enforce: 'pre'
25 | }),
26 | ],
27 | content:{
28 | pipeline:{
29 | include: [/\.([jt]sx|css)($|\?)/],
30 | exclude: []
31 | }
32 | }
33 | } )
34 |
--------------------------------------------------------------------------------
/src/rules/index.ts:
--------------------------------------------------------------------------------
1 | /* @export-submodules */
2 | export * from './align'
3 | export * from './animation'
4 | export * from './background'
5 | export * from './behaviors'
6 | export * from './border'
7 | export * from './color'
8 | export * from './container'
9 | export * from './decoration'
10 | export * from './default'
11 | export * from './divide'
12 | export * from './filters'
13 | export * from './flex'
14 | export * from './gap'
15 | export * from './grid'
16 | export * from './layout'
17 | export * from './line-clamp'
18 | export * from './position'
19 | export * from './question-mark'
20 | export * from './ring'
21 | export * from './safe-area'
22 | export * from './shadow'
23 | export * from './size'
24 | export * from './spacing'
25 |
26 | export * from './static'
27 | export * from './svg'
28 | export * from './transform'
29 | export * from './transition'
30 | export * from './typography'
31 | export * from './variables'
32 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/first-last/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | first:class last:class
6 |
7 |
8 |
9 |
10 | 第一个子元素为 bg-red
11 |
12 |
13 | 最后一个子元素为 bg-green
14 |
15 |
16 | 其他为 bg-blue
17 |
18 |
19 |
20 |
21 |
22 | 1
23 |
24 |
25 | 2
26 |
27 |
28 | 3
29 |
30 |
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/first-last/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | first:class last:class
6 |
7 |
8 |
9 |
10 | 第一个子元素为 bg-red
11 |
12 |
13 | 最后一个子元素为 bg-green
14 |
15 |
16 | 其他为 bg-blue
17 |
18 |
19 |
20 |
21 |
22 | 1
23 |
24 |
25 | 2
26 |
27 |
28 | 3
29 |
30 |
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/first-last/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | first:class last:class
6 |
7 |
8 |
9 |
10 | 第一个子元素为 bg-red
11 |
12 |
13 | 最后一个子元素为 bg-green
14 |
15 |
16 | 其他为 bg-blue
17 |
18 |
19 |
20 |
21 |
22 | 1
23 |
24 |
25 | 2
26 |
27 |
28 | 3
29 |
30 |
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/unocss.config.ts:
--------------------------------------------------------------------------------
1 | import presetWeapp from 'unocss-preset-weapp'
2 | import { extractorAttributify, transformerClass } from 'unocss-preset-weapp/transformer'
3 |
4 | const { presetWeappAttributify, transformerAttributify } = extractorAttributify()
5 |
6 | export default {
7 | presets: [
8 | // https://github.com/MellowCo/unocss-preset-weapp
9 | presetWeapp(),
10 | // attributify autocomplete
11 | presetWeappAttributify(),
12 | ],
13 | shortcuts: [
14 | {
15 | 'border-base': 'border border-gray-500_10',
16 | 'center': 'flex justify-center items-center',
17 | },
18 | ],
19 |
20 | transformers: [
21 | // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
22 | transformerAttributify(),
23 |
24 | // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
25 | transformerClass(),
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/attributify-mode/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | view
5 |
6 |
7 |
8 | view
9 |
10 |
11 |
12 | view
13 |
14 |
15 |
16 | red or blue
17 |
18 |
19 |
20 | 111
21 |
22 |
23 |
24 | 222
25 |
26 |
27 |
28 | 333
29 |
30 |
31 |
32 | view
33 |
34 |
35 |
36 | p
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/test/assets/output/preset-mini/targets-2.css:
--------------------------------------------------------------------------------
1 | /* layer: default */
2 | .cls.multi,
3 | section{--licl-text-opacity:1;color:rgb(156 163 175 / var(--licl-text-opacity));}
4 | @media (max-width: 500px){
5 | .max-\[500px\]\:bg-red-100{--licl-bg-opacity:1;background-color:rgb(254 226 226 / var(--licl-bg-opacity));}
6 | }
7 | @media (prefers-color-scheme: dark){
8 | .body_main{--licl-bg-opacity:1;background-color:rgb(255 255 255 / var(--licl-bg-opacity));}
9 | }
10 | @media (prefers-color-scheme: dark){@media (min-width: 300px){
11 | .dark\:min-\[300px\]\:bg-red-100{--licl-bg-opacity:1;background-color:rgb(254 226 226 / var(--licl-bg-opacity));}
12 | }}
13 | @media (min-width: 768px){
14 | aside{--licl-shadow:var(--licl-shadow-inset) 0 20px 25px -5px var(--licl-shadow-color, rgb(0 0 0 / 0.1)),var(--licl-shadow-inset) 0 8px 10px -6px var(--licl-shadow-color, rgb(0 0 0 / 0.1));box-shadow:var(--licl-ring-offset-shadow), var(--licl-ring-shadow), var(--licl-shadow);}
15 | }
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/first-last/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | first:class last:class
6 |
7 |
8 |
9 |
10 | 第一个子元素为 bg-red
11 |
12 |
13 | 最后一个子元素为 bg-green
14 |
15 |
16 | 其他为 bg-blue
17 |
18 |
19 |
20 |
21 |
22 | 1
23 |
24 |
25 | 2
26 |
27 |
28 | 3
29 |
30 |
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/first-last/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | first:class last:class
6 |
7 |
8 |
9 |
10 | 第一个子元素为 bg-red
11 |
12 |
13 | 最后一个子元素为 bg-green
14 |
15 |
16 | 其他为 bg-blue
17 |
18 |
19 |
20 |
21 |
22 | 1
23 |
24 |
25 | 2
26 |
27 |
28 | 3
29 |
30 |
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/first-last/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | first:class last:class
6 |
7 |
8 |
9 |
10 | 第一个子元素为 bg-red
11 |
12 |
13 | 最后一个子元素为 bg-green
14 |
15 |
16 | 其他为 bg-blue
17 |
18 |
19 |
20 |
21 |
22 | 1
23 |
24 |
25 | 2
26 |
27 |
28 | 3
29 |
30 |
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/border/components/BorderStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | border-style
5 |
6 |
7 |
8 | border-none
9 |
10 |
11 |
12 | border-solid
13 |
14 |
15 |
16 | border-dashed
17 |
18 |
19 |
20 | border-dotted
21 |
22 |
23 |
24 | border-double
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/rules/gap.ts:
--------------------------------------------------------------------------------
1 | import type { Rule, RuleContext } from '@unocss/core'
2 | import type { Theme } from '../theme'
3 | import { handler as h } from '../utils'
4 |
5 | const directions: Record = {
6 | '': '',
7 | 'x': 'column-',
8 | 'y': 'row-',
9 | 'col': 'column-',
10 | 'row': 'row-',
11 | }
12 |
13 | function handleGap([, d = '', s]: string[], { theme }: RuleContext) {
14 | const v = theme.spacing?.[s] ?? h.bracket.cssvar.global.remToRpx(s)
15 | if (v != null) {
16 | return {
17 | [`${directions[d]}gap`]: v,
18 | }
19 | }
20 | }
21 |
22 | export const gaps: Rule[] = [
23 | [/^(?:flex-|grid-)?gap-?()(.+)$/, handleGap, { autocomplete: ['gap-$spacing', 'gap-'] }],
24 | [/^(?:flex-|grid-)?gap-([xy])-?(.+)$/, handleGap, { autocomplete: ['gap-(x|y)-$spacing', 'gap-(x|y)-'] }],
25 | [/^(?:flex-|grid-)?gap-(col|row)-?(.+)$/, handleGap, { autocomplete: ['gap-(col|row)-$spacing', 'gap-(col|row)-'] }],
26 | ]
27 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/variants/supports.ts:
--------------------------------------------------------------------------------
1 | import type { VariantContext, VariantObject } from '@unocss/core'
2 | import type { Theme } from '../theme'
3 | import { variantGetParameter } from '@unocss/rule-utils'
4 | import { h } from '../utils'
5 |
6 | export const variantSupports: VariantObject = {
7 | name: 'supports',
8 | match(matcher, ctx: VariantContext) {
9 | const variant = variantGetParameter('supports-', matcher, ctx.generator.config.separators)
10 | if (variant) {
11 | const [match, rest] = variant
12 |
13 | let supports = h.bracket(match) ?? ''
14 | if (supports === '')
15 | supports = ctx.theme.supports?.[match] ?? ''
16 |
17 | if (supports) {
18 | return {
19 | matcher: rest,
20 | handle: (input, next) => next({
21 | ...input,
22 | parent: `${input.parent ? `${input.parent} $$ ` : ''}@supports ${supports}`,
23 | }),
24 | }
25 | }
26 | }
27 | },
28 | multiPass: true,
29 | }
30 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/LetterSpacing.tsx:
--------------------------------------------------------------------------------
1 |
2 | import {View} from '@tarojs/components'
3 |
4 | export default function LetterSpacing() {
5 | return (
6 |
7 |
8 | letter-spacing
9 |
10 |
11 | tracking-tighter
12 |
13 |
14 |
15 | tracking-tight
16 |
17 |
18 |
19 | tracking-normal
20 |
21 |
22 |
23 | tracking-wide
24 |
25 |
26 |
27 | tracking-wider
28 |
29 |
30 |
31 | tracking-widest
32 |
33 |
34 |
35 | tracking-5px
36 |
37 |
38 |
39 | tracking-5rpx
40 |
41 |
42 | )
43 | }
44 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/types/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.png';
4 | declare module '*.gif';
5 | declare module '*.jpg';
6 | declare module '*.jpeg';
7 | declare module '*.svg';
8 | declare module '*.css';
9 | declare module '*.less';
10 | declare module '*.scss';
11 | declare module '*.sass';
12 | declare module '*.styl';
13 |
14 | declare namespace NodeJS {
15 | interface ProcessEnv {
16 | /** NODE 内置环境变量, 会影响到最终构建生成产物 */
17 | NODE_ENV: 'development' | 'production',
18 | /** 当前构建的平台 */
19 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
20 | /**
21 | * 当前构建的小程序 appid
22 | * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
23 | * @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
24 | */
25 | TARO_APP_ID: string
26 | }
27 | }
28 |
29 | declare module '@tarojs/components' {
30 | export * from '@tarojs/components/types/index.vue3'
31 | }
32 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/types/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.png';
4 | declare module '*.gif';
5 | declare module '*.jpg';
6 | declare module '*.jpeg';
7 | declare module '*.svg';
8 | declare module '*.css';
9 | declare module '*.less';
10 | declare module '*.scss';
11 | declare module '*.sass';
12 | declare module '*.styl';
13 |
14 | declare namespace NodeJS {
15 | interface ProcessEnv {
16 | /** NODE 内置环境变量, 会影响到最终构建生成产物 */
17 | NODE_ENV: 'development' | 'production',
18 | /** 当前构建的平台 */
19 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
20 | /**
21 | * 当前构建的小程序 appid
22 | * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
23 | * @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
24 | */
25 | TARO_APP_ID: string
26 | }
27 | }
28 |
29 | declare module '@tarojs/components' {
30 | export * from '@tarojs/components/types/index.vue3'
31 | }
32 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/index.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/index.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/index.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 | import FontSize from './components/FontSize'
3 | import FontBold from './components/FontBold'
4 | import LetterSpacing from './components/LetterSpacing'
5 | import LineHeight from './components/LineHeight'
6 | import TextAlign from './components/TextAlign'
7 | import TextColor from './components/TextColor'
8 | import TextDecoration from './components/TextDecoration'
9 | import TextDecorationStyle from './components/TextDecorationStyle'
10 | import TextIndent from './components/TextIndent'
11 | import TextOpacity from './components/TextOpacity'
12 | import TextShadow from './components/TextShadow'
13 |
14 |
15 |
16 | export default function() {
17 | return (
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | )
32 | }
33 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/border/components/BorderStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | border-style
5 |
6 |
7 |
8 | border-none
9 |
10 |
11 |
12 | border-solid
13 |
14 |
15 |
16 | border-dashed
17 |
18 |
19 |
20 | border-dotted
21 |
22 |
23 |
24 | border-double
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/border/components/BorderStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | border-style
5 |
6 |
7 |
8 | border-none
9 |
10 |
11 |
12 | border-solid
13 |
14 |
15 |
16 | border-dashed
17 |
18 |
19 |
20 | border-dotted
21 |
22 |
23 |
24 | border-double
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/color/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bg-[#3498db]
5 |
6 |
7 | bg-[#3498db] 80
8 |
9 |
10 |
11 | bg-[#3498db] 60
12 |
13 |
14 |
15 | bg-[#3498db] 40
16 |
17 |
18 |
19 | bg-hex-e74c3c
20 |
21 |
22 |
23 | text-hex-8e44ad
24 |
25 |
26 |
27 | text-hex-8e44ad 80
28 |
29 |
30 |
31 | text-hex-8e44ad 60
32 |
33 |
34 |
35 | text-hex-8e44ad_40
36 |
37 |
38 |
39 | bg-hex-000 80 text-hex-fff 60
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/border/components/BorderStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | border-style
5 |
6 |
7 |
8 | border-none
9 |
10 |
11 |
12 | border-solid
13 |
14 |
15 |
16 | border-dashed
17 |
18 |
19 |
20 | border-dotted
21 |
22 |
23 |
24 | border-double
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/border/components/BorderStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | border-style
5 |
6 |
7 |
8 | border-none
9 |
10 |
11 |
12 | border-solid
13 |
14 |
15 |
16 | border-dashed
17 |
18 |
19 |
20 | border-dotted
21 |
22 |
23 |
24 | border-double
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/border/components/BorderStyle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | border-style
5 |
6 |
7 |
8 | border-none
9 |
10 |
11 |
12 | border-solid
13 |
14 |
15 |
16 | border-dashed
17 |
18 |
19 |
20 | border-dotted
21 |
22 |
23 |
24 | border-double
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/color/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bg-[#3498db]
5 |
6 |
7 | bg-[#3498db]/80
8 |
9 |
10 |
11 | bg-[#3498db]:60
12 |
13 |
14 |
15 | bg-[#3498db]_40
16 |
17 |
18 |
19 | bg-hex-e74c3c
20 |
21 |
22 |
23 | text-hex-8e44ad
24 |
25 |
26 |
27 | text-hex-8e44ad/80
28 |
29 |
30 |
31 | text-hex-8e44ad:60
32 |
33 |
34 |
35 | text-hex-8e44ad_40
36 |
37 |
38 |
39 | bg-hex-000/80 text-hex-fff:60
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/FontBold.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-bold
5 |
6 |
7 | font-thin
8 |
9 |
10 |
13 |
14 |
15 | font-light
16 |
17 |
18 |
19 | font-normal
20 |
21 |
22 |
23 | font-medium
24 |
25 |
26 |
27 | font-semibold
28 |
29 |
30 |
31 | font-bold
32 |
33 |
34 |
37 |
38 |
39 | font-black
40 |
41 |
42 |
43 | font-400
44 |
45 |
46 |
47 | font-600
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/FontBold.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-bold
5 |
6 |
7 | font-thin
8 |
9 |
10 |
13 |
14 |
15 | font-light
16 |
17 |
18 |
19 | font-normal
20 |
21 |
22 |
23 | font-medium
24 |
25 |
26 |
27 | font-semibold
28 |
29 |
30 |
31 | font-bold
32 |
33 |
34 |
37 |
38 |
39 | font-black
40 |
41 |
42 |
43 | font-400
44 |
45 |
46 |
47 | font-600
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/FontBold.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-bold
5 |
6 |
7 | font-thin
8 |
9 |
10 |
13 |
14 |
15 | font-light
16 |
17 |
18 |
19 | font-normal
20 |
21 |
22 |
23 | font-medium
24 |
25 |
26 |
27 | font-semibold
28 |
29 |
30 |
31 | font-bold
32 |
33 |
34 |
37 |
38 |
39 | font-black
40 |
41 |
42 |
43 | font-400
44 |
45 |
46 |
47 | font-600
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/FontBold.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-bold
5 |
6 |
7 | font-thin
8 |
9 |
10 |
13 |
14 |
15 | font-light
16 |
17 |
18 |
19 | font-normal
20 |
21 |
22 |
23 | font-medium
24 |
25 |
26 |
27 | font-semibold
28 |
29 |
30 |
31 | font-bold
32 |
33 |
34 |
37 |
38 |
39 | font-black
40 |
41 |
42 |
43 | font-400
44 |
45 |
46 |
47 | font-600
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/FontBold.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-bold
5 |
6 |
7 | font-thin
8 |
9 |
10 |
13 |
14 |
15 | font-light
16 |
17 |
18 |
19 | font-normal
20 |
21 |
22 |
23 | font-medium
24 |
25 |
26 |
27 | font-semibold
28 |
29 |
30 |
31 | font-bold
32 |
33 |
34 |
37 |
38 |
39 | font-black
40 |
41 |
42 |
43 | font-400
44 |
45 |
46 |
47 | font-600
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/FontBold.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-bold
5 |
6 |
7 | font-thin
8 |
9 |
10 |
13 |
14 |
15 | font-light
16 |
17 |
18 |
19 | font-normal
20 |
21 |
22 |
23 | font-medium
24 |
25 |
26 |
27 | font-semibold
28 |
29 |
30 |
31 | font-bold
32 |
33 |
34 |
37 |
38 |
39 | font-black
40 |
41 |
42 |
43 | font-400
44 |
45 |
46 |
47 | font-600
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/variants/dark.ts:
--------------------------------------------------------------------------------
1 | import type { Variant } from '@unocss/core'
2 | import type { PresetWeappOptions } from '..'
3 | import { toArray } from '@unocss/core'
4 | import { variantMatcher, variantParentMatcher } from '../utils'
5 |
6 | export function variantColorsMediaOrClass(options: PresetWeappOptions = {}): Variant[] {
7 | const { transformRules } = options
8 |
9 | if (options?.dark === 'class' || typeof options.dark === 'object') {
10 | const { dark = '.dark', light = '.light' } = typeof options.dark === 'string'
11 | ? {}
12 | : options.dark
13 | return [
14 |
15 | variantMatcher('dark', toArray(dark).map(dark => input => ({ prefix: `${dark} $$ ${input.prefix}` })), transformRules),
16 | variantMatcher('light', toArray(light).map(light => input => ({ prefix: `${light} $$ ${input.prefix}` })), transformRules),
17 | ]
18 | }
19 |
20 | return [
21 | variantParentMatcher('dark', '@media (prefers-color-scheme: dark)', transformRules),
22 | variantParentMatcher('light', '@media (prefers-color-scheme: light)', transformRules),
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/src/variants/media.ts:
--------------------------------------------------------------------------------
1 | import type { VariantContext, VariantObject } from '@unocss/core'
2 | import type { Theme } from '../theme'
3 | import { variantGetParameter } from '@unocss/rule-utils'
4 | import { h, variantParentMatcher } from '../utils'
5 |
6 | export const variantPrint: VariantObject = variantParentMatcher('print', '@media print')
7 |
8 | export const variantCustomMedia: VariantObject = {
9 | name: 'media',
10 | match(matcher, ctx: VariantContext) {
11 | const variant = variantGetParameter('media-', matcher, ctx.generator.config.separators)
12 | if (variant) {
13 | const [match, rest] = variant
14 |
15 | let media = h.bracket(match) ?? ''
16 | if (media === '')
17 | media = ctx.theme.media?.[match] ?? ''
18 |
19 | if (media) {
20 | return {
21 | matcher: rest,
22 | handle: (input, next) => next({
23 | ...input,
24 | parent: `${input.parent ? `${input.parent} $$ ` : ''}@media ${media}`,
25 | }),
26 | }
27 | }
28 | }
29 | },
30 | multiPass: true,
31 | }
32 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/border/components/BorderStyle.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function BorderStyle() {
4 | return (
5 |
6 |
7 | border-style
8 |
9 |
10 |
11 | border-none
12 |
13 |
14 |
15 | border-solid
16 |
17 |
18 |
19 | border-dashed
20 |
21 |
22 |
23 | border-dotted
24 |
25 |
26 |
27 | border-double
28 |
29 |
30 |
31 | )
32 | }
33 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/FontSize.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-size
5 |
6 |
7 | text-xs
8 |
9 |
10 | text-sm
11 |
12 |
13 | text-base
14 |
15 |
16 | text-lg
17 |
18 |
19 | text-40
20 |
21 |
22 | text-xl
23 |
24 |
25 | text-2xl
26 |
27 |
28 | text-3xl
29 |
30 |
31 | text-4xl
32 |
33 |
34 | text-5xl
35 |
36 |
37 | text-6xl
38 |
39 |
40 | text-7xl
41 |
42 |
43 | text-8xl
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/FontSize.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-size
5 |
6 |
7 | text-xs
8 |
9 |
10 | text-sm
11 |
12 |
13 | text-base
14 |
15 |
16 | text-lg
17 |
18 |
19 | text-40
20 |
21 |
22 | text-xl
23 |
24 |
25 | text-2xl
26 |
27 |
28 | text-3xl
29 |
30 |
31 | text-4xl
32 |
33 |
34 | text-5xl
35 |
36 |
37 | text-6xl
38 |
39 |
40 | text-7xl
41 |
42 |
43 | text-8xl
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/vue2_example/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test/__snapshots__/parser.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`multiple handlers for single variant 1`] = `
4 | "/* layer: default */
5 | .prefix1 .pre\\:foo,
6 | .prefix2 .pre\\:foo{name:bar;}"
7 | `;
8 |
9 | exports[`split string with custom separator 1`] = `
10 | "/* layer: default */
11 | .hover__bg-green-500:hover{--un-bg-opacity:1;background-color:rgb(34 197 94 / var(--un-bg-opacity));}
12 | .hover_a_bg-green-500:hover{--un-bg-opacity:1;background-color:rgb(34 197 94 / var(--un-bg-opacity));}
13 | .active__bg-red-500:active{--un-bg-opacity:1;background-color:rgb(239 68 68 / var(--un-bg-opacity));}
14 | .active_a_bg-red-500:active{--un-bg-opacity:1;background-color:rgb(239 68 68 / var(--un-bg-opacity));}"
15 | `;
16 |
17 | exports[`unable to generate token variant with explicit separator without dash 1`] = `
18 | "/* layer: default */
19 | .hover_c_bg-green-500:hover{--un-bg-opacity:1;background-color:rgb(34 197 94 / var(--un-bg-opacity));}
20 | .active_c_bg-red-500:active{--un-bg-opacity:1;background-color:rgb(239 68 68 / var(--un-bg-opacity));}"
21 | `;
22 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/FontSize.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | font-size
7 |
8 |
9 | text-xs
10 |
11 |
12 | text-sm
13 |
14 |
15 | text-base
16 |
17 |
18 | text-lg
19 |
20 |
21 | text-40
22 |
23 |
24 | text-xl
25 |
26 |
27 | text-2xl
28 |
29 |
30 | text-3xl
31 |
32 |
33 | text-4xl
34 |
35 |
36 | text-5xl
37 |
38 |
39 | text-6xl
40 |
41 |
42 | text-7xl
43 |
44 |
45 | text-8xl
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/FontSize.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | font-size
7 |
8 |
9 | text-xs
10 |
11 |
12 | text-sm
13 |
14 |
15 | text-base
16 |
17 |
18 | text-lg
19 |
20 |
21 | text-40
22 |
23 |
24 | text-xl
25 |
26 |
27 | text-2xl
28 |
29 |
30 | text-3xl
31 |
32 |
33 | text-4xl
34 |
35 |
36 | text-5xl
37 |
38 |
39 | text-6xl
40 |
41 |
42 | text-7xl
43 |
44 |
45 | text-8xl
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/FontSize.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | font-size
7 |
8 |
9 | text-xs
10 |
11 |
12 | text-sm
13 |
14 |
15 | text-base
16 |
17 |
18 | text-lg
19 |
20 |
21 | text-40
22 |
23 |
24 | text-xl
25 |
26 |
27 | text-2xl
28 |
29 |
30 | text-3xl
31 |
32 |
33 | text-4xl
34 |
35 |
36 | text-5xl
37 |
38 |
39 | text-6xl
40 |
41 |
42 | text-7xl
43 |
44 |
45 | text-8xl
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/variants/important.ts:
--------------------------------------------------------------------------------
1 | import type { VariantObject } from '@unocss/core'
2 | import type { Theme } from '../theme'
3 | import { cacheRestoreSelector } from 'unplugin-transform-class/utils'
4 |
5 | export function variantImportant(): VariantObject {
6 | let re: RegExp
7 |
8 | return {
9 | name: 'important',
10 | match(matcher, ctx) {
11 | if (!re)
12 | re = new RegExp(`^(important(?:${ctx.generator.config.separators.join('|')})|!)`)
13 |
14 | let base: string | undefined
15 | matcher = cacheRestoreSelector(matcher, ctx.theme?.transformRules)
16 | const match = matcher.match(re)
17 | if (match)
18 | base = matcher.slice(match[0].length)
19 | else if (matcher.endsWith('!'))
20 | base = matcher.slice(0, -1)
21 |
22 | if (base) {
23 | return {
24 | matcher: base,
25 | body: (body) => {
26 | body.forEach((v) => {
27 | if (v[1] != null)
28 | v[1] += ' !important'
29 | })
30 | return body
31 | },
32 | }
33 | }
34 | },
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/src/pages/font/components/TextIndent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-indent
5 |
6 |
7 |
8 | indent
9 |
10 |
11 |
12 | indent-2em
13 |
14 |
15 |
16 | indent-32rpx
17 |
18 |
19 |
20 | indent-xs
21 |
22 |
23 |
24 | indent-sm
25 |
26 |
27 |
28 | indent-md
29 |
30 |
31 |
32 | indent-lg
33 |
34 |
35 |
36 | indent-xl
37 |
38 |
39 |
40 | indent-2xl
41 |
42 |
43 |
44 | indent-3xl
45 |
46 |
47 |
48 | -indent-xs
49 |
50 |
51 |
52 | -indent-5rpx
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/TextIndent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-indent
5 |
6 |
7 |
8 | indent
9 |
10 |
11 |
12 | indent-2em
13 |
14 |
15 |
16 | indent-32rpx
17 |
18 |
19 |
20 | indent-xs
21 |
22 |
23 |
24 | indent-sm
25 |
26 |
27 |
28 | indent-md
29 |
30 |
31 |
32 | indent-lg
33 |
34 |
35 |
36 | indent-xl
37 |
38 |
39 |
40 | indent-2xl
41 |
42 |
43 |
44 | indent-3xl
45 |
46 |
47 |
48 | -indent-xs
49 |
50 |
51 |
52 | -indent-5rpx
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/examples/taro4_vite_vue3/src/pages/font/components/TextIndent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-indent
5 |
6 |
7 |
8 | indent
9 |
10 |
11 |
12 | indent-2em
13 |
14 |
15 |
16 | indent-32rpx
17 |
18 |
19 |
20 | indent-xs
21 |
22 |
23 |
24 | indent-sm
25 |
26 |
27 |
28 | indent-md
29 |
30 |
31 |
32 | indent-lg
33 |
34 |
35 |
36 | indent-xl
37 |
38 |
39 |
40 | indent-2xl
41 |
42 |
43 |
44 | indent-3xl
45 |
46 |
47 |
48 | -indent-xs
49 |
50 |
51 |
52 | -indent-5rpx
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/font/components/TextIndent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-indent
5 |
6 |
7 |
8 | indent
9 |
10 |
11 |
12 | indent-2em
13 |
14 |
15 |
16 | indent-32rpx
17 |
18 |
19 |
20 | indent-xs
21 |
22 |
23 |
24 | indent-sm
25 |
26 |
27 |
28 | indent-md
29 |
30 |
31 |
32 | indent-lg
33 |
34 |
35 |
36 | indent-xl
37 |
38 |
39 |
40 | indent-2xl
41 |
42 |
43 |
44 | indent-3xl
45 |
46 |
47 |
48 | -indent-xs
49 |
50 |
51 |
52 | -indent-5rpx
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/components/TextIndent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-indent
5 |
6 |
7 |
8 | indent
9 |
10 |
11 |
12 | indent-2em
13 |
14 |
15 |
16 | indent-32rpx
17 |
18 |
19 |
20 | indent-xs
21 |
22 |
23 |
24 | indent-sm
25 |
26 |
27 |
28 | indent-md
29 |
30 |
31 |
32 | indent-lg
33 |
34 |
35 |
36 | indent-xl
37 |
38 |
39 |
40 | indent-2xl
41 |
42 |
43 |
44 | indent-3xl
45 |
46 |
47 |
48 | -indent-xs
49 |
50 |
51 |
52 | -indent-5rpx
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/components/TextIndent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | text-indent
5 |
6 |
7 |
8 | indent
9 |
10 |
11 |
12 | indent-2em
13 |
14 |
15 |
16 | indent-32rpx
17 |
18 |
19 |
20 | indent-xs
21 |
22 |
23 |
24 | indent-sm
25 |
26 |
27 |
28 | indent-md
29 |
30 |
31 |
32 | indent-lg
33 |
34 |
35 |
36 | indent-xl
37 |
38 |
39 |
40 | indent-2xl
41 |
42 |
43 |
44 | indent-3xl
45 |
46 |
47 |
48 | -indent-xs
49 |
50 |
51 |
52 | -indent-5rpx
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/examples/uniapp_vue2/unocss.config.js:
--------------------------------------------------------------------------------
1 | import presetWeapp from 'unocss-preset-weapp'
2 | import { extractorAttributify, transformerClass } from 'unocss-preset-weapp/transformer'
3 |
4 | const { transformerAttributify, presetWeappAttributify } = extractorAttributify()
5 |
6 | export default {
7 | presets: [
8 | // https://github.com/MellowCo/unocss-preset-weapp
9 | presetWeapp({
10 | // h5兼容
11 | platform: 'uniapp',
12 | isH5: process.env.UNI_PLATFORM === 'h5',
13 | }),
14 |
15 | // attributify autocomplete
16 | presetWeappAttributify(),
17 | ],
18 | shortcuts: [
19 | {
20 | 'border-base': 'border border-gray-500_10',
21 | 'center': 'flex justify-center items-center',
22 | },
23 | ],
24 | transformers: [
25 | // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
26 | transformerAttributify(),
27 |
28 | // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
29 | transformerClass(),
30 | ],
31 | theme: {
32 | color: {
33 | bg: 'rgba(22, 33, 255, 1)',
34 | },
35 | },
36 | }
37 |
--------------------------------------------------------------------------------
/test/debug.test.ts:
--------------------------------------------------------------------------------
1 | import { createGenerator } from '@unocss/core'
2 | import { expect, it } from 'vitest'
3 | import presetWeapp from '../src/index'
4 |
5 | it('debug', async () => {
6 | const uno = await createGenerator({
7 | presets: [
8 | presetWeapp(),
9 | ],
10 | theme: {
11 | colors: {
12 | blackA7: 'hsla(0, 0%, 0%, 0.169)',
13 | },
14 | },
15 | })
16 |
17 | expect((await uno.generate('shadow-[0_0_7.5rem_0_var(--shadow)]', { preflights: false })).css)
18 | .toMatchInlineSnapshot(`
19 | "/* layer: default */
20 | .shadow-_lfl_0_0_7_dl_5rem_0_var_lbl_--shadow_lbr__lfr_{--un-shadow:0 0 7.5rem 0 var(--un-shadow-color, var(--shadow));box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}"
21 | `)
22 |
23 | expect((await uno.generate('shadow-[0_0_7.5rem_0_#000]', { preflights: false })).css)
24 | .toMatchInlineSnapshot(`
25 | "/* layer: default */
26 | .shadow-_lfl_0_0_7_dl_5rem_0__wn_000_lfr_{--un-shadow:0 0 7.5rem 0 var(--un-shadow-color, rgb(0 0 0));box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}"
27 | `)
28 | })
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 MellowCo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/index/index.tsx:
--------------------------------------------------------------------------------
1 | import {navigateTo} from '@tarojs/taro'
2 | import {View} from '@tarojs/components'
3 |
4 | export default function() {
5 | const list = [
6 | { name: 'font', path: '/pages/font/index' },
7 | { name: 'size', path: '/pages/size/index' },
8 | { name: 'shadow', path: '/pages/shadow/index' },
9 | { name: 'border', path: '/pages/border/index' },
10 | { name: 'spacing', path: '/pages/spacing/index' },
11 | { name: 'shortcuts', path: '/pages/shortcuts/index' },
12 | { name: 'color', path: '/pages/color/index' },
13 | { name: 'directives', path: '/pages/directives/index' },
14 | ]
15 |
16 | function to(url:string) {
17 | navigateTo({
18 | url,
19 | })
20 | }
21 |
22 | return (
23 |
24 |
25 | {
26 | list.map((item,index) => (
27 | to(item.path)}>
28 | { item.name }
29 |
30 | ))
31 | }
32 |
33 |
34 | )
35 | }
36 |
--------------------------------------------------------------------------------
/examples/uniapp_vue3/src/pages/font/components/FontSize.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | font-size
5 |
6 |
7 | text-xs
8 |
9 |
10 | text-sm
11 |
12 |
13 | text-base
14 |
15 |
16 | text-lg
17 |
18 |
19 | text-40
20 |
21 |
22 | text-xl
23 |
24 |
25 | text-2xl
26 |
27 |
28 | text-3xl
29 |
30 |
31 | text-4xl
32 |
33 |
34 | text-5xl
35 |
36 |
37 | text-6xl
38 |
39 |
40 | text-7xl
41 |
42 |
43 | text-8xl
44 |
45 |
46 |
47 |
48 |
49 |
54 |
--------------------------------------------------------------------------------
/test/wh-rpx.test.ts:
--------------------------------------------------------------------------------
1 | import { createGenerator } from '@unocss/core'
2 | import { describe, expect, it } from 'vitest'
3 | import { presetWeapp } from '../src'
4 |
5 | const whRemToRpx = await createGenerator({
6 | presets: [
7 | presetWeapp({
8 | whRpx: false,
9 | }),
10 | ],
11 | })
12 |
13 | const whRpx = await createGenerator({
14 | presets: [
15 | presetWeapp(),
16 | ],
17 | })
18 |
19 | const selectors = [
20 | // postion
21 | 'top-10',
22 | 'bottom-5',
23 | 'left-3',
24 | 'right-8',
25 |
26 | // size
27 | 'w-10',
28 | 'h-10',
29 | 'h-2',
30 |
31 | // typography
32 | 'text-base',
33 | 'text-20',
34 | 'text-size-20',
35 | 'text-1/2',
36 | ]
37 |
38 | describe('wh-rpx-test', () => {
39 | it('wh-rpx false', async () => {
40 | const code = selectors.join(' ')
41 | const { css } = await whRemToRpx.generate(code)
42 | await expect(css).toMatchFileSnapshot('./assets/output/wh-rpx/false.css')
43 | })
44 |
45 | it('default', async () => {
46 | const code = selectors.join(' ')
47 | const { css } = await whRpx.generate(code)
48 | await expect(css).toMatchFileSnapshot('./assets/output/wh-rpx/default.css')
49 | })
50 | })
51 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/FontBold.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function FontBold() {
4 | return (
5 |
6 |
7 | font-bold
8 |
9 |
10 | font-thin
11 |
12 |
13 |
14 | font-extralight
15 |
16 |
17 |
18 | font-light
19 |
20 |
21 |
22 | font-normal
23 |
24 |
25 |
26 | font-medium
27 |
28 |
29 |
30 | font-semibold
31 |
32 |
33 |
34 | font-bold
35 |
36 |
37 |
38 | font-extrabold
39 |
40 |
41 |
42 | font-black
43 |
44 |
45 |
46 | font-400
47 |
48 |
49 |
50 | font-600
51 |
52 |
53 | )
54 | }
55 |
--------------------------------------------------------------------------------
/examples/taro4_webpack5_vue3/src/pages/font/index.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 1111
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/shadow/index.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function() {
4 | return (
5 |
6 |
7 |
8 | shadow
9 |
10 |
11 | shadow-none
12 |
13 |
14 |
15 | shadow
16 |
17 |
18 |
19 | shadow-sm
20 |
21 |
22 |
23 | shadow-md
24 |
25 |
26 |
27 | shadow-lg
28 |
29 |
30 |
31 | shadow-xl
32 |
33 |
34 |
35 | shadow-2xl
36 |
37 |
38 |
39 | shadow-inner
40 |
41 |
42 |
43 | )
44 | }
45 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/FontSize.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function FontSize() {
4 | return (
5 |
6 |
7 | font-size
8 |
9 |
10 | text-xs
11 |
12 |
13 | text-sm
14 |
15 |
16 | text-base
17 |
18 |
19 | text-lg
20 |
21 |
22 | text-40
23 |
24 |
25 | text-xl
26 |
27 |
28 | text-2xl
29 |
30 |
31 | text-3xl
32 |
33 |
34 | text-4xl
35 |
36 |
37 | text-5xl
38 |
39 |
40 | text-6xl
41 |
42 |
43 | text-7xl
44 |
45 |
46 | text-8xl
47 |
48 |
49 | )}
50 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/font/index.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 1111
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/attributify-mode/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | div
5 |
6 |
7 |
8 | div
9 |
10 |
11 |
12 | div
13 |
14 |
15 |
16 | div
17 |
18 |
19 |
20 | div
21 |
22 |
23 |
24 | This conflicts with links' text prop
25 |
26 |
27 |
28 | 111
29 |
30 |
31 |
32 | 111
33 |
34 |
35 |
36 | 111
37 |
38 |
39 |
40 | prefixedOnly
41 |
42 |
43 |
46 |
47 |
48 |
49 | p
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/src/pages/rpxTranform/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | px
6 |
7 |
8 |
9 | px-class
10 |
11 |
12 |
13 |
14 |
15 | PX
16 |
17 |
18 |
19 | PX-class
20 |
21 |
22 |
23 |
24 |
25 | rpx
26 |
27 |
28 |
29 | rpx-class
30 |
31 |
32 |
33 |
34 |
35 |
36 |
58 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/shadow/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | shadow
6 |
7 |
8 | shadow-none
9 |
10 |
11 |
12 | shadow
13 |
14 |
15 |
16 | shadow-sm
17 |
18 |
19 |
20 | shadow-md
21 |
22 |
23 |
24 | shadow-lg
25 |
26 |
27 |
28 | shadow-xl
29 |
30 |
31 |
32 | shadow-2xl
33 |
34 |
35 |
36 | shadow-inner
37 |
38 |
39 |
40 | shadow-[0px_4px_4px_0px_rgba(237,_0,_0,_1)]
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/src/pages/font/components/TextIndent.tsx:
--------------------------------------------------------------------------------
1 | import {View} from '@tarojs/components'
2 |
3 | export default function TextIndent() {
4 | return (
5 |
6 |
7 | text-indent
8 |
9 |
10 |
11 | indent
12 |
13 |
14 |
15 | indent-2em
16 |
17 |
18 |
19 | indent-32rpx
20 |
21 |
22 |
23 | indent-xs
24 |
25 |
26 |
27 | indent-sm
28 |
29 |
30 |
31 | indent-md
32 |
33 |
34 |
35 | indent-lg
36 |
37 |
38 |
39 | indent-xl
40 |
41 |
42 |
43 | indent-2xl
44 |
45 |
46 |
47 | indent-3xl
48 |
49 |
50 |
51 | -indent-xs
52 |
53 |
54 |
55 | -indent-5rpx
56 |
57 |
58 | )
59 | }
60 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/config/prod.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"production"'
4 | },
5 | defineConstants: {
6 | },
7 | mini: {},
8 | h5: {
9 | /**
10 | * WebpackChain 插件配置
11 | * @docs https://github.com/neutrinojs/webpack-chain
12 | */
13 | // webpackChain (chain) {
14 | // /**
15 | // * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
16 | // * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
17 | // */
18 | // chain.plugin('analyzer')
19 | // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
20 |
21 | // /**
22 | // * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
23 | // * @docs https://github.com/chrisvfritz/prerender-spa-plugin
24 | // */
25 | // const path = require('path')
26 | // const Prerender = require('prerender-spa-plugin')
27 | // const staticDir = path.join(__dirname, '..', 'dist')
28 | // chain
29 | // .plugin('prerender')
30 | // .use(new Prerender({
31 | // staticDir,
32 | // routes: [ '/pages/index/index' ],
33 | // postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
34 | // }))
35 | // }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_react/config/prod.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"production"'
4 | },
5 | defineConstants: {
6 | },
7 | mini: {},
8 | h5: {
9 | /**
10 | * WebpackChain 插件配置
11 | * @docs https://github.com/neutrinojs/webpack-chain
12 | */
13 | // webpackChain (chain) {
14 | // /**
15 | // * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
16 | // * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
17 | // */
18 | // chain.plugin('analyzer')
19 | // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
20 |
21 | // /**
22 | // * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
23 | // * @docs https://github.com/chrisvfritz/prerender-spa-plugin
24 | // */
25 | // const path = require('path')
26 | // const Prerender = require('prerender-spa-plugin')
27 | // const staticDir = path.join(__dirname, '..', 'dist')
28 | // chain
29 | // .plugin('prerender')
30 | // .use(new Prerender({
31 | // staticDir,
32 | // routes: [ '/pages/index/index' ],
33 | // postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
34 | // }))
35 | // }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/taro_webpack5_vue3/config/prod.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"production"'
4 | },
5 | defineConstants: {
6 | },
7 | mini: {},
8 | h5: {
9 | /**
10 | * WebpackChain 插件配置
11 | * @docs https://github.com/neutrinojs/webpack-chain
12 | */
13 | // webpackChain (chain) {
14 | // /**
15 | // * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
16 | // * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
17 | // */
18 | // chain.plugin('analyzer')
19 | // .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
20 |
21 | // /**
22 | // * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
23 | // * @docs https://github.com/chrisvfritz/prerender-spa-plugin
24 | // */
25 | // const path = require('path')
26 | // const Prerender = require('prerender-spa-plugin')
27 | // const staticDir = path.join(__dirname, '..', 'dist')
28 | // chain
29 | // .plugin('prerender')
30 | // .use(new Prerender({
31 | // staticDir,
32 | // routes: [ '/pages/index/index' ],
33 | // postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
34 | // }))
35 | // }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/taro_webpack4_vue3/src/pages/attributify-mode/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
19 |
20 |
28 |
29 |
32 |
33 |
36 |
37 |
38 | This conflicts with links' text prop
39 |
40 |
41 |
42 | 111
43 |
44 |
45 |
46 | 111
47 |
48 |
49 |
50 | 111
51 |
52 |
53 |
54 | valueless
55 |
56 |
57 |
58 |
59 | p
60 |
61 |
62 |
63 |
64 |
67 |
--------------------------------------------------------------------------------