@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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
module Gem.Node exposing
|
|
2
|
+
( Block(..)
|
|
3
|
+
, Inline(..)
|
|
4
|
+
, Props
|
|
5
|
+
, Token
|
|
6
|
+
, block
|
|
7
|
+
, blocks
|
|
8
|
+
, inline
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
{-| The page node tree.
|
|
12
|
+
|
|
13
|
+
This is the other half of the framework's contract: the compiler writes these
|
|
14
|
+
shapes as JSON, this module decodes them. Nothing here is HTML, which is the
|
|
15
|
+
whole point — Elm cannot inject HTML, so code highlighting, embeds and
|
|
16
|
+
components all have to arrive as structure.
|
|
17
|
+
|
|
18
|
+
Component nodes (`comp`) carry a tag, a flat set of string props and already
|
|
19
|
+
parsed children, so a theme can render them without knowing what they mean.
|
|
20
|
+
|
|
21
|
+
@docs Block, Inline, Props, Token, block, blocks, inline
|
|
22
|
+
|
|
23
|
+
-}
|
|
24
|
+
|
|
25
|
+
import Dict exposing (Dict)
|
|
26
|
+
import Json.Decode as D
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
{-| Attribute values from a component tag. Flat strings on purpose: the tag
|
|
30
|
+
marks up prose, not application state.
|
|
31
|
+
-}
|
|
32
|
+
type alias Props =
|
|
33
|
+
Dict String String
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
{-| One syntax-highlighted run of text. `color` is a CSS color or a
|
|
37
|
+
`var(--shiki-token-*)` reference, so a single compile serves every theme.
|
|
38
|
+
-}
|
|
39
|
+
type alias Token =
|
|
40
|
+
{ text : String
|
|
41
|
+
, color : Maybe String
|
|
42
|
+
, italic : Bool
|
|
43
|
+
, bold : Bool
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
{-| A block-level node.
|
|
48
|
+
-}
|
|
49
|
+
type Block
|
|
50
|
+
= Heading Int String (List Inline)
|
|
51
|
+
| Paragraph (List Inline)
|
|
52
|
+
| CodeBlock { lang : Maybe String, title : Maybe String, lines : List (List Token) }
|
|
53
|
+
| ListBlock { ordered : Bool, start : Int, items : List (List Block) }
|
|
54
|
+
| Quote (List Block)
|
|
55
|
+
| Table { head : List (List Inline), rows : List (List (List Inline)) }
|
|
56
|
+
| Rule
|
|
57
|
+
| Raw String
|
|
58
|
+
| BlockComponent String Props (List Block)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
{-| An inline node.
|
|
62
|
+
-}
|
|
63
|
+
type Inline
|
|
64
|
+
= Text String
|
|
65
|
+
| InlineCode String
|
|
66
|
+
| Strong (List Inline)
|
|
67
|
+
| Em (List Inline)
|
|
68
|
+
| Del (List Inline)
|
|
69
|
+
| Link { href : String, title : Maybe String, external : Bool } (List Inline)
|
|
70
|
+
| Image { src : String, alt : String, title : Maybe String }
|
|
71
|
+
| LineBreak
|
|
72
|
+
| InlineComponent String Props (List Inline)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
{-| Decode a list of block nodes.
|
|
76
|
+
-}
|
|
77
|
+
blocks : D.Decoder (List Block)
|
|
78
|
+
blocks =
|
|
79
|
+
D.list block
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
{-| Decode one block node.
|
|
83
|
+
-}
|
|
84
|
+
block : D.Decoder Block
|
|
85
|
+
block =
|
|
86
|
+
D.field "t" D.string
|
|
87
|
+
|> D.andThen
|
|
88
|
+
(\kind ->
|
|
89
|
+
case kind of
|
|
90
|
+
"heading" ->
|
|
91
|
+
D.map3 Heading
|
|
92
|
+
(D.field "depth" D.int)
|
|
93
|
+
(D.field "id" D.string)
|
|
94
|
+
(D.field "nodes" (D.list inline))
|
|
95
|
+
|
|
96
|
+
"paragraph" ->
|
|
97
|
+
D.map Paragraph (D.field "nodes" (D.list inline))
|
|
98
|
+
|
|
99
|
+
"code" ->
|
|
100
|
+
D.map3
|
|
101
|
+
(\lang title lines ->
|
|
102
|
+
CodeBlock { lang = lang, title = title, lines = lines }
|
|
103
|
+
)
|
|
104
|
+
(D.maybe (D.field "lang" D.string))
|
|
105
|
+
(D.maybe (D.field "title" D.string))
|
|
106
|
+
(D.field "lines" (D.list (D.list token)))
|
|
107
|
+
|
|
108
|
+
"list" ->
|
|
109
|
+
D.map3
|
|
110
|
+
(\ordered start items ->
|
|
111
|
+
ListBlock { ordered = ordered, start = start, items = items }
|
|
112
|
+
)
|
|
113
|
+
(D.field "ordered" D.bool)
|
|
114
|
+
(D.oneOf [ D.field "start" D.int, D.succeed 1 ])
|
|
115
|
+
(D.field "items" (D.list (D.list block)))
|
|
116
|
+
|
|
117
|
+
"quote" ->
|
|
118
|
+
D.map Quote (D.field "nodes" (D.list block))
|
|
119
|
+
|
|
120
|
+
"table" ->
|
|
121
|
+
D.map2
|
|
122
|
+
(\head rows -> Table { head = head, rows = rows })
|
|
123
|
+
(D.field "head" (D.list (D.list inline)))
|
|
124
|
+
(D.field "rows" (D.list (D.list (D.list inline))))
|
|
125
|
+
|
|
126
|
+
"hr" ->
|
|
127
|
+
D.succeed Rule
|
|
128
|
+
|
|
129
|
+
"raw" ->
|
|
130
|
+
D.map Raw (D.field "text" D.string)
|
|
131
|
+
|
|
132
|
+
"comp" ->
|
|
133
|
+
D.map3 BlockComponent
|
|
134
|
+
(D.field "tag" D.string)
|
|
135
|
+
(D.field "props" props)
|
|
136
|
+
(D.field "nodes" (D.list block))
|
|
137
|
+
|
|
138
|
+
_ ->
|
|
139
|
+
D.succeed (Raw "")
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
{-| Decode one inline node.
|
|
144
|
+
-}
|
|
145
|
+
inline : D.Decoder Inline
|
|
146
|
+
inline =
|
|
147
|
+
D.field "t" D.string
|
|
148
|
+
|> D.andThen
|
|
149
|
+
(\kind ->
|
|
150
|
+
case kind of
|
|
151
|
+
"text" ->
|
|
152
|
+
D.map Text (D.field "text" D.string)
|
|
153
|
+
|
|
154
|
+
"code" ->
|
|
155
|
+
D.map InlineCode (D.field "text" D.string)
|
|
156
|
+
|
|
157
|
+
"strong" ->
|
|
158
|
+
D.map Strong (D.field "nodes" (D.list inline))
|
|
159
|
+
|
|
160
|
+
"em" ->
|
|
161
|
+
D.map Em (D.field "nodes" (D.list inline))
|
|
162
|
+
|
|
163
|
+
"del" ->
|
|
164
|
+
D.map Del (D.field "nodes" (D.list inline))
|
|
165
|
+
|
|
166
|
+
"link" ->
|
|
167
|
+
D.map3
|
|
168
|
+
(\href title nodes ->
|
|
169
|
+
Link
|
|
170
|
+
{ href = href
|
|
171
|
+
, title = title
|
|
172
|
+
, external = isExternal href
|
|
173
|
+
}
|
|
174
|
+
nodes
|
|
175
|
+
)
|
|
176
|
+
(D.field "href" D.string)
|
|
177
|
+
(D.maybe (D.field "title" D.string))
|
|
178
|
+
(D.field "nodes" (D.list inline))
|
|
179
|
+
|
|
180
|
+
"img" ->
|
|
181
|
+
D.map3
|
|
182
|
+
(\src alt title -> Image { src = src, alt = alt, title = title })
|
|
183
|
+
(D.field "src" D.string)
|
|
184
|
+
(D.field "alt" D.string)
|
|
185
|
+
(D.maybe (D.field "title" D.string))
|
|
186
|
+
|
|
187
|
+
"br" ->
|
|
188
|
+
D.succeed LineBreak
|
|
189
|
+
|
|
190
|
+
"comp" ->
|
|
191
|
+
D.map3 InlineComponent
|
|
192
|
+
(D.field "tag" D.string)
|
|
193
|
+
(D.field "props" props)
|
|
194
|
+
(D.field "nodes" (D.list inline))
|
|
195
|
+
|
|
196
|
+
_ ->
|
|
197
|
+
D.succeed (Text "")
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
props : D.Decoder Props
|
|
202
|
+
props =
|
|
203
|
+
D.dict D.string
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
token : D.Decoder Token
|
|
207
|
+
token =
|
|
208
|
+
D.map4 Token
|
|
209
|
+
(D.field "text" D.string)
|
|
210
|
+
(D.maybe (D.field "color" D.string))
|
|
211
|
+
(D.oneOf [ D.field "italic" D.bool, D.succeed False ])
|
|
212
|
+
(D.oneOf [ D.field "bold" D.bool, D.succeed False ])
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
isExternal : String -> Bool
|
|
216
|
+
isExternal href =
|
|
217
|
+
String.startsWith "http://" href
|
|
218
|
+
|| String.startsWith "https://" href
|
|
219
|
+
|| String.startsWith "mailto:" href
|