Skip to content

Commit dad8df0

Browse files
committed
inital comment
0 parents  commit dad8df0

37 files changed

+4728
-0
lines changed

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
*.pyc
2+
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
share/python-wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
MANIFEST
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.nox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
*.py,cover
52+
.hypothesis/
53+
.pytest_cache/
54+
cover/
55+
56+
# Translations
57+
# *.mo Needs to come with the package
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
db.sqlite3-journal
65+
66+
# Flask stuff:
67+
instance/
68+
.webassets-cache
69+
70+
# Scrapy stuff:
71+
.scrapy
72+
73+
# Sphinx documentation
74+
docs/_build/
75+
76+
# PyBuilder
77+
.pybuilder/
78+
target/
79+
80+
# Jupyter Notebook
81+
.ipynb_checkpoints
82+
83+
# IPython
84+
profile_default/
85+
ipython_config.py
86+
87+
# pyenv
88+
# For a library or package, you might want to ignore these files since the code is
89+
# intended to run in multiple environments; otherwise, check them in:
90+
.python-version
91+
92+
# pipenv
93+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96+
# install all needed dependencies.
97+
#Pipfile.lock
98+
99+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
100+
__pypackages__/
101+
102+
# Celery stuff
103+
celerybeat-schedule
104+
celerybeat.pid
105+
106+
# SageMath parsed files
107+
*.sage.py
108+
109+
# Environments
110+
.env
111+
.venv
112+
.vscode
113+
.mypy_cache
114+
.coverage
115+
htmlcov
116+
117+
dist
118+
test.py
119+
120+
docs/site
121+
122+
.DS_Store
123+
.idea
124+
local_install.sh
125+
dist
126+
test.py
127+
128+
docs/site
129+
site/

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.PHONY: help docs
2+
.DEFAULT_GOAL := help
3+
4+
help:
5+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6+
7+
clean: ## Removing cached python compiled files
8+
find . -name \*pyc | xargs rm -fv
9+
find . -name \*pyo | xargs rm -fv
10+
find . -name \*~ | xargs rm -fv
11+
find . -name __pycache__ | xargs rm -rfv
12+
find . -name .pytest_cache | xargs rm -rfv
13+
find . -name .ruff_cache | xargs rm -rfv
14+
find . -name .mypy_cache | xargs rm -rfv
15+
16+
install: ## Install dependencies
17+
pip install -r requirements.txt
18+
flit install --symlink
19+
20+
install-full: ## Install dependencies
21+
make install
22+
pre-commit install -f
23+
24+
lint:fmt ## Run code linters
25+
ruff check py_html tests
26+
#mypy ellar_sql_admin
27+
28+
fmt format:clean ## Run code formatters
29+
ruff format py_html
30+
ruff check --fix py_html
31+
32+
test:clean ## Run tests
33+
pytest
34+
35+
test-cov:clean ## Run tests with coverage
36+
pytest --cov=py_html --cov-report term-missing
37+
38+
pre-commit-lint: ## Runs Requires commands during pre-commit
39+
make clean
40+
make fmt
41+
make lint
42+
43+
doc-deploy:clean ## Run Deploy Documentation
44+
mkdocs gh-deploy --force --ignore-version
45+
46+
doc-serve: ## Launch doc local server
47+
mkdocs serve

README.md

Whitespace-only changes.

bootstrap_exercise.py

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
from py_html.el.base import render_component
2+
from starlette.responses import HTMLResponse
3+
4+
from ellar.common.responses.models import HTMLResponseModel
5+
6+
from ellar.common import ModuleRouter
7+
8+
from ellar.app import AppFactory
9+
from ellar_cli.main import create_ellar_cli
10+
11+
from py_html.contrib.bootstrap.icon import BIcon
12+
13+
from py_html.contrib.bootstrap.avatar import BAvatar, BAvatarGroup
14+
15+
from py_html.contrib.bootstrap.layout_grid_system import BContainer, BRow, BCol
16+
17+
from py_html.styles import StyleCSS
18+
import py_html.el as el
19+
20+
router = ModuleRouter("/example")
21+
22+
@router.get("/", response=HTMLResponse)
23+
def template():
24+
content = el.Html(
25+
content=(
26+
el.Head(
27+
content=lambda ctx: el.Fragment(
28+
el.Title(page_title="Bootstrap Example"),
29+
el.Meta(charset="utf-8"),
30+
el.Meta(name="viewport", content="width=device-width, initial-scale=1"),
31+
# Latest compiled and minified CSS
32+
el.Link(
33+
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css",
34+
rel="stylesheet"
35+
),
36+
el.Link(
37+
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css",
38+
rel="stylesheet"
39+
),
40+
# Latest compiled JavaScript
41+
el.Script(
42+
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
43+
),
44+
*(ctx.get('root_styles', []))
45+
)
46+
),
47+
el.Body(
48+
content=lambda ctx: el.Fragment(
49+
"""
50+
<div class="container-fluid">
51+
<h1>My First Bootstrap Page</h1>
52+
<p>This is some text.</p>
53+
</div>
54+
""",
55+
BContainer(
56+
fluid=True,
57+
content=(
58+
el.H1(content="My First Bootstrap Page"),
59+
el.P(content="This is some text."),
60+
)
61+
),
62+
BContainer(
63+
class_name="p-5 my-5 border",
64+
content=(
65+
el.H1(content="My First Bootstrap Page"),
66+
el.P(content="This is some text."),
67+
)
68+
),
69+
BContainer(
70+
class_name="p-5 my-5 bg-dark text-white",
71+
content=(
72+
el.H1(content="My First Bootstrap Page"),
73+
el.P(content="This is some text."),
74+
)
75+
),
76+
BContainer(
77+
class_name="p-5 my-5 bg-primary text-white",
78+
content=(
79+
el.H1(content="My First Bootstrap Page"),
80+
el.P(content="This is some text.")
81+
)
82+
),
83+
BContainer(
84+
class_name=f"p-5 my-5 border",
85+
content=(
86+
el.H1(content="Avatars Examples"),
87+
el.Div(class_name="mt-2", content=(
88+
BAvatar(text="Foo", class_name="mx-2", size="72px"),
89+
BAvatar(icon="people-fill", class_name="mx-2", size="72px"),
90+
BAvatar(
91+
icon="people-fill",
92+
class_name="mx-2",
93+
size="45px",
94+
badge='100',
95+
variant="primary",
96+
badge_variant="dark"
97+
),
98+
BAvatar(
99+
icon="people-fill",
100+
class_name="mx-2",
101+
size="45px",
102+
badge=BIcon(icon_name="exclamation-circle-fill",variant="warning"),
103+
variant="danger",
104+
badge_variant="danger",
105+
badge_position="bottom-left"
106+
),
107+
)),
108+
el.Hr(),
109+
el.H1(content="Avatars Group Examples"),
110+
el.Div(class_name="mt-2", content=(
111+
BAvatarGroup(
112+
size="4rem",
113+
over_lap=0.2,
114+
content=(
115+
BAvatar(text="Foo", size="72px"),
116+
BAvatar(icon="people-fill", size="72px"),
117+
BAvatar(
118+
icon="people-fill",
119+
size="45px",
120+
badge='100',
121+
variant="primary",
122+
badge_variant="dark"
123+
),
124+
BAvatar(
125+
icon="people-fill",
126+
size="45px",
127+
badge=BIcon(icon_name="exclamation-circle-fill", variant="warning"),
128+
variant="danger",
129+
badge_variant="danger",
130+
badge_position="bottom-left"
131+
),
132+
)
133+
)
134+
)),
135+
136+
)
137+
),
138+
BContainer(
139+
class_name="p-5 my-5 border",
140+
content=el.Div(
141+
class_name="h2 mb-0",
142+
content=(
143+
BIcon(icon_name="exclamation-circle-fill", class_name="mx-1", variant="success"),
144+
BIcon(icon_name="exclamation-circle-fill", class_name="mx-1",variant="warning"),
145+
BIcon(icon_name="exclamation-circle-fill", class_name="mx-1",variant="info"),
146+
BIcon(icon_name="exclamation-circle-fill", class_name="mx-1",variant="danger"),
147+
BIcon(icon_name="exclamation-circle-fill", class_name="mx-1",variant="primary"),
148+
BIcon(icon_name="exclamation-circle-fill", class_name="mx-1",variant="secondary"),
149+
BIcon(icon_name="exclamation-circle", class_name="mx-1 bg-info",variant="dark",),
150+
BIcon(icon_name="bell-fill", class_name="border rounded p-2 mx-1", variant="dark"),
151+
)
152+
)
153+
),
154+
el.Fragment(ctx.get('root_styles', [])),
155+
BContainer(
156+
class_name="p-5 my-5 bg-primary text-white",
157+
content=el.Fragment(
158+
BRow(
159+
class_name="justify-content-md-center",
160+
content=[
161+
BCol(col=True, lg=2, content="1 of 3", style=StyleCSS(background_color="red")),
162+
BCol(cols="12", md="auto", content="Variable width content",
163+
style=StyleCSS(background_color="yellow")),
164+
BCol(col=True, lg=2, content="Variable width content",
165+
style=StyleCSS(background_color="pink")),
166+
]
167+
),
168+
BRow(
169+
content=[
170+
BCol(content="1 of 3", style=StyleCSS(background_color="orange")),
171+
BCol(cols="12", md="auto", content="Variable width content",
172+
style=StyleCSS(background_color="gray")),
173+
BCol(col=True, lg=2, content="Variable width content",
174+
style=StyleCSS(background_color="smoke")),
175+
]
176+
)
177+
)
178+
),
179+
)
180+
)
181+
)
182+
)
183+
184+
return render_component(content, {})
185+
186+
def bootstrap():
187+
application = AppFactory.create_app(routers=[router])
188+
return application
189+
190+
191+
cli = create_ellar_cli("bootstrap_exercise:bootstrap")
192+
193+
194+
if __name__ == "__main__":
195+
cli()

py_html/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""PyHTML"""
2+
3+
__version__ = "0.1a1"

py_html/contrib/__init__.py

Whitespace-only changes.

py_html/contrib/bootstrap/__init__.py

Whitespace-only changes.

py_html/contrib/bootstrap/_types.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import typing as t
2+
3+
BVariants = t.Literal[
4+
"primary",
5+
"secondary",
6+
"success",
7+
"danger",
8+
"warning",
9+
"info",
10+
"light",
11+
"dark",
12+
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy