<commit_before>module Element.Device exposing (..)

{-| -}

import Window


type alias Device =
    { width : Int
    , height : Int
    , phone : Bool
    , tablet : Bool
    , desktop : Bool
    , bigDesktop : Bool
    , portrait : Bool
    }


match : Window.Size -> Device
match { width, height } =
    { width = width
    , height = height
    , phone = width <= 600
    , tablet = width > 600 && width <= 1200
    , desktop = width > 1200 && width <= 1800
    , bigDesktop = width > 1800
    , portrait = width > height
    }


{-|
Define two ranges that should linearly match up with each other.

Provide a value for the first and receive the calculated value for the second.

  fontsize = responsive (600, 1200) (16, 20) device.width

Will set the font-size between 16 and 20 when the device width is between 600 and 1200, using a linear scale.

-}
responsive : ( Float, Float ) -> ( Float, Float ) -> Float -> Float
responsive ( aMin, aMax ) ( bMin, bMax ) a =
    if a < aMin then
        bMin
    else if a > aMax then
        bMax
    else
        let
            deltaA =
                (a - aMin) / (aMax - aMin)
        in
            (deltaA * (bMax - bMin)) + bMin<commit_msg>Ranges for Device should be inclusive.<commit_after>module Element.Device exposing (..)

{-| -}

import Window


type alias Device =
    { width : Int
    , height : Int
    , phone : Bool
    , tablet : Bool
    , desktop : Bool
    , bigDesktop : Bool
    , portrait : Bool
    }


match : Window.Size -> Device
match { width, height } =
    { width = width
    , height = height
    , phone = width <= 600
    , tablet = width > 600 && width <= 1200
    , desktop = width > 1200 && width <= 1800
    , bigDesktop = width > 1800
    , portrait = width > height
    }


{-| Define two ranges that should linearly match up with each other.

Provide a value for the first and receive the calculated value for the second.

fontsize = responsive (600, 1200) (16, 20) device.width

Will set the font-size between 16 and 20 when the device width is between 600 and 1200, using a linear scale.

-}
responsive : ( Float, Float ) -> ( Float, Float ) -> Float -> Float
responsive ( aMin, aMax ) ( bMin, bMax ) a =
    if a <= aMin then
        bMin
    else if a >= aMax then
        bMax
    else
        let
            deltaA =
                (a - aMin) / (aMax - aMin)
        in
            (deltaA * (bMax - bMin)) + bMin
{'fraction_non_alphanumeric': 0.10153336096145876, 'fraction_numerical': 0.036469125569830084, 'mean_word_length': 2.036477987421384, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5288007', 'n_tokens_mistral': 826, 'n_tokens_neox': 707, 'n_words': 284}