Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version of spor-icon-elm in spor-elm #777

Merged
merged 4 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/spor-elm/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"elm/core": "1.0.0 <= v < 2.0.0",
"elm/svg": "1.0.1 <= v < 2.0.0",
"nsbno/spor-design-tokens-elm": "2.0.0 <= v < 3.0.0",
"nsbno/spor-icon-elm": "1.0.0 <= v < 2.0.0",
"nsbno/spor-icon-elm": "2.0.2 <= v < 3.0.0",
"rtfeldman/elm-css": "17.0.0 <= v < 18.0.0"
},
"test-dependencies": {}
}
}
101 changes: 63 additions & 38 deletions packages/spor-elm/src/Spor/LineTag/LineIcon.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Css exposing (Color, Style)
import Css.Global
import Html.Styled as Html exposing (Html)
import Html.Styled.Attributes as Attributes
import Spor.Icon.Transportation as Transportation
import Spor.Icon as Icon
import Spor.LineTag.Types exposing (Size(..), Variant(..))
import Spor.Token.Color.Alias as Alias
import Spor.Token.Color.Linjetag as Linjetag
Expand Down Expand Up @@ -152,115 +152,140 @@ iconColor variant =

icon : Variant -> Size -> Svg msg
icon variant size =
Svg.fromUnstyled <|
let
trainIcon size_ =
Icon.icon size_ Icon.Fill Icon.Train

expressBusIcon size_ =
Icon.icon size_ Icon.Fill Icon.ExpressBus

busIcon size_ =
Icon.icon size_ Icon.Fill Icon.Bus

ferryIcon size_ =
Icon.icon size_ Icon.Fill Icon.Ferry

subwayIcon size_ =
Icon.icon size_ Icon.Fill Icon.Subway

tramIcon size_ =
Icon.icon size_ Icon.Fill Icon.Tram

altTransportIcon size_ =
Icon.icon size_ Icon.Fill Icon.AltTransport

walkIcon size_ =
Icon.icon size_ Icon.Fill Icon.Walk
in
Icon.toHtml <|
case ( variant, size ) of
( LocalTrain, Sm ) ->
Transportation.trainFill18X18 []
trainIcon Icon.Size18

( LocalTrain, Md ) ->
Transportation.trainFill24X24 []
trainIcon Icon.Size24

( LocalTrain, Lg ) ->
Transportation.trainFill30X30 []
trainIcon Icon.Size30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hva med å lage en sizeToIconSize i let...in, så kan man i stedet si

( LocalTrain, size_ ) ->
   trainIcon <| sizeToIconSize size_
   
( RegionTrain, size_ ) ->
  trainIcon <| sizeToIconSize size_

osv..? 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hvis et case også har unikt ikon for sin variant kan egentlig ikonfunksjone bare ligge i den casen også!


( RegionTrain, Sm ) ->
Transportation.trainFill18X18 []
trainIcon Icon.Size18

( RegionTrain, Md ) ->
Transportation.trainFill24X24 []
trainIcon Icon.Size24

( RegionTrain, Lg ) ->
Transportation.trainFill30X30 []
trainIcon Icon.Size30

( RegionExpressTrain, Sm ) ->
Transportation.trainFill18X18 []
trainIcon Icon.Size18

( RegionExpressTrain, Md ) ->
Transportation.trainFill24X24 []
trainIcon Icon.Size24

( RegionExpressTrain, Lg ) ->
Transportation.trainFill30X30 []
trainIcon Icon.Size30

( LongDistanceTrain, Sm ) ->
Transportation.trainFill18X18 []
trainIcon Icon.Size18

( LongDistanceTrain, Md ) ->
Transportation.trainFill24X24 []
trainIcon Icon.Size24

( LongDistanceTrain, Lg ) ->
Transportation.trainFill30X30 []
trainIcon Icon.Size30

( AirportExpressTrain, Sm ) ->
Transportation.trainFill18X18 []
trainIcon Icon.Size18

( AirportExpressTrain, Md ) ->
Transportation.trainFill24X24 []
trainIcon Icon.Size24

( AirportExpressTrain, Lg ) ->
Transportation.trainFill30X30 []
trainIcon Icon.Size30

( VyBus, Sm ) ->
Transportation.expressBusFill18X18 []
expressBusIcon Icon.Size18

( VyBus, Md ) ->
Transportation.expressBusFill24X24 []
expressBusIcon Icon.Size24

( VyBus, Lg ) ->
Transportation.expressBusFill30X30 []
expressBusIcon Icon.Size30

( LocalBus, Sm ) ->
Transportation.busFill18X18 []
busIcon Icon.Size18

( LocalBus, Md ) ->
Transportation.busFill24X24 []
busIcon Icon.Size24

( LocalBus, Lg ) ->
Transportation.busFill30X30 []
busIcon Icon.Size30

( Ferry, Sm ) ->
Transportation.ferryFill18X18 []
ferryIcon Icon.Size18

( Ferry, Md ) ->
Transportation.ferryFill24X24 []
ferryIcon Icon.Size24

( Ferry, Lg ) ->
Transportation.ferryFill30X30 []
ferryIcon Icon.Size30

( Subway, Sm ) ->
Transportation.subwayFill18X18 []
subwayIcon Icon.Size18

( Subway, Md ) ->
Transportation.subwayFill24X24 []
subwayIcon Icon.Size24

( Subway, Lg ) ->
Transportation.subwayFill30X30 []
subwayIcon Icon.Size30

( Tram, Sm ) ->
Transportation.trainFill18X18 []
tramIcon Icon.Size18

( Tram, Md ) ->
Transportation.tramFill24X24 []
tramIcon Icon.Size24

( Tram, Lg ) ->
Transportation.trainFill30X30 []
tramIcon Icon.Size30

( AlternativeTransport, Sm ) ->
Transportation.altTransportFill18X18 []
altTransportIcon Icon.Size18

( AlternativeTransport, Md ) ->
Transportation.altTransportFill24X24 []
altTransportIcon Icon.Size24

( AlternativeTransport, Lg ) ->
Transportation.altTransportFill30X30 []
altTransportIcon Icon.Size30

( Walk, Sm ) ->
Transportation.walkFill18X18 []
walkIcon Icon.Size18

( Walk, Md ) ->
Transportation.walkFill24X24 []
walkIcon Icon.Size24

( Walk, Lg ) ->
Transportation.walkFill30X30 []
walkIcon Icon.Size30


backgroundColor : Variant -> Color
Expand Down
55 changes: 15 additions & 40 deletions packages/spor-elm/src/Spor/LineTag/TravelTag.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import Css exposing (Color, Style)
import Css.Global
import Html.Styled as Html exposing (Html)
import Html.Styled.Attributes as Attributes
import Spor.Icon.Feedback as Feedback
import Spor.Icon as Icon
import Spor.LineTag.LineIcon as LineIcon
import Spor.LineTag.LineText as LineText
import Spor.LineTag.Types exposing (DeviationLevel(..), Size(..), Variant(..))
import Spor.Token.Color.Alias as Alias
import Spor.Token.Color.Linjetag as Linjetag
import Spor.Token.Size.Spacing as Spacing
import Svg.Styled as Svg
import Svg.Styled.Attributes as SvgAttributes


{-| A component for displaying travel tags
Expand Down Expand Up @@ -267,22 +265,27 @@ backgroundColor variant =

deviationIcon : Maybe DeviationLevel -> Html msg
deviationIcon maybeDeviationLevel =
let
feedbackIcon type_ =
Icon.icon Icon.Size18 Icon.Fill type_
in
case maybeDeviationLevel of
Just deviationLevel ->
Html.span
[ Attributes.css [ deviationStyle deviationLevel ] ]
[ case deviationLevel of
Critical ->
Svg.fromUnstyled <| Feedback.errorFill18X18 []
[ Icon.toHtml <|
case deviationLevel of
Critical ->
feedbackIcon Icon.Error

Major ->
warningFill18x18
Major ->
feedbackIcon Icon.Warning

Minor ->
warningFill18x18
Minor ->
feedbackIcon Icon.Warning

Info ->
Svg.fromUnstyled <| Feedback.informationFill18X18 []
Info ->
feedbackIcon Icon.Information
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Her kan vi fjerne feedbackIcon fra alle casene og heller sette foran case-statementen. E.g.

feedbackIcon <| case deviationLevel of
   ...

]

Nothing ->
Expand Down Expand Up @@ -335,34 +338,6 @@ deviationStyle deviationLevel =
]


warningFill18x18 : Html msg
warningFill18x18 =
Svg.svg
[ SvgAttributes.width "18"
, SvgAttributes.height "18"
, SvgAttributes.fill "none"
, SvgAttributes.stroke "#fff"
, Attributes.attribute "stroke-width" "2"
, Attributes.attribute "paint-order" "stroke"
]
[ Svg.path
[ SvgAttributes.fillRule "evenodd"
, SvgAttributes.clipRule "evenodd"
, SvgAttributes.d "M7.897 1.506a1.25 1.25 0 0 1 2.206 0l6.75 12.656A1.25 1.25 0 0 1 15.75 16H2.25a1.25 1.25 0 0 1-1.103-1.838l6.75-12.656ZM9 6a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0v-4A.5.5 0 0 1 9 6Zm.625 6.375a.625.625 0 1 1-1.25 0 .625.625 0 0 1 1.25 0Z"
, SvgAttributes.fill "#E5A80C"
]
[]
, Svg.path
[ SvgAttributes.fillRule "evenodd"
, SvgAttributes.clipRule "evenodd"
, SvgAttributes.d "M9.5 6.5a.5.5 0 0 0-1 0v4a.5.5 0 0 0 1 0v-4ZM9 13a.625.625 0 1 0 0-1.25A.625.625 0 0 0 9 13Z"
, SvgAttributes.fill "#2B2B2C"
, SvgAttributes.stroke "none"
]
[]
]


deviationBorderStyle : Maybe DeviationLevel -> Style
deviationBorderStyle maybeDeviationLevel =
case maybeDeviationLevel of
Expand Down
Loading