eidosui 0.1.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eidos/__init__.py +0 -57
- eidos/components/headers.py +68 -0
- eidos/components/navigation.py +78 -0
- eidos/css/styles.css +430 -0
- eidos/css/themes/dark.css +119 -0
- eidos/css/themes/eidos-variables.css +190 -0
- eidos/css/themes/light.css +80 -0
- eidos/js/eidos.js +112 -0
- eidos/plugins/__init__.py +1 -0
- eidos/plugins/markdown/__init__.py +21 -0
- eidos/plugins/markdown/components.py +53 -0
- eidos/plugins/markdown/css/markdown.css +283 -0
- eidos/plugins/markdown/extensions/__init__.py +1 -0
- eidos/plugins/markdown/extensions/alerts.py +134 -0
- eidos/plugins/markdown/renderer.py +58 -0
- eidos/styles.py +80 -0
- eidos/tags.py +99 -0
- eidos/utils.py +72 -0
- eidosui-0.3.0.dist-info/METADATA +127 -0
- eidosui-0.3.0.dist-info/RECORD +22 -0
- eidosui-0.3.0.dist-info/licenses/LICENSE +21 -0
- eidos/components/__init__.py +0 -22
- eidos/components/forms.py +0 -57
- eidos/components/typography.py +0 -85
- eidos/core/__init__.py +0 -25
- eidos/core/helpers.py +0 -87
- eidos/core/styles.py +0 -92
- eidos/core/utils.py +0 -46
- eidos/static/eidos-ui.js +0 -74
- eidos/themes/dark.css +0 -52
- eidos/themes/light.css +0 -110
- eidosui-0.1.0.dist-info/METADATA +0 -61
- eidosui-0.1.0.dist-info/RECORD +0 -14
- {eidosui-0.1.0.dist-info → eidosui-0.3.0.dist-info}/WHEEL +0 -0
eidos/utils.py
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
"""Core utility functions for EidosUI."""
|
2
|
+
|
3
|
+
from typing import Optional, Union, List
|
4
|
+
import os
|
5
|
+
import sys
|
6
|
+
|
7
|
+
|
8
|
+
def stringify(*classes: Optional[Union[str, List[str]]]) -> str:
|
9
|
+
"""
|
10
|
+
Concatenate CSS classes, filtering out None values and flattening lists.
|
11
|
+
|
12
|
+
Args:
|
13
|
+
*classes: Variable number of class strings, lists of strings, or None values
|
14
|
+
|
15
|
+
Returns:
|
16
|
+
A single space-separated string of CSS classes
|
17
|
+
|
18
|
+
Examples:
|
19
|
+
>>> stringify("btn", "btn-primary")
|
20
|
+
"btn btn-primary"
|
21
|
+
|
22
|
+
>>> stringify("btn", None, "btn-lg")
|
23
|
+
"btn btn-lg"
|
24
|
+
|
25
|
+
>>> stringify(["btn", "btn-primary"], "mt-4")
|
26
|
+
"btn btn-primary mt-4"
|
27
|
+
"""
|
28
|
+
result = []
|
29
|
+
|
30
|
+
for class_ in classes:
|
31
|
+
if class_ is None:
|
32
|
+
continue
|
33
|
+
elif isinstance(class_, list):
|
34
|
+
# Recursively handle lists
|
35
|
+
result.extend(c for c in class_ if c)
|
36
|
+
elif isinstance(class_, str) and class_.strip():
|
37
|
+
result.append(class_.strip())
|
38
|
+
|
39
|
+
return " ".join(result)
|
40
|
+
|
41
|
+
|
42
|
+
def get_eidos_static_directory() -> str:
|
43
|
+
"""
|
44
|
+
Get the path to eidos static files for mounting in FastAPI/Air apps.
|
45
|
+
|
46
|
+
This function returns the directory containing the eidos package files,
|
47
|
+
which includes the CSS directory. Use this when mounting static files
|
48
|
+
in your application.
|
49
|
+
|
50
|
+
Returns:
|
51
|
+
The absolute path to the eidos package directory
|
52
|
+
|
53
|
+
Example:
|
54
|
+
>>> from fastapi.staticfiles import StaticFiles
|
55
|
+
>>> from eidos.utils import get_eidos_static_directory
|
56
|
+
>>> app.mount("/eidos", StaticFiles(directory=get_eidos_static_directory()), name="eidos")
|
57
|
+
"""
|
58
|
+
try:
|
59
|
+
from importlib.resources import files
|
60
|
+
import pathlib
|
61
|
+
# Convert MultiplexedPath to actual filesystem path
|
62
|
+
eidos_path = files('eidos')
|
63
|
+
if hasattr(eidos_path, '_paths'):
|
64
|
+
# MultiplexedPath - get the first valid path
|
65
|
+
for path in eidos_path._paths:
|
66
|
+
if isinstance(path, pathlib.Path) and path.exists():
|
67
|
+
return str(path)
|
68
|
+
# Try to get the path directly
|
69
|
+
return str(eidos_path)
|
70
|
+
except (ImportError, AttributeError):
|
71
|
+
# Fallback for development or if importlib.resources fails
|
72
|
+
return os.path.dirname(os.path.abspath(__file__))
|
@@ -0,0 +1,127 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: eidosui
|
3
|
+
Version: 0.3.0
|
4
|
+
Summary: A modern, Tailwind CSS-based UI library for air development
|
5
|
+
Project-URL: Homepage, https://github.com/isaac-flath/EidosUI
|
6
|
+
Project-URL: Repository, https://github.com/isaac-flath/EidosUI
|
7
|
+
Project-URL: Issues, https://github.com/isaac-flath/EidosUI/issues
|
8
|
+
Project-URL: Documentation, https://github.com/isaac-flath/EidosUI#readme
|
9
|
+
Author: Isaac Flath
|
10
|
+
License-Expression: MIT
|
11
|
+
License-File: LICENSE
|
12
|
+
Keywords: air,components,css,fastapi,tailwind,ui,web
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
14
|
+
Classifier: Intended Audience :: Developers
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
21
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
23
|
+
Requires-Python: >=3.10
|
24
|
+
Requires-Dist: air>=0.12
|
25
|
+
Requires-Dist: fastapi[standard]
|
26
|
+
Requires-Dist: uvicorn
|
27
|
+
Provides-Extra: dev
|
28
|
+
Requires-Dist: black; extra == 'dev'
|
29
|
+
Requires-Dist: isort; extra == 'dev'
|
30
|
+
Requires-Dist: mypy; extra == 'dev'
|
31
|
+
Requires-Dist: pytest; extra == 'dev'
|
32
|
+
Requires-Dist: ruff; extra == 'dev'
|
33
|
+
Provides-Extra: markdown
|
34
|
+
Requires-Dist: markdown>=3.4; extra == 'markdown'
|
35
|
+
Description-Content-Type: text/markdown
|
36
|
+
|
37
|
+
# EidosUI 🎨
|
38
|
+
|
39
|
+
A modern, flexible Tailwind CSS-based UI library for Python web frameworks. Built for maximum developer flexibility while providing excellent defaults.
|
40
|
+
|
41
|
+
> [!CAUTION]
|
42
|
+
> This library is not ready for anything yet. IN fact, this readme is more of design ideas than anything as much of what's in here isn't implemented yet!
|
43
|
+
|
44
|
+
|
45
|
+
## Design
|
46
|
+
|
47
|
+
### Base CSS
|
48
|
+
|
49
|
+
- `styles.css` : defines all the core css logic to create classes like `edios-mark`, `eidos-small`, etc.
|
50
|
+
- `light.css`/`dark.css` : These define lots of css variables used in `styles.css` and are themes
|
51
|
+
|
52
|
+
Users would create a custom theme by copying light/dark css files and changing the variable definitions.
|
53
|
+
|
54
|
+
### Styles
|
55
|
+
|
56
|
+
This has enums that make the Base CSS clases accessible in python. For example:
|
57
|
+
|
58
|
+
`styles.typography.h1` or `styles.buttons.primary`
|
59
|
+
|
60
|
+
### Tags
|
61
|
+
|
62
|
+
```python
|
63
|
+
def H1(*content, cls: str = None, **kwargs) -> air.H1:
|
64
|
+
"""Semantic H1 heading"""
|
65
|
+
return air.H1(*content, cls=stringify(styles.typography.h1, cls), **kwargs)
|
66
|
+
|
67
|
+
def Mark(*content, cls: str = None, **kwargs) -> air.Mark:
|
68
|
+
"""Highlighted text"""
|
69
|
+
return .Mark(*content, cls=stringify(styles.typography.mark, cls), **kwargs)
|
70
|
+
|
71
|
+
def Small(*content, cls: str = , **kwargs) -> air.Small:
|
72
|
+
"""Small text"""
|
73
|
+
return air.Small(*content, cls=stringify(styles.typography.small, cls), **kwargs)
|
74
|
+
```
|
75
|
+
|
76
|
+
### Components (Not Built Yet)
|
77
|
+
|
78
|
+
Theses are things that go beyond just exposing css to python. Here's a simple example of what might be added.
|
79
|
+
|
80
|
+
```python
|
81
|
+
class Table:
|
82
|
+
def __init__(self, cls: str = None, **kwargs):
|
83
|
+
"""Create an empty table with optional styling"""
|
84
|
+
self.cls = cls
|
85
|
+
self.kwargs = kwargs
|
86
|
+
|
87
|
+
@classmethod
|
88
|
+
def from_lists(cls, data: list[list], headers: list[str] = None, cls_: str = None, **kwargs):
|
89
|
+
"""Create table from list of lists"""
|
90
|
+
thead = []
|
91
|
+
if headers:
|
92
|
+
thead = THead(Tr(*[Th(header) for header in headers]))
|
93
|
+
|
94
|
+
tbody_rows = []
|
95
|
+
for data in row_data:
|
96
|
+
tbody_rows.append(Tr(*map(Td, row_data)))
|
97
|
+
tbody = TBody(*tbody_rows)
|
98
|
+
|
99
|
+
return Table(thead+tbody, cls=cls_, **kwargs)
|
100
|
+
|
101
|
+
@classmethod
|
102
|
+
def from_dicts(cls, data: list[dict], headers: list[str] = None, cls_: str = None, **kwargs):
|
103
|
+
"""Create table from list of dictionaries"""
|
104
|
+
thead = []
|
105
|
+
if headers:
|
106
|
+
thead = THead(Tr(*[Th(header) for header in headers]))
|
107
|
+
|
108
|
+
tbody_rows = []
|
109
|
+
for row in data:
|
110
|
+
tbody_rows.append(Tr(*[Td(row.get(header, "")) for header in (headers or list(row.keys()))]))
|
111
|
+
tbody = TBody(*tbody_rows)
|
112
|
+
|
113
|
+
return Table(thead+tbody, cls=cls_, **kwargs)
|
114
|
+
|
115
|
+
# Usage examples:
|
116
|
+
Table.from_lists([["A", "B"], ["C", "D"]], headers=["Col1", "Col2"])
|
117
|
+
Table.from_dicts([{"name": "John", "age": 25}], headers=["Name", "Age"])
|
118
|
+
```
|
119
|
+
|
120
|
+
## Plugins
|
121
|
+
|
122
|
+
### edios-md
|
123
|
+
|
124
|
+
This will be installable with `pip install "eidos[markdown]"`.
|
125
|
+
|
126
|
+
This is a plugin for rendering markdown that is well scoped to just markdown rendering. This module does markdown rendering well with table of contents with scrollspy, code highlighting, latex rendering, etc. It must be used with `EidosUI` as it uses css variables from there for the styling (so it is always in sync with the theme)
|
127
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
eidos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
eidos/styles.py,sha256=QupOwC0VuSZ6zdNJiNFT_PqTnvbJvaNplKO5M5xzMVI,2380
|
3
|
+
eidos/tags.py,sha256=2NidaD6JHDZ9nfSMXFKrG20eNc_u9K0t0t4xPdWJPUE,5966
|
4
|
+
eidos/utils.py,sha256=DUw2a--J2rpZLY7YD3-xtHSmrK0YrnJuPi4rwV41zT8,2345
|
5
|
+
eidos/components/headers.py,sha256=M4SZ_w_ius9cj7uRALo2niAkBz-iLYMVYAX8p556vyo,2005
|
6
|
+
eidos/components/navigation.py,sha256=_8xQxVuZYmOIWk_85pa1L1ECYAXphIxV4iFmolNRwWQ,2515
|
7
|
+
eidos/css/styles.css,sha256=KvrqNpdi7y0felLNhXwgys7cD4mbWjd5EzSqQWxjRgg,9770
|
8
|
+
eidos/css/themes/dark.css,sha256=yUDNz7iLEJ_Q63MrKXlrhYcpojm1L2eNUOthzhYc3Vs,4170
|
9
|
+
eidos/css/themes/eidos-variables.css,sha256=s4_CUivnqvndE4c7T1stp59orEHL_0C9tmN0rxai7bU,5686
|
10
|
+
eidos/css/themes/light.css,sha256=kESbN5Z4ovCn-Q3fxilQcjafgMCIyyJiocU9kMC5sIM,2674
|
11
|
+
eidos/js/eidos.js,sha256=ag6aoyWIE234ZoMiXJV-KVgBTsPR-fZd5Qhuo4rEeh0,5048
|
12
|
+
eidos/plugins/__init__.py,sha256=Cv4nNAV74tOvyPyb2oEg7q2yhrHLC1lGwbWYjdT9Z4Y,25
|
13
|
+
eidos/plugins/markdown/__init__.py,sha256=FuifCP1MmO0ACy7mq_kTwKLMnw8K15td_6E3Ihlrir4,555
|
14
|
+
eidos/plugins/markdown/components.py,sha256=jz3yu4LIgBOTx0MS2o703al90jAquScmKehQQHV2dmY,1388
|
15
|
+
eidos/plugins/markdown/renderer.py,sha256=NJYTJWgDySTUkrihYudLvRSR4hr6QeAqTpzZGN4eyo8,1971
|
16
|
+
eidos/plugins/markdown/css/markdown.css,sha256=RxNx7aJDmJMx3zuydX10uAMaPFtl9r6zOFDni9Idsdk,6226
|
17
|
+
eidos/plugins/markdown/extensions/__init__.py,sha256=wOdOyCcb-4lxEm77GMnJLst8JepecDcrN4sp3HO_q9A,28
|
18
|
+
eidos/plugins/markdown/extensions/alerts.py,sha256=q1d49KyjPoTiK6OJ7gKvuwrFxM3BjPwssQnp6qhpFDs,4541
|
19
|
+
eidosui-0.3.0.dist-info/METADATA,sha256=Dz7d3-Q3dAxHKOpJFD7YivKEukMDM4kQldJGYH5z7kE,4749
|
20
|
+
eidosui-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
21
|
+
eidosui-0.3.0.dist-info/licenses/LICENSE,sha256=evjPJs6lg9eka9CYtC6ErQrZ71IovVbdvZqqz3ax8E8,1064
|
22
|
+
eidosui-0.3.0.dist-info/RECORD,,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Feldroy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
eidos/components/__init__.py
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
"""EidosUI Components - Simple MVP"""
|
2
|
-
|
3
|
-
# Semantic Typography
|
4
|
-
from .typography import (
|
5
|
-
H1, H2, H3, H4, H5, H6,
|
6
|
-
P, Text, Em, Strong, A,
|
7
|
-
Code, Pre, Mark, Small
|
8
|
-
)
|
9
|
-
|
10
|
-
# Forms
|
11
|
-
from .forms import (
|
12
|
-
Button, Input, Textarea, Select, Label, FormGroup
|
13
|
-
)
|
14
|
-
|
15
|
-
__all__ = [
|
16
|
-
# Typography
|
17
|
-
"H1", "H2", "H3", "H4", "H5", "H6",
|
18
|
-
"P", "Text", "Em", "Strong", "A",
|
19
|
-
"Code", "Pre", "Mark", "Small",
|
20
|
-
# Forms
|
21
|
-
"Button", "Input", "Textarea", "Select", "Label", "FormGroup",
|
22
|
-
]
|
eidos/components/forms.py
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
"""Form components for EidosUI"""
|
2
|
-
|
3
|
-
import fastapi_tags as ft
|
4
|
-
from ..core.styles import button_styles, form_styles
|
5
|
-
from ..core.utils import merge_classes
|
6
|
-
|
7
|
-
|
8
|
-
def Button(*content, cls: str = button_styles.primary, size_cls: str = button_styles.md, **kwargs) -> ft.Button:
|
9
|
-
"""Highly flexible button component that takes classes directly"""
|
10
|
-
return ft.Button(
|
11
|
-
*content,
|
12
|
-
cls=merge_classes(cls, size_cls),
|
13
|
-
**kwargs
|
14
|
-
)
|
15
|
-
|
16
|
-
|
17
|
-
def Input(cls: str = form_styles.input, size_cls: str = "", state_cls: str = "", **kwargs) -> ft.Input:
|
18
|
-
"""Flexible input component with class-based styling"""
|
19
|
-
return ft.Input(
|
20
|
-
cls=merge_classes(cls, size_cls, state_cls),
|
21
|
-
**kwargs
|
22
|
-
)
|
23
|
-
|
24
|
-
|
25
|
-
def Textarea(cls: str = form_styles.textarea, **kwargs) -> ft.Textarea:
|
26
|
-
"""Flexible textarea component"""
|
27
|
-
return ft.Textarea(
|
28
|
-
cls=cls,
|
29
|
-
**kwargs
|
30
|
-
)
|
31
|
-
|
32
|
-
|
33
|
-
def Select(*options, cls: str = form_styles.select, **kwargs) -> ft.Select:
|
34
|
-
"""Flexible select component"""
|
35
|
-
return ft.Select(
|
36
|
-
*options,
|
37
|
-
cls=cls,
|
38
|
-
**kwargs
|
39
|
-
)
|
40
|
-
|
41
|
-
|
42
|
-
def Label(text: str, cls: str = form_styles.label, **kwargs) -> ft.Label:
|
43
|
-
"""Flexible label component"""
|
44
|
-
return ft.Label(
|
45
|
-
text,
|
46
|
-
cls=cls,
|
47
|
-
**kwargs
|
48
|
-
)
|
49
|
-
|
50
|
-
|
51
|
-
def FormGroup(*content, cls: str = form_styles.form_group, **kwargs) -> ft.Div:
|
52
|
-
"""Form group container with default spacing"""
|
53
|
-
return ft.Div(
|
54
|
-
*content,
|
55
|
-
cls=cls,
|
56
|
-
**kwargs
|
57
|
-
)
|
eidos/components/typography.py
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
"""Semantic typography components for EidosUI"""
|
2
|
-
|
3
|
-
import fastapi_tags as ft
|
4
|
-
from ..core.styles import typography_styles
|
5
|
-
from ..core.utils import merge_classes
|
6
|
-
|
7
|
-
|
8
|
-
def H1(*content, cls: str = typography_styles.h1, **kwargs) -> ft.H1:
|
9
|
-
"""Semantic H1 heading"""
|
10
|
-
return ft.H1(*content, cls=cls, **kwargs)
|
11
|
-
|
12
|
-
|
13
|
-
def H2(*content, cls: str = typography_styles.h2, **kwargs) -> ft.H2:
|
14
|
-
"""Semantic H2 heading"""
|
15
|
-
return ft.H2(*content, cls=cls, **kwargs)
|
16
|
-
|
17
|
-
|
18
|
-
def H3(*content, cls: str = typography_styles.h3, **kwargs) -> ft.H3:
|
19
|
-
"""Semantic H3 heading"""
|
20
|
-
return ft.H3(*content, cls=cls, **kwargs)
|
21
|
-
|
22
|
-
|
23
|
-
def H4(*content, cls: str = typography_styles.h4, **kwargs) -> ft.H4:
|
24
|
-
"""Semantic H4 heading"""
|
25
|
-
return ft.H4(*content, cls=cls, **kwargs)
|
26
|
-
|
27
|
-
|
28
|
-
def H5(*content, cls: str = typography_styles.h5, **kwargs) -> ft.H5:
|
29
|
-
"""Semantic H5 heading"""
|
30
|
-
return ft.H5(*content, cls=cls, **kwargs)
|
31
|
-
|
32
|
-
|
33
|
-
def H6(*content, cls: str = typography_styles.h6, **kwargs) -> ft.H6:
|
34
|
-
"""Semantic H6 heading"""
|
35
|
-
return ft.H6(*content, cls=cls, **kwargs)
|
36
|
-
|
37
|
-
|
38
|
-
def P(*content, cls: str = typography_styles.body, **kwargs) -> ft.P:
|
39
|
-
"""Semantic paragraph"""
|
40
|
-
return ft.P(*content, cls=cls, **kwargs)
|
41
|
-
|
42
|
-
|
43
|
-
def Text(*content, cls: str = typography_styles.body, **kwargs) -> ft.Span:
|
44
|
-
"""Generic text span"""
|
45
|
-
return ft.Span(*content, cls=cls, **kwargs)
|
46
|
-
|
47
|
-
|
48
|
-
def Em(*content, cls: str = typography_styles.em, **kwargs) -> ft.Em:
|
49
|
-
"""Semantic emphasis (italic)"""
|
50
|
-
return ft.Em(*content, cls=cls, **kwargs)
|
51
|
-
|
52
|
-
|
53
|
-
def Strong(*content, cls: str = typography_styles.strong, **kwargs) -> ft.Strong:
|
54
|
-
"""Semantic strong emphasis (bold)"""
|
55
|
-
return ft.Strong(*content, cls=cls, **kwargs)
|
56
|
-
|
57
|
-
|
58
|
-
def A(*content, href: str = "#", cls: str = typography_styles.link, **kwargs) -> ft.A:
|
59
|
-
"""Semantic anchor link"""
|
60
|
-
return ft.A(*content, href=href, cls=cls, **kwargs)
|
61
|
-
|
62
|
-
|
63
|
-
def Code(*content, cls: str = typography_styles.code, **kwargs) -> ft.Code:
|
64
|
-
"""Inline code"""
|
65
|
-
return ft.Code(*content, cls=cls, **kwargs)
|
66
|
-
|
67
|
-
|
68
|
-
def Pre(*content, cls: str = typography_styles.pre, **kwargs) -> ft.Pre:
|
69
|
-
"""Preformatted text block"""
|
70
|
-
return ft.Pre(*content, cls=cls, **kwargs)
|
71
|
-
|
72
|
-
|
73
|
-
# def Blockquote(*content, cls: str = typography_styles.blockquote, **kwargs) -> ft.Blockquote:
|
74
|
-
# """Semantic blockquote"""
|
75
|
-
# return ft.Blockquote(*content, cls=cls, **kwargs)
|
76
|
-
|
77
|
-
|
78
|
-
def Mark(*content, cls: str = typography_styles.mark, **kwargs) -> ft.Mark:
|
79
|
-
"""Highlighted text"""
|
80
|
-
return ft.Mark(*content, cls=cls, **kwargs)
|
81
|
-
|
82
|
-
|
83
|
-
def Small(*content, cls: str = typography_styles.small, **kwargs) -> ft.Small:
|
84
|
-
"""Small text"""
|
85
|
-
return ft.Small(*content, cls=cls, **kwargs)
|
eidos/core/__init__.py
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
"""Core functionality for EidosUI theme and style system"""
|
2
|
-
|
3
|
-
from .styles import (
|
4
|
-
button_styles,
|
5
|
-
typography_styles,
|
6
|
-
form_styles,
|
7
|
-
)
|
8
|
-
from .utils import merge_classes
|
9
|
-
from .helpers import (
|
10
|
-
serve_eidos_static,
|
11
|
-
create_eidos_head_tag,
|
12
|
-
get_theme_css,
|
13
|
-
get_eidos_js,
|
14
|
-
)
|
15
|
-
|
16
|
-
__all__ = [
|
17
|
-
"button_styles",
|
18
|
-
"typography_styles",
|
19
|
-
"form_styles",
|
20
|
-
"merge_classes",
|
21
|
-
"serve_eidos_static",
|
22
|
-
"create_eidos_head_tag",
|
23
|
-
"get_theme_css",
|
24
|
-
"get_eidos_js",
|
25
|
-
]
|
eidos/core/helpers.py
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
"""Helper functions for easy EidosUI integration"""
|
2
|
-
|
3
|
-
import importlib.resources
|
4
|
-
from pathlib import Path
|
5
|
-
from typing import Optional
|
6
|
-
from fastapi import FastAPI
|
7
|
-
from fastapi.staticfiles import StaticFiles
|
8
|
-
|
9
|
-
|
10
|
-
def get_theme_css(theme: str = "light") -> str:
|
11
|
-
"""Get CSS content for a theme directly from the package"""
|
12
|
-
try:
|
13
|
-
with importlib.resources.open_text("eidos.themes", f"{theme}.css") as f:
|
14
|
-
return f.read()
|
15
|
-
except FileNotFoundError:
|
16
|
-
return ""
|
17
|
-
|
18
|
-
|
19
|
-
def get_eidos_js() -> str:
|
20
|
-
"""Get JavaScript content directly from the package"""
|
21
|
-
try:
|
22
|
-
with importlib.resources.open_text("eidos.static", "eidos-ui.js") as f:
|
23
|
-
return f.read()
|
24
|
-
except FileNotFoundError:
|
25
|
-
return ""
|
26
|
-
|
27
|
-
def serve_eidos_static(app: FastAPI, prefix: str = "/eidos") -> None:
|
28
|
-
"""
|
29
|
-
Automatically mount EidosUI static files to a FastAPI app
|
30
|
-
|
31
|
-
Args:
|
32
|
-
app: FastAPI application instance
|
33
|
-
prefix: URL prefix for static files (default: "/eidos")
|
34
|
-
"""
|
35
|
-
try:
|
36
|
-
# Get the package directory paths
|
37
|
-
with importlib.resources.path("eidos", "static") as static_path:
|
38
|
-
app.mount(f"{prefix}/static", StaticFiles(directory=str(static_path)), name="eidos_static")
|
39
|
-
|
40
|
-
with importlib.resources.path("eidos", "themes") as themes_path:
|
41
|
-
app.mount(f"{prefix}/themes", StaticFiles(directory=str(themes_path)), name="eidos_themes")
|
42
|
-
|
43
|
-
except Exception as e:
|
44
|
-
# Fallback for development - try relative paths
|
45
|
-
import os
|
46
|
-
package_dir = Path(__file__).parent.parent
|
47
|
-
|
48
|
-
if (package_dir / "static").exists():
|
49
|
-
app.mount(f"{prefix}/static", StaticFiles(directory=str(package_dir / "static")), name="eidos_static")
|
50
|
-
|
51
|
-
if (package_dir / "themes").exists():
|
52
|
-
app.mount(f"{prefix}/themes", StaticFiles(directory=str(package_dir / "themes")), name="eidos_themes")
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
def create_eidos_head_tag(
|
59
|
-
title: str = "EidosUI App",
|
60
|
-
themes: list = ["light", "dark"],
|
61
|
-
prefix: str = "/eidos",
|
62
|
-
include_tailwind: bool = True
|
63
|
-
):
|
64
|
-
"""Create a fastapi-tags Head component with EidosUI setup"""
|
65
|
-
import fastapi_tags as ft
|
66
|
-
|
67
|
-
head_content = []
|
68
|
-
|
69
|
-
head_content.extend([
|
70
|
-
ft.Meta(charset="UTF-8"),
|
71
|
-
ft.Meta(name="viewport", content="width=device-width, initial-scale=1.0"),
|
72
|
-
ft.Title(title)
|
73
|
-
])
|
74
|
-
|
75
|
-
if include_tailwind:
|
76
|
-
head_content.append(ft.Script(src="https://cdn.tailwindcss.com"))
|
77
|
-
|
78
|
-
# Add CSS links
|
79
|
-
for theme in themes:
|
80
|
-
head_content.append(ft.Link(rel="stylesheet", href=f"{prefix}/themes/{theme}.css"))
|
81
|
-
|
82
|
-
# Add JS script
|
83
|
-
head_content.append(ft.Script(src=f"{prefix}/static/eidos-ui.js"))
|
84
|
-
|
85
|
-
return ft.Head(*head_content)
|
86
|
-
|
87
|
-
|
eidos/core/styles.py
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
"""Style dataclasses for EidosUI components using CSS variables"""
|
2
|
-
|
3
|
-
from dataclasses import dataclass
|
4
|
-
|
5
|
-
|
6
|
-
@dataclass(frozen=True)
|
7
|
-
class ButtonStyles:
|
8
|
-
"""Button style variations using CSS variables"""
|
9
|
-
|
10
|
-
# Primary styles (most commonly used)
|
11
|
-
primary: str = "bg-[var(--color-primary)] hover:bg-[var(--color-primary-hover)] text-[var(--color-primary-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:ring-offset-2 shadow-sm hover:shadow-md active:scale-95"
|
12
|
-
secondary: str = "bg-[var(--color-secondary)] hover:bg-[var(--color-secondary-hover)] text-[var(--color-secondary-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-secondary)] focus:ring-offset-2 shadow-sm hover:shadow-md active:scale-95"
|
13
|
-
ghost: str = "text-[var(--color-primary)] hover:bg-[var(--color-primary-light)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:ring-offset-2 active:scale-95"
|
14
|
-
|
15
|
-
# Semantic styles
|
16
|
-
success: str = "bg-[var(--color-success)] hover:bg-[var(--color-success-hover)] text-[var(--color-success-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-success)] focus:ring-offset-2 shadow-sm hover:shadow-md active:scale-95"
|
17
|
-
cta: str = "bg-[var(--color-cta)] hover:bg-[var(--color-cta-hover)] text-[var(--color-cta-foreground)] font-semibold rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-cta)] focus:ring-offset-2 shadow-md hover:shadow-lg active:scale-95 transform"
|
18
|
-
warning: str = "bg-[var(--color-warning)] hover:bg-[var(--color-warning-hover)] text-[var(--color-warning-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-warning)] focus:ring-offset-2 shadow-sm hover:shadow-md active:scale-95"
|
19
|
-
error: str = "bg-[var(--color-error)] hover:bg-[var(--color-error-hover)] text-[var(--color-error-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-error)] focus:ring-offset-2 shadow-sm hover:shadow-md active:scale-95"
|
20
|
-
info: str = "bg-[var(--color-info)] hover:bg-[var(--color-info-hover)] text-[var(--color-info-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-info)] focus:ring-offset-2 shadow-sm hover:shadow-md active:scale-95"
|
21
|
-
|
22
|
-
# Size variations
|
23
|
-
sm: str = "px-3 py-1.5 text-sm"
|
24
|
-
md: str = "px-4 py-2 text-base" # Default size
|
25
|
-
lg: str = "px-6 py-3 text-lg"
|
26
|
-
xl: str = "px-8 py-4 text-xl"
|
27
|
-
|
28
|
-
# Icon styles
|
29
|
-
icon_sm: str = "p-1.5"
|
30
|
-
icon_md: str = "p-2"
|
31
|
-
icon_lg: str = "p-3"
|
32
|
-
|
33
|
-
# Special styles
|
34
|
-
outline_primary: str = "border-2 border-[var(--color-primary)] text-[var(--color-primary)] hover:bg-[var(--color-primary)] hover:text-[var(--color-primary-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:ring-offset-2 active:scale-95"
|
35
|
-
outline_secondary: str = "border-2 border-[var(--color-secondary)] text-[var(--color-secondary)] hover:bg-[var(--color-secondary)] hover:text-[var(--color-secondary-foreground)] font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-secondary)] focus:ring-offset-2 active:scale-95"
|
36
|
-
link: str = "text-[var(--color-primary)] hover:text-[var(--color-primary-hover)] underline-offset-4 hover:underline font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:ring-offset-2 rounded active:scale-95"
|
37
|
-
|
38
|
-
|
39
|
-
@dataclass(frozen=True)
|
40
|
-
class TypographyStyles:
|
41
|
-
"""Typography style variations using CSS variables"""
|
42
|
-
|
43
|
-
# Heading styles (mobile-first responsive)
|
44
|
-
h1: str = "text-2xl sm:text-3xl lg:text-4xl font-bold text-[var(--color-text)] leading-tight"
|
45
|
-
h2: str = "text-xl sm:text-2xl lg:text-3xl font-semibold text-[var(--color-text)] leading-tight"
|
46
|
-
h3: str = "text-lg sm:text-xl lg:text-2xl font-semibold text-[var(--color-text)] leading-tight"
|
47
|
-
h4: str = "text-base sm:text-lg lg:text-xl font-semibold text-[var(--color-text)] leading-tight"
|
48
|
-
h5: str = "text-sm sm:text-base lg:text-lg font-medium text-[var(--color-text)] leading-tight"
|
49
|
-
h6: str = "text-xs sm:text-sm lg:text-base font-medium text-[var(--color-text)] leading-tight"
|
50
|
-
|
51
|
-
# Body text styles
|
52
|
-
body: str = "text-base text-[var(--color-text)] leading-relaxed"
|
53
|
-
|
54
|
-
# Semantic emphasis
|
55
|
-
em: str = "italic"
|
56
|
-
strong: str = "font-semibold"
|
57
|
-
small: str = "text-sm text-[var(--color-text-muted)]"
|
58
|
-
|
59
|
-
# Links
|
60
|
-
link: str = "text-[var(--color-primary)] hover:text-[var(--color-primary-hover)] underline underline-offset-2 transition-colors duration-200"
|
61
|
-
|
62
|
-
# Text decorations
|
63
|
-
code: str = "font-mono bg-[var(--color-surface)] px-1.5 py-0.5 rounded text-sm"
|
64
|
-
pre: str = "bg-[var(--color-surface)] border border-[var(--color-border)] rounded-lg p-4 overflow-x-auto text-sm font-mono"
|
65
|
-
mark: str = "bg-[var(--color-warning-light)] px-1 rounded"
|
66
|
-
blockquote: str = "border-l-4 border-[var(--color-primary)] pl-6 py-2 italic text-[var(--color-text-muted)]"
|
67
|
-
|
68
|
-
|
69
|
-
@dataclass(frozen=True)
|
70
|
-
class FormStyles:
|
71
|
-
"""Form component styles using CSS variables"""
|
72
|
-
|
73
|
-
# Input styles
|
74
|
-
input: str = "w-full px-3 py-2 bg-[var(--color-input)] border border-[var(--color-border)] rounded-lg text-[var(--color-text)] placeholder:text-[var(--color-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition-colors duration-200"
|
75
|
-
|
76
|
-
# Textarea
|
77
|
-
textarea: str = "w-full px-3 py-2 bg-[var(--color-input)] border border-[var(--color-border)] rounded-lg text-[var(--color-text)] placeholder:text-[var(--color-text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition-colors duration-200 resize-y min-h-[80px]"
|
78
|
-
|
79
|
-
# Select
|
80
|
-
select: str = "w-full px-3 py-2 bg-[var(--color-input)] border border-[var(--color-border)] rounded-lg text-[var(--color-text)] focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] focus:border-transparent transition-colors duration-200 appearance-none"
|
81
|
-
|
82
|
-
# Labels
|
83
|
-
label: str = "block text-sm font-medium text-[var(--color-text)] mb-1"
|
84
|
-
|
85
|
-
# Form groups
|
86
|
-
form_group: str = "space-y-2"
|
87
|
-
|
88
|
-
|
89
|
-
# Global style instances for easy access
|
90
|
-
button_styles = ButtonStyles()
|
91
|
-
typography_styles = TypographyStyles()
|
92
|
-
form_styles = FormStyles()
|
eidos/core/utils.py
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
"""Utility functions for EidosUI"""
|
2
|
-
|
3
|
-
from typing import Union, Optional, List
|
4
|
-
|
5
|
-
|
6
|
-
def merge_classes(*classes: Optional[Union[str, List[str]]]) -> str:
|
7
|
-
"""
|
8
|
-
Merge multiple class strings, handling None values and lists
|
9
|
-
|
10
|
-
Args:
|
11
|
-
*classes: Variable number of class strings, lists of strings, or None values
|
12
|
-
|
13
|
-
Returns:
|
14
|
-
A single merged class string with duplicates removed and proper spacing
|
15
|
-
|
16
|
-
Examples:
|
17
|
-
>>> merge_classes("text-base", "font-bold", None, "text-center")
|
18
|
-
"text-base font-bold text-center"
|
19
|
-
|
20
|
-
>>> merge_classes(["bg-blue-500", "hover:bg-blue-600"], "rounded-lg")
|
21
|
-
"bg-blue-500 hover:bg-blue-600 rounded-lg"
|
22
|
-
"""
|
23
|
-
result = []
|
24
|
-
|
25
|
-
for cls in classes:
|
26
|
-
if cls is None:
|
27
|
-
continue
|
28
|
-
|
29
|
-
if isinstance(cls, (list, tuple)):
|
30
|
-
# Handle lists/tuples of classes
|
31
|
-
for item in cls:
|
32
|
-
if item and isinstance(item, str):
|
33
|
-
result.extend(item.split())
|
34
|
-
elif isinstance(cls, str) and cls.strip():
|
35
|
-
# Handle string classes
|
36
|
-
result.extend(cls.split())
|
37
|
-
|
38
|
-
# Remove duplicates while preserving order
|
39
|
-
seen = set()
|
40
|
-
unique_classes = []
|
41
|
-
for class_name in result:
|
42
|
-
if class_name not in seen:
|
43
|
-
seen.add(class_name)
|
44
|
-
unique_classes.append(class_name)
|
45
|
-
|
46
|
-
return ' '.join(unique_classes)
|