Skip to content

Commit 1cfea7f

Browse files
committed
ui/refactor: help dropdown + /help route.
1 parent 1a83b8d commit 1cfea7f

File tree

11 files changed

+512
-262
lines changed

11 files changed

+512
-262
lines changed

Diff for: assets/js/bulma_drivers.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ function closeModal(e, modal, app) {
666666
//
667667

668668
function triggerHelp(e, el, app) {
669-
app.ports.triggerHelpFromJs.send(null)
669+
var v = el.dataset.help;
670+
if (!v) v = "";
671+
app.ports.triggerHelpFromJs.send(v)
670672
}
671673

672674
function triggerJoin(e, el, app) {

Diff for: assets/sass/fractal6.scss

+24-8
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,13 @@ figcaption {
937937
height: $navbar-height;
938938
}
939939

940-
.navbar-item {
941-
.navbar-link:hover, .navbar-link.is-active {
942-
// @debug: There is an background overflow on hover, bulma padding things... :/
943-
background: none !important;
944-
}
945-
}
940+
// @deprecated ?
941+
//.navbar-item {
942+
// .navbar-link:hover, .navbar-link.is-active {
943+
// // @debug: There is an background overflow on hover, bulma padding things... :/
944+
// background: none !important;
945+
// }
946+
//}
946947

947948
// Fix right navbar top on touch
948949
.navbar-touch-end {
@@ -997,6 +998,13 @@ figcaption {
997998
border-bottom: solid 1px var(--grey-darker);
998999
border-left: solid 1px var(--grey-darker);
9991000
border-right: solid 1px var(--grey-darker);
1001+
.navbar-item:hover { // @bulma bad!
1002+
background-color: var(--navbar-item-hover-background-color);
1003+
cursor: pointer;
1004+
}
1005+
.navbar-divider {
1006+
margin:0;
1007+
}
10001008
}
10011009
}
10021010

@@ -2588,7 +2596,8 @@ i.is-liked {
25882596
.tabs {
25892597
li {
25902598
a, span {
2591-
color: var(--grey);
2599+
color: var(--text-light);
2600+
opacity: 0.6;
25922601
align-items: center;
25932602
display: flex;
25942603
justify-content: center;
@@ -2597,7 +2606,8 @@ i.is-liked {
25972606
}
25982607
&.is-active {
25992608
a, span {
2600-
color: var(--grey-darker);
2609+
color: var(--text);
2610+
opacity: 1;
26012611
border-bottom-color: orange !important;
26022612
border-bottom-style: solid;
26032613
border-bottom-width: 2px;
@@ -2608,6 +2618,12 @@ i.is-liked {
26082618

26092619
}
26102620
}
2621+
&.columns {
2622+
.tabs {
2623+
margin-bottom: 1rem;
2624+
}
2625+
2626+
}
26112627
}
26122628

26132629
//

Diff for: melm.py

+55-35
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
'''Elm module generator from templates.
44
55
Usage:
6-
melm add [-w] [-t TEMPLATE ] MODULE_NAME...
7-
melm push [-w] MODULE_NAME...
6+
melm add [-w] [-t TEMPLATE ] MODULE_NAME
7+
melm push [-w] MODULE_SOURCE MODULE_TARGET
88
99
Commands:
1010
add Add a new sub-component.
@@ -58,9 +58,9 @@ def checks(self):
5858
def run(self):
5959
q = self.conf
6060
if q["add"]:
61-
self.add_subcomponent(q["MODULE_NAME"][0])
61+
self.add_subcomponent(q["MODULE_NAME"])
6262
elif q["push"]:
63-
self.push_subcomponent(*q["MODULE_NAME"])
63+
self.push_subcomponent(q["MODULE_SOURCE"], q["MODULE_TARGET"])
6464

6565
def get_module_map(self, module_name):
6666
modules = module_name.split(".")
@@ -85,6 +85,7 @@ def add_subcomponent(self, module_name):
8585
print(s)
8686

8787
def push_subcomponent(self, module_name_source, module_name_target):
88+
""" See self.rmatch for the sec doc. """
8889
push_in_submodule = False
8990
if "Components" in module_name_target.split('.'):
9091
push_in_submodule = True
@@ -102,24 +103,26 @@ def push_subcomponent(self, module_name_source, module_name_target):
102103
pos = 0,
103104
),
104105
dict(
105-
reg = r"\n",
106+
reg = r"}",
106107
pos = -1,
107-
t = ", ${module_basename_lower1} : ${module_basename}.State"
108+
t = ", ${module_basename_lower1} : ${module_basename}.State",
109+
before = True
108110
)
109111
]
110112
init_spec = [
111113
dict(
112-
reg = r"^init .*?=\s*let.*? in ",
114+
reg = r"^init .*?=\s*let.*? in\s",
113115
pos = 0,
114116
),
115117
dict(
116118
reg = r"^\s*model\s*=\s*{.*?}",
117119
pos = 0,
118120
),
119121
dict(
120-
reg = r"\n",
122+
reg = r"}",
121123
pos = -1,
122-
t = ", ${module_basename_lower1} = ${module_basename}.init global.session.user"
124+
t = ", ${module_basename_lower1} = ${module_basename}.init global.session.user",
125+
before = True
123126
)
124127
]
125128
msg_spec = [
@@ -129,7 +132,7 @@ def push_subcomponent(self, module_name_source, module_name_target):
129132
),
130133
dict(
131134
reg = r"\n",
132-
pos = -3,
135+
pos = -4,
133136
t = "| ${module_basename}Msg ${module_basename}.Msg"
134137
)
135138
]
@@ -142,43 +145,45 @@ def push_subcomponent(self, module_name_source, module_name_target):
142145
reg = r"\n",
143146
pos = -3,
144147
t = '''
145-
${module_basename}Msg msg ->
146-
let
147-
( data, out ) = ${module_basename}.update apis msg model.${module_basename_lower1}
148-
149-
( cmds, gcmds ) = %s
150-
in
151-
( %s )
152-
''' % ('mapGlobalOutcmds out.gcmds' if not push_in_submodule else '([], [])'
153-
,"{model | ${module_basename_lower1} = data}, out.cmds |> List.map (\m -> Cmd.map ${module_basename}Msg m) |> List.append cmds |> Cmd.batch, Cmd.batch gcmds" if not push_in_submodule else
154-
"{ model | ${module_basename_lower1} = data }, out2 (List.map (\m -> Cmd.map ${module_basename}Msg m) out.cmds |> List.append cmds) (out.gcmds ++ gcmds)")
148+
${module_basename}Msg msg ->
149+
let
150+
( data, out ) = ${module_basename}.update apis msg model.${module_basename_lower1}
151+
152+
( cmds, gcmds ) = %s
153+
in
154+
( %s )\n''' % ('mapGlobalOutcmds out.gcmds' if not push_in_submodule else '([], [])'
155+
,"{model | ${module_basename_lower1} = data}, out.cmds |> List.map (\m -> Cmd.map ${module_basename}Msg m) |> List.append cmds |> Cmd.batch, Cmd.batch gcmds" if not push_in_submodule else
156+
"{ model | ${module_basename_lower1} = data }, out2 (List.map (\m -> Cmd.map ${module_basename}Msg m) out.cmds |> List.append cmds) (out.gcmds ++ gcmds)"),
157+
indent_offset = 4,
155158
),
156159
]
157160
subscriptions_spec = [
158161
dict(
159162
reg = r"^subscriptions .*?=.*?\n\n\n",
160163
pos = 0,
161-
t = "|> Sub.batch" if not push_in_submodule else ""
164+
t = "|> Sub.batch" if not push_in_submodule else "",
165+
before = True,
162166
),
163167
dict(
164168
reg = r"\n",
165-
pos = -4,
169+
pos = -2 if not push_in_submodule else -4,
166170
t = "++ (${module_basename}.subscriptions |> List.map (\s -> Sub.map ${module_basename}Msg s))"
167171
)
168172
]
169173
view_spec = [
170174
dict(
171-
reg = r"^view .*?=.*?\n\n\n",
175+
reg = r"^view .*?=.*?(\n\n\n|\Z)",
172176
pos = 0,
173177
),
174178
dict(
175179
reg = r"\s+body\s*=\s*\[.*?\]",
176180
pos = 0,
177181
),
178182
dict(
179-
reg = r"\n",
183+
reg = r"\]",
180184
pos = -1,
181-
t = ", ${module_basename}.view {} model.${module_basename_lower1} |> Html.map ${module_basename}Msg"
185+
t = ", ${module_basename}.view {} model.${module_basename_lower1} |> Html.map ${module_basename}Msg",
186+
before= True,
182187
)
183188
]
184189

@@ -219,26 +224,27 @@ def rmatch(self, regs, content, mapping=None):
219224
reg: regexp,
220225
pos: int (0 for the first match and -1 for the last match)
221226
t: template to add
227+
-- OPTIONAL
228+
before: insert content before the match (default after)
229+
indent_offset: int (substract some indentation)
222230
}
223231
224232
'''
225233

226234
if len(regs) == 0:
227235
return
228236

229-
#print(content)
230-
#print('-'*29)
231-
232237
reg = regs[0]
233238
lines = []
234239
for m in re.finditer(reg["reg"], content, re.MULTILINE|re.DOTALL):
235240
start, end = m.start(), m.end()
236241
line_start, line_end = content[0:start].count("\n"), content[0:end].count("\n")
237242
# recompute start/end after/before the next/previous newline.
238-
offset = content[start:end].find('\n')
239-
start = (start if offset < 0 else start + offset)+1
240-
offset = content[:end][::-1].find('\n')
241-
end = (end if offset < 0 else end - offset)-1
243+
# WTF?
244+
#offset = content[start:end].find('\n')
245+
#start = (start if offset < 0 else start + offset)+1
246+
#offset = content[:end][::-1].find('\n')
247+
#end = (end if offset < 0 else end - offset)-1 # @debug: end < start ??
242248
lines.append((line_start, line_end, start, end, m.group()))
243249

244250
if len(lines) == 0:
@@ -258,11 +264,25 @@ def rmatch(self, regs, content, mapping=None):
258264
if temp[line - offset].strip() != n.strip():
259265
# Get the indent of the last line of content that is not empty
260266
indent = len(temp[line-offset]) - len(temp[line-offset].lstrip())
267+
if reg.get("indent_offset") and indent >= reg["indent_offset"]:
268+
indent -= reg["indent_offset"]
261269
# indent the patch
262-
n = list(map(lambda x: " "*indent + x.lstrip(), n.split("\n")))
263-
extension = temp[:line+1] + n + temp[line+1:]
270+
n = list(map(lambda x: " "*indent + x, n.split("\n")))
271+
272+
# Pasting index
273+
if reg.get("before"):
274+
nr = 0
275+
last = temp[line-1]
276+
while last == "":
277+
nr += 1
278+
last = temp[line-1-nr]
279+
else:
280+
nr = -1
281+
282+
# Rebuild content
283+
extension = temp[:line-nr] + n + temp[line-nr:]
264284
content = "\n".join(extension)
265-
end = end + len(n)
285+
end += len(n)
266286

267287
r = self.rmatch(regs[1:], content[start:end], mapping=mapping)
268288
if r:

Diff for: src/Bulk/View.elm

-2
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ viewPin conf focus tension =
269269
[ A.icon ("icon-alert-circle icon-sm marginTensionStatus has-text-" ++ statusColor tension.status) ]
270270
, viewTensionDateAndUser conf "has-text-weight-light" tension.createdAt tension.createdBy
271271
]
272-
273-
--, div [ class "level-right" ] []
274272
]
275273
]
276274
]

Diff for: src/Components/Navbar.elm

+15-5
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ notificationButton cls user notif url =
133133
case user of
134134
LoggedIn _ ->
135135
a
136-
[ class ("navbar-item " ++ cls)
136+
[ class ("navbar-item px-3 " ++ cls)
137137
, href (toHref Notifications)
138138
, title T.notifications
139139
, classList [ ( "is-active", fromUrl url == Just Notifications ) ]
@@ -165,12 +165,22 @@ helpButton user =
165165
case user of
166166
LoggedIn _ ->
167167
div
168-
[ class "navbar-item helpTrigger"
168+
[ class "navbar-item has-dropdown px-2"
169169
, title "Help and feedback"
170170
]
171171
[ div [ class "navbar-link is-arrowless is-hidden-touch" ]
172172
[ div [ class "button is-rounded is-small has-background-navbar", style "height" "inherit" ] [ A.icon "icon-question" ] ]
173173
, div [ class "button-light is-hidden-tablet" ] [ A.icon1 "icon-question" "Help" ]
174+
, div [ class "navbar-dropdown" ]
175+
[ div [ class "navbar-item pb-3 helpTrigger", attribute "data-help" "QuickHelp" ]
176+
[ text T.quickHelp ]
177+
, hr [ class "navbar-divider" ] []
178+
, div [ class "navbar-item py-3 helpTrigger", attribute "data-help" "AskQuestion" ]
179+
[ text T.askQuestion ]
180+
, hr [ class "navbar-divider" ] []
181+
, div [ class "navbar-item pt-3 helpTrigger", attribute "data-help" "Feedback" ]
182+
[ text T.giveFeedback ]
183+
]
174184
]
175185

176186
LoggedOut ->
@@ -213,15 +223,15 @@ userButtons user url replaceUrl =
213223
[ A.icon1 "icon-home" T.home ]
214224
, a [ class "navbar-item", href (toHref <| Dynamic_Settings { param1 = uctx.username }) ]
215225
[ A.icon1 "icon-tool" T.settings ]
216-
, span [ id "themeTrigger", class "navbar-item is-w" ]
226+
, div [ id "themeTrigger", class "navbar-item pb-3" ]
217227
[ A.icon1 "icon-moon" T.toggleLightMode ]
218228
, hr [ class "navbar-divider" ] []
219-
, a [ class "navbar-item", href (toHref New_Orga) ]
229+
, a [ class "navbar-item py-3", href (toHref New_Orga) ]
220230
[ A.icon1 "icon-plus" T.newOrganisation ]
221231
, hr [ class "navbar-divider" ] []
222232

223233
-- Prevout logout to be log in the browser history (@debug do not work)
224-
, div [ class "navbar-item button-light", onClick (replaceUrl (toHref Logout)) ]
234+
, div [ class "navbar-item pt-3", onClick (replaceUrl (toHref Logout)) ]
225235
[ A.icon1 "icon-power" T.signout ]
226236
]
227237
]

0 commit comments

Comments
 (0)