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

Custom theme is not not applied #3056

Closed
blelem opened this issue Jan 1, 2022 · 0 comments · Fixed by #3057
Closed

Custom theme is not not applied #3056

blelem opened this issue Jan 1, 2022 · 0 comments · Fixed by #3057
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@blelem
Copy link
Contributor

blelem commented Jan 1, 2022

ALL software version info

Version 0.12.6. Problem can also be reproed using latest code available in the repo.

Description of expected behavior and the observed behavior

When using a css theme that is not located the BUNDLE_DIR, the BasicTemplate ignores the provided value, and uses the base_css instead.

Complete, minimal, self-contained example code that reproduces the issue

This is closely following the example from https://panel.holoviz.org/user_guide/Templates.html:

import param
import pathlib
from panel.template import BootstrapTemplate
from panel.template.theme import DefaultTheme, Theme

class BootstrapAcfTheme(DefaultTheme):
     # To repro the issue, the css provided here should not be in the BUNDLE_DIR
    css = param.Filename(default=pathlib.Path(__file__).parent / 'bootstrap-acf.css')
    _template = BootstrapTemplate

#Providing my own theme to the BootstrapTemplate
bootstrap_theme = BootstrapTemplate(title='Autocorrelation function', theme=BootstrapAcfTheme)
bootstrap_theme.show()

Upon rendering the page, the {{ raw_css }} tag from the template is replaced by the base_css instead of the content of bootstrap-acf.css. The served web page contains the following snippet, which comes from \panel\template\theme\default.css

...
<style type="text/css">
#header {
  background-color: #00aa41;
}
</style>

Code

This issue seems to be due to a cut and paste error. Line 620 uses theme.base_css, I am quite certain that it should use theme.css instead. Line 620 is an exact copy of line 613.

if theme.css:
basename = os.path.basename(theme.css)
if (BUNDLE_DIR / name / basename).is_file():
css_files['theme'] = dist_path + f'bundled/{name}/{basename}'
else:
with open(theme.base_css, encoding='utf-8') as f:
raw_css.append(f.read())

I'll provide a PR that corrects this.

@philippjfr philippjfr added this to the v0.13.0 milestone Jan 3, 2022
@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants