@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.
Files changed (121) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +13 -0
  3. package/README.md +24 -2
  4. package/assets/fonts/Hypography-Italic.woff2 +0 -0
  5. package/assets/fonts/Hypography-Regular.woff2 +0 -0
  6. package/assets/fonts/PPFraktionMono-Variable.ttf +0 -0
  7. package/assets/fonts/PPFraktionMonoItalic-Variable.ttf +0 -0
  8. package/assets/fonts/PPFraktionSans-Variable.ttf +0 -0
  9. package/assets/fonts/PPFraktionSansItalic-Variable.ttf +0 -0
  10. package/bin/gem-elm.js +3 -0
  11. package/dist/browser/boot.d.ts +10 -0
  12. package/dist/browser/boot.js +14 -0
  13. package/dist/browser/color-scheme.d.ts +9 -0
  14. package/dist/browser/color-scheme.js +76 -0
  15. package/dist/browser/ports.d.ts +37 -0
  16. package/dist/browser/ports.js +90 -0
  17. package/dist/browser/router.d.ts +5 -0
  18. package/dist/browser/router.js +35 -0
  19. package/dist/browser/runtime.d.ts +12 -0
  20. package/dist/browser/runtime.js +22 -0
  21. package/dist/browser/tabs.d.ts +9 -0
  22. package/dist/browser/tabs.js +69 -0
  23. package/dist/default/theme.css +4664 -0
  24. package/dist/default/theme.js +13652 -0
  25. package/dist/node/build.d.ts +16 -0
  26. package/dist/node/build.js +48 -0
  27. package/dist/node/cli.d.ts +2 -0
  28. package/dist/node/cli.js +21 -0
  29. package/elm.json +28 -0
  30. package/package.json +86 -4
  31. package/src/app/Gem/App.elm +1275 -0
  32. package/src/app/Gem/CharmSticker.elm +35 -0
  33. package/src/app/Gem/Components.elm +292 -0
  34. package/src/app/Gem/Main.elm +17 -0
  35. package/src/app/Gem/Ports.elm +32 -0
  36. package/src/app/Gem/Shell.elm +964 -0
  37. package/src/browser/theme.d.ts +1 -0
  38. package/src/core/Gem/Node.elm +219 -0
  39. package/src/core/Gem/Page.elm +409 -0
  40. package/src/core/Gem/Render.elm +472 -0
  41. package/src/core/Gem/Slots.elm +11 -0
  42. package/src/styles/docs.scss +1083 -0
  43. package/src/styles/fonts.scss +51 -0
  44. package/src/styles/gem.scss +362 -0
  45. package/src/styles/theme.scss +8 -0
  46. package/src/styles/ui/burger.scss +272 -0
  47. package/src/styles/ui/button.scss +350 -0
  48. package/src/styles/ui/charmtone.scss +70 -0
  49. package/src/styles/ui/controls-extra.scss +316 -0
  50. package/src/styles/ui/controls.scss +110 -0
  51. package/src/styles/ui/display.scss +359 -0
  52. package/src/styles/ui/dropdown.scss +341 -0
  53. package/src/styles/ui/form.scss +314 -0
  54. package/src/styles/ui/menu.scss +200 -0
  55. package/src/styles/ui/meter.scss +124 -0
  56. package/src/styles/ui/modal.scss +545 -0
  57. package/src/styles/ui/oauth.scss +50 -0
  58. package/src/styles/ui/page-nav.scss +63 -0
  59. package/src/styles/ui/reset.scss +111 -0
  60. package/src/styles/ui/scrollbar.scss +39 -0
  61. package/src/styles/ui/search.scss +164 -0
  62. package/src/styles/ui/sidebar.scss +229 -0
  63. package/src/styles/ui/squircle.scss +60 -0
  64. package/src/styles/ui/table.scss +97 -0
  65. package/src/styles/ui/theme.scss +132 -0
  66. package/src/styles/ui/toast.scss +587 -0
  67. package/src/styles/ui/toc.scss +128 -0
  68. package/src/styles/ui/typography.scss +21 -0
  69. package/src/styles/ui/ui.scss +33 -0
  70. package/src/ui/Ui/Badge.elm +51 -0
  71. package/src/ui/Ui/Banner.elm +97 -0
  72. package/src/ui/Ui/Burger.elm +259 -0
  73. package/src/ui/Ui/Button.elm +261 -0
  74. package/src/ui/Ui/Card.elm +32 -0
  75. package/src/ui/Ui/Cards.elm +15 -0
  76. package/src/ui/Ui/ChoiceGroup.elm +62 -0
  77. package/src/ui/Ui/CopyButton.elm +139 -0
  78. package/src/ui/Ui/Divider.elm +16 -0
  79. package/src/ui/Ui/Dropdown.elm +600 -0
  80. package/src/ui/Ui/Empty.elm +41 -0
  81. package/src/ui/Ui/ErrorBubble.elm +34 -0
  82. package/src/ui/Ui/Field.elm +45 -0
  83. package/src/ui/Ui/FormStatus.elm +32 -0
  84. package/src/ui/Ui/Icon.elm +381 -0
  85. package/src/ui/Ui/InlineForm.elm +51 -0
  86. package/src/ui/Ui/Input.elm +113 -0
  87. package/src/ui/Ui/KeyValue.elm +25 -0
  88. package/src/ui/Ui/ListRow.elm +67 -0
  89. package/src/ui/Ui/Loader.elm +32 -0
  90. package/src/ui/Ui/Logo/Charm.elm +21 -0
  91. package/src/ui/Ui/Logo/CharmMark.elm +32 -0
  92. package/src/ui/Ui/Logo/CharmSticker.elm +35 -0
  93. package/src/ui/Ui/Logo/Discord.elm +26 -0
  94. package/src/ui/Ui/Logo/GitHub.elm +21 -0
  95. package/src/ui/Ui/Logo/Google.elm +21 -0
  96. package/src/ui/Ui/Logo/Hexy.elm +29 -0
  97. package/src/ui/Ui/Logo/Hyper.elm +42 -0
  98. package/src/ui/Ui/Logo/Integration.elm +117 -0
  99. package/src/ui/Ui/Logo/Prism.elm +35 -0
  100. package/src/ui/Ui/Logos.elm +115 -0
  101. package/src/ui/Ui/Menu.elm +348 -0
  102. package/src/ui/Ui/Meter.elm +132 -0
  103. package/src/ui/Ui/Modal.elm +247 -0
  104. package/src/ui/Ui/Motion.elm +32 -0
  105. package/src/ui/Ui/NumberBox.elm +86 -0
  106. package/src/ui/Ui/OAuthButton.elm +39 -0
  107. package/src/ui/Ui/PageNav.elm +65 -0
  108. package/src/ui/Ui/Pager.elm +49 -0
  109. package/src/ui/Ui/Search.elm +396 -0
  110. package/src/ui/Ui/SearchBox.elm +78 -0
  111. package/src/ui/Ui/Section.elm +21 -0
  112. package/src/ui/Ui/Sidebar.elm +239 -0
  113. package/src/ui/Ui/Stat.elm +29 -0
  114. package/src/ui/Ui/Switch.elm +34 -0
  115. package/src/ui/Ui/Table.elm +89 -0
  116. package/src/ui/Ui/Tabs.elm +280 -0
  117. package/src/ui/Ui/ToC.elm +120 -0
  118. package/src/ui/Ui/Toast.elm +1145 -0
  119. package/src/ui/Ui/Toolbar.elm +31 -0
  120. package/src/ui/Ui/TwoStepConfirm.elm +159 -0
  121. package/src/ui/Ui/Typography.elm +33 -0
@@ -0,0 +1,35 @@
1
+ module Gem.CharmSticker exposing (view)
2
+
3
+ import Html exposing (Html)
4
+ import Svg exposing (g, path, svg)
5
+ import Svg.Attributes exposing (class, d, fill, viewBox)
6
+
7
+
8
+ {-| The Charm sticker: the wordmark and mascot printed on a purple
9
+ rounded blob. Unlike the plain wordmark it carries its own brand
10
+ colors, so it ignores the surrounding text color. Source SVG backed up
11
+ in `src/img/charm-sticker.svg`.
12
+ -}
13
+ view : Html msg
14
+ view =
15
+ svg
16
+ [ class "charm-sticker"
17
+ , viewBox "0 0 215.92 122.78"
18
+ ]
19
+ [ path
20
+ [ fill "#6B50FF"
21
+ , d "M211.9 28.75c-3.05-2.97-7.33-4.28-11.47-5.55-.79-.24-1.98-.61-2.35-.76-3.07-1.25-3.85-2.39-6.63-7.02-.69-1.15-1.47-2.46-2.37-3.84l-.29-.46C186.48 7.51 181.68 0 172.95 0c-.79 0-1.58.07-2.35.2-5.76.99-9.45 5.45-12.58 10.12-1 1.5-1.87 2.91-2.63 4.15-1.25 2.04-2.53 4.38-4.54 5.82-3.02 2.16-8.07 4.2-18.27 4.2l-87.34-.03c-15.36 0-28.2 7.09-36.15 19.98C3.06 54.2 0 67.24 0 83.19c0 23.65 16.39 39.54 40.81 39.55l120.72.04c11.9 0 23.32-4.61 31.33-13.51 8.6-9.55 11.72-22.02 13.09-34.5.33-3 .29-5.86.26-8.38-.04-3.01-.07-5.61.48-7.65.53-1.94 1.8-3.9 3.42-6.39.69-1.07 1.41-2.17 2.14-3.38l.22-.36c.8-1.31 2.01-3.29 2.77-5.77 1.6-5.23.35-10.49-3.34-14.08Z"
22
+ ]
23
+ []
24
+ , g
25
+ [ fill "#FFFAF1" ]
26
+ [ path
27
+ [ d "M187.84 85.37c-1.03 3.36-2.33 6.35-3.93 8.94-4.96 8.04-12.7 12.29-22.37 12.28l-120.72-.04c-15.66 0-24.64-8.52-24.64-23.36 0-12.91 2.25-23.09 6.68-30.26 4.97-8.05 12.7-12.3 22.38-12.3l86.58.03c-.55-1.85-.56-3.69-.13-5.39l-86.46-.03c-11.64 0-20.96 5.13-26.96 14.85-4.96 8.03-7.47 19.17-7.48 33.09 0 17.73 11.5 28.74 30.02 28.75l120.72.04c11.64 0 20.96-5.13 26.96-14.84 2.03-3.3 3.64-7.14 4.84-11.46-.68.11-1.33.16-1.91.16-1.09 0-2.27-.16-3.58-.47Z"
28
+ ]
29
+ []
30
+ , path
31
+ [ d "M204.36 36.48c-1.73-1.68-7.81-3.01-10.35-4.04-8-3.25-9.67-8.3-14-15.01-1.53-2.36-4.33-7.16-7.6-6.6-1.96.34-4.36 3.89-5.43 5.48-4.6 6.88-6.26 12.2-14.81 15.19-3.33 1.16-10.24 2.1-12.77 3.96-2.65 1.95-.17 5.12 1.2 7.11 3.16 4.59 7.07 8.6 8.65 14.16 1.62 5.7.55 11.24.73 16.99.15 4.89.65 8.41 6.54 6.66 6.43-1.91 12.48-7.16 19.54-6.21 4.17.56 7.86 2.85 11.79 4.08 5.06 1.59 6.78.66 7.37-4.67.65-5.89-.52-11.86 1.05-17.68 1.3-4.79 4.24-8.37 6.71-12.5 1.1-1.84 3.31-5.04 1.38-6.93ZM170.5 48.99c-2.16.15-2.42-3.4-.32-3.69 2.25-.31 2.59 3.53.32 3.69m5.5-3.93c-.21 1.19-1.79 1.38-2.2.15-.24-.73-.22-4.3-.1-5.17.09-.59.37-1.24 1.05-1.31.72-.07 1.22.62 1.28 1.27.1 1.04.14 4.1-.04 5.06Zm4 3.56h4.22c.06 3.26-4.35 3.28-4.22 0m10.28-3.78c-.22 1.61-2.01 1.52-2.21.25-.15-.92-.12-4.11 0-5.08.03-.23.14-.6.29-.76.75-.82 1.79-.13 1.93.9.13.93.12 3.76 0 4.69Zm2.73 3.98c-1.62-.39-1.49-3.43.34-3.5 2.29-.08 2.07 4.08-.34 3.5M38.45 84.35c1.63 0 3.15-.68 4.33-1.64.73-.59 1.47-.43 1.63.27.06.26.07.53.07.81 0 3.09-2.46 6.78-8.68 6.77-5.06 0-8.53-2.25-7.93-9.07l.61-6.92c.37-4.34 2-8.04 5.15-10.09 1.67-1.07 3.8-1.68 6.4-1.68 4.08 0 5.38 1.64 5.38 3.41 0 1.1-.52 2.26-1.33 2.92-.08.06-.21.11-.36.08-.71-.13-1.39-.2-2.07-.2-1.48 0-2.83.33-3.8 1.21-.83.75-1.39 1.91-1.53 3.55l-.65 7.1c-.19 2.01.42 3.46 2.78 3.46ZM63.1 62.8c-1.58 0-2.97.42-4.22 1.26-.65.47-1.46 1.3-1.9 1.82-.29.34-.57.05-.54-.15s1.1-11.48 1.1-11.48c.09-.94-.65-1.64-1.95-1.64-1.39 0-2.97.42-4.45 1.31-1.02.61-1.49 1.87-1.63 3.32l-2.7 31.03c-.14 1.49.28 2.29 1.72 2.29s3.01-.28 4.4-1.21c.98-.66 1.67-1.64 1.81-3.23l1.21-13.93c.09-.84.42-1.35 1.21-1.82.37-.23 1.16-.37 1.67-.37.79 0 1.07.47.98 1.4l-1.49 17.38c-.09.98.46 1.77 1.9 1.78s2.87-.42 4.45-1.4c1.02-.61 1.49-1.73 1.62-3.18l1.49-17.29c.37-4.11-1.3-5.89-4.68-5.89m46.87 2.92c0-1.68-.84-2.9-2.88-2.9-2.41 0-3.88 1.76-4.65 3.49-.04.1-.14.35-.39.29s-.21-.34-.21-.34l.16-1.81c.09-.94-.46-1.63-1.76-1.64-1.39 0-2.87.42-4.36 1.31-1.02.61-1.48 1.87-1.62 3.32l-1.81 20.84c-.14 1.5.28 2.29 1.72 2.29 1.39 0 3.01-.28 4.4-1.21.98-.66 1.67-1.64 1.81-3.23l.98-11.92c.23-2.57 2.23-4.02 4.68-4.11.64-.04 1.32 0 2 .17.4.1.66-.24.77-.44.75-1.44 1.18-2.88 1.18-4.12Zm30.98 20.29 1.49-17.29c.38-4.11-1.2-5.89-4.59-5.89-1.76 0-3.29.47-4.64 1.5-.55.42-1.39 1.19-1.62 1.48-.11.14-.43.22-.53-.11-.46-1.51-1.46-2.87-4.47-2.87-1.81 0-3.39.51-4.78 1.64-.51.37-1.22 1.13-1.43 1.43-.18.26-.53.12-.5-.16.04-.32.12-1.27.12-1.27.09-.94-.46-1.64-1.76-1.64-1.39 0-2.87.42-4.36 1.31-1.02.61-1.49 1.87-1.62 3.32l-1.82 20.84c-.14 1.49.28 2.29 1.72 2.29s3.01-.28 4.4-1.22c.98-.66 1.67-1.63 1.81-3.23l1.26-14.67c.09-.84.42-1.35 1.21-1.82.37-.23 1.07-.37 1.58-.37.79 0 .93.47.83 1.4l-1.54 18.13c-.09.98.46 1.78 1.9 1.78s2.88-.42 4.45-1.4c1.02-.61 1.48-1.73 1.62-3.18l1.26-14.49c.05-.75.47-1.4 1.21-1.87.37-.23 1.02-.37 1.53-.37.79 0 .93.47.84 1.4l-1.54 18.13c-.09.98.46 1.78 1.9 1.78 1.39 0 2.88-.42 4.45-1.4 1.02-.61 1.48-1.73 1.62-3.18m20.81 5.05c0-1.22-.74-1.78-1.95-1.78h-15.53c-1.58 0-2.32 1.35-2.32 3.59 0 1.22.74 1.78 1.9 1.78h15.58c1.58 0 2.32-1.35 2.32-3.59M90.74 65.81 89.02 86c-.14 1.45-.56 2.52-1.62 3.18-1.58.98-3.02 1.4-4.27 1.4s-1.85-.7-1.76-1.64c0 0 .09-1.33.15-1.71s-.38-.47-.56-.13c-.17.34-.56 1-.94 1.37-1.11 1.17-2.5 2.1-4.82 2.1-4.31 0-5.65-3.79-5.33-7.71l.7-8.08c.42-4.86 2.04-7.52 4.64-9.3 2.32-1.59 5.29-2.66 8.77-2.66 1.86 0 3.53.19 4.54.47 1.9.52 2.32 1.27 2.23 2.52Zm-7.97 2.84c-.19-.05-.51-.09-.98-.09-.93 0-1.67.37-2.22 1.03-.51.61-.83 1.54-.93 2.71l-.93 10.65c-.09 1.31.42 1.87 1.44 1.87.6 0 1.11-.19 1.53-.51.51-.38.83-.98.88-1.68l1.21-13.97Zm79.32 17.43h.68v2.02h.54v-2.02h.69v-.44h-1.91zm2.18 2.02h.53v-.43c0-.33-.02-.67-.04-1.01l.51 1.38h.49l.51-1.38c-.02.35-.04.7-.04 1v.43h.54v-2.45h-.6l-.65 1.84-.65-1.84h-.6v2.45Z"
32
+ ]
33
+ []
34
+ ]
35
+ ]
@@ -0,0 +1,292 @@
1
+ module Gem.Components exposing (default, withInteractive)
2
+
3
+ {-| The tier-2 seam: one function from a tag to a view.
4
+
5
+ The defaults are the library itself — `badge`, `stat` and `divider` render
6
+ Ui components, so prose and the app speak the same design language. Tags
7
+ that need somewhere to send a message (a button, a banner's dismiss) are added
8
+ by `withInteractive`, which takes the no-op message from the host. That keeps
9
+ this module free of a dependency on the app's `Msg` type.
10
+
11
+ Anything else is either a callout (Gem's own block) or, when the tag
12
+ contains a dash, a custom element the host's JavaScript registers.
13
+
14
+ -}
15
+
16
+ import Dict exposing (Dict)
17
+ import Gem.Slots exposing (Slots)
18
+ import Html exposing (Html)
19
+ import Html.Attributes as A
20
+ import Ui.Badge
21
+ import Ui.Banner
22
+ import Ui.Button
23
+ import Ui.Card
24
+ import Ui.Divider
25
+ import Ui.Icon
26
+ import Ui.Stat
27
+ import String
28
+
29
+
30
+ {-| The built-in registry.
31
+ -}
32
+ default : Slots msg
33
+ default =
34
+ { component =
35
+ \tag props children ->
36
+ case tag of
37
+ "callout" ->
38
+ callout props children
39
+
40
+ "badge" ->
41
+ Ui.Badge.view Ui.Badge.Label (text props "label")
42
+
43
+ "ui-badge" ->
44
+ Ui.Badge.view (badgeKind props) (text props "label")
45
+
46
+ "ui-divider" ->
47
+ Ui.Divider.view (text props "label") []
48
+
49
+ "ui-stat" ->
50
+ Ui.Stat.view
51
+ { value = text props "value"
52
+ , caption = maybeText props "label"
53
+ , attributes = []
54
+ }
55
+
56
+ "kbd" ->
57
+ Html.kbd [ A.class "code-inline" ] children
58
+
59
+ "row" ->
60
+ Html.div [ A.class "demo-row" ] children
61
+
62
+ "demo" ->
63
+ Html.div [ A.class "demo" ] children
64
+
65
+ "ui-card" ->
66
+ Ui.Card.view
67
+ { title = text props "title"
68
+ , description = text props "desc"
69
+ , href = maybeText props "href"
70
+ }
71
+
72
+ "ui-cards" ->
73
+ Html.div [ A.class "cards" ] children
74
+
75
+ _ ->
76
+ customElement tag props children
77
+ }
78
+
79
+
80
+ {-| Add the components that need to send a message: the host passes its
81
+ no-op, so a button in prose is real Ui markup that does nothing.
82
+ -}
83
+ withInteractive : msg -> Slots msg -> Slots msg
84
+ withInteractive noop base =
85
+ { base
86
+ | component =
87
+ \tag props children ->
88
+ case tag of
89
+ "ui-button" ->
90
+ Ui.Button.view
91
+ { label = text props "label"
92
+ , variant = buttonVariant props
93
+ , size = buttonSize props
94
+ , wide = False
95
+ , disabled = flag props "disabled"
96
+ , busy = Nothing
97
+ , icon = Nothing
98
+ , onClick = noop
99
+ , attributes = []
100
+ }
101
+
102
+ "ui-banner" ->
103
+ Ui.Banner.view
104
+ { kind = bannerKind props
105
+ , title = text props "title"
106
+ , body = text props "body"
107
+ , action = Nothing
108
+ , onDismiss = Nothing
109
+ , attributes = []
110
+ }
111
+
112
+ _ ->
113
+ base.component tag props children
114
+ }
115
+
116
+
117
+ {-| The prose callout. The library has banners for page-level messages,
118
+ which carry a fixed body string; prose needs a block that holds arbitrary
119
+ markdown, so the shape is: a tinted card, an icon tile, a mono eyebrow, and
120
+ the children underneath.
121
+ -}
122
+ callout : Dict String String -> List (Html msg) -> Html msg
123
+ callout props children =
124
+ let
125
+ tone =
126
+ text props "type"
127
+
128
+ kind =
129
+ case tone of
130
+ "warn" ->
131
+ "warn"
132
+
133
+ "warning" ->
134
+ "warn"
135
+
136
+ "danger" ->
137
+ "danger"
138
+
139
+ "success" ->
140
+ "success"
141
+
142
+ _ ->
143
+ "note"
144
+
145
+ label =
146
+ maybeText props "title" |> Maybe.withDefault (toneName kind)
147
+ in
148
+ Html.div [ A.class ("callout callout--" ++ kind) ]
149
+ [ Html.div [ A.class "callout-head" ]
150
+ [ Html.span [ A.class "callout-icon" ] [ Ui.Icon.view (toneIcon kind) ]
151
+ , Html.span [ A.class "callout-title" ] [ Html.text label ]
152
+ ]
153
+ , Html.div [ A.class "callout-body" ] children
154
+ ]
155
+
156
+
157
+ toneIcon : String -> Ui.Icon.Icon
158
+ toneIcon kind =
159
+ case kind of
160
+ "warn" ->
161
+ Ui.Icon.ToastWarn
162
+
163
+ "danger" ->
164
+ Ui.Icon.ToastError
165
+
166
+ "success" ->
167
+ Ui.Icon.ToastSuccess
168
+
169
+ _ ->
170
+ Ui.Icon.ToastInfo
171
+
172
+
173
+ toneName : String -> String
174
+ toneName kind =
175
+ case kind of
176
+ "warn" ->
177
+ "Warning"
178
+
179
+ "danger" ->
180
+ "Danger"
181
+
182
+ "success" ->
183
+ "Success"
184
+
185
+ _ ->
186
+ "Note"
187
+
188
+
189
+ customElement : String -> Dict String String -> List (Html msg) -> Html msg
190
+ customElement tag props children =
191
+ if String.contains "-" tag then
192
+ Html.node tag
193
+ (props
194
+ |> Dict.toList
195
+ |> List.map (\( key, value ) -> A.attribute key value)
196
+ )
197
+ children
198
+
199
+ else
200
+ Html.div
201
+ [ A.class "gem-unknown"
202
+ , A.attribute "data-component" tag
203
+ ]
204
+ children
205
+
206
+
207
+ badgeKind : Dict String String -> Ui.Badge.Kind
208
+ badgeKind props =
209
+ case text props "kind" of
210
+ "active" ->
211
+ Ui.Badge.Active
212
+
213
+ "revoked" ->
214
+ Ui.Badge.Revoked
215
+
216
+ "expired" ->
217
+ Ui.Badge.Expired
218
+
219
+ _ ->
220
+ Ui.Badge.Label
221
+
222
+
223
+ buttonVariant : Dict String String -> Ui.Button.Variant
224
+ buttonVariant props =
225
+ case text props "variant" of
226
+ "secondary" ->
227
+ Ui.Button.Secondary
228
+
229
+ "ghost" ->
230
+ Ui.Button.Ghost
231
+
232
+ "danger" ->
233
+ Ui.Button.Danger
234
+
235
+ "danger-solid" ->
236
+ Ui.Button.DangerSolid
237
+
238
+ _ ->
239
+ Ui.Button.Primary
240
+
241
+
242
+ buttonSize : Dict String String -> Ui.Button.Size
243
+ buttonSize props =
244
+ case text props "size" of
245
+ "regular" ->
246
+ Ui.Button.Regular
247
+
248
+ "xs" ->
249
+ Ui.Button.Xs
250
+
251
+ _ ->
252
+ Ui.Button.Compact
253
+
254
+
255
+ bannerKind : Dict String String -> Ui.Banner.Kind
256
+ bannerKind props =
257
+ case text props "kind" of
258
+ "success" ->
259
+ Ui.Banner.Success
260
+
261
+ "warning" ->
262
+ Ui.Banner.Warning
263
+
264
+ "danger" ->
265
+ Ui.Banner.Destructive
266
+
267
+ _ ->
268
+ Ui.Banner.Neutral
269
+
270
+
271
+ text : Dict String String -> String -> String
272
+ text props key =
273
+ Dict.get key props |> Maybe.withDefault ""
274
+
275
+
276
+ maybeText : Dict String String -> String -> Maybe String
277
+ maybeText props key =
278
+ case Dict.get key props of
279
+ Just value ->
280
+ if String.isEmpty value then
281
+ Nothing
282
+
283
+ else
284
+ Just value
285
+
286
+ Nothing ->
287
+ Nothing
288
+
289
+
290
+ flag : Dict String String -> String -> Bool
291
+ flag props key =
292
+ Dict.get key props == Just "true"
@@ -0,0 +1,17 @@
1
+ module Gem.Main exposing (main)
2
+
3
+ {-| The default theme's entry point.
4
+
5
+ A project that wants its own components writes this module instead and calls
6
+ `Gem.App.app` with its own registry, which is the whole customization story
7
+ for Elm.
8
+ -}
9
+
10
+ import Gem.App
11
+ import Gem.Components as Components
12
+ import Json.Decode
13
+
14
+
15
+ main : Program Json.Decode.Value Gem.App.Model Gem.App.Msg
16
+ main =
17
+ Gem.App.app (Components.withInteractive Gem.App.Noop Components.default)
@@ -0,0 +1,32 @@
1
+ port module Gem.Ports exposing (copyMarkdown, copyToClipboard, onScroll, openExternal, saveTheme, setMeta)
2
+
3
+ {-| The edges Elm cannot reach: clipboard writes, theme persistence, scroll
4
+ positions, opening chatbot links, and updating the document's meta tags.
5
+ -}
6
+
7
+
8
+ port saveTheme : String -> Cmd msg
9
+
10
+
11
+ port copyToClipboard : String -> Cmd msg
12
+
13
+
14
+ {-| Fetch a page's markdown and copy it — the "Copy page" action.
15
+ -}
16
+ port copyMarkdown : String -> Cmd msg
17
+
18
+
19
+ port onScroll : (Float -> msg) -> Sub msg
20
+
21
+
22
+ port openExternal : String -> Cmd msg
23
+
24
+
25
+ port setMeta :
26
+ { title : String
27
+ , description : String
28
+ , keywords : String
29
+ , url : String
30
+ , image : String
31
+ }
32
+ -> Cmd msg