This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0 1.0.1
README

Css.Helpers

Utility functions for elm-css.

toCssIdentifier : a -> String

Converts an arbitrary value to a valid CSS identifier by calling toString on it, trimming it, replacing chunks of whitespace with -, and stripping out invalid characters.

identifierToString : a -> b -> String

Converts an arbitrary identifier to a valid CSS identifier, then prepends the given namespace.

module Css.Helpers exposing (toCssIdentifier, identifierToString)

{-| Utility functions for elm-css.

@docs toCssIdentifier, identifierToString
-}

import Regex
import String


{-| Converts an arbitrary value to a valid CSS identifier by calling
`toString` on it, trimming it, replacing chunks of whitespace with `-`,
and stripping out invalid characters.
-}
toCssIdentifier : a -> String
toCssIdentifier identifier =
    identifier
        |> toString
        |> String.trim
        |> Regex.replace Regex.All (Regex.regex "\\s+") (\_ -> "-")
        |> Regex.replace Regex.All (Regex.regex "[^a-zA-Z0-9_-]") (\_ -> "")


{-| Converts an arbitrary identifier to a valid CSS identifier, then prepends
the given namespace.
-}
identifierToString : a -> b -> String
identifierToString name identifier =
    (toCssIdentifier name) ++ (toCssIdentifier identifier)