gluestack / gluestack-ui

React & React Native Components & Patterns (copy-paste components & patterns crafted with Tailwind CSS (NativeWind))
https://gluestack.io/
MIT License
2.26k stars 110 forks source link

SVG descendant styles not being applied in dark mode #2177

Open jordmccord opened 3 months ago

jordmccord commented 3 months ago

Description

When applying descendant styles to an SVG color prop they change in dark mode.

CodeSandbox/Snack link

/

Steps to reproduce

  1. Create styled component using Svg from react-native-svg e.g:
    
    import { styled } from '@gluestack-style/react';

import { Svg } from 'react-native-svg';

const SpinnerSVG = styled( Svg, { color: '$purple800', _dark: { color: '$darkPurple800', }, }, { componentName: 'SpinnerSvg', ancestorStyle: ['_svg'], descendantStyle: ['_circle'], } );

export default SpinnerSVG;

2. Use that component in a parent component like Button
3. Style the child component e.g `Button.ts` blue variant:
```js
...
blue: {
  _spinner: {
    _svg: {
      color: '$blue400',
    },
  },
  _dark: {
    _spinner: {
      _svg: {
        color: '$darkBlue400',
      },
    }
  }
}
...
  1. See the SVG color only change in light mode

Screenshot 2024-05-22 at 10 58 34 Light mode changes color

Screenshot 2024-05-22 at 10 58 43 Dark mode reverts to default colour

gluestack-ui Version

@gluestack-style/react@1.0.56, @gluestack-ui/themed@1.1.26

Platform

Other Platform

No response

Additional Information

There is also a TS error saying color prop doesn't exist in dark mode see: Screenshot 2024-05-22 at 10 59 05

Works fine on web but not on Android or iOS

ankit-tailor commented 3 months ago

Hey @jordmccord, Thanks for reporting the issue. We'll look into it.

jordmccord commented 2 months ago

Hey @ankit-tailor, did you manage to take a look?