mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-25 22:53:34 +03:00
Use svgs in internal modeling
This commit is contained in:
parent
4a336577f7
commit
25af73784c
@ -151,7 +151,7 @@ button :
|
|||||||
->
|
->
|
||||||
{ label : String
|
{ label : String
|
||||||
, state : ButtonState
|
, state : ButtonState
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
}
|
}
|
||||||
-> Html msg
|
-> Html msg
|
||||||
button config content =
|
button config content =
|
||||||
@ -312,7 +312,7 @@ NOTE: Links do not support two-line labels.
|
|||||||
-}
|
-}
|
||||||
link :
|
link :
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
, url : String
|
, url : String
|
||||||
, size : ButtonSize
|
, size : ButtonSize
|
||||||
, style : ButtonStyle
|
, style : ButtonStyle
|
||||||
@ -335,7 +335,7 @@ linkSpa :
|
|||||||
-> (route -> msg)
|
-> (route -> msg)
|
||||||
->
|
->
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
, size : ButtonSize
|
, size : ButtonSize
|
||||||
, style : ButtonStyle
|
, style : ButtonStyle
|
||||||
, width : ButtonWidth
|
, width : ButtonWidth
|
||||||
@ -361,7 +361,7 @@ some url and have it open to an external site
|
|||||||
-}
|
-}
|
||||||
linkExternal :
|
linkExternal :
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
, url : String
|
, url : String
|
||||||
, size : ButtonSize
|
, size : ButtonSize
|
||||||
, style : ButtonStyle
|
, style : ButtonStyle
|
||||||
@ -379,7 +379,7 @@ linkWithMethod :
|
|||||||
String
|
String
|
||||||
->
|
->
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
, url : String
|
, url : String
|
||||||
, size : ButtonSize
|
, size : ButtonSize
|
||||||
, style : ButtonStyle
|
, style : ButtonStyle
|
||||||
@ -397,7 +397,7 @@ linkWithTracking :
|
|||||||
msg
|
msg
|
||||||
->
|
->
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
, url : String
|
, url : String
|
||||||
, size : ButtonSize
|
, size : ButtonSize
|
||||||
, style : ButtonStyle
|
, style : ButtonStyle
|
||||||
@ -421,7 +421,7 @@ linkExternalWithTracking :
|
|||||||
msg
|
msg
|
||||||
->
|
->
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
, url : String
|
, url : String
|
||||||
, size : ButtonSize
|
, size : ButtonSize
|
||||||
, style : ButtonStyle
|
, style : ButtonStyle
|
||||||
@ -443,7 +443,7 @@ linkBase :
|
|||||||
-> List (Attribute msg)
|
-> List (Attribute msg)
|
||||||
->
|
->
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe IconType
|
, icon : Maybe Svg
|
||||||
, url : String
|
, url : String
|
||||||
, size : ButtonSize
|
, size : ButtonSize
|
||||||
, style : ButtonStyle
|
, style : ButtonStyle
|
||||||
@ -500,8 +500,8 @@ buttonStyles size width colorPalette =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
viewLabel : Maybe IconType -> String -> Html msg
|
viewLabel : Maybe Svg -> String -> Html msg
|
||||||
viewLabel icn label =
|
viewLabel maybeSvg label =
|
||||||
Nri.Ui.styled Html.span
|
Nri.Ui.styled Html.span
|
||||||
"button-label-span"
|
"button-label-span"
|
||||||
[ Css.overflow Css.hidden -- Keep scrollbars out of our button
|
[ Css.overflow Css.hidden -- Keep scrollbars out of our button
|
||||||
@ -509,12 +509,12 @@ viewLabel icn label =
|
|||||||
, Css.padding2 (Css.px 2) Css.zero -- Without a bit of bottom padding, text that extends below the baseline, like "g" gets cut off
|
, Css.padding2 (Css.px 2) Css.zero -- Without a bit of bottom padding, text that extends below the baseline, like "g" gets cut off
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
(case icn of
|
(case maybeSvg of
|
||||||
Nothing ->
|
Nothing ->
|
||||||
renderMarkdown label
|
renderMarkdown label
|
||||||
|
|
||||||
Just iconType ->
|
Just svg ->
|
||||||
Icon.decorativeIcon iconType :: renderMarkdown label
|
NriSvg.toHtml svg :: renderMarkdown label
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import ModuleExample as ModuleExample exposing (Category(..), ModuleExample, Mod
|
|||||||
import Nri.Ui.AssetPath exposing (Asset)
|
import Nri.Ui.AssetPath exposing (Asset)
|
||||||
import Nri.Ui.Button.V8 as Button
|
import Nri.Ui.Button.V8 as Button
|
||||||
import Nri.Ui.Icon.V4 as Icon
|
import Nri.Ui.Icon.V4 as Icon
|
||||||
|
import Nri.Ui.Svg.V1 as NriSvg exposing (Svg)
|
||||||
import Nri.Ui.Text.V2 as Text
|
import Nri.Ui.Text.V2 as Text
|
||||||
|
|
||||||
|
|
||||||
@ -34,11 +35,10 @@ type ButtonType
|
|||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
example :
|
example :
|
||||||
{ r | teach_assignments_copyWhite_svg : Asset }
|
(String -> ModuleMessages Msg parentMsg)
|
||||||
-> (String -> ModuleMessages Msg parentMsg)
|
|
||||||
-> State
|
-> State
|
||||||
-> ModuleExample parentMsg
|
-> ModuleExample parentMsg
|
||||||
example assets unnamedMessages state =
|
example unnamedMessages state =
|
||||||
let
|
let
|
||||||
messages =
|
messages =
|
||||||
unnamedMessages "ButtonExample"
|
unnamedMessages "ButtonExample"
|
||||||
@ -46,7 +46,7 @@ example assets unnamedMessages state =
|
|||||||
{ filename = "Nri.Ui.Button.V8"
|
{ filename = "Nri.Ui.Button.V8"
|
||||||
, category = Buttons
|
, category = Buttons
|
||||||
, content =
|
, content =
|
||||||
[ viewButtonExamples assets messages state ]
|
[ viewButtonExamples messages state ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -58,8 +58,18 @@ init assets =
|
|||||||
|> Control.field "icon"
|
|> Control.field "icon"
|
||||||
(Control.maybe False <|
|
(Control.maybe False <|
|
||||||
Control.choice
|
Control.choice
|
||||||
( "Performance", Control.value (Icon.performance assets) )
|
( "Performance"
|
||||||
[ ( "Lock", Control.value (Icon.lock assets) )
|
, Icon.performance assets
|
||||||
|
|> Icon.decorativeIcon
|
||||||
|
|> NriSvg.fromHtml
|
||||||
|
|> Control.value
|
||||||
|
)
|
||||||
|
[ ( "Lock"
|
||||||
|
, Icon.lock assets
|
||||||
|
|> Icon.decorativeIcon
|
||||||
|
|> NriSvg.fromHtml
|
||||||
|
|> Control.value
|
||||||
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> Control.field "width"
|
|> Control.field "width"
|
||||||
@ -105,7 +115,7 @@ update msg state =
|
|||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ label : String
|
{ label : String
|
||||||
, icon : Maybe Icon.IconType
|
, icon : Maybe Svg
|
||||||
, width : Button.ButtonWidth
|
, width : Button.ButtonWidth
|
||||||
, buttonType : ButtonType
|
, buttonType : ButtonType
|
||||||
, state : Button.ButtonState
|
, state : Button.ButtonState
|
||||||
@ -113,18 +123,17 @@ type alias Model =
|
|||||||
|
|
||||||
|
|
||||||
viewButtonExamples :
|
viewButtonExamples :
|
||||||
{ r | teach_assignments_copyWhite_svg : Asset }
|
ModuleMessages Msg parentMsg
|
||||||
-> ModuleMessages Msg parentMsg
|
|
||||||
-> State
|
-> State
|
||||||
-> Html parentMsg
|
-> Html parentMsg
|
||||||
viewButtonExamples assets messages (State control) =
|
viewButtonExamples messages (State control) =
|
||||||
let
|
let
|
||||||
model =
|
model =
|
||||||
Control.currentValue control
|
Control.currentValue control
|
||||||
in
|
in
|
||||||
[ Control.view (State >> SetState >> messages.wrapper) control
|
[ Control.view (State >> SetState >> messages.wrapper) control
|
||||||
|> fromUnstyled
|
|> fromUnstyled
|
||||||
, buttons assets messages model
|
, buttons messages model
|
||||||
, toggleButtons messages
|
, toggleButtons messages
|
||||||
, Button.delete
|
, Button.delete
|
||||||
{ label = "Delete Something"
|
{ label = "Delete Something"
|
||||||
@ -161,11 +170,10 @@ allStyles =
|
|||||||
|
|
||||||
|
|
||||||
buttons :
|
buttons :
|
||||||
{ r | teach_assignments_copyWhite_svg : Asset }
|
ModuleMessages Msg parentMsg
|
||||||
-> ModuleMessages Msg parentMsg
|
|
||||||
-> Model
|
-> Model
|
||||||
-> Html parentMsg
|
-> Html parentMsg
|
||||||
buttons assets messages model =
|
buttons messages model =
|
||||||
let
|
let
|
||||||
exampleRow style =
|
exampleRow style =
|
||||||
List.concat
|
List.concat
|
||||||
|
@ -215,7 +215,7 @@ nriThemedModules : ModuleStates -> List (ModuleExample Msg)
|
|||||||
nriThemedModules model =
|
nriThemedModules model =
|
||||||
[ Examples.Alert.example
|
[ Examples.Alert.example
|
||||||
, Examples.BannerAlert.example
|
, Examples.BannerAlert.example
|
||||||
, Examples.Button.example assets (exampleMessages ButtonExampleMsg) model.buttonExampleState
|
, Examples.Button.example (exampleMessages ButtonExampleMsg) model.buttonExampleState
|
||||||
, Examples.ClickableText.example assets (exampleMessages ClickableTextExampleMsg) model.clickableTextExampleState
|
, Examples.ClickableText.example assets (exampleMessages ClickableTextExampleMsg) model.clickableTextExampleState
|
||||||
, Examples.Checkbox.example CheckboxExampleMsg model.checkboxExampleState
|
, Examples.Checkbox.example CheckboxExampleMsg model.checkboxExampleState
|
||||||
, Examples.Dropdown.example DropdownMsg model.dropdownState
|
, Examples.Dropdown.example DropdownMsg model.dropdownState
|
||||||
|
Loading…
Reference in New Issue
Block a user