Skip to content

Commit d2fb2f9

Browse files
committed
wip
1 parent cfc29ae commit d2fb2f9

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

docs/_static/custom.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,9 @@ h2 {
100100
display: none;
101101
}
102102
}
103+
104+
.iommi_logo_menu {
105+
/*noinspection CssUnknownTarget*/
106+
background: url(https://docs.iommi.rocks/en/latest/_static/images/iommi_logo_text_only.svg) no-repeat;
107+
background-size: contain;
108+
}

docs/test_doc_main_menu.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"""
1515
Main menu
1616
~~~~~~~~~
17+
18+
The main menu component in iommi is used to create the main navigation for your app. This is primarily useful for SaaS or internal apps. It creates a sidebar menu with support for nested menu items, and centralized access control that automatically shows only menu items the user has access to.
19+
20+
To set up your main menu you declare it, register the `iommi.experimental.main_menu.menu_access_control_middleware` middleware, and define the `IOMMI_MAIN_MENU` setting to point to where you have defined it (like `IOMMI_MAIN_MENU = 'your_app.main_menu.main_menu'`).
21+
22+
Access control is recursive, meaning that if a user does not have access to a menu item, it is automatically denied access to all subitems.
1723
"""
1824

1925

@@ -24,7 +30,11 @@ def fake_view():
2430
menu_declaration = MainMenu(
2531
items=dict(
2632
artists=M(
27-
icon='guitar',
33+
icon='user',
34+
view=fake_view,
35+
),
36+
albums=M(
37+
icon='compact-disc',
2838
view=fake_view,
2939
),
3040
),

iommi/static/css/iommi_main_menu.css

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
--iommi-menu-width: 18rem;
33
--iommi-iommi-menu-width: 4rem;
44
--iommi-menu-background-color: #0d6efd;
5-
--iommi-menu-text-color-color: white;
5+
--iommi-menu-text-color-color: #689fff;
66
}
77

88
body {
@@ -189,13 +189,22 @@ body.right_sidebar_menu_active.compact_menu {
189189
}
190190
}
191191

192-
.dryft_logo_menu {
192+
.iommi_logo_menu {
193193
margin-top: 0.5rem;
194194
margin-left: 0.7rem;
195195
margin-bottom: 0.5rem;
196-
display: block;
197196
padding: 1rem;
198197
zoom: 148%;
198+
height: 1rem;
199+
width: 5rem;
200+
/*noinspection CssUnknownTarget*/
201+
background: url(/static/images/logo.svg);
202+
background-size: cover;
203+
display: block;
204+
}
205+
206+
.iommi_logo_menu a.nav-link {
207+
color: transparent !important;
199208
}
200209

201210
.container {
@@ -224,14 +233,14 @@ body.right_sidebar_menu_active.compact_menu {
224233
.compact_menu .menu {
225234
width: var(--iommi-iommi-menu-width);
226235

227-
.dryft_logo_menu {
236+
.iommi_logo_menu {
228237
zoom: 0.7;
229238

230239
height: 5rem;
231240
width: 5rem;
232241
margin-left: 0.4rem;
233242
/*noinspection CssUnknownTarget*/
234-
background: url(/static/images/logo_icon_white.svg);
243+
background: url(/static/images/logo_compact.svg);
235244
background-size: cover;
236245
}
237246

@@ -343,10 +352,10 @@ body.right_sidebar_menu_active.compact_menu {
343352
width: 100%;
344353
height: 3rem;
345354

346-
.dryft_logo_menu {
355+
.iommi_logo_menu {
347356

348357
/*noinspection CssUnknownTarget*/
349-
background: url(/static/images/logo2-white.svg);
358+
background: url(/static/images/logo_compact_mobile.svg);
350359
margin-top: 1rem;
351360
margin-left: 1rem;
352361
margin-bottom: 1rem;

iommi/templates/iommi/main_menu/menu.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<div class="menu">
33

44
<nav>
5-
{% block before_ul %}{% endblock %}
5+
{% block before_ul %}
6+
<a id="menu-logo" href="/"><div class="iommi_logo_menu"></div></a>
7+
{% endblock %}
68
<ul>
79
{% block before_items %}{% endblock %}
810

tests/main_menu.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from iommi.experimental.main_menu import MainMenu
2+
3+
main_menu = MainMenu()

tests/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
USE_TZ = False
4242

4343
IOMMI_DEFAULT_STYLE = 'test'
44+
IOMMI_MAIN_MENU = 'tests.main_menu.main_menu'
4445

4546
MIDDLEWARE = [
4647
'iommi.experimental.main_menu.menu_access_control_middleware',

0 commit comments

Comments
 (0)