diff --git a/example/elm.json b/example/elm.json index f2208b2..73930ca 100644 --- a/example/elm.json +++ b/example/elm.json @@ -1,25 +1,28 @@ { - "type": "application", - "source-directories": ["src", ".elm-land/src", "../src"], - "elm-version": "0.19.1", - "dependencies": { - "direct": { - "elm/browser": "1.0.2", - "elm/core": "1.0.5", - "elm/html": "1.0.0", - "elm/json": "1.1.3", - "elm/url": "1.0.0", - "hmsk/elm-vite-plugin-helper": "1.0.1", - "mdgriffith/elm-ui": "1.1.8", - "vladimirlogachev/elm-modular-grid": "2.0.1" + "type": "application", + "source-directories": [ + "src", + ".elm-land/src", + "../src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/browser": "1.0.2", + "elm/core": "1.0.5", + "elm/html": "1.0.0", + "elm/json": "1.1.3", + "elm/url": "1.0.0", + "mdgriffith/elm-ui": "1.1.8", + "vladimirlogachev/elm-modular-grid": "2.0.1" + }, + "indirect": { + "elm/time": "1.0.0", + "elm/virtual-dom": "1.0.3" + } }, - "indirect": { - "elm/time": "1.0.0", - "elm/virtual-dom": "1.0.3" + "test-dependencies": { + "direct": {}, + "indirect": {} } - }, - "test-dependencies": { - "direct": {}, - "indirect": {} - } } diff --git a/example/review/src/ReviewConfig.elm b/example/review/src/ReviewConfig.elm index 5068827..ea4bb4f 100644 --- a/example/review/src/ReviewConfig.elm +++ b/example/review/src/ReviewConfig.elm @@ -58,7 +58,7 @@ config = , NoUnused.Patterns.rule , NoExposingEverything.rule , NoUnused.Variables.rule - , NoImportingEverything.rule [ "Element" ] + , NoImportingEverything.rule [ "Element", "GridLayout1", "GridLayout2", "GridLayout3" ] , NoMissingTypeAnnotation.rule , NoMissingTypeAnnotationInLetIn.rule , NoPrematureLetComputation.rule diff --git a/example/src/Pages/Home_.elm b/example/src/Pages/Home_.elm index 49ae972..1625814 100644 --- a/example/src/Pages/Home_.elm +++ b/example/src/Pages/Home_.elm @@ -2,7 +2,6 @@ module Pages.Home_ exposing (Model, Msg, page) import Color import Effect -import Html.Attributes import Element exposing (..) import Element.Background as Background import Element.Font as Font @@ -14,7 +13,6 @@ import Route exposing (Route) import Shared import TextStyle import View exposing (View) -import VitePluginHelper type alias Model = @@ -43,7 +41,7 @@ page shared _ = color1 : ExtraColor color1 = ExtraColor.oklchPercent 68.64 0.255 36.4 - + color2 : ExtraColor color2 = @@ -54,11 +52,16 @@ color3 : ExtraColor color3 = ExtraColor.oklchPercent 83.93 0.336 147.57 + color4 : ExtraColor color4 = ExtraColor.oklchPercent 91.28 0.208 102.04 +pageTitle : String +pageTitle = + "elm-ui color extra" + -- VIEW @@ -67,7 +70,7 @@ color4 = view : Shared.Model -> View msg view { layout } = { title = "elm-ui-color-extra" - , attributes = [ Background.color Color.black ] + , attributes = [ Background.color Color.black, Font.color Color.white ] , element = viewMobile layout } @@ -79,16 +82,19 @@ viewMobile layout = [ width fill , spacing layout.grid.gutter ] - (gridRow layout - [ gridColumn layout { widthSteps = 3 } [Font.color Color.white ] [text "OKLCH" ] - , gridColumn layout { widthSteps = 3 } [Font.color Color.white ] [text "RGB fallback" ] - ]:: List.map (viewColor layout) [color1, color2, color3, color4]) - + ([ paragraph TextStyle.header [ text pageTitle ] + , gridRow layout + [ gridColumn layout { widthSteps = 2 } [ Font.color Color.white ] [ text "OKLCH" ] + , gridColumn layout { widthSteps = 2 } [ Font.color Color.white ] [ text "RGB fallback" ] + ] + ] + ++ List.map (viewColor layout) [ color1, color2, color3, color4 ] + ) + viewColor : LayoutState -> ExtraColor -> Element msg viewColor layout c = - gridRow layout - [ gridBox layout { widthSteps = 3, heightSteps = 3 } [ ExtraColor.backgroundColor c ] [ ] - , gridBox layout { widthSteps = 3, heightSteps = 3 } [ Background.color (ExtraColor.toRgba c) ] [ ] - ] - + gridRow layout + [ gridBox layout { widthSteps = 2, heightSteps = 2 } [ ExtraColor.backgroundColor c ] [] + , gridBox layout { widthSteps = 2, heightSteps = 2 } [ Background.color (ExtraColor.toRgba c) ] [] + ] diff --git a/example/src/TextStyle.elm b/example/src/TextStyle.elm index 7cf1037..e489645 100644 --- a/example/src/TextStyle.elm +++ b/example/src/TextStyle.elm @@ -1,19 +1,14 @@ -module TextStyle exposing (body, headerMobile, subheaderMobile) +module TextStyle exposing (body, header) import Element exposing (..) import Element.Font as Font -headerMobile : List (Attribute msg) -headerMobile = +header : List (Attribute msg) +header = [ Font.size 55, Font.bold, Font.family [ Font.typeface "Inter", Font.sansSerif ] ] -subheaderMobile : List (Attribute msg) -subheaderMobile = - [ Font.size 34, Font.medium, Font.family [ Font.typeface "Inter", Font.sansSerif ] ] - - body : List (Attribute msg) body = [ Font.size 20, Font.regular, Font.family [ Font.typeface "Inter", Font.sansSerif ] ] diff --git a/src/Culori.elm b/src/Culori.elm index fec863f..d0a23c9 100644 --- a/src/Culori.elm +++ b/src/Culori.elm @@ -54,6 +54,7 @@ convertLchToLab { l, c, h, alpha } = convertOklabToLrgb : LabColor -> RgbaColor convertOklabToLrgb { l, a, b, alpha } = let + l_ : Float l_ = l * 0.9999999984505198 @@ -63,6 +64,7 @@ convertOklabToLrgb { l, a, b, alpha } = * b |> (\x -> x ^ 3) + m : Float m = l * 1.0000000088817609 @@ -72,6 +74,7 @@ convertOklabToLrgb { l, a, b, alpha } = * b |> (\x -> x ^ 3) + s : Float s = l * 1.0000000546724108 @@ -91,17 +94,20 @@ convertOklabToLrgb { l, a, b, alpha } = fn : Float -> Float fn c = let + absC : Float absC = abs c - - sign = - if c < 0 then - -1 - - else - 1 in if absC > 0.0031308 then + let + sign : Float + sign = + if c < 0 then + -1 + + else + 1 + in sign * (1.055 * (absC ^ (1 / 2.4)) - 0.055) else