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

Allow adjusting templates' header height and hiding it #6125

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 panel/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,9 @@ class BasicTemplate(BaseTemplate):
header_color = param.String(doc="""
Optional header text color override.""")

header_height = param.String(default="64px", doc="""
Optional header height override.""")

location = param.Boolean(default=True, readonly=True)

_actions = param.ClassSelector(default=TemplateActions(), class_=TemplateActions)
Expand Down Expand Up @@ -772,6 +775,7 @@ def _update_vars(self, *args) -> None:
self._render_variables['app_favicon'] = favicon
self._render_variables['app_favicon_type'] = self._get_favicon_type(self.favicon)
self._render_variables['header_background'] = self.header_background
self._render_variables['header_height'] = self.header_height
self._render_variables['header_color'] = self.header_color
self._render_variables['main_max_width'] = self.main_max_width
self._render_variables['sidebar_width'] = self.sidebar_width
Expand Down
9 changes: 8 additions & 1 deletion panel/template/fast/list/fast_list_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
background-color: var(--background-color);
font-family: var(--body-font);
}
#header {
{% if header_height.startswith('0') %}
display: none;
{% else %}
height: {{ header_height }};
{% endif %}
}
#header a {
color: currentColor;
}
Expand Down Expand Up @@ -87,7 +94,7 @@
<fast-design-system-provider id="body-design-provider" use-defaults>
<div id="container">
<fast-design-system-provider id="header-design-provider">
<nav id="header" {{ 'class="shadow"' if style.shadow else '' }} >
<nav id="header" {% if hide_header %}style="display: none;"{% endif %} {{ 'class="shadow"' if style.shadow else '' }} >
{% if nav or sidebar_footer %}
<span onclick="{{ 'openNav()' if collapsed_sidebar else 'closeNav()' }}" id="sidebar-button">
<div class="pn-bar"></div>
Expand Down
20 changes: 17 additions & 3 deletions panel/template/material/material.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,29 @@
#header {
--mdc-theme-background: var(--header-background);
--mdc-theme-on-background: var(--header-color);
background-color: var(--header-background);
color: var(--header-color);
background-color: var(--header-background);
color: var(--header-color);
}
#header-items {
height: 100%;
}
.mdc-top-app-bar__section--align-start {
height: {{ header_height }}; /* Adjust the height for the align-start section */

}
.mdc-drawer {
width: var(--sidebar-width) !important;
}
.mdc-drawer.mdc-drawer--open:not(.mdc-drawer--closing)+.mdc-drawer-app-content {
margin-left: var(--sidebar-width) !important;
}
.mdc-top-app-bar--fixed-adjust {
{% if header_height.startswith('0') %}
padding-top: 0px;
{% else %}
padding-top: calc({{ header_height }} + 10px); /* Adjust the padding so sidebar / main isn't underneath */
{% endif %}
}
</style>

<!-- Template JS -->
Expand All @@ -78,7 +92,7 @@
<!-- goes in body -->
{% block contents %}
<div class="mdc-typography" id="container">
<header class="mdc-top-app-bar app-bar mdc-top-app-bar--fixed" id="header">
<header class="mdc-top-app-bar app-bar mdc-top-app-bar--fixed" id="header" {% if header_height.startswith('0') %}style="display: none;"{% endif %}>
<div class="mdc-top-app-bar__row">
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
{% if nav %}
Expand Down
Loading