Skip to content

Commit

Permalink
Merge pull request #1612 from gluestack/release/@gluestack-style/reac…
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-tailor authored Jan 11, 2024
2 parents d5c5eb7 + 2c32b3a commit 2a5d535
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions packages/styled/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @gluestack-style/react

## 1.0.36

### Patch Changes

- - Fixed data theme id attribute

## 1.0.35

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/styled/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gluestack-style/react",
"description": "A universal & performant styling library for React Native, Next.js & React",
"version": "1.0.35",
"version": "1.0.36",
"keywords": [
"React Native",
"Next.js",
Expand Down
19 changes: 13 additions & 6 deletions packages/styled/react/src/StyledProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const StyledProvider: React.FC<{

const { themes } = useTheme();
const styledContext = useStyled();
const isParentProviderExist = styledContext?.config ? true : false;
const isParentProviderExist =
Object.keys(styledContext?.config).length > 0 ? true : false;

const themeContextValue = React.useMemo(() => {
if (colorMode) {
Expand Down Expand Up @@ -139,7 +140,9 @@ export const StyledProvider: React.FC<{

if (currentColorMode) {
if (!isParentProviderExist) {
document.body.setAttribute('data-theme-id', currentColorMode);
documentElement
.querySelector('body')
?.setAttribute('data-theme-id', currentColorMode);
documentElement.classList.add(`gs-${currentColorMode}`);
}
} else {
Expand All @@ -158,14 +161,18 @@ export const StyledProvider: React.FC<{
if (currentColor) {
if (currentColor === 'dark') {
if (!isParentProviderExist) {
document.body.setAttribute('data-theme-id', 'dark');
documentElement
.querySelector('body')
?.setAttribute('data-theme-id', 'dark');
documentElement.classList.remove(`gs-light`);
}
documentElement.classList.remove(`gs-light`);
} else {
if (!isParentProviderExist) {
document.body.setAttribute('data-theme-id', 'light');
documentElement
.querySelector('body')
?.setAttribute('data-theme-id', 'light');
documentElement.classList.remove(`gs-dark`);
}
documentElement.classList.remove(`gs-dark`);
}
if (!isParentProviderExist) {
documentElement.classList.add(`gs-${currentColor}`);
Expand Down

0 comments on commit 2a5d535

Please sign in to comment.