Name | schorle JSON |
Version |
0.0.25
JSON |
| download |
home_page | None |
Summary | Server-driven UI kit for Python with async support |
upload_time | 2024-04-26 20:23:08 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | None |
keywords |
async
python
server-driven-ui
ui
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<p align="center">
<img src="https://raw.githubusercontent.com/renardeinside/schorle/main/raw/with_text.svg" class="align-center" height="150" alt="logo" />
</p>
**`Schorle` (pronounced as [ˈʃɔʁlə](https://en.wikipedia.org/wiki/Schorle)) is a server-driven UI kit for Python with
async support.**
---
<p align="center">
<a href="https://pypi.org/project/schorle/" style="text-decoration: none">
<img src="https://img.shields.io/pypi/v/schorle?color=green&style=for-the-badge" alt="Latest Python Release"/>
</a>
<img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge" alt="We use black for formatting"/>
<a href="https://codecov.io/gh/renardeinside/schorle" style="text-decoration: none">
<img src="https://img.shields.io/codecov/c/gh/renardeinside/schorle?style=for-the-badge"
alt="codecov"/>
</a>
</p>
---
**Note:** This project is in an early stage of development. It is not ready for production use.
## Installation
```bash
pip install schorle
```
## Usage
Take a look at the [examples](examples) directory.
## Concepts
We use the following approaches to handle various cases:
- Rendering HTML elements is done using Python functions.
### Elements
In contrast to using templating engines, Schorle uses Python functions to create HTML elements.
This approach allows for better type checking and code completion.
```python
from schorle.text import text
from schorle.element import div
from schorle.rendering_context import rendering_context
def my_element():
with div():
text("Hey!")
with rendering_context() as ctx:
my_element()
print(ctx.to_lxml())
```
Although this might seem a bit complicated, in actual applications it works nicely when Elements are used inside the
Components.
## Components
Components are reusable parts of the UI. They are created using Python classes.
```python
from schorle.component import Component
from schorle.element import div
from schorle.text import text
class MyComponent(Component):
def render(self):
with div():
text("Hey!")
print(
MyComponent().to_string()
)
```
Note that the `render` method is used to define the structure of the component.
Since `render` is a method, you can use all the power of Python to create dynamic components, like this:
```python
from schorle.component import Component
from schorle.element import div, span
from schorle.text import text
class MyComponent(Component):
def render(self):
with div():
for idx in range(10):
with span():
text("Hey!") if idx % 2 == 0 else text("Ho!")
```
Pretty much any Python code can be used to create the structure of the component.
## Running the application
Schorle application is a thin wrapper around [FastAPI](https://fastapi.tiangolo.com/). To run the application,
use `uvicorn`:
```bash
uvicorn examples.static:app --reload
```
Under the hood, Schorle uses FastAPI, so you can use all the features provided by FastAPI.
To access the FastAPI application instance, use the `backend` attribute:
```python
from schorle.app import Schorle
app = Schorle()
app.backend.add_middleware(...) # add FastAPI middleware
```
## Dev reload
`Schorle` supports dev reload out of the box. To enable it, use the `--reload` flag:
```bash
uvicorn examples.todo:app --reload
```
On any change in the code, the server will restart automatically, and the client will re-fetch the page.
## Tech stack
On the backend:
- [FastAPI](https://fastapi.tiangolo.com/) - web framework
- [Pydantic](https://docs.pydantic.dev/latest/) - classes and utilities for elements
On the frontend:
- [Tailwind CSS](https://tailwindcss.com/) - CSS framework
- [DaisyUI](https://daisyui.com/) - Component library for Tailwind CSS
- [Lucide Icons](https://lucide.dev/) - Icon library
## Optimizing the site performance
`Schorle` has several features to optimize the site performance:
- Client-server communications are happening over WebSockets and inside a Worker
- CSS/JS libraries are served as brotli-compressed files
## Roadmap
- [x] Add dev reload
- [x] Add server communication channel
- [ ] Add state (global)
- [x] Add state at component level
- [ ] Add more elements
- [x] Add support for icons
- [ ] Add convenient attributes API
- [ ] Add more examples
- [ ] Add tests
- [ ] Add CI/CD
- [ ] Add documentation
- [ ] Add support for Plotly-based charts
- [ ] Add support for Vega-based charts
- [ ] Refactor the imports
Raw data
{
"_id": null,
"home_page": null,
"name": "schorle",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "async, python, server-driven-ui, ui",
"author": null,
"author_email": "renardeinside <polarpersonal@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/0f/da/9072f04b56a07a85df0f4f6e132d3dad67a3e958db6ba720adddddcb64a3/schorle-0.0.25.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/renardeinside/schorle/main/raw/with_text.svg\" class=\"align-center\" height=\"150\" alt=\"logo\" />\n</p>\n\n**`Schorle` (pronounced as [\u02c8\u0283\u0254\u0281l\u0259](https://en.wikipedia.org/wiki/Schorle)) is a server-driven UI kit for Python with\nasync support.**\n\n---\n\n<p align=\"center\">\n <a href=\"https://pypi.org/project/schorle/\" style=\"text-decoration: none\">\n <img src=\"https://img.shields.io/pypi/v/schorle?color=green&style=for-the-badge\" alt=\"Latest Python Release\"/>\n </a>\n <img src=\"https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge\" alt=\"We use black for formatting\"/>\n <a href=\"https://codecov.io/gh/renardeinside/schorle\" style=\"text-decoration: none\">\n <img src=\"https://img.shields.io/codecov/c/gh/renardeinside/schorle?style=for-the-badge\"\n alt=\"codecov\"/>\n </a>\n</p>\n\n---\n\n**Note:** This project is in an early stage of development. It is not ready for production use.\n\n## Installation\n\n```bash\npip install schorle\n```\n\n## Usage\n\nTake a look at the [examples](examples) directory.\n\n## Concepts\n\nWe use the following approaches to handle various cases:\n\n- Rendering HTML elements is done using Python functions.\n\n### Elements\n\nIn contrast to using templating engines, Schorle uses Python functions to create HTML elements.\nThis approach allows for better type checking and code completion.\n\n```python\nfrom schorle.text import text\nfrom schorle.element import div\nfrom schorle.rendering_context import rendering_context\n\n\ndef my_element():\n with div():\n text(\"Hey!\")\n\n\nwith rendering_context() as ctx:\n my_element()\n print(ctx.to_lxml())\n```\n\nAlthough this might seem a bit complicated, in actual applications it works nicely when Elements are used inside the\nComponents.\n\n## Components\n\nComponents are reusable parts of the UI. They are created using Python classes.\n\n```python\n\nfrom schorle.component import Component\nfrom schorle.element import div\nfrom schorle.text import text\n\n\nclass MyComponent(Component):\n def render(self):\n with div():\n text(\"Hey!\")\n\n\nprint(\n MyComponent().to_string()\n)\n```\n\nNote that the `render` method is used to define the structure of the component.\n\nSince `render` is a method, you can use all the power of Python to create dynamic components, like this:\n\n```python\n\nfrom schorle.component import Component\nfrom schorle.element import div, span\nfrom schorle.text import text\n\n\nclass MyComponent(Component):\n def render(self):\n with div():\n for idx in range(10):\n with span():\n text(\"Hey!\") if idx % 2 == 0 else text(\"Ho!\")\n```\n\nPretty much any Python code can be used to create the structure of the component.\n\n## Running the application\n\nSchorle application is a thin wrapper around [FastAPI](https://fastapi.tiangolo.com/). To run the application,\nuse `uvicorn`:\n\n```bash\nuvicorn examples.static:app --reload\n```\n\nUnder the hood, Schorle uses FastAPI, so you can use all the features provided by FastAPI.\nTo access the FastAPI application instance, use the `backend` attribute:\n\n```python\nfrom schorle.app import Schorle\n\napp = Schorle()\n\napp.backend.add_middleware(...) # add FastAPI middleware\n```\n\n## Dev reload\n\n`Schorle` supports dev reload out of the box. To enable it, use the `--reload` flag:\n\n```bash\nuvicorn examples.todo:app --reload\n```\n\nOn any change in the code, the server will restart automatically, and the client will re-fetch the page.\n\n## Tech stack\n\nOn the backend:\n- [FastAPI](https://fastapi.tiangolo.com/) - web framework\n- [Pydantic](https://docs.pydantic.dev/latest/) - classes and utilities for elements\n\nOn the frontend:\n- [Tailwind CSS](https://tailwindcss.com/) - CSS framework\n- [DaisyUI](https://daisyui.com/) - Component library for Tailwind CSS\n- [Lucide Icons](https://lucide.dev/) - Icon library\n\n\n## Optimizing the site performance\n\n`Schorle` has several features to optimize the site performance:\n\n- Client-server communications are happening over WebSockets and inside a Worker\n- CSS/JS libraries are served as brotli-compressed files\n\n## Roadmap\n\n- [x] Add dev reload\n- [x] Add server communication channel\n- [ ] Add state (global)\n- [x] Add state at component level\n- [ ] Add more elements\n- [x] Add support for icons\n- [ ] Add convenient attributes API\n- [ ] Add more examples\n- [ ] Add tests\n- [ ] Add CI/CD\n- [ ] Add documentation\n- [ ] Add support for Plotly-based charts\n- [ ] Add support for Vega-based charts\n- [ ] Refactor the imports",
"bugtrack_url": null,
"license": null,
"summary": "Server-driven UI kit for Python with async support",
"version": "0.0.25",
"project_urls": {
"Documentation": "https://github.com/renardeinside/schorle#readme",
"Issues": "https://github.com/renardeinside/schorle/issues",
"Source": "https://github.com/renardeinside/schorle"
},
"split_keywords": [
"async",
" python",
" server-driven-ui",
" ui"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "957439e1a470727f62a190c84101e44bc67ba54270ba5699eedad36b1f0e64e0",
"md5": "2931126d316cc36957dafcb2a2a84219",
"sha256": "8386bac116a2c988b16bcc7e245ad3f9b47a9a49e516dba5f88acd89dfea3e85"
},
"downloads": -1,
"filename": "schorle-0.0.25-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2931126d316cc36957dafcb2a2a84219",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 666298,
"upload_time": "2024-04-26T20:23:07",
"upload_time_iso_8601": "2024-04-26T20:23:07.230330Z",
"url": "https://files.pythonhosted.org/packages/95/74/39e1a470727f62a190c84101e44bc67ba54270ba5699eedad36b1f0e64e0/schorle-0.0.25-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0fda9072f04b56a07a85df0f4f6e132d3dad67a3e958db6ba720adddddcb64a3",
"md5": "04a3f871d21eebb1272609d136a58108",
"sha256": "99d7971fdf372e707d97418e107c607ef64e4aa09a04363c2111d95209e369fd"
},
"downloads": -1,
"filename": "schorle-0.0.25.tar.gz",
"has_sig": false,
"md5_digest": "04a3f871d21eebb1272609d136a58108",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 154229,
"upload_time": "2024-04-26T20:23:08",
"upload_time_iso_8601": "2024-04-26T20:23:08.809007Z",
"url": "https://files.pythonhosted.org/packages/0f/da/9072f04b56a07a85df0f4f6e132d3dad67a3e958db6ba720adddddcb64a3/schorle-0.0.25.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-26 20:23:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "renardeinside",
"github_project": "schorle#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "schorle"
}