mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
37 lines
896 B
Python
37 lines
896 B
Python
from abc import ABC
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class Style(BaseModel):
|
|
"""常用样式"""
|
|
|
|
padding: str = "0px"
|
|
margin: str = "0px"
|
|
border: str = "0px"
|
|
border_radius: str = "0px"
|
|
text_align: Literal["left", "right", "center"] = "left"
|
|
color: str = "#000"
|
|
font_size: str = "16px"
|
|
|
|
|
|
class Component(ABC):
|
|
def __init__(self, background_color: str = "#fff", is_container: bool = False):
|
|
self.extra_style = []
|
|
self.style = Style()
|
|
self.background_color = background_color
|
|
self.is_container = is_container
|
|
self.children = []
|
|
|
|
def add_child(self, child: "Component | str"):
|
|
self.children.append(child)
|
|
|
|
def set_style(self, style: Style):
|
|
self.style = style
|
|
|
|
def add_style(self, style: str):
|
|
self.extra_style.append(style)
|
|
|
|
def to_html(self) -> str: ...
|