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
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
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)
|
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
|
|
|
import ModuleExample exposing (Category(..), 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-10-30 01:54:59 +03:00
|
|
|
[ viewLarge "Mastery Icons"
|
2019-10-30 01:44:21 +03:00
|
|
|
[ deprecatedIcon { icon = Icon.gardening { startingOffBadge_png = Asset "assets/images/starting-off-badge.png" }, background = Colors.blue, alt = "Gardening" }
|
|
|
|
, deprecatedIcon { icon = Icon.highFive { level3Badge_png = Asset "assets/images/level-3-badge.png" }, background = Colors.blue, alt = "HighFive" }
|
|
|
|
, deprecatedIcon { icon = Icon.okay { level2Badge_png = Asset "assets/images/level-2-badge.png" }, background = Colors.blue, alt = "Okay" }
|
|
|
|
, deprecatedIcon { icon = Icon.thumbsUp { level1Badge_png = Asset "assets/images/level-1-badge.png" }, background = Colors.blue, alt = "ThumbsUp" }
|
|
|
|
, deprecatedIcon { icon = Icon.masteryBadge { masteryBadge = "icon-mastery-badge" }, background = Colors.frost, alt = "Badge " }
|
2018-06-22 20:39:00 +03:00
|
|
|
]
|
2019-10-30 01:54:59 +03:00
|
|
|
, viewLarge "Student Assignment Actions"
|
2019-10-30 01:44:21 +03:00
|
|
|
[ deprecatedIcon { icon = Icon.assignmentStartButtonPrimary { assignmentStartButtonPrimary_svg = Asset "assets/images/assignment-start-button-primary.svg" }, background = Colors.frost, alt = "Start primary" }
|
|
|
|
, deprecatedIcon { icon = Icon.assignmentStartButtonSecondary { assignmentStartButtonSecondary_svg = Asset "assets/images/assignment-start-button-secondary.svg" }, background = Colors.frost, alt = "Start secondary" }
|
2018-06-22 21:24:06 +03:00
|
|
|
]
|
2019-10-30 01:54:59 +03:00
|
|
|
, viewLarge "Social Media"
|
2019-10-30 01:44:21 +03:00
|
|
|
[ deprecatedIcon { icon = Icon.facebook { facebookBlue_svg = Asset "assets/images/facebook-blue.svg" }, background = Colors.frost, alt = "Facebook" }
|
|
|
|
, deprecatedIcon { icon = Icon.twitter { twitterBlue_svg = Asset "assets/images/twitter-blue.svg" }, background = Colors.frost, alt = "Twitter" }
|
|
|
|
, deprecatedIcon { icon = Icon.clever { clever = "icon-clever" }, background = Colors.frost, alt = "Clever" }
|
2018-06-22 20:39:00 +03:00
|
|
|
]
|
2019-10-30 01:54:59 +03:00
|
|
|
, viewLarge "Bulbs and Tips"
|
2019-10-30 01:44:21 +03:00
|
|
|
[ deprecatedIcon { icon = Icon.bulb { bulb = "icon-bulb" }, background = Colors.frost, alt = "Bulb" }
|
|
|
|
, deprecatedIcon { icon = Icon.lightBulb { hint_png = Asset "assets/images/hint.png" }, background = Colors.frost, alt = "LightBulb" }
|
|
|
|
, deprecatedIcon { icon = Icon.helpSvg { help = "icon-help" }, background = Colors.frost, alt = "Help" }
|
2018-06-22 20:39:00 +03:00
|
|
|
]
|
2019-10-30 01:54:59 +03:00
|
|
|
, viewLarge "Locks and keys"
|
2019-10-30 01:44:21 +03:00
|
|
|
[ deprecatedIcon { icon = Icon.key { key = "icon-key" }, background = Colors.frost, alt = "Key" }
|
|
|
|
, deprecatedIcon { icon = Icon.lock { lock = "icon-lock" }, background = Colors.frost, alt = "Lock" }
|
2018-06-22 20:39:00 +03:00
|
|
|
]
|
2019-10-30 01:54:59 +03:00
|
|
|
, viewLarge "Uncategorized (SVGs)"
|
2019-10-30 02:53:10 +03:00
|
|
|
[ deprecatedIcon { icon = Icon.logo { logoRedBlack_svg = Asset "assets/images/logo-red-black.svg" }, background = Colors.frost, alt = "Logo" }
|
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
|
|
|
]
|
|
|
|
)
|