Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "vertical layout" template #3

Merged
merged 41 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
626fd12
Add "vertical layout" template
Dec 3, 2021
b4d91a7
Pooling of "horizontal" and "vertical" layout
Dec 3, 2021
6f63581
Update src/Helper/ContextHelper.php
cavasinf Dec 3, 2021
cc86c6c
Update src/Helper/ContextHelper.php
cavasinf Dec 3, 2021
2b07d71
Change layout includes files location
Dec 3, 2021
ccc4f46
Set getLayout to private access
Dec 3, 2021
58a754c
BugFix block overriding from "base" (user) template
Dec 6, 2021
c284556
BugFix block horizontal template name
Dec 6, 2021
af9a000
Add "HTML attribute id" config to primary blocks
Dec 10, 2021
40325cb
Add hasActiveChildren() on menu + auto open tree
Dec 13, 2021
d3809ea
Merge branch 'main' into layout-vertical
cavasinf Dec 21, 2021
6e39911
Add new tabler param to ConfigurationTest
Dec 22, 2021
de1240b
BugFix when focus out, active menu was closed
Jan 3, 2022
d01dee9
Add dark-mode for header and navbar individually
Jan 3, 2022
13597db
Add new dark param into default configuration for tests
Jan 3, 2022
7d3989b
Merge branch 'main' into layout-vertical
kevinpapst Jan 8, 2022
5eea967
remove required config, it has a default value
kevinpapst Jan 8, 2022
0085d69
Update templates/includes/layout_vertical.html.twig
cavasinf Jan 10, 2022
e831141
Use include navbar template
Jan 10, 2022
62b2fb6
Add `header` block as default from layout vertical
Jan 10, 2022
90e3e3b
singular = hasActiveChild()
Jan 10, 2022
e8c7df1
Remove hacky include way
Jan 10, 2022
a33825a
Add `navbar` block as default from layout horizontal
Jan 10, 2022
e224005
Update menu twig to allows childs of a child item
Feb 18, 2022
21b1119
Explode layout option into twigs layout
Feb 18, 2022
58591e6
Remove `layout` tabler configuration
Feb 18, 2022
56e4f1d
Remove `layout` tabler configuration
Feb 18, 2022
6534bcc
Merge branch 'main' into layout-vertical
Feb 18, 2022
7500575
BugFix extends & variable layout type
Feb 18, 2022
9e280c7
Clean unused `includes`
Feb 18, 2022
ec345da
Add badge option on child item
Feb 21, 2022
4e51950
Merge branch 'main' into layout-vertical
Mar 8, 2022
bcc1ab5
[Redo] Update menu twig to allows childs of a child item
Mar 8, 2022
f80cf40
Remove navbar embeded (twig doens't allow block override in embeded f…
Mar 26, 2022
efaf141
Redo PR #74
Mar 26, 2022
636fc1a
Switch navbar into macro
Mar 26, 2022
a1e81cc
Add safe escape
Mar 26, 2022
72512a0
Merge branch 'main' into layout-vertical
Apr 13, 2022
081ae49
remove tabler_layoutType, do not show badge on first level vertical m…
kevinpapst May 17, 2022
9d2c766
remove tabler_layoutType, do not show badge on first level vertical m…
kevinpapst May 17, 2022
0558b4b
added missing commits
kevinpapst May 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/packages/tabler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ tabler:
dark_mode: true
# condensed = one nav-bar, false = two nav-bars
navbar_condensed: true
# true = dark mode, false = light mode (on header)
header_dark: false
# true = dark mode, false = light mode (on menu)
navbar_dark: false
# overlap = https://preview.tabler.io/layout-navbar-overlap.html
navbar_overlap: false
# true = boxed layout, false = full-screen
Expand Down
15 changes: 11 additions & 4 deletions docs/layout.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Using the layout

In order to use the layout, your views should extend from the provided `layout`
In order to use the layout, your views should extend from the provided `layouts`

```twig
{% extends '@Tabler/layout-horizontal.html.twig' %}
```

OR

```twig
{% extends '@Tabler/layout.html.twig' %}
{% extends '@Tabler/layout-vertical.html.twig' %}
```

## Layout files
Expand All @@ -11,9 +18,9 @@ This bundle ships with two main template files which you can extend in your them

**For all your admin pages**

The default `layout.html.twig` file can be used with:
The default `layout-horizontal.html.twig` can be used with:
```
{% extends '@Tabler/layout.html.twig' %}
{% extends '@Tabler/layout-horizontal.html.twig' %}
```

**For your security screens**
Expand Down
4 changes: 2 additions & 2 deletions docs/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Search and replace
```
with
```
{% extends '@Tabler/layout.html.twig' %}
{% extends '@Tabler/layout-horizontal.html.twig' %}
```

Search and replace:
Expand Down Expand Up @@ -86,7 +86,7 @@ Replace
```
with
```
{% extends '@Tabler/layout.html.twig' %}
{% extends '@Tabler/layout-horizontal.html.twig' %}
```

The file:
Expand Down
6 changes: 6 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ private function getOptionsConfig(): NodeDefinition
->booleanNode('dark_mode')
->defaultFalse()
->end()
->booleanNode('header_dark')
->defaultFalse()
->end()
->booleanNode('navbar_dark')
->defaultFalse()
->end()
->booleanNode('navbar_condensed')
->defaultTrue()
->end()
Expand Down
20 changes: 20 additions & 0 deletions src/Helper/ContextHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ public function setIsDarkMode(bool $isDarkMode): void
$this->setOption('dark_mode', $isDarkMode);
}

public function isHeaderDark(): bool
{
return (bool) $this->getOption('header_dark');
}

public function setIsHeaderDark(bool $isHeaderDark): void
{
$this->setOption('header_dark', $isHeaderDark);
}

public function isNavbarDark(): bool
{
return (bool) $this->getOption('navbar_dark');
}

public function setIsNavbarDark(bool $isNavbarDark): void
{
$this->setOption('navbar_dark', $isNavbarDark);
}

public function isBoxedLayout(): bool
{
return (bool) $this->getOption('boxed_layout');
Expand Down
5 changes: 5 additions & 0 deletions src/Model/MenuItemModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ public function getActiveChild(): ?MenuItemInterface
return null;
}

public function hasActiveChild(): bool
{
return null !== $this->getActiveChild();
}

public function isActive(): bool
{
return $this->isActive;
Expand Down
124 changes: 86 additions & 38 deletions templates/includes/menu.html.twig
Original file line number Diff line number Diff line change
@@ -1,47 +1,95 @@
{% if menu is not defined %}
{% set menu = tabler_menu(app.request) %}
{% endif %}

{% if menu is defined and menu is not null %}
<ul class="navbar-nav">
{% for item in menu %}
<li id="{{ item.identifier }}" class="nav-item {{ item.isActive ? 'active' : '' }} {{ item.hasChildren? 'dropdown' : '' }}">
<a {% if item.hasChildren -%}
class="nav-link dropdown-toggle" href="#navbar-base" data-bs-toggle="dropdown" role="button" aria-expanded="false"
{%- else -%}
class="nav-link" href="{{ '/' in item.route ? item.route : path(item.route|tabler_route, item.routeArgs) }}"
{%- endif -%}>
{% if item.icon %}
<span class="nav-link-icon d-md-none d-lg-inline-block text-center">
{{ tabler_icon(item.icon, false, item.icon) }}
</span>
{% endif %}
<span class="nav-link-title">{{ item.label|trans }}</span>
{% if item.badge is not null or item.badgeColor is not null %}
<span class="badge bg-{{ item.badgeColor|default('blue') }}">{{ item.badge }}</span>
{% endif %}
</a>

{% if item.hasChildren %}
<div class="dropdown-menu">
<ul class="navbar-nav {{ navbar_class | default('') }}">
{% for item in menu %}
<li id="{{ item.identifier }}" class="nav-item {{ item.isActive ? 'active' : '' }} {{ item.hasChildren? 'dropdown' : '' }}">
<a
{% if item.hasChildren %}
class="nav-link dropdown-toggle" role="button"
data-bs-toggle="dropdown" data-bs-auto-close="{{ tabler_layoutType is same as "vertical" ? 'false' : 'outside' }}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabler_layoutType is used here for example

aria-expanded="{{ tabler_layoutType is same as "vertical" }}"
{% else %}
class="nav-link" href="{{ '/' in item.route ? item.route : path(item.route|tabler_route, item.routeArgs) }}"
{% endif %}
>
{{ _self.item_icon(item) }}
<span class="nav-link-title">{{ item.label|trans }}</span>
{{ _self.item_badge(item) }}
</a>

{{ _self.item_childs(item, tabler_layoutType) }}

</li>
{% endfor %}
</ul>
{% endif %}






{% macro item_childs(item, tabler_layoutType) %}
{% if item.hasChildren %}
<div class="dropdown-menu {{ tabler_layoutType is same as "vertical" and item.isActive ? 'show':'' }}" data-bs-popper="none">
<div class="dropdown-menu-columns">
<div class="dropdown-menu-column">

{% for child in item.children %}
{% if child.divider %}
{% if not loop.last -%}
<hr class="dropdown-divider">
{%- endif %}

{% if child.hasChildren %}
<div class="dropend">
<a class="dropdown-item dropdown-toggle" role="button"
data-bs-toggle="dropdown" data-bs-auto-close="{{ tabler_layoutType is same as "vertical" ? 'false' : 'outside' }}"
aria-expanded="{{ tabler_layoutType is same as "vertical" }}"
>
{{ _self.item_icon(child) }}
{{ child.label|trans }}
{{ _self.item_badge(child) }}
</a>

{{ _self.item_childs(child, tabler_layoutType) }}

</div>
{% else %}
<a class="dropdown-item {{ child.isActive ? 'active':'' }}" href="{{ '/' in child.route ? child.route : path(child.route|tabler_route, child.routeArgs) }}">
{% if child.icon %}
<span class="nav-link-icon d-md-none d-lg-inline-block text-center">
{{ tabler_icon(child.icon, false, child.icon) }}
</span>
{% endif %}
{{ child.label|trans }}
</a>
{{ _self.child_item(child) }}
{% endif %}

{% endfor %}
</div>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
{% endif %}
{% endmacro %}

{% macro child_item(child) %}
{% if child.divider %}
{% if not loop.last -%}
<hr class="dropdown-divider">
{%- endif %}
{% else %}
<a
class="dropdown-item {{ child.isActive ? 'active':'' }}"
{% if not child.hasChildren %}href="{{ '/' in child.route ? child.route : path(child.route|tabler_route, child.routeArgs) }}"{% endif %}
>
{{ _self.item_icon(child) }}
{{ child.label|trans }}
{{ _self.item_badge(child) }}
</a>
{% endif %}
{% endmacro %}

{% macro item_icon(item) %}
{% if item.icon %}
<span class="nav-link-icon d-md-none d-lg-inline-block text-center">{{ tabler_icon(item.icon, false, item.icon) }}</span>
{% endif %}
{% endmacro %}

{% macro item_badge(item) %}
{% if item.badge is not null or item.badgeColor is not null %}
<span class="badge bg-{{ item.badgeColor|default('blue') }}">{{ item.badge }}</span>
{% endif %}
{% endmacro %}
Loading