Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #152 from gluestack/fix/inline-specificity-web
Browse files Browse the repository at this point in the history
fix: inline style specificity
  • Loading branch information
surajahmed authored Apr 25, 2023
2 parents 9457d8d + 5751836 commit 39158cb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
15 changes: 10 additions & 5 deletions example/storybook/src/api/Specificity/Specificity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ export function Specificity({ ...args }) {
variant="redbox"
states={{ hover: true }}
bg="$red500"
// sx={{
// _dark: {
// bg: '$amber900',
// },
// }}
sx={{
'_dark': {
bg: '$blue500',
},
'@md': {
_dark: {
bg: '$green400',
},
},
}}
// sx={{ style: { bg: '$amber400' } }}
>
<Text>bluebox - sm</Text>
Expand Down
20 changes: 13 additions & 7 deletions packages/react/src/utils/cssify/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,26 @@ const createCssRule = (
prefixColorMode: string
) => {
let rule;
const dataMediaSelector = prefixClassName
? `.${prefixClassName} [data-${dataType}~="${stringHash}"]`
: `[data-${dataType}~="${stringHash}"]`;
const dataMediaSelector = `[data-${dataType}~="${stringHash}"]`;

if (isMedia(mediaQuery) && isColorScheme(colorSchemeQuery)) {
// rule = `${mediaQuery} {${colorSchemeQuery} {${dataMediaSelector} ${css}} .${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}}`;
rule = `${mediaQuery} {.${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}}`;
rule = prefixClassName
? `${mediaQuery} {.${prefixClassName}.${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}}`
: `${mediaQuery} {.${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}}`;
} else if (isMedia(mediaQuery)) {
rule = `${mediaQuery} {${dataMediaSelector} ${css}}`;
rule = prefixClassName
? `${mediaQuery} {.${prefixClassName} ${dataMediaSelector} ${css}}`
: `${mediaQuery} {${dataMediaSelector} ${css}}`;
} else if (isColorScheme(colorSchemeQuery)) {
// rule = `${colorSchemeQuery} {${dataMediaSelector} ${css}} .${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}`;
rule = `.${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}`;
rule = prefixClassName
? `.${prefixClassName}.${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}`
: `.${prefixColorMode}${colorMode} ${dataMediaSelector} ${css}`;
} else {
rule = `${dataMediaSelector}${mediaQuery} ${css}`;
rule = prefixClassName
? `.${prefixClassName} ${dataMediaSelector}${mediaQuery} ${css}`
: `${dataMediaSelector}${mediaQuery} ${css}`;
}

return rule;
Expand Down

0 comments on commit 39158cb

Please sign in to comment.