Commit ed9467e4 authored by Cédric F.'s avatar Cédric F.

Blend colors when multiple events for one week

parent ae9d42cc
Pipeline #5411882 passed with stage
in 1 minute and 6 seconds
......@@ -5,6 +5,7 @@ import Collage exposing (Form, LineStyle)
import Element exposing (Element)
import Text exposing (Text)
import Color exposing (Color)
import Color.Interpolate
import Date exposing (Date)
import Time exposing (Time)
import DateExtra
......@@ -196,31 +197,54 @@ week model year week =
(Date.toTime event.from <= time)
&& (Date.toTime event.to >= time)
event =
List.filter match model.events |> List.reverse |> List.head
-- TODO: mix colors when multiple events
-- http://package.elm-lang.org/packages/eskimoblood/elm-color-extra/3.2.3/Color-Interpolate
events =
List.filter match model.events
colors =
List.map .color events
weekColor =
List.head colors |> Maybe.andThen mixColors
mixColors firstColor =
Just <|
List.foldl
(\oldColor ->
\newColor ->
Color.Interpolate.interpolate
Color.Interpolate.HSL
oldColor
newColor
0.5
)
firstColor
(List.drop 1 colors)
filled color =
Collage.square weekWidth |> Collage.filled color
outlined =
Collage.square (weekWidth - weekBorder) |> Collage.outlined lineStyle
in
if isCurrentWeek model time then
if isEvenSecond model then
Collage.square weekWidth |> Collage.filled Color.black
filled Color.black
else
Collage.square (weekWidth - weekBorder) |> Collage.outlined lineStyle
outlined
else
case event of
case weekColor of
Nothing ->
if outOfBounds model time then
Collage.square weekWidth |> Collage.filled Color.lightGrey
filled Color.lightGrey
else if isKid model time || isOld model time then
Collage.square weekWidth |> Collage.filled Color.grey
filled Color.grey
else if isPast model time then
Collage.square weekWidth |> Collage.filled Color.black
filled Color.black
else
Collage.square (weekWidth - weekBorder) |> Collage.outlined lineStyle
outlined
Just event ->
Collage.square weekWidth |> Collage.filled event.color
Just color ->
filled color
outOfBounds : Model -> Time -> Bool
......
......@@ -3,5 +3,4 @@
https://www.reddit.com/r/GetMotivated/comments/1vyf9r/made_for_myself_thought_of_you_weeks_left/cexas8u
- responsive
- store location / countries
- blend colors when multiple events for one week
- store goals
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment