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

Styling: adding !important modifier does not set dynamic CSS variable for styling control flow #728

Open
Namek opened this issue Jan 10, 2025 · 0 comments

Comments

@Namek
Copy link
Contributor

Namek commented Jan 10, 2025

This is a follow-up of the #727 about the case not working in styles. Also, I need to use !important because of this issue of the style ordering: #723

Issue: using an if causes using a dynamically created CSS variable. However, adding the !important modifier stops variables being set (see 2nd screenshot below).

Sandbox:
https://mint-lang.com/sandbox/6sgyVm785ocTDw

Image
type Edge {
  Start
  Middle
  End
}

component Main {
  fun render : Html {
    <div>
      <p>"All text below should NOT be black"</p>
      <hr/>
      <p::test(Edge.Start)>"Hello Wold!"</p>
      <p::test(Edge.Middle)>"Hello Wold!"</p>
      <p::test(Edge.End)>"Hello Wold!"</p>
      <hr/>
      <p::test2(Edge.Start)>"Hello Wold!"</p>
      <p::test2(Edge.Middle)>"Hello Wold!"</p>
      <p::test2(Edge.End)>"Hello Wold!"</p>
    </div>
  }

  style test(edge : Edge) {
    case edge {
      Start => {
        color: red;
      }
      Middle => {
        color: green;
      }
      End => {
        color: brown;
      }
    }
  }

  style test2(edge : Edge) {
    if edge == Edge.Start {
      color: red !important;
    }

    else if edge == Edge.Middle {
      color: green !important;
    }

    else if edge == Edge.End {
      color: brown !important;
    }
  }
}
Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant