Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix css prop inline media style applied #37

Merged

Conversation

tkow
Copy link
Contributor

@tkow tkow commented Nov 8, 2022

This PR fixes css prop passed from parent component doesn't interpret media prop.

Now,

<Component
  css={{
    '@bp1': {
      margin: 1
    }
  }}
/>

is valid as css type defined.

@tkow
Copy link
Contributor Author

tkow commented Nov 15, 2022

@Temzasse
Hi, sorry to interrupt you, but I made two more PRs fixes bugs. When you have time to spare them, could you check them?

Copy link
Owner

@Temzasse Temzasse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🙏🏻 ✨

Not directly related to this PR but I realized we are calculating the mediaKey partially incorrectly in resolveMediaRangeQuery. It only handles media queries but not boolean flags for cases where you just want to have something like this:

const isTablet = DeviceInfo().isTablet();

createStitches({
  media: {
    phone: !isTablet,
    tablet: isTablet,
  }
});

const Example = styled('View', {
  backgroundColor: 'red',
  '@tablet': {
    backgroundColor: 'blue',
  }
});

I will take a look at resolveMediaRangeQuery and try to fix this. Basically mediaKey should be an array since it's possible to have two media keys be valid at the same time, eg. tablet and lg.

@Temzasse
Copy link
Owner

Thanks! 🙏🏻 ✨

Not directly related to this PR but I realized we are calculating the mediaKey partially incorrectly in resolveMediaRangeQuery. It only handles media queries but not boolean flags for cases where you just want to have something like this:

const isTablet = DeviceInfo().isTablet();

createStitches({
  media: {
    phone: !isTablet,
    tablet: isTablet,
  }
});

const Example = styled('View', {
  backgroundColor: 'red',
  '@tablet': {
    backgroundColor: 'blue',
  }
});

I will take a look at resolveMediaRangeQuery and try to fix this. Basically mediaKey should be an array since it's possible to have two media keys be valid at the same time, eg. tablet and lg.

Added a new issue about this: #39

@Temzasse Temzasse merged commit 70dc38a into Temzasse:main Nov 15, 2022
@Temzasse
Copy link
Owner

@tkow this was release in v0.3.1.

tkow added a commit to MOCHI-inc-JAPAN/stitches-native that referenced this pull request Nov 16, 2022
* Fix css prop inline media style applied (Temzasse#37)

* fix: inline style media properties available

* chore: add example inline media style

* Cleanup code

* v0.3.1

* fix: handle boolean flag media prop and multiple media styles can be applied

* chore: add multiple media example

Co-authored-by: Teemu Taskula <themetor@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants