@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,128 @@
|
|
|
1
|
+
@use "charmtone";
|
|
2
|
+
@use "controls" as *;
|
|
3
|
+
|
|
4
|
+
// The table of contents: a centered header, items on a flat list.
|
|
5
|
+
// No rail — the blush edge on the active item is the only marker.
|
|
6
|
+
|
|
7
|
+
.toc {
|
|
8
|
+
font-size: 0.8125rem;
|
|
9
|
+
|
|
10
|
+
.toc-title {
|
|
11
|
+
margin: 0 0 0.75rem;
|
|
12
|
+
font-size: 0.75rem;
|
|
13
|
+
font-weight: 620;
|
|
14
|
+
letter-spacing: 0.08em;
|
|
15
|
+
color: var(--tertiary);
|
|
16
|
+
text-align: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
ul {
|
|
20
|
+
list-style: none;
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 0;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
ul ul {
|
|
28
|
+
// Children keep the highlight rail in the same column as the
|
|
29
|
+
// parent; only the label indents, never the border.
|
|
30
|
+
margin-left: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
li a {
|
|
34
|
+
display: block;
|
|
35
|
+
padding: 0.3rem 0.9rem;
|
|
36
|
+
border-left: 2px solid transparent;
|
|
37
|
+
color: var(--muted);
|
|
38
|
+
text-decoration: none;
|
|
39
|
+
line-height: 1.4;
|
|
40
|
+
transition:
|
|
41
|
+
color 125ms ease,
|
|
42
|
+
border-color 125ms ease;
|
|
43
|
+
|
|
44
|
+
&:hover {
|
|
45
|
+
color: var(--fg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
li li a {
|
|
50
|
+
padding-left: 1.6rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
li.active a {
|
|
54
|
+
border-left-color: charmtone.$blush;
|
|
55
|
+
color: var(--fg);
|
|
56
|
+
font-weight: 620;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Collapsible shape (the mobile pattern): the list folds behind the
|
|
60
|
+
// title, which becomes a toggle button with a chevron. On wide
|
|
61
|
+
// screens the CSS re-opens the list and quiets the button, so one
|
|
62
|
+
// render serves both.
|
|
63
|
+
&.collapsible ul {
|
|
64
|
+
display: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&.collapsible.open ul {
|
|
68
|
+
display: flex;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.toc-toggle {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: space-between;
|
|
75
|
+
width: 100%;
|
|
76
|
+
// The .toc-title margins don't apply to the button: the collapsed
|
|
77
|
+
// band centers it instead. Its label starts where the item labels
|
|
78
|
+
// do (rail + item padding), folded or open, at every width.
|
|
79
|
+
margin: 0;
|
|
80
|
+
padding: 0;
|
|
81
|
+
padding-left: calc(0.9rem + 2px);
|
|
82
|
+
border: none;
|
|
83
|
+
background: none;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
font: inherit;
|
|
86
|
+
|
|
87
|
+
.chevron {
|
|
88
|
+
display: flex;
|
|
89
|
+
color: var(--muted);
|
|
90
|
+
transition: transform 150ms ease;
|
|
91
|
+
|
|
92
|
+
svg {
|
|
93
|
+
width: 0.9rem;
|
|
94
|
+
height: 0.9rem;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&.collapsible .toc-toggle .chevron {
|
|
100
|
+
transform: rotate(-90deg);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.collapsible.open .toc-toggle .chevron {
|
|
104
|
+
transform: rotate(0deg);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Open, the toggle heads the list and keeps the plain title's gap.
|
|
108
|
+
&.collapsible.open .toc-toggle {
|
|
109
|
+
margin-bottom: 0.75rem;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@media (min-width: 1024.02px) {
|
|
113
|
+
&.collapsible ul {
|
|
114
|
+
display: flex;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Always open up here: the quieted toggle is the list's heading.
|
|
118
|
+
&.collapsible .toc-toggle {
|
|
119
|
+
cursor: default;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
margin-bottom: 0.75rem;
|
|
122
|
+
|
|
123
|
+
.chevron {
|
|
124
|
+
display: none;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@use "charmtone";
|
|
2
|
+
@use "controls" as *;
|
|
3
|
+
|
|
4
|
+
// Typography helpers: quiet copy, section labels, field hints.
|
|
5
|
+
|
|
6
|
+
.muted {
|
|
7
|
+
color: var(--muted);
|
|
8
|
+
font-size: 0.875rem;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.section-label {
|
|
12
|
+
margin: 0;
|
|
13
|
+
font-size: 1rem;
|
|
14
|
+
font-weight: 650;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.hint {
|
|
18
|
+
margin: 0;
|
|
19
|
+
color: var(--muted);
|
|
20
|
+
font-size: 0.8125rem;
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The UI kit's stylesheet manifest. Each partial owns one concern; the
|
|
2
|
+
// @use order below is load-bearing, not alphabetical: CSS emits in
|
|
3
|
+
// first-use order and the cascade depends on it. `controls` emits
|
|
4
|
+
// nothing (tokens and mixins only), `reset` is a layer, and the base
|
|
5
|
+
// partials (typography, button, form, table, display) must come
|
|
6
|
+
// before the widgets that refine their shapes (controls-extra,
|
|
7
|
+
// dropdown, modal, toast, meter, oauth).
|
|
8
|
+
//
|
|
9
|
+
// After restructuring or reordering partials, verify the cascade is
|
|
10
|
+
// unchanged by compiling before and after and diffing the output.
|
|
11
|
+
|
|
12
|
+
@use "reset";
|
|
13
|
+
@use "theme";
|
|
14
|
+
@use "scrollbar";
|
|
15
|
+
@use "controls";
|
|
16
|
+
@use "squircle";
|
|
17
|
+
@use "typography";
|
|
18
|
+
@use "button";
|
|
19
|
+
@use "form";
|
|
20
|
+
@use "table";
|
|
21
|
+
@use "display";
|
|
22
|
+
@use "controls-extra";
|
|
23
|
+
@use "dropdown";
|
|
24
|
+
@use "search";
|
|
25
|
+
@use "modal";
|
|
26
|
+
@use "toast";
|
|
27
|
+
@use "meter";
|
|
28
|
+
@use "oauth";
|
|
29
|
+
@use "menu";
|
|
30
|
+
@use "sidebar";
|
|
31
|
+
@use "toc";
|
|
32
|
+
@use "page-nav";
|
|
33
|
+
@use "burger";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Ui.Badge exposing (Kind(..), view)
|
|
2
|
+
|
|
3
|
+
{-| The status chip. Translucent fills with the saturated text on top —
|
|
4
|
+
the idiom the team roster's role badges set. Used in table cells and
|
|
5
|
+
list rows for state ("Active", "Revoked") and for labels ("Staff").
|
|
6
|
+
-}
|
|
7
|
+
|
|
8
|
+
import Html exposing (Html, span, text)
|
|
9
|
+
import Html.Attributes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
{-| The chip's meaning. `Label` is the bare badge for non-status labels
|
|
13
|
+
("Staff", plan names); the three statuses color from the theme's
|
|
14
|
+
status tokens.
|
|
15
|
+
-}
|
|
16
|
+
type Kind
|
|
17
|
+
= Label
|
|
18
|
+
| Active
|
|
19
|
+
| Revoked
|
|
20
|
+
| Expired
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
kindClass : Kind -> Maybe String
|
|
24
|
+
kindClass kind =
|
|
25
|
+
case kind of
|
|
26
|
+
Label ->
|
|
27
|
+
Nothing
|
|
28
|
+
|
|
29
|
+
Active ->
|
|
30
|
+
Just "active"
|
|
31
|
+
|
|
32
|
+
Revoked ->
|
|
33
|
+
Just "revoked"
|
|
34
|
+
|
|
35
|
+
Expired ->
|
|
36
|
+
Just "expired"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
{-| Render a badge chip with the given text.
|
|
40
|
+
-}
|
|
41
|
+
view : Kind -> String -> Html msg
|
|
42
|
+
view kind label =
|
|
43
|
+
let
|
|
44
|
+
kindAttrs =
|
|
45
|
+
kindClass kind
|
|
46
|
+
|> Maybe.map (\cls -> [ ( cls, True ) ])
|
|
47
|
+
|> Maybe.withDefault []
|
|
48
|
+
in
|
|
49
|
+
span
|
|
50
|
+
[ Html.Attributes.classList (( "badge", True ) :: kindAttrs) ]
|
|
51
|
+
[ text label ]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
module Ui.Banner exposing (Kind(..), view)
|
|
2
|
+
|
|
3
|
+
{-| The banner: a loud, bordered notice block for page-level messages —
|
|
4
|
+
the danger zone, plan deprecation warnings, stale-snapshot notices.
|
|
5
|
+
Four near-identical copies across the dashboard collapse into this one
|
|
6
|
+
API.
|
|
7
|
+
-}
|
|
8
|
+
|
|
9
|
+
import Html exposing (Attribute, Html, button, div, p, text)
|
|
10
|
+
import Html.Attributes
|
|
11
|
+
import Html.Events
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
{-| The banner's tone. The default is neutral — a hairline frame with
|
|
15
|
+
no status to color it. `Success`, `Warning` and `Destructive` tint
|
|
16
|
+
it; `Destructive` is the danger zone.
|
|
17
|
+
-}
|
|
18
|
+
type Kind
|
|
19
|
+
= Neutral
|
|
20
|
+
| Success
|
|
21
|
+
| Warning
|
|
22
|
+
| Destructive
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
kindClass : Kind -> Maybe String
|
|
26
|
+
kindClass kind =
|
|
27
|
+
case kind of
|
|
28
|
+
Neutral ->
|
|
29
|
+
Nothing
|
|
30
|
+
|
|
31
|
+
Success ->
|
|
32
|
+
Just "success"
|
|
33
|
+
|
|
34
|
+
Warning ->
|
|
35
|
+
Just "warning"
|
|
36
|
+
|
|
37
|
+
Destructive ->
|
|
38
|
+
Just "destructive"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
{-| Render a banner. `action` rides under the copy (usually a danger
|
|
42
|
+
solid or primary button); `onDismiss` makes the banner dismissible
|
|
43
|
+
with a ghost button when present.
|
|
44
|
+
-}
|
|
45
|
+
view :
|
|
46
|
+
{ kind : Kind
|
|
47
|
+
, title : String
|
|
48
|
+
, body : String
|
|
49
|
+
, action : Maybe { label : String, onClick : msg }
|
|
50
|
+
, onDismiss : Maybe msg
|
|
51
|
+
, attributes : List (Attribute msg)
|
|
52
|
+
}
|
|
53
|
+
-> Html msg
|
|
54
|
+
view config =
|
|
55
|
+
let
|
|
56
|
+
actionHtml =
|
|
57
|
+
case config.action of
|
|
58
|
+
Just action ->
|
|
59
|
+
[ button
|
|
60
|
+
[ Html.Attributes.type_ "button"
|
|
61
|
+
, Html.Events.onClick action.onClick
|
|
62
|
+
]
|
|
63
|
+
[ text action.label ]
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
Nothing ->
|
|
67
|
+
[]
|
|
68
|
+
|
|
69
|
+
dismissHtml =
|
|
70
|
+
case config.onDismiss of
|
|
71
|
+
Just onDismiss ->
|
|
72
|
+
[ button
|
|
73
|
+
[ Html.Attributes.type_ "button"
|
|
74
|
+
, Html.Attributes.class "ghost"
|
|
75
|
+
, Html.Events.onClick onDismiss
|
|
76
|
+
]
|
|
77
|
+
[ text "Dismiss" ]
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
Nothing ->
|
|
81
|
+
[]
|
|
82
|
+
in
|
|
83
|
+
div
|
|
84
|
+
[ Html.Attributes.classList
|
|
85
|
+
(( "banner", True )
|
|
86
|
+
:: (kindClass config.kind
|
|
87
|
+
|> Maybe.map (\cls -> [ ( cls, True ) ])
|
|
88
|
+
|> Maybe.withDefault []
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
([ p [ Html.Attributes.class "title" ] [ text config.title ]
|
|
93
|
+
, p [] [ text config.body ]
|
|
94
|
+
]
|
|
95
|
+
++ actionHtml
|
|
96
|
+
++ dismissHtml
|
|
97
|
+
)
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
module Ui.Burger exposing (Model, Msg(..), init, subscriptions, update, view)
|
|
2
|
+
|
|
3
|
+
{-| The burger menu: the fixed corner toggle (four stacked bars in the
|
|
4
|
+
house zest-to-julep run), a dimming overlay, and a full-width drawer
|
|
5
|
+
that springs down from the top and scrolls its contents. The host owns
|
|
6
|
+
what's inside — nav lists, theme tabs, anything.
|
|
7
|
+
|
|
8
|
+
type Msg = BurgerMsg Ui.Burger.Msg
|
|
9
|
+
|
|
10
|
+
( burger, cmd ) =
|
|
11
|
+
Ui.Burger.update msg model.burger
|
|
12
|
+
|
|
13
|
+
Ui.Burger.view
|
|
14
|
+
{ label = "Ui\nMenu"
|
|
15
|
+
, logo = Just wordmark
|
|
16
|
+
, header = Just (themeTabs, sidebar)
|
|
17
|
+
, onToggle = BurgerMsg Ui.Burger.Toggled
|
|
18
|
+
, onClose = BurgerMsg Ui.Burger.Closed
|
|
19
|
+
, attributes = []
|
|
20
|
+
}
|
|
21
|
+
model.burger
|
|
22
|
+
|
|
23
|
+
-}
|
|
24
|
+
|
|
25
|
+
import Browser.Events
|
|
26
|
+
import Html exposing (Html, div, text)
|
|
27
|
+
import Html.Attributes
|
|
28
|
+
import Html.Events
|
|
29
|
+
import Spring
|
|
30
|
+
import Svg exposing (path, svg)
|
|
31
|
+
import Svg.Attributes as SvgAttr
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
-- MODEL
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
{-| The drawer's slide runs on a spring: `open` flips the target and
|
|
39
|
+
the frames carry the drawer between hidden and shown until it rests.
|
|
40
|
+
-}
|
|
41
|
+
type alias Model =
|
|
42
|
+
{ open : Bool
|
|
43
|
+
, spring : Spring.Spring
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
init : Model
|
|
48
|
+
init =
|
|
49
|
+
{ open = False
|
|
50
|
+
, spring = Spring.create { value = 0, target = 0 }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
-- CONFIG
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
drawerSpring : Spring.Config
|
|
59
|
+
drawerSpring =
|
|
60
|
+
Spring.config { tension = 210, friction = 20 }
|
|
61
|
+
|> Spring.setEquilibriumThreshold 0.001
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
-- MSG
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
type Msg
|
|
69
|
+
= Toggled
|
|
70
|
+
| Closed
|
|
71
|
+
| Frame Float
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
-- UPDATE
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
update : Msg -> Model -> ( Model, Cmd Msg )
|
|
79
|
+
update msg model =
|
|
80
|
+
case msg of
|
|
81
|
+
Toggled ->
|
|
82
|
+
( { model
|
|
83
|
+
| open = not model.open
|
|
84
|
+
, spring =
|
|
85
|
+
Spring.create
|
|
86
|
+
{ value = Spring.value model.spring
|
|
87
|
+
, target =
|
|
88
|
+
if model.open then
|
|
89
|
+
0
|
|
90
|
+
|
|
91
|
+
else
|
|
92
|
+
1
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
, Cmd.none
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
Closed ->
|
|
99
|
+
( { model
|
|
100
|
+
| open = False
|
|
101
|
+
, spring =
|
|
102
|
+
Spring.create { value = Spring.value model.spring, target = 0 }
|
|
103
|
+
}
|
|
104
|
+
, Cmd.none
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
Frame dt ->
|
|
108
|
+
( { model | spring = Spring.update drawerSpring dt model.spring }
|
|
109
|
+
, Cmd.none
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
{-| Frames only run while the drawer is in motion.
|
|
114
|
+
-}
|
|
115
|
+
subscriptions : Model -> Sub Msg
|
|
116
|
+
subscriptions model =
|
|
117
|
+
if Spring.equilibrium model.spring then
|
|
118
|
+
Sub.none
|
|
119
|
+
|
|
120
|
+
else
|
|
121
|
+
Browser.Events.onAnimationFrameDelta Frame
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
-- VIEW
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
{-| Render the whole assembly: the corner toggle, the overlay, and the
|
|
129
|
+
drawer. Everything lives inside one root so the host places a single
|
|
130
|
+
node; the pieces position themselves fixed.
|
|
131
|
+
|
|
132
|
+
The drawer carries the mobile menu: the brand block on the logo band,
|
|
133
|
+
then the header block, which is the whole body (the desktop sidebar and
|
|
134
|
+
any controls the host wants above it). The toggle and overlay/dismiss
|
|
135
|
+
clicks come back as `onToggle` and `onClose`; a navigation closes the
|
|
136
|
+
drawer through the host's own URL handling.
|
|
137
|
+
|
|
138
|
+
-}
|
|
139
|
+
view :
|
|
140
|
+
{ label : String
|
|
141
|
+
, logo : Maybe (Html msg)
|
|
142
|
+
, header : Maybe (Html msg)
|
|
143
|
+
, onToggle : msg
|
|
144
|
+
, onClose : msg
|
|
145
|
+
, attributes : List (Html.Attribute msg)
|
|
146
|
+
}
|
|
147
|
+
-> Model
|
|
148
|
+
-> Html msg
|
|
149
|
+
view config model =
|
|
150
|
+
let
|
|
151
|
+
progress =
|
|
152
|
+
Spring.value model.spring
|
|
153
|
+
|
|
154
|
+
shown =
|
|
155
|
+
progress > 0.5
|
|
156
|
+
|
|
157
|
+
atRest =
|
|
158
|
+
Spring.equilibrium model.spring
|
|
159
|
+
in
|
|
160
|
+
div
|
|
161
|
+
([ Html.Attributes.classList
|
|
162
|
+
[ ( "burger", True )
|
|
163
|
+
, ( "open", shown )
|
|
164
|
+
]
|
|
165
|
+
]
|
|
166
|
+
++ config.attributes
|
|
167
|
+
)
|
|
168
|
+
[ -- The corner toggle: four bars in the zest-to-julep run over
|
|
169
|
+
-- a salt label block. Fades out while the drawer is open.
|
|
170
|
+
div
|
|
171
|
+
[ Html.Attributes.class "burger-toggle"
|
|
172
|
+
, Html.Events.onClick config.onToggle
|
|
173
|
+
, Html.Attributes.attribute "aria-expanded"
|
|
174
|
+
(if model.open then
|
|
175
|
+
"true"
|
|
176
|
+
|
|
177
|
+
else
|
|
178
|
+
"false"
|
|
179
|
+
)
|
|
180
|
+
, Html.Attributes.attribute "aria-controls" "burger-drawer"
|
|
181
|
+
, Html.Attributes.attribute "aria-label" "Open menu"
|
|
182
|
+
]
|
|
183
|
+
[ div [ Html.Attributes.class "bars" ]
|
|
184
|
+
(List.repeat 4 (div [] []))
|
|
185
|
+
, div [ Html.Attributes.class "label" ]
|
|
186
|
+
[ text config.label ]
|
|
187
|
+
]
|
|
188
|
+
, div
|
|
189
|
+
[ Html.Attributes.class "burger-overlay"
|
|
190
|
+
, Html.Events.onClick config.onClose
|
|
191
|
+
]
|
|
192
|
+
[]
|
|
193
|
+
, Html.nav
|
|
194
|
+
([ Html.Attributes.id "burger-drawer"
|
|
195
|
+
, Html.Attributes.classList
|
|
196
|
+
[ ( "burger-drawer", True )
|
|
197
|
+
, ( "open", shown )
|
|
198
|
+
]
|
|
199
|
+
, Html.Attributes.attribute "aria-label" "Main navigation"
|
|
200
|
+
, Html.Attributes.attribute "aria-hidden"
|
|
201
|
+
(if shown then
|
|
202
|
+
"false"
|
|
203
|
+
|
|
204
|
+
else
|
|
205
|
+
"true"
|
|
206
|
+
)
|
|
207
|
+
]
|
|
208
|
+
++ (if atRest && progress == 0 then
|
|
209
|
+
[]
|
|
210
|
+
|
|
211
|
+
else
|
|
212
|
+
[ Html.Attributes.style "transform"
|
|
213
|
+
("translateY(calc(-100% + "
|
|
214
|
+
++ String.fromFloat (progress * 100)
|
|
215
|
+
++ "%))"
|
|
216
|
+
)
|
|
217
|
+
]
|
|
218
|
+
)
|
|
219
|
+
++ config.attributes
|
|
220
|
+
)
|
|
221
|
+
([ div [ Html.Attributes.class "burger-logo" ]
|
|
222
|
+
[ config.logo |> Maybe.withDefault (text "")
|
|
223
|
+
, Html.button
|
|
224
|
+
[ Html.Attributes.type_ "button"
|
|
225
|
+
, Html.Attributes.class "burger-close"
|
|
226
|
+
, Html.Events.onClick config.onClose
|
|
227
|
+
, Html.Attributes.attribute "aria-label" "Close menu"
|
|
228
|
+
, Html.Attributes.attribute "aria-controls" "burger-drawer"
|
|
229
|
+
]
|
|
230
|
+
[ closeIcon ]
|
|
231
|
+
]
|
|
232
|
+
]
|
|
233
|
+
++ [ div [ Html.Attributes.class "burger-content" ]
|
|
234
|
+
(case config.header of
|
|
235
|
+
Just header ->
|
|
236
|
+
[ div [ Html.Attributes.class "burger-header" ] [ header ] ]
|
|
237
|
+
|
|
238
|
+
Nothing ->
|
|
239
|
+
[]
|
|
240
|
+
)
|
|
241
|
+
]
|
|
242
|
+
)
|
|
243
|
+
]
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
closeIcon : Html msg
|
|
247
|
+
closeIcon =
|
|
248
|
+
svg
|
|
249
|
+
[ SvgAttr.viewBox "0 0 24 24"
|
|
250
|
+
, SvgAttr.class "burger-close-icon"
|
|
251
|
+
]
|
|
252
|
+
[ path
|
|
253
|
+
[ SvgAttr.d "M6 6 L18 18 M18 6 L6 18"
|
|
254
|
+
, SvgAttr.stroke "currentColor"
|
|
255
|
+
, SvgAttr.strokeWidth "2.5"
|
|
256
|
+
, SvgAttr.strokeLinecap "round"
|
|
257
|
+
]
|
|
258
|
+
[]
|
|
259
|
+
]
|