Skip to content

Styling: case control flow doesn't add attributes #727

Closed
@Namek

Description

@Namek

Issue: no color is applied in the example below.

https://mint-lang.com/sandbox/kCgrWZIMx8CVeA

Image
type Edge {
  Start
  Middle
  End
}

component Main {
  fun render : Html {
    <div>
      <p::test(Edge.Start)>"Hello Wold!"</p>
      <p::test(Edge.Middle)>"Hello Wold!"</p>
      <p::test(Edge.End)>"Hello Wold!"</p>
    </div>
  }

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

The workaround is to use ifs:

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

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

    else if edge == Edge.End {
      color: brown;
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    languageLanguage feature

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions