@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,120 @@
|
|
|
1
|
+
module Ui.ToC exposing (Item(..), view)
|
|
2
|
+
|
|
3
|
+
{-| The table of contents: a quiet anchor rail with a flat hairline,
|
|
4
|
+
the blush edge marking the section in view. Nested entries indent
|
|
5
|
+
under their parent — same rail, no curves.
|
|
6
|
+
-}
|
|
7
|
+
|
|
8
|
+
import Html exposing (Attribute, Html, nav, span, text)
|
|
9
|
+
import Html.Attributes
|
|
10
|
+
import Html.Events
|
|
11
|
+
import Ui.Icon
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
{-| One entry: the label shown, the anchor it links to, and any
|
|
15
|
+
nested sub-entries. A custom type because the nesting is recursive
|
|
16
|
+
(type aliases can't recurse).
|
|
17
|
+
-}
|
|
18
|
+
type Item
|
|
19
|
+
= Item
|
|
20
|
+
{ label : String
|
|
21
|
+
, href : String
|
|
22
|
+
, children : List Item
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
itemsView : Maybe String -> List Item -> Html msg
|
|
27
|
+
itemsView active items =
|
|
28
|
+
Html.ul []
|
|
29
|
+
(List.map
|
|
30
|
+
(\(Item item) ->
|
|
31
|
+
Html.li
|
|
32
|
+
[ Html.Attributes.classList
|
|
33
|
+
[ ( "active", active == Just item.href ) ]
|
|
34
|
+
]
|
|
35
|
+
([ Html.a [ Html.Attributes.href item.href ] [ text item.label ] ]
|
|
36
|
+
++ (if List.isEmpty item.children then
|
|
37
|
+
[]
|
|
38
|
+
|
|
39
|
+
else
|
|
40
|
+
[ itemsView active item.children ]
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
items
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
{-| Render the table of contents. `active` is the href of the
|
|
49
|
+
current section (or nothing).
|
|
50
|
+
|
|
51
|
+
`disclosure` folds the list behind its title: a `Just` turns the
|
|
52
|
+
title into a toggle button (chevron and all) and the list only shows
|
|
53
|
+
while `open` — the mobile pattern. `Nothing` renders the quiet
|
|
54
|
+
title-over-list the desktop rail uses. Both shapes render the same
|
|
55
|
+
dom, so one call serves both; the responsive split is CSS's job.
|
|
56
|
+
|
|
57
|
+
-}
|
|
58
|
+
view :
|
|
59
|
+
{ title : String
|
|
60
|
+
, items : List Item
|
|
61
|
+
, active : Maybe String
|
|
62
|
+
, disclosure : Maybe { open : Bool, onToggle : msg }
|
|
63
|
+
, attributes : List (Attribute msg)
|
|
64
|
+
}
|
|
65
|
+
-> Html msg
|
|
66
|
+
view config =
|
|
67
|
+
nav
|
|
68
|
+
([ Html.Attributes.class "toc"
|
|
69
|
+
, Html.Attributes.classList
|
|
70
|
+
[ ( "collapsible"
|
|
71
|
+
, case config.disclosure of
|
|
72
|
+
Just _ ->
|
|
73
|
+
True
|
|
74
|
+
|
|
75
|
+
Nothing ->
|
|
76
|
+
False
|
|
77
|
+
)
|
|
78
|
+
, ( "open"
|
|
79
|
+
, case config.disclosure of
|
|
80
|
+
Just d ->
|
|
81
|
+
d.open
|
|
82
|
+
|
|
83
|
+
Nothing ->
|
|
84
|
+
True
|
|
85
|
+
)
|
|
86
|
+
]
|
|
87
|
+
, Html.Attributes.attribute "aria-label" config.title
|
|
88
|
+
]
|
|
89
|
+
++ config.attributes
|
|
90
|
+
)
|
|
91
|
+
(titleView config.disclosure config.title
|
|
92
|
+
:: [ itemsView config.active config.items ]
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
{-| The title: a plain heading, or a toggle button when the ToC is
|
|
97
|
+
collapsible (the chevron folds with the open state).
|
|
98
|
+
-}
|
|
99
|
+
titleView : Maybe { open : Bool, onToggle : msg } -> String -> Html msg
|
|
100
|
+
titleView disclosure title =
|
|
101
|
+
case disclosure of
|
|
102
|
+
Just d ->
|
|
103
|
+
Html.button
|
|
104
|
+
[ Html.Attributes.class "toc-title toc-toggle"
|
|
105
|
+
, Html.Attributes.attribute "aria-expanded"
|
|
106
|
+
(if d.open then
|
|
107
|
+
"true"
|
|
108
|
+
|
|
109
|
+
else
|
|
110
|
+
"false"
|
|
111
|
+
)
|
|
112
|
+
, Html.Events.onClick d.onToggle
|
|
113
|
+
]
|
|
114
|
+
[ span [ Html.Attributes.class "label" ] [ text title ]
|
|
115
|
+
, span [ Html.Attributes.class "chevron" ]
|
|
116
|
+
[ Ui.Icon.view Ui.Icon.Chevron ]
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
Nothing ->
|
|
120
|
+
Html.p [ Html.Attributes.class "toc-title" ] [ text title ]
|