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

Nesting Mixins in Media Queries and Selectors #40

Closed
jantimon opened this issue Dec 6, 2023 · 1 comment
Closed

Nesting Mixins in Media Queries and Selectors #40

jantimon opened this issue Dec 6, 2023 · 1 comment

Comments

@jantimon
Copy link
Owner

jantimon commented Dec 6, 2023

Currently, next-yak lacks support for nesting mixins within media queries and nestings.

const Button = styled.button`
  @media (min-width: 768px) {
    ${hoverStyles}
  }
`;

Problem:

The above code results in unexpected behavior since hoverStyles generates its own class name, which is independent from Button and therefore also independent of the Button components nested usage of the mixin.

MVP:

Display a clear error message when users attempt to use mixins in unsupported contexts, such as media queries or nested structures.

Caution

next-yak currently does not allow mixins to be used directly within media queries or nested structures

Inline mixin:

If doable we should probable add support for nesting mixins directly within a component, enabling constructs like the following:

const Button = styled.button`
  &:focus {
    ${({$primary}) => $primary && css`color: red`}
  }
`;

Additional Considerations:

We might add support for mixins which are imported from .yak files e.g.:

import { hoverStyles } from "./mixins.yak";
const Button = styled.button`
  @media (min-width: 768px) {
    ${hoverStyles}
  }
`;
@jantimon
Copy link
Owner Author

[email protected] adds better errors - thanks @Mad-Kat

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

No branches or pull requests

1 participant