Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aria-x and data-x support (unocss/unocss#1816)
- Loading branch information
Showing
12 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const aria = { | ||
busy: 'busy="true"', | ||
checked: 'checked="true"', | ||
disabled: 'disabled="true"', | ||
expanded: 'expanded="true"', | ||
hidden: 'hidden="true"', | ||
pressed: 'pressed="true"', | ||
readonly: 'readonly="true"', | ||
required: 'required="true"', | ||
selected: 'selected="true"', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { VariantContext, VariantObject } from '@unocss/core' | ||
import type { Theme } from '../theme' | ||
import { handler as h, variantGetParameter } from '../utils' | ||
|
||
export const variantAria: VariantObject = { | ||
name: 'aria', | ||
match(matcher, { theme }: VariantContext<Theme>) { | ||
const variant = variantGetParameter('aria', matcher, [':', '-']) | ||
if (variant) { | ||
const [match, rest] = variant | ||
const aria = h.bracket(match) ?? theme.aria?.[match] ?? '' | ||
if (aria) { | ||
return { | ||
matcher: rest, | ||
selector: s => `${s}[aria-${aria}]`, | ||
} | ||
} | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { VariantContext, VariantObject } from '@unocss/core' | ||
import type { Theme } from '../theme' | ||
import { handler as h, variantGetParameter } from '../utils' | ||
|
||
export const variantDataAttribute: VariantObject = { | ||
name: 'data', | ||
match(matcher, { theme }: VariantContext<Theme>) { | ||
const variant = variantGetParameter('data', matcher, [':', '-']) | ||
if (variant) { | ||
const [match, rest] = variant | ||
const dataAttribute = h.bracket(match) ?? theme.data?.[match] ?? '' | ||
|
||
if (dataAttribute) { | ||
return { | ||
matcher: rest, | ||
selector: s => `${s}[data-${dataAttribute}]`, | ||
} | ||
} | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters