Skip to content

Commit

Permalink
fix(preset-theme-default): merge user shortcutOverrides in shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-solanki committed Dec 30, 2022
1 parent a1f46c5 commit 407862a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
1 change: 0 additions & 1 deletion packages/preset-theme-default/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default defineBuildConfig({
externals: [
'@unocss/core',
'@unocss/reset',
'defu',
],
hooks: {
'mkdist:done': () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/preset-theme-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
"vuejs",
"vue"
],
"dependencies": {
"defu": "^6.1.1"
},
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@unocss/core": "^0.45.30",
Expand Down
11 changes: 6 additions & 5 deletions packages/preset-theme-default/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Preset } from '@unocss/core'
import { defu } from 'defu'
import { rules } from './rules'
import { shortcuts } from './shortcuts'
import { variants } from './variants'
Expand All @@ -15,7 +14,7 @@ interface PresetOptions {
export const colors = ['primary', 'success', 'info', 'warning', 'danger'] as const
export type Colors = typeof colors

export function presetThemeDefault(options: PresetOptions = {}): Preset {
export function presetThemeDefault(options: PresetOptions = {}): Preset {
return {
name: '@anu-vue/preset-theme-default',
theme: {
Expand Down Expand Up @@ -47,9 +46,11 @@ export function presetThemeDefault(options: PresetOptions = {}): Preset {
...['top', 'right', 'bottom', 'left'].map(dir => `a-drawer-anchor-${dir}`),
],
rules,
shortcuts: options.shortcutOverrides
? defu(options.shortcutOverrides, shortcuts)
: shortcuts,
shortcuts: options.shortcutOverrides === undefined
? shortcuts
: Array.isArray(options.shortcutOverrides)
? [...options.shortcutOverrides, ...shortcuts]
: [...Object.entries(options.shortcutOverrides), ...shortcuts],
variants,
}
}
4 changes: 2 additions & 2 deletions packages/preset-theme-default/src/shortcuts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Preset } from '@unocss/core'
import type { Preset, StaticShortcutMap } from '@unocss/core'

const shortcuts: Preset['shortcuts'] = [
const shortcuts: Exclude<Preset['shortcuts'], undefined | StaticShortcutMap> = [
// 👉 States
[/^states:?(\d+)?$/, ([, op]) => `\
relative \
Expand Down
9 changes: 3 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 407862a

Please sign in to comment.