{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from awesome_panel_extensions.awesome_panel.notebook import Header\n", "Header(folder=\"examples/reference/frameworks/fast\", notebook=\"FastButton.ipynb\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Fast Button - Reference Guide\n", "\n", "The `FastButton` widget is based on the [fast-button](https://explore.fast.design/components/fast-button) web component and extends the built in [Panel Button](https://panel.holoviz.org/reference/widgets/Button.html).\n", "\n", "\n", " \n", " \n", " \n", "
\n", "\n", "\n", "#### Parameters:\n", "\n", "* **``name``** (str): The label of the Button\n", "* **``button_type``** (str): A button theme. One of `default`, `primary`, `success`, `info` or `danger`.\n", "\n", "* **``apperance``** (string): Determines the appearance of the button. One of `accent`, `lightweight`, `neutral`, `outline` or `stealth`. Defaults to `neutral`.\n", "* **``autofocus``** (bool): The autofocus attribute. Defaults to `False`.\n", "\n", "* **``clicks``** (int): The number of times the `FastButton` has been clicked.\n", "\n", "The `FastButton` has the same layout and styling parameters as most other widgets. For example `width` and `sizing_mode`.\n", "\n", "Please note that you can only use the Fast components inside a custom Panel template that\n", "\n", "- Loads the [Fast `javascript` library](https://www.fast.design/docs/components/getting-started#from-cdn).\n", "- Wraps the content of the `` html tag inside the [fast-design-system-provider](https://www.fast.design/docs/components/getting-started#add-components) tag.\n", "\n", "We provide the `FastTemplate` for easy usage. \n", "\n", "You can also develop your own custom [Panel template](https://panel.holoviz.org/user_guide/Templates.html) if you need something special. For example combining it with more [fast.design](https://fast.design/) web components and the [Fluent Design System](https://www.microsoft.com/design/fluent/#/) to create **VS Code** and **Microsoft Office** like experiences.\n", "\n", "Please note that Fast components will not work in older, legacy browser like Internet Explorer.\n", "\n", "___\n", "\n", "Let's start by importing the dependencies" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import param\n", "import panel as pn\n", "from awesome_panel_extensions.frameworks.fast import FastTemplate, FastButton\n", "\n", "pn.config.sizing_mode = \"stretch_width\"\n", "pn.extension()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Parameters\n", "\n", "Let's explore the parameters of the `FastButton`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "button = FastButton(name=\"Click me\", sizing_mode=\"fixed\", width=200, appearance=\"accent\")\n", "\n", "button_parameters = [\"name\", \"button_type\", \"disabled\", \"appearance\", \"autofocus\", \"clicks\", \"width\", \"height\", \"sizing_mode\"]\n", "\n", "app=pn.Row(\n", " button\n", ")\n", "template=FastTemplate(main=[app])\n", "template" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "settings_pane = pn.WidgetBox(pn.Param(button, parameters=button_parameters, show_name=False))\n", "settings_pane" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## pn.Param\n", "\n", "Let's verify that that `FastButton` can be used as a widget by `pn.Param`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "WIDGETS = {\n", " \"click_me\": {\n", " \"type\": FastButton, \"appearance\": \"accent\", \"sizing_mode\": \"fixed\", \"width\": 200\n", " }\n", "}\n", "\n", "class ParameterizedApp(param.Parameterized):\n", " click_me = param.Action()\n", " clicks = param.Integer(default=0)\n", " view = param.Parameter()\n", " \n", " \n", " def __init__(self, **params):\n", " super().__init__(**params)\n", " \n", " self.view = pn.Param(self, parameters=[\"click_me\", \"clicks\"], widgets=WIDGETS)\n", " self.click_me = self._click_me\n", " \n", " def _click_me(self,*events):\n", " self.clicks+=1\n", " \n", "parameterized_app = ParameterizedApp()\n", "paremeterized_template = FastTemplate(main=[parameterized_app.view])\n", "paremeterized_template" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Resources\n", "\n", "- [fast.design](https://fast.design/)\n", "- [fast-button](https://explore.fast.design/components/fast-button)\n", "\n", "## Known Issues\n", "\n", "- None so far.\n", "\n", "\n", " \n", " \n", " \n", "
\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }