Skip to content

Commit 4b90f3e

Browse files
authored
Merge pull request #321 from pratikb64/add-dark-mode-button
feat: add dark mode button
2 parents 3fabfd0 + 2233d33 commit 4b90f3e

File tree

1 file changed

+61
-43
lines changed

1 file changed

+61
-43
lines changed
Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,85 @@
11
{% macro render_item(item, submenu=False, parent=False) %}
22
{% if item.child_items %}
33

4-
{% if parent %}
4+
{% if parent %}
55

6-
{%- set dropdown_id = 'id-' + frappe.utils.generate_hash('Dropdown', 12) -%}
7-
<li class="nav-item dropdown {% if submenu %} dropdown-submenu {% endif %}">
8-
<a class="navbar-link dropdown-toggle" href="#" id="{{ dropdown_id }}" role="button"
9-
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
10-
{{ _(item.label) }}
11-
</a>
12-
<ul class="dropdown-menu" aria-labelledby="{{ dropdown_id }}">
13-
{% for child in item.child_items %}
14-
{{ render_item(child, True) }}
15-
{% endfor %}
16-
</ul>
17-
</li>
18-
{% else %}
19-
{%- set dropdown_id = 'id-' + frappe.utils.generate_hash('Dropdown', 12) -%}
20-
<li class="dropdown {% if submenu %} dropdown-submenu {% endif %}">
21-
<a class="dropdown-item dropdown-toggle" href="#" id="{{ dropdown_id }}" role="button"
22-
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
23-
{{ _(item.label) }}
24-
</a>
25-
<ul class="dropdown-menu" aria-labelledby="{{ dropdown_id }}">
26-
{% for child in item.child_items %}
27-
{{ render_item(child, True) }}
28-
{% endfor %}
29-
</ul>
30-
</li>
31-
{% endif %}
6+
{%- set dropdown_id = 'id-' + frappe.utils.generate_hash('Dropdown', 12) -%}
7+
<li class="nav-item dropdown {% if submenu %} dropdown-submenu {% endif %}">
8+
<a class="navbar-link dropdown-toggle" href="#" id="{{ dropdown_id }}" role="button" data-toggle="dropdown"
9+
aria-haspopup="true" aria-expanded="false">
10+
{{ _(item.label) }}
11+
</a>
12+
<ul class="dropdown-menu" aria-labelledby="{{ dropdown_id }}">
13+
{% for child in item.child_items %}
14+
{{ render_item(child, True) }}
15+
{% endfor %}
16+
</ul>
17+
</li>
18+
{% else %}
19+
{%- set dropdown_id = 'id-' + frappe.utils.generate_hash('Dropdown', 12) -%}
20+
<li class="dropdown {% if submenu %} dropdown-submenu {% endif %}">
21+
<a class="dropdown-item dropdown-toggle" href="#" id="{{ dropdown_id }}" role="button" data-toggle="dropdown"
22+
aria-haspopup="true" aria-expanded="false">
23+
{{ _(item.label) }}
24+
</a>
25+
<ul class="dropdown-menu" aria-labelledby="{{ dropdown_id }}">
26+
{% for child in item.child_items %}
27+
{{ render_item(child, True) }}
28+
{% endfor %}
29+
</ul>
30+
</li>
31+
{% endif %}
3232

3333
{% else %}
3434

35-
{% if parent %}
36-
<li class="nav-item">
37-
<a class="navbar-link" href="{{ (item.url or '')|abs_url }}"
38-
{% if item.open_in_new_tab %} target="_blank" {% endif %}>
39-
{{ _(item.label) }}
40-
</a>
41-
</li>
42-
{% else %}
43-
<a class="dropdown-item" href="{{ (item.url or '') | abs_url }}"
44-
{% if item.open_in_new_tab %} target="_blank" {% endif %}>
35+
{% if parent %}
36+
<li class="nav-item">
37+
<a class="navbar-link" href="{{ (item.url or '')|abs_url }}" {% if item.open_in_new_tab %} target="_blank" {% endif
38+
%}>
4539
{{ _(item.label) }}
4640
</a>
47-
{% endif %}
41+
</li>
42+
{% else %}
43+
<a class="dropdown-item" href="{{ (item.url or '') | abs_url }}" {% if item.open_in_new_tab %} target="_blank" {% endif
44+
%}>
45+
{{ _(item.label) }}
46+
</a>
47+
{% endif %}
4848

4949
{% endif %}
5050
{% endmacro %}
5151

5252
<ul class="navbar-nav">
5353
{% include "wiki/doctype/wiki_page/templates/navbar_search.html" %}
5454
{%- for item in navbar_items -%}
55-
{% if not item.parent_label and item.right -%}
56-
{{ render_item(item, parent=True) }}
57-
{%- endif -%}
55+
{% if not item.parent_label and item.right -%}
56+
{{ render_item(item, parent=True) }}
57+
{%- endif -%}
5858
{%- endfor %}
5959
{% if not only_static %}
60-
{% block navbar_right_extension %}{% endblock %}
60+
{% block navbar_right_extension %}{% endblock %}
6161
{% endif %}
6262
<div class="d-block d-sm-none sm-sidebar">
6363
<!--sidebar-->
6464
</div>
65+
<div class="sun-moon-container">
66+
<svg class="feather feather-moon hide" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"
67+
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
68+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
69+
</svg>
70+
<svg class="feather feather-sun hide" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"
71+
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
72+
<circle cx="12" cy="12" r="5"></circle>
73+
<line x1="12" y1="1" x2="12" y2="3"></line>
74+
<line x1="12" y1="21" x2="12" y2="23"></line>
75+
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
76+
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
77+
<line x1="1" y1="12" x2="3" y2="12"></line>
78+
<line x1="21" y1="12" x2="23" y2="12"></line>
79+
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
80+
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
81+
</svg>
82+
</div>
6583
{% include "templates/includes/navbar/navbar_login.html" %}
6684

6785

@@ -70,4 +88,4 @@
7088
<a class="btn btn-primary navbar-cta" href="{{ call_to_action_url | abs_url }}">
7189
{{ call_to_action }}
7290
</a>
73-
{%- endif -%}
91+
{%- endif -%}

0 commit comments

Comments
 (0)