-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a00c069
commit f4132e9
Showing
4 changed files
with
87 additions
and
2 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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import rules from './rules/index.js' | ||
import theme from './theme.js' | ||
import blocklistVariants from './variants/index.js' | ||
|
||
export default function presetRnMpx () { | ||
return { | ||
name: '@mpxjs/unocss-preset-rn', | ||
rules, | ||
theme | ||
theme, | ||
blocklist: [ | ||
...blocklistVariants | ||
] | ||
} | ||
} |
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,75 @@ | ||
import { | ||
variantAria, | ||
variantTaggedAriaAttributes, | ||
variantChildren, | ||
variantCombinators, | ||
variantContainerQuery, | ||
variantTaggedDataAttributes, | ||
variantLanguageDirections, | ||
variantStartingStyle, | ||
variantSupports, | ||
variantSelector, | ||
variantCssLayer, | ||
variantScope | ||
} from '@unocss/preset-mini/variants' | ||
import { | ||
variantCombinators as windVariantCombinator, | ||
variantContrasts, | ||
variantMotions, | ||
variantSpaceAndDivide, | ||
variantStickyHover, | ||
placeholderModifier | ||
} from '@unocss/preset-wind/variants' | ||
|
||
const wrapVariant = function (variant) { | ||
return function (raw) { | ||
const ctx = { | ||
rawSelector: raw, | ||
theme: this.config, | ||
generator: this | ||
} | ||
const { match } = variant | ||
if (match(raw, ctx)) { | ||
this._mpx2rnUnsuportedRules = this._mpx2rnUnsuportedRules || [] | ||
this._mpx2rnUnsuportedRules.push(raw) | ||
return true | ||
} | ||
} | ||
} | ||
|
||
const transformVariants = function (variantsArr) { | ||
return variantsArr.map(variants => { | ||
if (Array.isArray(variants)) { | ||
return variants.map(variant => wrapVariant(variant)) | ||
} else { | ||
return wrapVariant(variants) | ||
} | ||
}).reduce((preV, curV) => { | ||
if (Array.isArray(curV)) { | ||
return preV.concat(...curV) | ||
} else { | ||
return preV.concat(curV) | ||
} | ||
}, []) | ||
} | ||
|
||
export default transformVariants([ | ||
variantAria, | ||
variantTaggedAriaAttributes, | ||
variantChildren, | ||
variantCombinators, | ||
variantContainerQuery, | ||
variantTaggedDataAttributes, | ||
variantLanguageDirections, | ||
variantStartingStyle, | ||
variantSupports, | ||
variantSelector, | ||
variantCssLayer, | ||
variantScope, | ||
windVariantCombinator, | ||
variantContrasts, | ||
variantMotions, | ||
variantSpaceAndDivide, | ||
variantStickyHover, | ||
placeholderModifier | ||
]) |
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