# pylint: disable=redefined-outer-name,protected-access # pylint: disable=missing-function-docstring,missing-module-docstring,missing-class-docstring import holoviews as hv import numpy as np from bokeh.document import Document from holoviews import opts from panel.config import config from panel.layout import Column from panel.pane import HoloViews, HTML, Markdown from panel.param import Param from panel.template.fast.grid import FastGridTemplate, FastGridDarkTheme from panel.widgets import Button hv.extension("bokeh") ACCENT_COLOR = "#f63366" # "lightblue" opts.defaults(opts.Ellipse(line_width=3, color=ACCENT_COLOR)) def test_template_theme_parameter(): template = FastGridTemplate(title="Fast", theme="dark") # Not '#3f3f3f' which is for the Vanilla theme doc = template.server_doc(Document()) assert doc.theme._json['attrs']['Figure']['background_fill_color']=="#181818" assert isinstance(template._get_theme(), FastGridDarkTheme) COLLAPSED_ICON = """ """ # noqa EXPANDED_ICON = """ """ # noqa NAVIGATION_HTML = f""" Home Gallery Awesome List About

Main

{ COLLAPSED_ICON }{ EXPANDED_ICON }

Share on Social

Star on Github Share on Twitter Share on LinkedIn Share on Reddit Share on Facebook Share by mail { COLLAPSED_ICON }{ EXPANDED_ICON }
""" # noqa INFO = """ ## The adaptive interface system for modern web experiences. Interfaces built with FAST adapt to your design system and can be used with any modern UI Framework by leveraging industry standard Web Components. Checkout the Component Gallery. ### Panel and Fast You can now use Fast with the HoloViz Panel framework. This app is based on the *`FastGridTemplate`* and the *Fast Components* provided by the awesome-panel-extensions package. You can use it via `pip install awesome-panel-extensions` and `from awesome_panel_extensions.frameworks import fast`. """ # noqa def _create_hvplot(): # Generate some data cl1 = np.random.normal(loc=2, scale=0.2, size=(200, 200)) cl2x = np.random.normal(loc=-2, scale=0.6, size=200) cl2y = np.random.normal(loc=-2, scale=0.1, size=200) cl3 = np.random.normal(loc=0, scale=1.5, size=(400, 400)) # Create an overlay of points and ellipses clusters = ( hv.Points(cl1).opts(color="blue") * hv.Points((cl2x, cl2y)).opts(color="green") * hv.Points(cl3).opts(color="#FDDC22") ) plot = clusters * hv.Ellipse(2, 2, 2) * hv.Ellipse(-2, -2, (4, 2)) return plot def _navigation_menu(): return HTML(NAVIGATION_HTML) def _sidebar_items(): return [ Markdown("## Settings"), _navigation_menu(), ] def _fast_button_card(): button = Button(name="Click me", button_type="primary") button.param.name.precedence = 0 button.param.clicks.precedence = 0 button.param.disabled.precedence = 0 button.param.button_type.precedence = 0 button_parameters = [ "name", "button_type", "clicks", "disabled", "width", "height", "sizing_mode", ] settings = Param( button, parameters=button_parameters, show_name=False, sizing_mode="stretch_width", ) return Column( HTML("

Button

"), button, HTML("

Parameters

"), settings, sizing_mode="stretch_both", ) def test_app(): app = FastGridTemplate( title="FastGridTemplate w. Layout Persistence", site="Panel", accent_base_color=ACCENT_COLOR, header_background=ACCENT_COLOR, # header_color="#000000", header_accent_base_color="#FFFFFF", row_height=50, prevent_collision=True, # main_layout="", save_layout=True, ) app.main[0:7, 0:6] = Markdown(INFO, sizing_mode="stretch_both") app.main[0:7, 6:12] = HoloViews(_create_hvplot(), sizing_mode="stretch_both") app.main[7:18, 0:6] = _fast_button_card() app.main[7:14, 6:12] = HoloViews(_create_hvplot(), sizing_mode="stretch_both") app.sidebar.extend(_sidebar_items()) return app if __name__.startswith("bokeh"): config.sizing_mode = "stretch_width" test_app().servable()