Skip to content

Commit 0c58c56

Browse files
committed
improve the shell component
Fix errors and improve the style and layout of pages
1 parent c070ef5 commit 0c58c56

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

sqlpage/templates/shell.handlebars

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="{{language}}">
2+
<html lang="{{language}}" style="font-size: 18px">
33
<head>
44
<meta charset="utf-8"/>
55
<title>{{default title "SQLPage"}}</title>
@@ -26,29 +26,48 @@
2626
integrity="sha384-swGeMi9+uRunpz44HGkid0/L1Ud704D+qdaEAOQfA6SLGa5DMxL1CQl+4nAakber" crossorigin="anonymous">
2727
</head>
2828

29-
<body>
30-
{{#if title}}
31-
<header class="page-header">
32-
<nav class="navbar navbar-dark bg-primary">
29+
<body class="layout-boxed">
30+
<div class="page">
31+
{{#if title}}
32+
<nav class="navbar navbar-expand-md navbar-light">
3333
<div class="container-fluid">
34-
<a class="navbar-brand" href="{{#if link}}{{link}}{{else}}#{{/if}}">
34+
<a class="navbar-brand" href="{{#if link}}{{link}}{{else}}/{{/if}}">
35+
{{#if image}}
36+
<img src="{{image}}" alt="{{title}}" width="32" height="32"
37+
class="navbar-brand-image">
38+
{{/if}}
3539
{{#if icon}}
36-
<img src="{{image}}" alt="" width="32" height="32"
37-
class="d-inline-block align-text-top">
40+
<i class="icon ti ti-{{icon}}"></i>
3841
{{/if}}
3942
{{title}}
4043
</a>
44+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
45+
data-bs-target="#navbar-menu" aria-controls="navbar-menu" aria-expanded="false"
46+
aria-label="Toggle navigation">
47+
<span class="navbar-toggler-icon"></span>
48+
</button>
49+
<div class="collapse navbar-collapse" id="navbar-menu">
50+
<ul class="navbar-nav ms-auto">
51+
{{#each (to_array menu_item)}}
52+
<li class="nav-item">
53+
<a class="nav-link text-capitalize" href="{{this}}.sql">{{this}}</a>
54+
</li>
55+
{{/each}}
56+
</ul>
57+
{{#if search_target}}
58+
<form class="d-flex" role="search" target="{{search_target}}">
59+
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"
60+
name="search">
61+
<button class="btn btn-outline-success" type="submit">Search</button>
62+
</form>
63+
{{/if}}
64+
</div>
4165
</div>
4266
</nav>
43-
</header>
44-
{{/if}}
45-
46-
<main class="layout-boxed">
47-
<div class="page">
48-
<main class="page-wrapper container-xl mt-3">
49-
{{~#each_row~}}{{~/each_row~}}
50-
</main>
51-
</div>
52-
</main>
67+
{{/if}}
68+
<main class="page-wrapper container-xl pt-3 px-md-5 px-sm-3">
69+
{{~#each_row~}}{{~/each_row~}}
70+
</main>
71+
</div>
5372
</body>
5473
</html>

src/templates.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ impl AllTemplates {
187187
handlebars.register_helper("minus", Box::new(minus));
188188

189189
handlebars.register_helper("sum", Box::new(sum_helper));
190+
191+
handlebars_helper!(to_array: |x: Json| match x {
192+
JsonValue::Array(arr) => arr.clone(),
193+
other => vec![other.clone()]
194+
});
195+
handlebars.register_helper("to_array", Box::new(to_array));
196+
190197
let mut this = Self {
191198
handlebars,
192199
split_templates: FileCache::new(),

0 commit comments

Comments
 (0)