Skip to content

Commit

Permalink
feat: focus-visible:
Browse files Browse the repository at this point in the history
  • Loading branch information
MellowCo committed Jun 15, 2023
1 parent e8732e4 commit b6c4a17
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/variants/pseudo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,16 @@ const PseudoClassFunctions = [
'has',
]

const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith('::')).map(([key]) => key).join('|')
const PseudoClassesColonStr = Object.entries(PseudoClassesColon).filter(([, pseudo]) => !pseudo.startsWith('::')).map(([key]) => key).join('|')
const PseudoClassesStr = Object.entries(PseudoClasses)
.filter(([, pseudo]) => !pseudo.startsWith('::'))
.map(([key]) => key)
.sort((a, b) => b.length - a.length)
.join('|')
const PseudoClassesColonStr = Object.entries(PseudoClassesColon)
.filter(([, pseudo]) => !pseudo.startsWith('::'))
.map(([key]) => key)
.sort((a, b) => b.length - a.length)
.join('|')
const PseudoClassFunctionsStr = PseudoClassFunctions.join('|')

function taggedPseudoClassMatcher(tag: string, parent: string, combinator: string): VariantObject {
Expand Down Expand Up @@ -184,8 +192,14 @@ function taggedPseudoClassMatcher(tag: string, parent: string, combinator: strin
}
}

const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join('|')
const PseudoClassesAndElementsColonStr = Object.entries(PseudoClassesColon).map(([key]) => key).join('|')
const PseudoClassesAndElementsStr = Object.entries(PseudoClasses)
.map(([key]) => key)
.sort((a, b) => b.length - a.length)
.join('|')
const PseudoClassesAndElementsColonStr = Object.entries(PseudoClassesColon)
.map(([key]) => key)
.sort((a, b) => b.length - a.length)
.join('|')

export function variantPseudoClassesAndElements(): VariantObject<Theme> {
let PseudoClassesAndElementsRE: RegExp
Expand Down
1 change: 1 addition & 0 deletions test/assets/output/preset-mini-targets.css
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ unocss .scope-\[unocss\]\:block{display:block;}
.outline-revert-layer{outline-style:revert-layer;}
.outline-unset{outline-style:unset;}
.outline-none{outline:2px solid transparent;outline-offset:2px;}
.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px;}
.appearance-none{-webkit-appearance:none;appearance:none;}
.order-\$variable{order:var(--variable);}
.order-first{order:-9999;}
Expand Down
1 change: 1 addition & 0 deletions test/assets/output/preset-weapp-rules.css
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ unocss .scope-_lfl11_unocss_lfr11__cl11_block{display:block;}
.outline-revert-layer{outline-style:revert-layer;}
.outline-unset{outline-style:unset;}
.outline-none{outline:2px solid transparent;outline-offset:2px;}
.focus-visible_cl11_outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px;}
.appearance-none{-webkit-appearance:none;appearance:none;}
.order-_do11_variable{order:var(--variable);}
.order-first{order:-9999;}
Expand Down
1 change: 1 addition & 0 deletions test/assets/output/preset-weapp.css
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ unocss .scope-_lfl_unocss_lfr__cl_block{display:block;}
.outline-revert-layer{outline-style:revert-layer;}
.outline-unset{outline-style:unset;}
.outline-none{outline:2px solid transparent;outline-offset:2px;}
.focus-visible_cl_outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px;}
.appearance-none{-webkit-appearance:none;appearance:none;}
.order-_do_variable{order:var(--variable);}
.order-first{order:-9999;}
Expand Down
1 change: 1 addition & 0 deletions test/assets/preset-mini-targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ export const presetMiniTargets: string[] = [
'first-line:bg-green-400',
'first-letter:bg-green-400',
'group-hover:group-focus:text-center',
'focus-visible:outline-none',
'hover:!p-1',
'hover:not-first:checked:bg-red/10',
'hover:p-5',
Expand Down

0 comments on commit b6c4a17

Please sign in to comment.