Skip to content

Lucius/Cassius mixins #194

@okdewit

Description

@okdewit

If I implement the Lucius mixin example:

transition val =
    [luciusMixin|
        -webkit-transition: #{val};
        -moz-transition: #{val};
        -ms-transition: #{val};
        -o-transition: #{val};
        transition: #{val};
    |]

myCSS =
    [lucius|
        .some-class {
            ^{transition "all 4s ease"}
        }
    |]

I get a type error:

 No instance for (IsString a0)
      arising from the literal ‘"all 0.2s ease-out"’
    The type variable ‘a0’ is ambiguous

Which I solved by defining the type explicitly, although I do not know if this is correct.

module Mixin where

{-# LANGUAGE QuasiQuotes #-}
import Text.Lucius
import Data.Text

transition :: Text -> Mixin
transition val =
    [luciusMixin|
        -webkit-transition: #{val};
        -moz-transition: #{val};
        -ms-transition: #{val};
        -o-transition: #{val};
        transition: #{val};
    |]

Then, in a .lucius template file this works fine:

#menu {
    ^{transition "all 0.2s ease-out"}
}

but in a .cassius file this doesn't, both with luciusMixin and cassiusMixin:

#menu
    ^{transition "all 0.2s ease-out"}
#menu {
    ^{transition "all 0.2s ease-out"};}
" (line 12, column 1):
unexpected end of input
expecting "#", "@", "/*", "\\" or ":"
    Code: widgetFile "main"
    In the splice: $(widgetFile "main")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions