Skip to content

Commit

Permalink
feat: support space between and divide width, close #21
Browse files Browse the repository at this point in the history
  • Loading branch information
nei1ee committed May 29, 2023
1 parent 0e97c72 commit 156c8c5
Show file tree
Hide file tree
Showing 11 changed files with 2,023 additions and 2,157 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@
"build:taro:h5": "npm -C playgrounds/tarojs run build:h5"
},
"devDependencies": {
"@antfu/eslint-config": "^0.38.6",
"@iconify-json/tabler": "^1.1.74",
"@types/node": "^18.16.10",
"@antfu/eslint-config": "^0.39.3",
"@iconify-json/tabler": "^1.1.77",
"@types/node": "^18.16.16",
"@unocss-applet/preset-applet": "workspace:*",
"@unocss-applet/preset-rem-rpx": "workspace:*",
"@unocss-applet/transformer-applet": "workspace:*",
"@unocss-applet/transformer-attributify": "workspace:*",
"@unocss-applet/utils": "workspace:*",
"bumpp": "^9.1.0",
"eslint": "^8.40.0",
"eslint": "^8.41.0",
"esno": "^0.16.3",
"magic-string": "^0.30.0",
"rimraf": "^5.0.0",
"rimraf": "^5.0.1",
"typescript": "^5.0.4",
"unbuild": "^1.2.1",
"unocss": "^0.51.13",
"unocss": "^0.52.4",
"unocss-applet": "workspace:*",
"unocss-preset-extra": "^0.5.2",
"vite": "^4.3.6",
"vitest": "^0.31.0"
"vite": "^4.3.9",
"vitest": "^0.31.1"
}
}
6 changes: 3 additions & 3 deletions packages/preset-applet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"dependencies": {
"@unocss-applet/utils": "workspace:*",
"@unocss/core": "^0.51.13",
"@unocss/preset-mini": "^0.51.13",
"@unocss/preset-uno": "^0.51.13"
"@unocss/core": "^0.52.4",
"@unocss/preset-mini": "^0.52.4",
"@unocss/preset-uno": "^0.52.4"
}
}
32 changes: 31 additions & 1 deletion packages/preset-applet/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Preset } from 'unocss'
import type { Preset, Variant } from 'unocss'
import { presetUno } from 'unocss'
import type { PresetUnoOptions, Theme } from '@unocss/preset-uno'
import { normalizePreflights } from '@unocss/preset-mini'
Expand All @@ -20,6 +20,33 @@ export interface PresetAppletOptions extends PresetUnoOptions {
* @default ['.', ':', '%', '!', '#', '(', ')', '[', '/', ']', ',', '$', '{', '}', '@', '+', '^', '&', '<', '>', '\'']
*/
unsupportedChars?: string[]

/**
* Space Between and Divide Width Elements
* @default ['view', 'button', 'text', 'image']
*/
betweenElements?: string[]
}

function variantSpaceAndDivide(options: PresetAppletOptions): Variant<Theme>[] {
const betweenElements = options?.betweenElements ?? ['view', 'button', 'text', 'image']

return [
(matcher) => {
if (matcher.startsWith('_'))
return

if (/space-?([xy])-?(-?.+)$/.test(matcher) || /divide-/.test(matcher)) {
return {
matcher,
selector: (input) => {
const selectors = betweenElements.map(el => `${input}>${el}+${el}`)
return selectors.join(',')
},
}
}
},
]
}

export default function presetApplet(options: PresetAppletOptions = {}): Preset<Theme> {
Expand Down Expand Up @@ -61,5 +88,8 @@ export default function presetApplet(options: PresetAppletOptions = {}): Preset<
return util
},
],
variants: [
...variantSpaceAndDivide(options),
],
}
}
56 changes: 28 additions & 28 deletions playgrounds/tarojs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,37 @@
"ios >= 8"
],
"dependencies": {
"@babel/runtime": "^7.21.5",
"@tarojs/components": "3.6.6",
"@tarojs/helper": "3.6.6",
"@tarojs/plugin-framework-vue3": "3.6.6",
"@tarojs/plugin-html": "^3.6.6",
"@tarojs/plugin-platform-alipay": "3.6.6",
"@tarojs/plugin-platform-jd": "3.6.6",
"@tarojs/plugin-platform-qq": "3.6.6",
"@tarojs/plugin-platform-swan": "3.6.6",
"@tarojs/plugin-platform-tt": "3.6.6",
"@tarojs/plugin-platform-weapp": "3.6.6",
"@tarojs/router": "3.6.6",
"@tarojs/runtime": "3.6.6",
"@tarojs/shared": "3.6.6",
"@tarojs/taro": "3.6.6",
"@tarojs/taro-h5": "3.6.6",
"vue": "^3.3.2"
"@babel/runtime": "^7.22.3",
"@tarojs/components": "3.6.7",
"@tarojs/helper": "3.6.7",
"@tarojs/plugin-framework-vue3": "3.6.7",
"@tarojs/plugin-html": "^3.6.7",
"@tarojs/plugin-platform-alipay": "3.6.7",
"@tarojs/plugin-platform-jd": "3.6.7",
"@tarojs/plugin-platform-qq": "3.6.7",
"@tarojs/plugin-platform-swan": "3.6.7",
"@tarojs/plugin-platform-tt": "3.6.7",
"@tarojs/plugin-platform-weapp": "3.6.7",
"@tarojs/router": "3.6.7",
"@tarojs/runtime": "3.6.7",
"@tarojs/shared": "3.6.7",
"@tarojs/taro": "3.6.7",
"@tarojs/taro-h5": "3.6.7",
"vue": "^3.3.4"
},
"devDependencies": {
"@babel/core": "^7.21.8",
"@tarojs/cli": "3.6.6",
"@tarojs/webpack5-runner": "3.6.6",
"@types/webpack-env": "^1.18.0",
"@unocss/webpack": "^0.51.13",
"@babel/core": "^7.22.1",
"@tarojs/cli": "3.6.7",
"@tarojs/webpack5-runner": "3.6.7",
"@types/webpack-env": "^1.18.1",
"@unocss/webpack": "^0.52.4",
"@vue/babel-plugin-jsx": "^1.1.1",
"@vue/compiler-sfc": "^3.3.2",
"babel-preset-taro": "3.6.6",
"css-loader": "6.7.3",
"style-loader": "3.3.2",
"@vue/compiler-sfc": "^3.3.4",
"babel-preset-taro": "3.6.7",
"css-loader": "6.8.1",
"style-loader": "3.3.3",
"typescript": "^5.0.4",
"vue-loader": "^17.1.1",
"webpack": "5.82.1"
"vue-loader": "^17.1.2",
"webpack": "5.84.1"
}
}
40 changes: 20 additions & 20 deletions playgrounds/uni-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,30 @@
"build:quickapp-webview-union": "uni build -p quickapp-webview-union"
},
"dependencies": {
"@dcloudio/uni-app": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-app-plus": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-components": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-h5": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3080220230511001",
"ano-ui": "^0.7.7",
"vue": "^3.3.2",
"@dcloudio/uni-app": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-app-plus": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-components": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-h5": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3080320230523001",
"ano-ui": "^0.8.0",
"vue": "^3.3.4",
"vue-i18n": "^9.2.2"
},
"devDependencies": {
"@dcloudio/types": "^3.3.3",
"@dcloudio/uni-automator": "3.0.0-alpha-3080220230511001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3080220230511001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3080220230511001",
"@iconify-json/carbon": "^1.1.16",
"postcss": "^8.4.23",
"@dcloudio/uni-automator": "3.0.0-alpha-3080320230523001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3080320230523001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3080320230523001",
"@iconify-json/carbon": "^1.1.17",
"postcss": "^8.4.24",
"sass": "^1.62.1",
"vite-plugin-inspect": "^0.7.26"
"vite-plugin-inspect": "^0.7.28"
}
}
6 changes: 5 additions & 1 deletion playgrounds/uni-app/src/pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ const fixed = ref(true)
</div>
</template>
</div>
<div>
<div >
before:content-test
<div class="before:content-['english']" />
<div class="before:content-['中文']" />
</div>
<div class="divide-y-4 space-y-2 divide-red divide-solid">
<div>1</div>
<div>2</div>
</div>
</div>
</template>

Expand Down
File renamed without changes.
Loading

0 comments on commit 156c8c5

Please sign in to comment.