@charmland/gem 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +177 -0
- package/NOTICE +13 -0
- package/README.md +24 -2
- package/assets/fonts/Hypography-Italic.woff2 +0 -0
- package/assets/fonts/Hypography-Regular.woff2 +0 -0
- package/assets/fonts/PPFraktionMono-Variable.ttf +0 -0
- package/assets/fonts/PPFraktionMonoItalic-Variable.ttf +0 -0
- package/assets/fonts/PPFraktionSans-Variable.ttf +0 -0
- package/assets/fonts/PPFraktionSansItalic-Variable.ttf +0 -0
- package/bin/gem-elm.js +3 -0
- package/dist/browser/boot.d.ts +10 -0
- package/dist/browser/boot.js +14 -0
- package/dist/browser/color-scheme.d.ts +9 -0
- package/dist/browser/color-scheme.js +76 -0
- package/dist/browser/ports.d.ts +37 -0
- package/dist/browser/ports.js +90 -0
- package/dist/browser/router.d.ts +5 -0
- package/dist/browser/router.js +35 -0
- package/dist/browser/runtime.d.ts +12 -0
- package/dist/browser/runtime.js +22 -0
- package/dist/browser/tabs.d.ts +9 -0
- package/dist/browser/tabs.js +69 -0
- package/dist/default/theme.css +4664 -0
- package/dist/default/theme.js +13815 -0
- package/dist/node/build.d.ts +16 -0
- package/dist/node/build.js +48 -0
- package/dist/node/cli.d.ts +2 -0
- package/dist/node/cli.js +21 -0
- package/elm.json +28 -0
- package/package.json +86 -4
- package/src/app/Gem/App.elm +1268 -0
- package/src/app/Gem/CharmSticker.elm +35 -0
- package/src/app/Gem/Components.elm +292 -0
- package/src/app/Gem/Main.elm +17 -0
- package/src/app/Gem/Ports.elm +32 -0
- package/src/app/Gem/Shell.elm +957 -0
- package/src/browser/theme.d.ts +1 -0
- package/src/core/Gem/Node.elm +219 -0
- package/src/core/Gem/Page.elm +560 -0
- package/src/core/Gem/Render.elm +510 -0
- package/src/core/Gem/Slots.elm +11 -0
- package/src/styles/docs.scss +1083 -0
- package/src/styles/fonts.scss +51 -0
- package/src/styles/gem.scss +362 -0
- package/src/styles/theme.scss +8 -0
- package/src/styles/ui/burger.scss +272 -0
- package/src/styles/ui/button.scss +350 -0
- package/src/styles/ui/charmtone.scss +70 -0
- package/src/styles/ui/controls-extra.scss +316 -0
- package/src/styles/ui/controls.scss +110 -0
- package/src/styles/ui/display.scss +359 -0
- package/src/styles/ui/dropdown.scss +341 -0
- package/src/styles/ui/form.scss +314 -0
- package/src/styles/ui/menu.scss +200 -0
- package/src/styles/ui/meter.scss +124 -0
- package/src/styles/ui/modal.scss +545 -0
- package/src/styles/ui/oauth.scss +50 -0
- package/src/styles/ui/page-nav.scss +63 -0
- package/src/styles/ui/reset.scss +111 -0
- package/src/styles/ui/scrollbar.scss +39 -0
- package/src/styles/ui/search.scss +164 -0
- package/src/styles/ui/sidebar.scss +229 -0
- package/src/styles/ui/squircle.scss +60 -0
- package/src/styles/ui/table.scss +97 -0
- package/src/styles/ui/theme.scss +132 -0
- package/src/styles/ui/toast.scss +587 -0
- package/src/styles/ui/toc.scss +128 -0
- package/src/styles/ui/typography.scss +21 -0
- package/src/styles/ui/ui.scss +33 -0
- package/src/ui/Ui/Badge.elm +51 -0
- package/src/ui/Ui/Banner.elm +97 -0
- package/src/ui/Ui/Burger.elm +259 -0
- package/src/ui/Ui/Button.elm +261 -0
- package/src/ui/Ui/Card.elm +32 -0
- package/src/ui/Ui/Cards.elm +15 -0
- package/src/ui/Ui/ChoiceGroup.elm +62 -0
- package/src/ui/Ui/CopyButton.elm +139 -0
- package/src/ui/Ui/Divider.elm +16 -0
- package/src/ui/Ui/Dropdown.elm +600 -0
- package/src/ui/Ui/Empty.elm +41 -0
- package/src/ui/Ui/ErrorBubble.elm +34 -0
- package/src/ui/Ui/Field.elm +45 -0
- package/src/ui/Ui/FormStatus.elm +32 -0
- package/src/ui/Ui/Icon.elm +381 -0
- package/src/ui/Ui/InlineForm.elm +51 -0
- package/src/ui/Ui/Input.elm +113 -0
- package/src/ui/Ui/KeyValue.elm +25 -0
- package/src/ui/Ui/ListRow.elm +67 -0
- package/src/ui/Ui/Loader.elm +32 -0
- package/src/ui/Ui/Logo/Charm.elm +21 -0
- package/src/ui/Ui/Logo/CharmMark.elm +32 -0
- package/src/ui/Ui/Logo/CharmSticker.elm +35 -0
- package/src/ui/Ui/Logo/Discord.elm +26 -0
- package/src/ui/Ui/Logo/GitHub.elm +21 -0
- package/src/ui/Ui/Logo/Google.elm +21 -0
- package/src/ui/Ui/Logo/Hexy.elm +29 -0
- package/src/ui/Ui/Logo/Hyper.elm +42 -0
- package/src/ui/Ui/Logo/Integration.elm +117 -0
- package/src/ui/Ui/Logo/Prism.elm +35 -0
- package/src/ui/Ui/Logos.elm +115 -0
- package/src/ui/Ui/Menu.elm +348 -0
- package/src/ui/Ui/Meter.elm +132 -0
- package/src/ui/Ui/Modal.elm +247 -0
- package/src/ui/Ui/Motion.elm +32 -0
- package/src/ui/Ui/NumberBox.elm +86 -0
- package/src/ui/Ui/OAuthButton.elm +39 -0
- package/src/ui/Ui/PageNav.elm +65 -0
- package/src/ui/Ui/Pager.elm +49 -0
- package/src/ui/Ui/Search.elm +396 -0
- package/src/ui/Ui/SearchBox.elm +78 -0
- package/src/ui/Ui/Section.elm +21 -0
- package/src/ui/Ui/Sidebar.elm +239 -0
- package/src/ui/Ui/Stat.elm +29 -0
- package/src/ui/Ui/Switch.elm +34 -0
- package/src/ui/Ui/Table.elm +89 -0
- package/src/ui/Ui/Tabs.elm +280 -0
- package/src/ui/Ui/ToC.elm +120 -0
- package/src/ui/Ui/Toast.elm +1145 -0
- package/src/ui/Ui/Toolbar.elm +31 -0
- package/src/ui/Ui/TwoStepConfirm.elm +159 -0
- package/src/ui/Ui/Typography.elm +33 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
module Ui.Modal exposing
|
|
2
|
+
( Config
|
|
3
|
+
, confirm
|
|
4
|
+
, reveal
|
|
5
|
+
, view
|
|
6
|
+
, withAttributes
|
|
7
|
+
, withContent
|
|
8
|
+
, withDismissible
|
|
9
|
+
, withMaxWidth
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
{-| The modal: an overlay with a backdrop and a native `<dialog>`.
|
|
13
|
+
The overlay scaffold used to be copy-pasted across five pages; this is
|
|
14
|
+
the one implementation.
|
|
15
|
+
|
|
16
|
+
`view` renders the raw scaffold for anything custom (form dialogs,
|
|
17
|
+
multi-step flows). `confirm` and `reveal` are the two product recipes
|
|
18
|
+
built on it. Pass `dismissible = Just msg` to close on backdrop
|
|
19
|
+
click; `Nothing` pins the dialog — the convention while a submit is
|
|
20
|
+
in flight, and required for the one-time secret reveal.
|
|
21
|
+
|
|
22
|
+
-}
|
|
23
|
+
|
|
24
|
+
import Html exposing (Attribute, Html, button, div, footer, h2, node, p, text)
|
|
25
|
+
import Html.Attributes as Attr
|
|
26
|
+
import Html.Events
|
|
27
|
+
import Ui.Button
|
|
28
|
+
import Ui.CopyButton
|
|
29
|
+
import Ui.Icon
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
{-| The scaffold's configuration. `content` sits inside the dialog
|
|
33
|
+
surface; style it with the `.modal` descendant hooks (fields, hints,
|
|
34
|
+
footers) documented on the site.
|
|
35
|
+
-}
|
|
36
|
+
type alias Config msg =
|
|
37
|
+
{ dismissible : Maybe msg
|
|
38
|
+
, maxWidth : Maybe Int
|
|
39
|
+
, content : List (Html msg)
|
|
40
|
+
, attributes : List (Attribute msg)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
{-| Make the backdrop clickable and hand over the dismiss message.
|
|
45
|
+
-}
|
|
46
|
+
withDismissible : msg -> Config msg -> Config msg
|
|
47
|
+
withDismissible onDismiss config =
|
|
48
|
+
{ config | dismissible = Just onDismiss }
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
{-| Cap the dialog's width (in rem).
|
|
52
|
+
-}
|
|
53
|
+
withMaxWidth : Int -> Config msg -> Config msg
|
|
54
|
+
withMaxWidth px config =
|
|
55
|
+
{ config | maxWidth = Just px }
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
{-| Set the dialog's content.
|
|
59
|
+
-}
|
|
60
|
+
withContent : List (Html msg) -> Config msg -> Config msg
|
|
61
|
+
withContent content config =
|
|
62
|
+
{ config | content = content }
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
{-| Add extra attributes (ids, test selectors, additional handlers).
|
|
66
|
+
-}
|
|
67
|
+
withAttributes : List (Attribute msg) -> Config msg -> Config msg
|
|
68
|
+
withAttributes attributes config =
|
|
69
|
+
{ config | attributes = config.attributes ++ attributes }
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
{-| The plain scaffold: overlay, backdrop, open dialog. Stack nothing
|
|
73
|
+
else above it (the overlay carries the top z-index).
|
|
74
|
+
-}
|
|
75
|
+
view : Config msg -> Html msg
|
|
76
|
+
view config =
|
|
77
|
+
let
|
|
78
|
+
backdrop =
|
|
79
|
+
case config.dismissible of
|
|
80
|
+
Just onDismiss ->
|
|
81
|
+
[ div
|
|
82
|
+
[ Attr.class "modal-backdrop"
|
|
83
|
+
, Html.Events.onClick onDismiss
|
|
84
|
+
]
|
|
85
|
+
[]
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
Nothing ->
|
|
89
|
+
[ div [ Attr.class "modal-backdrop" ] [] ]
|
|
90
|
+
|
|
91
|
+
widthStyle =
|
|
92
|
+
case config.maxWidth of
|
|
93
|
+
Just px ->
|
|
94
|
+
[ Attr.style "max-width" (String.fromInt px ++ "rem") ]
|
|
95
|
+
|
|
96
|
+
Nothing ->
|
|
97
|
+
[]
|
|
98
|
+
|
|
99
|
+
-- The dismiss chip: the small X in the dialog's top corner, the
|
|
100
|
+
-- one affordance every non-blocking dialog shares. A
|
|
101
|
+
-- non-dismissible dialog (a submit in flight, the secret reveal)
|
|
102
|
+
-- renders none.
|
|
103
|
+
closeChip =
|
|
104
|
+
case config.dismissible of
|
|
105
|
+
Just onDismiss ->
|
|
106
|
+
[ button
|
|
107
|
+
[ Attr.class "close"
|
|
108
|
+
, Attr.type_ "button"
|
|
109
|
+
, Attr.attribute "aria-label" "Close"
|
|
110
|
+
, Html.Events.onClick onDismiss
|
|
111
|
+
]
|
|
112
|
+
[ Html.span [ Attr.attribute "aria-hidden" "true" ] [ Ui.Icon.view Ui.Icon.Close ] ]
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
Nothing ->
|
|
116
|
+
[]
|
|
117
|
+
in
|
|
118
|
+
div [ Attr.class "modal-overlay" ]
|
|
119
|
+
(backdrop
|
|
120
|
+
++ [ node "dialog"
|
|
121
|
+
([ Attr.attribute "open" ""
|
|
122
|
+
, Attr.attribute "role" "dialog"
|
|
123
|
+
, Attr.attribute "aria-modal" "true"
|
|
124
|
+
, Attr.class "modal"
|
|
125
|
+
]
|
|
126
|
+
++ widthStyle
|
|
127
|
+
++ config.attributes
|
|
128
|
+
)
|
|
129
|
+
(closeChip ++ config.content)
|
|
130
|
+
]
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
{-| The confirm dialog recipe: a short question, one line of
|
|
135
|
+
consequence, and a pair of buttons. `confirmVariant` picks the
|
|
136
|
+
confirm button's color (usually `DangerSolid`); `primaryFirst`
|
|
137
|
+
flips the footer order for the plan-cancel pattern, where the
|
|
138
|
+
destructive action leads.
|
|
139
|
+
-}
|
|
140
|
+
confirm :
|
|
141
|
+
{ title : String
|
|
142
|
+
, body : String
|
|
143
|
+
, confirmLabel : String
|
|
144
|
+
, confirmVariant : Ui.Button.Variant
|
|
145
|
+
, cancelLabel : String
|
|
146
|
+
, primaryFirst : Bool
|
|
147
|
+
, onConfirm : msg
|
|
148
|
+
, onCancel : msg
|
|
149
|
+
, dismissible : Maybe msg
|
|
150
|
+
, attributes : List (Attribute msg)
|
|
151
|
+
}
|
|
152
|
+
-> Html msg
|
|
153
|
+
confirm config =
|
|
154
|
+
let
|
|
155
|
+
cancelButton =
|
|
156
|
+
Ui.Button.view
|
|
157
|
+
{ label = config.cancelLabel
|
|
158
|
+
, variant = Ui.Button.Ghost
|
|
159
|
+
, size = Ui.Button.Regular
|
|
160
|
+
, wide = False
|
|
161
|
+
, disabled = False
|
|
162
|
+
, busy = Nothing
|
|
163
|
+
, icon = Nothing
|
|
164
|
+
, onClick = config.onCancel
|
|
165
|
+
, attributes = []
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
confirmButton =
|
|
169
|
+
Ui.Button.view
|
|
170
|
+
{ label = config.confirmLabel
|
|
171
|
+
, variant = config.confirmVariant
|
|
172
|
+
, size = Ui.Button.Regular
|
|
173
|
+
, wide = False
|
|
174
|
+
, disabled = False
|
|
175
|
+
, busy = Nothing
|
|
176
|
+
, icon = Nothing
|
|
177
|
+
, onClick = config.onConfirm
|
|
178
|
+
, attributes = []
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
buttons =
|
|
182
|
+
if config.primaryFirst then
|
|
183
|
+
[ confirmButton, cancelButton ]
|
|
184
|
+
|
|
185
|
+
else
|
|
186
|
+
[ cancelButton, confirmButton ]
|
|
187
|
+
in
|
|
188
|
+
view
|
|
189
|
+
{ dismissible = config.dismissible
|
|
190
|
+
, maxWidth = Nothing
|
|
191
|
+
, attributes = [ Attr.class "confirm" ] ++ config.attributes
|
|
192
|
+
, content =
|
|
193
|
+
[ h2 [] [ text config.title ]
|
|
194
|
+
, p [] [ text config.body ]
|
|
195
|
+
, footer [] buttons
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
{-| The one-time secret reveal: a warning line, the secret in a mono
|
|
201
|
+
readout with a copy button riding inside it, and a single Done button.
|
|
202
|
+
Deliberately not dismissible — the secret shows exactly once and the
|
|
203
|
+
host unmounts the dialog when done.
|
|
204
|
+
-}
|
|
205
|
+
reveal :
|
|
206
|
+
{ warning : List (Html msg)
|
|
207
|
+
, secret : String
|
|
208
|
+
, doneLabel : String
|
|
209
|
+
, onDone : msg
|
|
210
|
+
, copiedModel : Ui.CopyButton.Model
|
|
211
|
+
, onCopyMsg : Ui.CopyButton.Msg -> msg
|
|
212
|
+
, attributes : List (Attribute msg)
|
|
213
|
+
}
|
|
214
|
+
-> Html msg
|
|
215
|
+
reveal config =
|
|
216
|
+
view
|
|
217
|
+
{ dismissible = Nothing
|
|
218
|
+
, maxWidth = Just 34
|
|
219
|
+
, attributes = [ Attr.class "reveal" ] ++ config.attributes
|
|
220
|
+
, content =
|
|
221
|
+
[ p [ Attr.class "reveal-warn" ] config.warning
|
|
222
|
+
, p [ Attr.class "reveal-token" ]
|
|
223
|
+
[ Html.code [] [ text config.secret ]
|
|
224
|
+
, Html.map config.onCopyMsg
|
|
225
|
+
(Ui.CopyButton.view
|
|
226
|
+
{ text = config.secret
|
|
227
|
+
, label = "Copy token"
|
|
228
|
+
, attributes = []
|
|
229
|
+
}
|
|
230
|
+
config.copiedModel
|
|
231
|
+
)
|
|
232
|
+
]
|
|
233
|
+
, footer []
|
|
234
|
+
[ Ui.Button.view
|
|
235
|
+
{ label = config.doneLabel
|
|
236
|
+
, variant = Ui.Button.Primary
|
|
237
|
+
, size = Ui.Button.Regular
|
|
238
|
+
, wide = True
|
|
239
|
+
, disabled = False
|
|
240
|
+
, busy = Nothing
|
|
241
|
+
, icon = Nothing
|
|
242
|
+
, onClick = config.onDone
|
|
243
|
+
, attributes = []
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
]
|
|
247
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Motion exposing (step)
|
|
2
|
+
|
|
3
|
+
{-| Frame stepping for `carlsson87/spring`.
|
|
4
|
+
|
|
5
|
+
The library advances a spring with one explicit Euler step per call, and
|
|
6
|
+
that goes unstable once a single step outgrows the spring's period: at
|
|
7
|
+
the drawer's tension (280) anything past about 120ms. A frame that long
|
|
8
|
+
is ordinary — a page rendering on a phone, a tab coming back from the
|
|
9
|
+
background — and one is enough to fling a sheet thousands of percent off
|
|
10
|
+
screen and leave it there.
|
|
11
|
+
|
|
12
|
+
-}
|
|
13
|
+
|
|
14
|
+
import Spring exposing (Spring)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
{-| Advances a spring by a frame's delta in slices of at most 16ms. The
|
|
18
|
+
delta is capped at 100ms first, so a long stall resumes the motion where
|
|
19
|
+
it was rather than jumping to its end.
|
|
20
|
+
-}
|
|
21
|
+
step : Spring.Config -> Float -> Spring -> Spring
|
|
22
|
+
step config deltaMs spring =
|
|
23
|
+
slice config (min deltaMs 100) spring
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
slice : Spring.Config -> Float -> Spring -> Spring
|
|
27
|
+
slice config remaining spring =
|
|
28
|
+
if remaining <= 16 then
|
|
29
|
+
Spring.update config remaining spring
|
|
30
|
+
|
|
31
|
+
else
|
|
32
|
+
slice config (remaining - 16) (Spring.update config 16 spring)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
module Ui.NumberBox exposing (view)
|
|
2
|
+
|
|
3
|
+
{-| The number box: a numeric field whose native spinner is replaced by
|
|
4
|
+
our own chevron steppers. The native spinner cannot be sized and
|
|
5
|
+
paints its own platform background over the field; the chevrons stay
|
|
6
|
+
on-theme.
|
|
7
|
+
-}
|
|
8
|
+
|
|
9
|
+
import Html exposing (Attribute, Html, button, div, input)
|
|
10
|
+
import Html.Attributes as Attr exposing (type_, value)
|
|
11
|
+
import Html.Events
|
|
12
|
+
import Ui.Icon
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
{-| Render a number box. `step` is the increment the steppers apply;
|
|
16
|
+
pass `min`/`max` bounds as `Maybe Int` (they clamp the steppers, not
|
|
17
|
+
typed input). The typed value always arrives through `onInput` as the
|
|
18
|
+
raw string — parse at your own boundary.
|
|
19
|
+
-}
|
|
20
|
+
view :
|
|
21
|
+
{ value : String
|
|
22
|
+
, onInput : String -> msg
|
|
23
|
+
, onStep : Int -> msg
|
|
24
|
+
, step : Int
|
|
25
|
+
, min : Maybe Int
|
|
26
|
+
, max : Maybe Int
|
|
27
|
+
, attributes : List (Attribute msg)
|
|
28
|
+
}
|
|
29
|
+
-> Html msg
|
|
30
|
+
view config =
|
|
31
|
+
let
|
|
32
|
+
currentValue =
|
|
33
|
+
String.toInt (String.trim config.value)
|
|
34
|
+
|
|
35
|
+
canStep delta =
|
|
36
|
+
case Maybe.map ((+) delta) currentValue of
|
|
37
|
+
Nothing ->
|
|
38
|
+
False
|
|
39
|
+
|
|
40
|
+
Just candidate ->
|
|
41
|
+
aboveMin candidate && belowMax candidate
|
|
42
|
+
|
|
43
|
+
aboveMin candidate =
|
|
44
|
+
case config.min of
|
|
45
|
+
Just min ->
|
|
46
|
+
candidate >= min
|
|
47
|
+
|
|
48
|
+
Nothing ->
|
|
49
|
+
True
|
|
50
|
+
|
|
51
|
+
belowMax candidate =
|
|
52
|
+
case config.max of
|
|
53
|
+
Just max ->
|
|
54
|
+
candidate <= max
|
|
55
|
+
|
|
56
|
+
Nothing ->
|
|
57
|
+
True
|
|
58
|
+
|
|
59
|
+
stepperButton delta icon =
|
|
60
|
+
button
|
|
61
|
+
[ Attr.classList [ ( "down", delta < 0 ) ]
|
|
62
|
+
, Attr.type_ "button"
|
|
63
|
+
, Attr.disabled (not (canStep delta))
|
|
64
|
+
, Attr.attribute "aria-label"
|
|
65
|
+
(if delta < 0 then
|
|
66
|
+
"Decrease"
|
|
67
|
+
|
|
68
|
+
else
|
|
69
|
+
"Increase"
|
|
70
|
+
)
|
|
71
|
+
, Html.Events.onClick (config.onStep (config.step * delta))
|
|
72
|
+
]
|
|
73
|
+
[ Ui.Icon.view icon ]
|
|
74
|
+
in
|
|
75
|
+
div ([ Attr.class "number-box" ] ++ config.attributes)
|
|
76
|
+
[ input
|
|
77
|
+
[ type_ "number"
|
|
78
|
+
, value config.value
|
|
79
|
+
, Html.Events.onInput config.onInput
|
|
80
|
+
]
|
|
81
|
+
[]
|
|
82
|
+
, div [ Attr.class "steppers" ]
|
|
83
|
+
[ stepperButton 1 Ui.Icon.Chevron
|
|
84
|
+
, stepperButton -1 Ui.Icon.Chevron
|
|
85
|
+
]
|
|
86
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Ui.OAuthButton exposing (view)
|
|
2
|
+
|
|
3
|
+
{-| The social sign-in button from the auth screens: a provider logo
|
|
4
|
+
beside a label, rendered as an anchor (the flow leaves the page).
|
|
5
|
+
-}
|
|
6
|
+
|
|
7
|
+
import Html exposing (Attribute, Html, a, text)
|
|
8
|
+
import Html.Attributes as Attr
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
{-| Render the button. `logo` is the provider's mark (an asset, not a
|
|
12
|
+
Ui icon); `disabled` dims it when the backend reports the provider
|
|
13
|
+
off.
|
|
14
|
+
-}
|
|
15
|
+
view :
|
|
16
|
+
{ logo : List (Html msg)
|
|
17
|
+
, label : String
|
|
18
|
+
, href : String
|
|
19
|
+
, disabled : Bool
|
|
20
|
+
, attributes : List (Attribute msg)
|
|
21
|
+
}
|
|
22
|
+
-> Html msg
|
|
23
|
+
view config =
|
|
24
|
+
let
|
|
25
|
+
disabledAttrs =
|
|
26
|
+
if config.disabled then
|
|
27
|
+
[ Attr.class "disabled", Attr.attribute "aria-disabled" "true" ]
|
|
28
|
+
|
|
29
|
+
else
|
|
30
|
+
[]
|
|
31
|
+
in
|
|
32
|
+
a
|
|
33
|
+
([ Attr.class "social"
|
|
34
|
+
, Attr.href config.href
|
|
35
|
+
]
|
|
36
|
+
++ disabledAttrs
|
|
37
|
+
++ config.attributes
|
|
38
|
+
)
|
|
39
|
+
(config.logo ++ [ text config.label ])
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Ui.PageNav exposing (Item, view)
|
|
2
|
+
|
|
3
|
+
{-| The page's prev/next rail: two cards at the foot of a docs page —
|
|
4
|
+
the previous page on the left, the next on the right — each carrying
|
|
5
|
+
the neighbour's title and a one-line hint of its description. The
|
|
6
|
+
description truncates with an ellipsis, so pass the full copy and let
|
|
7
|
+
the rail keep it to a taste.
|
|
8
|
+
-}
|
|
9
|
+
|
|
10
|
+
import Html exposing (Html, span, text)
|
|
11
|
+
import Html.Attributes
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
{-| One neighbour. `description` renders as a single truncated line;
|
|
15
|
+
pass an empty string to render the title alone.
|
|
16
|
+
-}
|
|
17
|
+
type alias Item =
|
|
18
|
+
{ title : String
|
|
19
|
+
, description : String
|
|
20
|
+
, href : String
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
itemView : String -> String -> Item -> Html msg
|
|
25
|
+
itemView directionLabel directionClass item =
|
|
26
|
+
Html.a
|
|
27
|
+
[ Html.Attributes.class ("page-nav-link " ++ directionClass)
|
|
28
|
+
, Html.Attributes.href item.href
|
|
29
|
+
]
|
|
30
|
+
[ span [ Html.Attributes.class "page-nav-dir" ] [ text directionLabel ]
|
|
31
|
+
, span [ Html.Attributes.class "page-nav-title" ] [ text item.title ]
|
|
32
|
+
, span [ Html.Attributes.class "page-nav-desc" ] [ text item.description ]
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
{-| Render the rail. `previous` and `next` are the neighbours; a
|
|
37
|
+
missing side renders empty so the other card keeps its alignment
|
|
38
|
+
(previous left, next right).
|
|
39
|
+
-}
|
|
40
|
+
view :
|
|
41
|
+
{ previous : Maybe Item
|
|
42
|
+
, next : Maybe Item
|
|
43
|
+
, attributes : List (Html.Attribute msg)
|
|
44
|
+
}
|
|
45
|
+
-> Html msg
|
|
46
|
+
view config =
|
|
47
|
+
Html.nav
|
|
48
|
+
([ Html.Attributes.class "page-nav"
|
|
49
|
+
, Html.Attributes.attribute "aria-label" "Pagination"
|
|
50
|
+
]
|
|
51
|
+
++ config.attributes
|
|
52
|
+
)
|
|
53
|
+
[ case config.previous of
|
|
54
|
+
Just item ->
|
|
55
|
+
itemView "Previous" "prev" item
|
|
56
|
+
|
|
57
|
+
Nothing ->
|
|
58
|
+
Html.text ""
|
|
59
|
+
, case config.next of
|
|
60
|
+
Just item ->
|
|
61
|
+
itemView "Next" "next" item
|
|
62
|
+
|
|
63
|
+
Nothing ->
|
|
64
|
+
Html.text ""
|
|
65
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Ui.Pager exposing (view)
|
|
2
|
+
|
|
3
|
+
{-| The page-number pager: a summary line on the left, Previous /
|
|
4
|
+
position / Next on the right. Used under staff lists and the usage
|
|
5
|
+
table.
|
|
6
|
+
-}
|
|
7
|
+
|
|
8
|
+
import Html exposing (Attribute, Html, div, span, text)
|
|
9
|
+
import Html.Attributes
|
|
10
|
+
import Ui.Button
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
{-| Render a pager. `summary` is the left-hand copy ("Page 2 of 12 ·
|
|
14
|
+
240 items", or Usage's "Showing 51–60 of 1,204 requests"); when a
|
|
15
|
+
boundary is hit its button disables.
|
|
16
|
+
-}
|
|
17
|
+
view :
|
|
18
|
+
{ summary : String
|
|
19
|
+
, page : Int
|
|
20
|
+
, pages : Int
|
|
21
|
+
, onPrev : msg
|
|
22
|
+
, onNext : msg
|
|
23
|
+
, attributes : List (Attribute msg)
|
|
24
|
+
}
|
|
25
|
+
-> Html msg
|
|
26
|
+
view config =
|
|
27
|
+
let
|
|
28
|
+
pagerButton label target disabled =
|
|
29
|
+
Ui.Button.view
|
|
30
|
+
{ label = label
|
|
31
|
+
, variant = Ui.Button.Secondary
|
|
32
|
+
, size = Ui.Button.Compact
|
|
33
|
+
, wide = False
|
|
34
|
+
, disabled = disabled
|
|
35
|
+
, busy = Nothing
|
|
36
|
+
, icon = Nothing
|
|
37
|
+
, onClick = target
|
|
38
|
+
, attributes = []
|
|
39
|
+
}
|
|
40
|
+
in
|
|
41
|
+
div ([ Html.Attributes.class "pager" ] ++ config.attributes)
|
|
42
|
+
[ span [ Html.Attributes.class "summary" ] [ text config.summary ]
|
|
43
|
+
, div [ Html.Attributes.class "pages" ]
|
|
44
|
+
[ pagerButton "Previous" config.onPrev (config.page <= 1)
|
|
45
|
+
, span [ Html.Attributes.class "position" ]
|
|
46
|
+
[ text (String.fromInt config.page ++ " / " ++ String.fromInt config.pages) ]
|
|
47
|
+
, pagerButton "Next" config.onNext (config.page >= config.pages)
|
|
48
|
+
]
|
|
49
|
+
]
|