2018-06-22 20:39:00 +03:00
|
|
|
module Examples.Icon exposing (example)
|
Extract `Nri.Icon` from the monolith
The recommendation is to break the styles API rather than the view API
when moving something out of the monolith into this repo.
`Nri.Icon` is not really setup for that sort of breakage.
If we would prefer to have the styles break rather than the view,
that will take more work.
Work that can be done independent of the extraction.
The transition in the monolith ought to look something like:
```elm
module Nri.Icon exposing (..)
import Html exposing (Html)
import Nri.SvgSprite
import Nri.Ui.Icon.V1 exposing (Assets, IconType)
icon : { alt : String, icon : IconType } -> Html msg
icon config =
Nri.Ui.Icon.V1.icon assets
assets : Assets {}
assets =
{ activity = Nri.SvgSprite.activity
, arrowDown = Nri.SvgSprite.arrowDown
, attention_svg = Nri.Assets.attention_svg
...
}
```
So hopefully, the change is still very small on the monolith side.
There's maybe a bigger concern than which API breaks.
`Nri.Icon` has some behavior for a11y.
We could definitely change the internals over during the extraction.
But, since all of these changes are value-level changes,
it's very likely that we'll break something in the process.
That's a bigger concern because instead of affecting
the handful of Engineers working at NRI,
we would be affecting the millions of people using the site.
We shouldn't fear making those kinds of changes.
However, we should make them when we can give them the appropriate
attention they deserve.
Not when one person is trying to move as fast as possible to avoid
race conditions of moving modules between repos.
2018-03-29 03:34:56 +03:00
|
|
|
|
|
|
|
{-|
|
|
|
|
|
|
|
|
@docs example, styles
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
2020-03-24 03:33:42 +03:00
|
|
|
import Category exposing (Category(..))
|
2019-10-01 03:30:35 +03:00
|
|
|
import Css
|
|
|
|
import Css.Global
|
|
|
|
import Html.Styled as Html exposing (Html)
|
|
|
|
import Html.Styled.Attributes exposing (css)
|
2020-03-24 03:33:42 +03:00
|
|
|
import ModuleExample exposing (ModuleExample)
|
2019-10-30 01:30:13 +03:00
|
|
|
import Nri.Ui.AssetPath as AssetPath exposing (Asset(..))
|
2019-10-01 03:10:09 +03:00
|
|
|
import Nri.Ui.Colors.V1 as Colors
|
2019-10-30 01:54:59 +03:00
|
|
|
import Nri.Ui.Heading.V2 as Heading
|
2019-05-29 20:20:30 +03:00
|
|
|
import Nri.Ui.Icon.V5 as Icon
|
2019-10-30 01:54:59 +03:00
|
|
|
import Nri.Ui.Text.V4 as Text
|
Extract `Nri.Icon` from the monolith
The recommendation is to break the styles API rather than the view API
when moving something out of the monolith into this repo.
`Nri.Icon` is not really setup for that sort of breakage.
If we would prefer to have the styles break rather than the view,
that will take more work.
Work that can be done independent of the extraction.
The transition in the monolith ought to look something like:
```elm
module Nri.Icon exposing (..)
import Html exposing (Html)
import Nri.SvgSprite
import Nri.Ui.Icon.V1 exposing (Assets, IconType)
icon : { alt : String, icon : IconType } -> Html msg
icon config =
Nri.Ui.Icon.V1.icon assets
assets : Assets {}
assets =
{ activity = Nri.SvgSprite.activity
, arrowDown = Nri.SvgSprite.arrowDown
, attention_svg = Nri.Assets.attention_svg
...
}
```
So hopefully, the change is still very small on the monolith side.
There's maybe a bigger concern than which API breaks.
`Nri.Icon` has some behavior for a11y.
We could definitely change the internals over during the extraction.
But, since all of these changes are value-level changes,
it's very likely that we'll break something in the process.
That's a bigger concern because instead of affecting
the handful of Engineers working at NRI,
we would be affecting the millions of people using the site.
We shouldn't fear making those kinds of changes.
However, we should make them when we can give them the appropriate
attention they deserve.
Not when one person is trying to move as fast as possible to avoid
race conditions of moving modules between repos.
2018-03-29 03:34:56 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-| -}
|
2018-03-29 13:58:41 +03:00
|
|
|
example : ModuleExample msg
|
|
|
|
example =
|
2019-10-01 03:16:46 +03:00
|
|
|
{ name = "Nri.Ui.Icon.V5"
|
Extract `Nri.Icon` from the monolith
The recommendation is to break the styles API rather than the view API
when moving something out of the monolith into this repo.
`Nri.Icon` is not really setup for that sort of breakage.
If we would prefer to have the styles break rather than the view,
that will take more work.
Work that can be done independent of the extraction.
The transition in the monolith ought to look something like:
```elm
module Nri.Icon exposing (..)
import Html exposing (Html)
import Nri.SvgSprite
import Nri.Ui.Icon.V1 exposing (Assets, IconType)
icon : { alt : String, icon : IconType } -> Html msg
icon config =
Nri.Ui.Icon.V1.icon assets
assets : Assets {}
assets =
{ activity = Nri.SvgSprite.activity
, arrowDown = Nri.SvgSprite.arrowDown
, attention_svg = Nri.Assets.attention_svg
...
}
```
So hopefully, the change is still very small on the monolith side.
There's maybe a bigger concern than which API breaks.
`Nri.Icon` has some behavior for a11y.
We could definitely change the internals over during the extraction.
But, since all of these changes are value-level changes,
it's very likely that we'll break something in the process.
That's a bigger concern because instead of affecting
the handful of Engineers working at NRI,
we would be affecting the millions of people using the site.
We shouldn't fear making those kinds of changes.
However, we should make them when we can give them the appropriate
attention they deserve.
Not when one person is trying to move as fast as possible to avoid
race conditions of moving modules between repos.
2018-03-29 03:34:56 +03:00
|
|
|
, category = Icons
|
|
|
|
, content =
|
2019-11-26 01:32:50 +03:00
|
|
|
[ viewLarge "Bulbs and Tips"
|
2019-10-30 04:06:53 +03:00
|
|
|
[ deprecatedIcon { icon = Icon.lightBulb { hint_png = Asset "assets/images/hint.png" }, background = Colors.frost, alt = "LightBulb" }
|
2018-06-22 20:39:00 +03:00
|
|
|
]
|
Extract `Nri.Icon` from the monolith
The recommendation is to break the styles API rather than the view API
when moving something out of the monolith into this repo.
`Nri.Icon` is not really setup for that sort of breakage.
If we would prefer to have the styles break rather than the view,
that will take more work.
Work that can be done independent of the extraction.
The transition in the monolith ought to look something like:
```elm
module Nri.Icon exposing (..)
import Html exposing (Html)
import Nri.SvgSprite
import Nri.Ui.Icon.V1 exposing (Assets, IconType)
icon : { alt : String, icon : IconType } -> Html msg
icon config =
Nri.Ui.Icon.V1.icon assets
assets : Assets {}
assets =
{ activity = Nri.SvgSprite.activity
, arrowDown = Nri.SvgSprite.arrowDown
, attention_svg = Nri.Assets.attention_svg
...
}
```
So hopefully, the change is still very small on the monolith side.
There's maybe a bigger concern than which API breaks.
`Nri.Icon` has some behavior for a11y.
We could definitely change the internals over during the extraction.
But, since all of these changes are value-level changes,
it's very likely that we'll break something in the process.
That's a bigger concern because instead of affecting
the handful of Engineers working at NRI,
we would be affecting the millions of people using the site.
We shouldn't fear making those kinds of changes.
However, we should make them when we can give them the appropriate
attention they deserve.
Not when one person is trying to move as fast as possible to avoid
race conditions of moving modules between repos.
2018-03-29 03:34:56 +03:00
|
|
|
]
|
|
|
|
}
|
2019-10-01 03:30:35 +03:00
|
|
|
|
|
|
|
|
2019-10-30 01:54:59 +03:00
|
|
|
viewLarge :
|
|
|
|
String
|
|
|
|
-> List ( String, Html msg )
|
|
|
|
-> Html msg
|
|
|
|
viewLarge headerText icons =
|
|
|
|
Html.section [ css [ Css.marginTop (Css.px 16) ] ]
|
|
|
|
[ Heading.h2 [] [ Html.text headerText ]
|
|
|
|
, Html.div [ css [ Css.displayFlex, Css.flexWrap Css.wrap ] ]
|
|
|
|
(List.map viewIcon icons)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
viewIcon : ( String, Html msg ) -> Html msg
|
|
|
|
viewIcon ( name, assignmentIcon ) =
|
|
|
|
Html.div
|
|
|
|
[ css
|
|
|
|
[ Css.margin (Css.px 10)
|
|
|
|
, Css.width (Css.px 160)
|
|
|
|
, Css.boxShadow4 (Css.px 10) (Css.px 5) (Css.px 5) Colors.navy
|
|
|
|
, Css.displayFlex
|
|
|
|
, Css.flexDirection Css.column
|
|
|
|
, Css.alignItems Css.center
|
|
|
|
, Css.justifyContent Css.flexStart
|
|
|
|
]
|
|
|
|
]
|
|
|
|
[ Html.div
|
|
|
|
[ css
|
|
|
|
[ Css.height (Css.px 80)
|
|
|
|
, Css.width (Css.px 80)
|
|
|
|
, Css.margin (Css.px 10)
|
|
|
|
, Css.color Colors.green
|
|
|
|
]
|
|
|
|
]
|
|
|
|
[ assignmentIcon
|
|
|
|
]
|
|
|
|
, Text.mediumBody [ Html.text name ]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-10-30 01:44:21 +03:00
|
|
|
deprecatedIcon : { alt : String, background : Css.Color, icon : Icon.IconType } -> ( String, Html msg )
|
2019-10-01 03:30:35 +03:00
|
|
|
deprecatedIcon { alt, background, icon } =
|
|
|
|
( alt
|
|
|
|
, Html.div
|
|
|
|
[ css
|
|
|
|
[ Css.backgroundColor background
|
|
|
|
, Css.height (Css.px 80)
|
|
|
|
, Css.width (Css.px 80)
|
|
|
|
, Css.displayFlex
|
|
|
|
, Css.alignItems Css.center
|
|
|
|
, Css.justifyContent Css.center
|
|
|
|
, Css.Global.descendants
|
|
|
|
[ Css.Global.img
|
|
|
|
[ Css.maxWidth (Css.pct 100)
|
|
|
|
, Css.maxHeight (Css.pct 100)
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
2019-10-30 01:44:21 +03:00
|
|
|
[ Icon.icon { alt = alt, icon = icon }
|
2019-10-01 03:30:35 +03:00
|
|
|
]
|
|
|
|
)
|