{-# LANGUAGE
OverloadedStrings
, GeneralizedNewtypeDeriving
#-}
module Clay.Transition
(
transition
, transitions
, transitionProperty
, transitionProperties
, transitionDuration
, transitionDurations
, TimingFunction
, transitionTimingFunction
, transitionTimingFunctions
, ease, easeIn, easeOut, easeInOut, linear, stepStart, stepEnd, stepStop
, stepsStart, stepsStop
, cubicBezier
, transitionDelay
, transitionDelays
)
where
import Data.Text (Text)
import Clay.Common
import Clay.Property
import Clay.Stylesheet
import Clay.Time
transition :: Text -> Time -> TimingFunction -> Time -> Css
transition :: Text -> Time -> TimingFunction -> Time -> Css
transition Text
p Time
d TimingFunction
f Time
e = Prefixed -> (Text, (Time, (TimingFunction, Time))) -> Css
forall a. Val a => Prefixed -> a -> Css
prefixed (Prefixed
browsers Prefixed -> Prefixed -> Prefixed
forall a. Semigroup a => a -> a -> a
<> Prefixed
"transition") (Text
p Text
-> (Time, (TimingFunction, Time))
-> (Text, (Time, (TimingFunction, Time)))
forall a b. a -> b -> (a, b)
! Time
d Time -> (TimingFunction, Time) -> (Time, (TimingFunction, Time))
forall a b. a -> b -> (a, b)
! TimingFunction
f TimingFunction -> Time -> (TimingFunction, Time)
forall a b. a -> b -> (a, b)
! Time
e)
transitions :: [(Text, Time, TimingFunction, Time)] -> Css
transitions :: [(Text, Time, TimingFunction, Time)] -> Css
transitions [] = Key Value -> Value -> Css
forall a. Val a => Key a -> a -> Css
key Key Value
"transition" (Value
forall a. None a => a
none :: Value)
transitions [(Text, Time, TimingFunction, Time)]
x = Prefixed -> [Value] -> Css
forall a. Val a => Prefixed -> a -> Css
prefixed (Prefixed
browsers Prefixed -> Prefixed -> Prefixed
forall a. Semigroup a => a -> a -> a
<> Prefixed
"transition")
([Value] -> Css) -> [Value] -> Css
forall a b. (a -> b) -> a -> b
$ ((Text, Time, TimingFunction, Time) -> Value)
-> [(Text, Time, TimingFunction, Time)] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map (\(Text
p, Time
d, TimingFunction
f, Time
e) -> (Text, (Time, (TimingFunction, Time))) -> Value
forall a. Val a => a -> Value
value (Text
p Text
-> (Time, (TimingFunction, Time))
-> (Text, (Time, (TimingFunction, Time)))
forall a b. a -> b -> (a, b)
! Time
d Time -> (TimingFunction, Time) -> (Time, (TimingFunction, Time))
forall a b. a -> b -> (a, b)
! TimingFunction
f TimingFunction -> Time -> (TimingFunction, Time)
forall a b. a -> b -> (a, b)
! Time
e)) [(Text, Time, TimingFunction, Time)]
x
transitionProperty :: Text -> Css
transitionProperty :: Text -> Css
transitionProperty = Key Text -> Text -> Css
forall a. Val a => Key a -> a -> Css
key Key Text
"transition-property"
transitionProperties :: [Text] -> Css
transitionProperties :: [Text] -> Css
transitionProperties [] = Key Value -> Value -> Css
forall a. Val a => Key a -> a -> Css
key Key Value
"transition-property" (Value
forall a. None a => a
none :: Value)
transitionProperties [Text]
x = Key [Text] -> [Text] -> Css
forall a. Val a => Key a -> a -> Css
key Key [Text]
"transition-property" [Text]
x
transitionDuration :: Time -> Css
transitionDuration :: Time -> Css
transitionDuration = Key Time -> Time -> Css
forall a. Val a => Key a -> a -> Css
key Key Time
"transition-duration"
transitionDurations :: [Time] -> Css
transitionDurations :: [Time] -> Css
transitionDurations [] = Key Value -> Value -> Css
forall a. Val a => Key a -> a -> Css
key Key Value
"transition-duration" (Value
forall a. None a => a
none :: Value)
transitionDurations [Time]
x = Key [Time] -> [Time] -> Css
forall a. Val a => Key a -> a -> Css
key Key [Time]
"transition-duration" [Time]
x
newtype TimingFunction = TimingFunction Value
deriving (TimingFunction -> Value
(TimingFunction -> Value) -> Val TimingFunction
forall a. (a -> Value) -> Val a
value :: TimingFunction -> Value
$cvalue :: TimingFunction -> Value
Val, Value -> TimingFunction
(Value -> TimingFunction) -> Other TimingFunction
forall a. (Value -> a) -> Other a
other :: Value -> TimingFunction
$cother :: Value -> TimingFunction
Other, TimingFunction
TimingFunction -> Auto TimingFunction
forall a. a -> Auto a
auto :: TimingFunction
$cauto :: TimingFunction
Auto)
ease, easeIn, easeOut, easeInOut, linear, stepStart, stepEnd, stepStop :: TimingFunction
ease :: TimingFunction
ease = Value -> TimingFunction
forall a. Other a => Value -> a
other Value
"ease"
easeIn :: TimingFunction
easeIn = Value -> TimingFunction
forall a. Other a => Value -> a
other Value
"ease-in"
easeOut :: TimingFunction
easeOut = Value -> TimingFunction
forall a. Other a => Value -> a
other Value
"ease-out"
easeInOut :: TimingFunction
easeInOut = Value -> TimingFunction
forall a. Other a => Value -> a
other Value
"ease-in-out"
linear :: TimingFunction
linear = Value -> TimingFunction
forall a. Other a => Value -> a
other Value
"linear"
stepStart :: TimingFunction
stepStart = Value -> TimingFunction
forall a. Other a => Value -> a
other Value
"step-start"
stepEnd :: TimingFunction
stepEnd = Value -> TimingFunction
forall a. Other a => Value -> a
other Value
"step-end"
stepStop :: TimingFunction
stepStop = TimingFunction
stepEnd
{-# DEPRECATED stepStop "Use `stepEnd` instead." #-}
stepsStart, stepsStop :: Integer -> TimingFunction
stepsStart :: Integer -> TimingFunction
stepsStart Integer
s = Value -> TimingFunction
forall a. Other a => Value -> a
other (Value
"steps(" Value -> Value -> Value
forall a. Semigroup a => a -> a -> a
<> Integer -> Value
forall a. Val a => a -> Value
value Integer
s Value -> Value -> Value
forall a. Semigroup a => a -> a -> a
<> Value
", start)")
stepsStop :: Integer -> TimingFunction
stepsStop Integer
s = Value -> TimingFunction
forall a. Other a => Value -> a
other (Value
"steps(" Value -> Value -> Value
forall a. Semigroup a => a -> a -> a
<> Integer -> Value
forall a. Val a => a -> Value
value Integer
s Value -> Value -> Value
forall a. Semigroup a => a -> a -> a
<> Value
", end)")
cubicBezier :: Double -> Double -> Double -> Double -> TimingFunction
cubicBezier :: Double -> Double -> Double -> Double -> TimingFunction
cubicBezier Double
a Double
b Double
c Double
d = Value -> TimingFunction
forall a. Other a => Value -> a
other (Value
"cubic-bezier(" Value -> Value -> Value
forall a. Semigroup a => a -> a -> a
<> [Double] -> Value
forall a. Val a => a -> Value
value [Double
a, Double
b, Double
c, Double
d] Value -> Value -> Value
forall a. Semigroup a => a -> a -> a
<> Value
")")
transitionTimingFunction :: TimingFunction -> Css
transitionTimingFunction :: TimingFunction -> Css
transitionTimingFunction = Key TimingFunction -> TimingFunction -> Css
forall a. Val a => Key a -> a -> Css
key Key TimingFunction
"transition-timing-function"
transitionTimingFunctions :: [TimingFunction] -> Css
transitionTimingFunctions :: [TimingFunction] -> Css
transitionTimingFunctions [] = Key Value -> Value -> Css
forall a. Val a => Key a -> a -> Css
key Key Value
"transition-timing-function" (Value
forall a. None a => a
none :: Value)
transitionTimingFunctions [TimingFunction]
x = Key [TimingFunction] -> [TimingFunction] -> Css
forall a. Val a => Key a -> a -> Css
key Key [TimingFunction]
"transition-timing-function" [TimingFunction]
x
transitionDelay :: Time -> Css
transitionDelay :: Time -> Css
transitionDelay = Key Time -> Time -> Css
forall a. Val a => Key a -> a -> Css
key Key Time
"transition-delay"
transitionDelays :: [Time] -> Css
transitionDelays :: [Time] -> Css
transitionDelays = Key [Time] -> [Time] -> Css
forall a. Val a => Key a -> a -> Css
key Key [Time]
"transition-delay"