Skip to content

Commit

Permalink
fix(presetUni): types error
Browse files Browse the repository at this point in the history
  • Loading branch information
KeJunMao committed Oct 17, 2023
1 parent 018aac2 commit bc2b813
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion playground/src/pages/index.h5.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div container mx-auto py-10>
<view class="cursor-pointer border-1 inline-block p-2 rounded uni-h5:mx-auto uni-mp-weixin:bg-red uni-[h5]:bg-blue">
<view class="cursor-pointer border-1 inline-block p-2 rounded uni-web:mx-auto uni-h5:mx-auto">
h5 page
</view>
</div>
Expand Down
2 changes: 1 addition & 1 deletion playground/src/pages/index.mp-weixin.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div container mx-auto py-10>
<view class="bg-blue cursor-pointer border-1 inline-block p-2 rounded">
<view class="bg-blue cursor-pointer border-1 inline-block p-2 rounded uni-wechat:mx-auto uni-mp:mx-auto">
weixin page
</view>
</div>
Expand Down
6 changes: 6 additions & 0 deletions playground/uno.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ export default defineConfig({
transformerDirectives(),
transformerVariantGroup(),
],
theme: {
platforms: {
wechat: 'mp-weixin',
web: 'h5',
},
},
})
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function defineConfig<T extends object = Theme>(config: UserConfig<T> & U
attributify: config.attributify,
}
if (!config.presets)
// @ts-expect-error ignore
config.presets = [presetUni(options)]

const transformers = createTransformers(resolveOptions(options))
Expand Down
15 changes: 6 additions & 9 deletions src/presetUni.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { builtInPlatforms } from '@uni-helper/uni-env'
import type { PresetFactory } from 'unocss'
import { definePreset } from 'unocss'

import type { Preset } from 'unocss'
import type { Theme } from '@unocss/preset-mini'
import { resolveOptions } from './options'
import { createPresets } from './presets'
import type { UserUniPresetOptions } from './types'
import { createVariants } from './variants'

const presetFactoryUni: PresetFactory = (userOptions: UserUniPresetOptions = {}) => {
export function presetUni<T extends object = Theme>(userOptions: UserUniPresetOptions = {}): Preset<T> {
const options = resolveOptions(userOptions)
const presets = createPresets(options)
const variants = createVariants()
const presets = createPresets<T>(options)
const variants = createVariants<T>()

return {
name: 'unocss-preset-uni',
Expand All @@ -24,8 +23,6 @@ const presetFactoryUni: PresetFactory = (userOptions: UserUniPresetOptions = {})
acc[withoutPrefix] = platform
return acc
}, { mp: 'mp', app: 'app', quickapp: 'quickapp' } as any),
},
} as any,
}
}

export const presetUni = definePreset(presetFactoryUni)

0 comments on commit bc2b813

Please sign in to comment.