@charmland/gem 0.0.0-stage → 0.1.0
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 +13652 -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 +1275 -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 +964 -0
- package/src/browser/theme.d.ts +1 -0
- package/src/core/Gem/Node.elm +219 -0
- package/src/core/Gem/Page.elm +409 -0
- package/src/core/Gem/Render.elm +472 -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,31 @@
|
|
|
1
|
+
module Ui.Toolbar exposing (view)
|
|
2
|
+
|
|
3
|
+
{-| The page header: the pane's h1 heading with its action controls
|
|
4
|
+
riding the same row, right-aligned. Every dashboard section opens
|
|
5
|
+
with one.
|
|
6
|
+
-}
|
|
7
|
+
|
|
8
|
+
import Html exposing (Attribute, Html, div, h1, text)
|
|
9
|
+
import Html.Attributes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
{-| Render a toolbar. `actions` ride the heading's baseline on the
|
|
13
|
+
right (search boxes, create buttons, dropdowns).
|
|
14
|
+
-}
|
|
15
|
+
view :
|
|
16
|
+
{ title : String
|
|
17
|
+
, actions : List (Html msg)
|
|
18
|
+
, attributes : List (Attribute msg)
|
|
19
|
+
}
|
|
20
|
+
-> Html msg
|
|
21
|
+
view config =
|
|
22
|
+
div ([ Html.Attributes.class "toolbar" ] ++ config.attributes)
|
|
23
|
+
[ div [ Html.Attributes.class "toolbar-head" ]
|
|
24
|
+
[ h1 [] [ text config.title ]
|
|
25
|
+
, if List.isEmpty config.actions then
|
|
26
|
+
Html.text ""
|
|
27
|
+
|
|
28
|
+
else
|
|
29
|
+
div [ Html.Attributes.class "actions" ] config.actions
|
|
30
|
+
]
|
|
31
|
+
]
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
module Ui.TwoStepConfirm exposing
|
|
2
|
+
( Config
|
|
3
|
+
, Model
|
|
4
|
+
, Msg(..)
|
|
5
|
+
, disarm
|
|
6
|
+
, init
|
|
7
|
+
, subscriptions
|
|
8
|
+
, update
|
|
9
|
+
, view
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
{-| The two-step confirm button from the billing page: the first click
|
|
13
|
+
arms it (the label swaps and the fill turns julep), the second
|
|
14
|
+
confirms. A click or keypress anywhere else cancels.
|
|
15
|
+
|
|
16
|
+
Host wiring: keep a `Model` in your page state, map the component's
|
|
17
|
+
`Msg` wholesale, and batch `subscriptions` with your own. Map
|
|
18
|
+
`Confirmed` to your confirm action _and_ to `disarm` — the component
|
|
19
|
+
cannot reach into your model, so the host clears the armed state when
|
|
20
|
+
it acts.
|
|
21
|
+
|
|
22
|
+
Both labels stay in the layout so the wider one sets the width — the
|
|
23
|
+
button never resizes mid-interaction.
|
|
24
|
+
|
|
25
|
+
-}
|
|
26
|
+
|
|
27
|
+
import Browser.Events
|
|
28
|
+
import Html exposing (Attribute, Html, button, span, text)
|
|
29
|
+
import Html.Attributes as Attr
|
|
30
|
+
import Html.Events
|
|
31
|
+
import Json.Decode as Decode
|
|
32
|
+
import Ui.Dropdown
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
{-| The button's two labels. `onConfirm` is NOT called by the
|
|
36
|
+
component: the host maps `Confirmed` and acts there.
|
|
37
|
+
-}
|
|
38
|
+
type alias Config =
|
|
39
|
+
{ idle : String
|
|
40
|
+
, armed : String
|
|
41
|
+
, attributes : List (Attribute Msg)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
{-| Whether the button is waiting for its second click.
|
|
46
|
+
-}
|
|
47
|
+
type alias Model =
|
|
48
|
+
{ armed : Bool
|
|
49
|
+
, id : String
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
{-| Create the model for the widget with the given DOM id — ids must
|
|
54
|
+
be unique per page instance because the disarm listeners target them.
|
|
55
|
+
-}
|
|
56
|
+
init : String -> Model
|
|
57
|
+
init id =
|
|
58
|
+
{ armed = False
|
|
59
|
+
, id = id
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
{-| Internal messages; the host maps them wholesale.
|
|
64
|
+
-}
|
|
65
|
+
type Msg
|
|
66
|
+
= Clicked
|
|
67
|
+
| Confirmed
|
|
68
|
+
| Disarm
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
{-| Force the button back to idle (e.g. after the host's confirm
|
|
72
|
+
action fires).
|
|
73
|
+
-}
|
|
74
|
+
disarm : Model -> Model
|
|
75
|
+
disarm model =
|
|
76
|
+
{ model | armed = False }
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
{-| Advance the armed state.
|
|
80
|
+
-}
|
|
81
|
+
update : Msg -> Model -> ( Model, Cmd Msg )
|
|
82
|
+
update msg model =
|
|
83
|
+
case msg of
|
|
84
|
+
Clicked ->
|
|
85
|
+
( { model | armed = True }, Cmd.none )
|
|
86
|
+
|
|
87
|
+
Confirmed ->
|
|
88
|
+
( { model | armed = False }, Cmd.none )
|
|
89
|
+
|
|
90
|
+
Disarm ->
|
|
91
|
+
( { model | armed = False }, Cmd.none )
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
{-| Outside presses and stray keys disarm the button while armed.
|
|
95
|
+
Enter and Space on the button itself are excluded: they turn into the
|
|
96
|
+
confirming click.
|
|
97
|
+
-}
|
|
98
|
+
subscriptions : Model -> Sub Msg
|
|
99
|
+
subscriptions model =
|
|
100
|
+
if model.armed then
|
|
101
|
+
Sub.batch
|
|
102
|
+
[ Ui.Dropdown.subscriptions model.id True Disarm
|
|
103
|
+
, Browser.Events.onKeyDown (keyDecoder model.id)
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
else
|
|
107
|
+
Sub.none
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
{-| Enter and Space on the armed button turn into a click, which
|
|
111
|
+
confirms; every other key, anywhere, cancels.
|
|
112
|
+
-}
|
|
113
|
+
keyDecoder : String -> Decode.Decoder Msg
|
|
114
|
+
keyDecoder id =
|
|
115
|
+
Decode.map2 Tuple.pair
|
|
116
|
+
(Decode.field "key" Decode.string)
|
|
117
|
+
(Decode.oneOf [ Decode.at [ "target", "id" ] Decode.string, Decode.succeed "" ])
|
|
118
|
+
|> Decode.andThen
|
|
119
|
+
(\( key, targetId ) ->
|
|
120
|
+
if targetId == id && (key == "Enter" || key == " ") then
|
|
121
|
+
Decode.fail "button key confirms"
|
|
122
|
+
|
|
123
|
+
else
|
|
124
|
+
Decode.succeed Disarm
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
ariaHidden : Bool -> String
|
|
129
|
+
ariaHidden hidden =
|
|
130
|
+
if hidden then
|
|
131
|
+
"true"
|
|
132
|
+
|
|
133
|
+
else
|
|
134
|
+
"false"
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
{-| Render the armed/idle button.
|
|
138
|
+
-}
|
|
139
|
+
view : Config -> Model -> Html Msg
|
|
140
|
+
view config model =
|
|
141
|
+
button
|
|
142
|
+
([ Attr.classList [ ( "primary", True ), ( "purchase", True ), ( "armed", model.armed ) ]
|
|
143
|
+
, Attr.type_ "button"
|
|
144
|
+
, Attr.id model.id
|
|
145
|
+
, Html.Events.onClick
|
|
146
|
+
(if model.armed then
|
|
147
|
+
Confirmed
|
|
148
|
+
|
|
149
|
+
else
|
|
150
|
+
Clicked
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
++ config.attributes
|
|
154
|
+
)
|
|
155
|
+
[ span [ Attr.class "labels" ]
|
|
156
|
+
[ span [ Attr.attribute "aria-hidden" (ariaHidden model.armed) ] [ text config.idle ]
|
|
157
|
+
, span [ Attr.attribute "aria-hidden" (ariaHidden (not model.armed)) ] [ text config.armed ]
|
|
158
|
+
]
|
|
159
|
+
]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Ui.Typography exposing (hint, muted, sectionLabel)
|
|
2
|
+
|
|
3
|
+
{-| Typography helpers: the small copy treatments every page leans on.
|
|
4
|
+
They are Html wrappers around the house classes so call sites never
|
|
5
|
+
write the class names themselves.
|
|
6
|
+
-}
|
|
7
|
+
|
|
8
|
+
import Html exposing (Html, p)
|
|
9
|
+
import Html.Attributes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
{-| A quiet helper paragraph, muted to one step below body copy. Used
|
|
13
|
+
beside toolbars and tables, and as the explainer under a heading.
|
|
14
|
+
-}
|
|
15
|
+
muted : List (Html msg) -> Html msg
|
|
16
|
+
muted =
|
|
17
|
+
p [ Html.Attributes.class "muted" ]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
{-| A section heading: the small, bold label above a group of controls
|
|
21
|
+
("Inline form", "Danger zone").
|
|
22
|
+
-}
|
|
23
|
+
sectionLabel : List (Html msg) -> Html msg
|
|
24
|
+
sectionLabel =
|
|
25
|
+
Html.h3 [ Html.Attributes.class "section-label" ]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
{-| Helper copy under a field: conversion math, format notes, the
|
|
29
|
+
"what happens if you do this" line.
|
|
30
|
+
-}
|
|
31
|
+
hint : List (Html msg) -> Html msg
|
|
32
|
+
hint =
|
|
33
|
+
p [ Html.Attributes.class "hint" ]
|