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

Fix sidebar width issues and make it customizable #2301

Merged
merged 9 commits into from
May 14, 2021
Merged

Conversation

MarcSkovMadsen
Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen commented May 9, 2021

Fixes #2223

The problem is that the sidebar width does not match the default fixed width of buttons and dropdowns. Furthermore users are also requesting the ability to configure the sidebar width. The problem is shown below.

image

@MarcSkovMadsen
Copy link
Collaborator Author

I have added a sidebar_width parameter to all templates and set to the default to somewhere between 300px and 370px depending on the template. I've fixed a few other css issues along the way.

The functionality can be tested via

from panel import param
import panel as pn

def template_with_sidebar(Template=pn.template.FastListTemplate, sidebar=True):
    button = pn.widgets.Button(name="Click Me")
    select = pn.widgets.Select(name="Select", value=1, options=[1,2,3,4,5])
    if sidebar:
        title = Template.name + " Sidebar Width Test"
    else:
        title = Template.name + " No Sidebar Width Test"
    template = Template(
        site="Home",
        title=title,
        main=["Hello"]
        )
    if sidebar:
        template.sidebar[:]=[button, select, pn.Param(select)]
    return template

def template_without_sidebar(Template=pn.template.FastListTemplate):
    return Template(
        title="No Sidebar Width Test",
        main=["Hello"]
        )

apps = {
    "vanilla-template": template_with_sidebar(Template=pn.template.VanillaTemplate),
    "vanilla-template-no-sidebar": template_with_sidebar(Template=pn.template.VanillaTemplate, sidebar=False),
    "material-template": template_with_sidebar(Template=pn.template.MaterialTemplate),
    "material-template-no-sidebar": template_with_sidebar(Template=pn.template.MaterialTemplate, sidebar=False),
    "bootstrap-template": template_with_sidebar(Template=pn.template.BootstrapTemplate),
    "bootstrap-template-no-sidebar": template_with_sidebar(Template=pn.template.BootstrapTemplate, sidebar=False),
    "react-template": template_with_sidebar(Template=pn.template.ReactTemplate),
    "react-template-no-sidebar": template_with_sidebar(Template=pn.template.ReactTemplate, sidebar=False),
    "fast-list-template": template_with_sidebar(Template=pn.template.FastListTemplate),
    "fast-list-template-no-sidebar": template_with_sidebar(Template=pn.template.FastListTemplate, sidebar=False),
    "fast-grid-template": template_with_sidebar(Template=pn.template.FastGridTemplate),
    "fast-grid-template-no-sidebar": template_with_sidebar(Template=pn.template.FastGridTemplate, sidebar=False),
}

if __name__.startswith("bokeh"):
    template = "react"
    apps[template + "-template"].servable()
if __name__=="__main__":
    pn.serve(apps)
sidebar_width_test.mp4

@MarcSkovMadsen
Copy link
Collaborator Author

Only outstanding thing to do is to document it across notebooks.

@codecov
Copy link

codecov bot commented May 9, 2021

Codecov Report

Merging #2301 (d9557c8) into master (b90cf0e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2301   +/-   ##
=======================================
  Coverage   84.02%   84.03%           
=======================================
  Files         181      181           
  Lines       21940    21946    +6     
=======================================
+ Hits        18436    18442    +6     
  Misses       3504     3504           
Impacted Files Coverage Δ
panel/template/base.py 79.13% <100.00%> (+0.09%) ⬆️
panel/template/bootstrap/__init__.py 100.00% <100.00%> (ø)
panel/template/golden/__init__.py 90.00% <100.00%> (+0.52%) ⬆️
panel/template/material/__init__.py 100.00% <100.00%> (ø)
panel/template/react/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b90cf0e...d9557c8. Read the comment docs.

@jbednar
Copy link
Member

jbednar commented May 9, 2021

Thanks! Very useful!

@MarcSkovMadsen MarcSkovMadsen changed the title Fix sidebar width issues and make is customizable Fix sidebar width issues and make it customizable May 14, 2021
@MarcSkovMadsen MarcSkovMadsen added this to the v0.11.4 milestone May 14, 2021
@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented May 14, 2021

I have now documented and also implemented the GoldenTemplate. I believe this is ready.

When you have time @philippjfr . Please review and let me know if there is more to do. Thanks.

@philippjfr
Copy link
Member

Happy with this, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make default width of sidebar match default width of components
3 participants