From 041b285197bca2c4213af260d2b0edb75759c902 Mon Sep 17 00:00:00 2001 From: anubrag Date: Thu, 18 Jan 2024 12:08:28 +0530 Subject: [PATCH] update unstyed --- app-examples/unstyled_example/.gitignore | 4 ++ .../unstyled_example/assets/favicon.ico | Bin 0 -> 15406 bytes .../unstyled_example/assets/github.svg | 10 ++++ .../assets/gradient_underline.svg | 2 + app-examples/unstyled_example/assets/icon.svg | 3 + .../unstyled_example/assets/logo_darkmode.svg | 2 + .../unstyled_example/assets/paneleft.svg | 13 +++++ .../assets/text_logo_darkmode.svg | 2 + .../unstyled_example/__init__.py | 3 + .../unstyled_example/unstyled_example.py | 54 ++++++++++++++++++ app-examples/unstyled_example/xtconfig.py | 5 ++ nextpy/__init__.py | 7 ++- nextpy/__init__.pyi | 19 ++++-- nextpy/frontend/components/__init__.py | 1 - nextpy/frontend/components/proxy/__init__.py | 6 +- nextpy/frontend/components/proxy/unstyled.py | 26 +++++++++ 16 files changed, 145 insertions(+), 12 deletions(-) create mode 100644 app-examples/unstyled_example/.gitignore create mode 100644 app-examples/unstyled_example/assets/favicon.ico create mode 100644 app-examples/unstyled_example/assets/github.svg create mode 100644 app-examples/unstyled_example/assets/gradient_underline.svg create mode 100644 app-examples/unstyled_example/assets/icon.svg create mode 100644 app-examples/unstyled_example/assets/logo_darkmode.svg create mode 100644 app-examples/unstyled_example/assets/paneleft.svg create mode 100644 app-examples/unstyled_example/assets/text_logo_darkmode.svg create mode 100644 app-examples/unstyled_example/unstyled_example/__init__.py create mode 100644 app-examples/unstyled_example/unstyled_example/unstyled_example.py create mode 100644 app-examples/unstyled_example/xtconfig.py create mode 100644 nextpy/frontend/components/proxy/unstyled.py diff --git a/app-examples/unstyled_example/.gitignore b/app-examples/unstyled_example/.gitignore new file mode 100644 index 00000000..eab0d4b0 --- /dev/null +++ b/app-examples/unstyled_example/.gitignore @@ -0,0 +1,4 @@ +*.db +*.py[cod] +.web +__pycache__/ \ No newline at end of file diff --git a/app-examples/unstyled_example/assets/favicon.ico b/app-examples/unstyled_example/assets/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..1f55d3be060bb3a53118ff759b317978debf9f28 GIT binary patch literal 15406 zcmeI33zS`Db;qv-t%3-Ym(T|hAJw2sB&8COIx?Ai?>YBQsxAk`0#c=UP3D<-+?h!x zcV5Z7GOtX6krDx|m7tV@v=$Y#f(v;mk1kL&g^Fk(O+qB^$L??MbG~!WOomJ*tdJ~M zXRW=ybMHOh+5i1N`}@BA?fp$6@rJ~4iBnEV&`wLtJ3f*4>qH_kZCdd8y{9G;Yx(Yi z3&P*ulSusdj6~wS+(Q?71mDw4_$Qe;Ws;ruh-4PrFWK_q32!>cmy(_Tgp@82`if*K z9+#4Z=N#nr1Adb1!e0-t@cIg_DH5- zrDPg2L7%3l#BbV7-~HmZAWM)|Wa)E~T5>)*e?mX7*CF*t1JB6qlT6bd`tTXCev4_f z?@|#jkF@QSbo-U!*WXPa?T0jSPmX(?MTNiNq2lvyoT?fFYKp% zT))K*C*P?)#J7H2cZ#H!?MA)`&VL=F&ole95B;@Y`+jt(1pT}&+GR-h9!Yo4h07bo zH{0kF;Zwq_``U3lQq3@T-O_J{VtfV`y5O4X* zlJ41$(6@j=iel$!5bt!v`{`moj+6AND{a@?%;?K)6SN%Xr=WV6k z&3v^>vJ19IY56VSm@(0u^ICPr`!h%0g6$h^u5|Ndww!sV{3XdO9Fd~xQ(n#Y;?FtU zYsr+~hrL^|H<+t!&eeIh0t}UpGIxIp|9I2kK7X=)*ogjexL2K~S9K#g?^kX@Zjf1x zCr|dA!~H$bUx9wr8S2eeajjClSN!V7Sbt{gTyZEmZ0+zW{+N07Z8p~wEjry={anUa z59c2DEOh<=j<;Yhe6wDu-b}b|Woy7tyP0+5Mk%g3YkXh#3~g&5$6E3QGl z%KZHR^ZwJckFwU>EMD`~lFm)jxzY8N(#l)VxiQdNjc#2lL&?^ne-UdIYp1u!lbJPd zas5oE&9O~qh*$d|@tQs@UgIEZ&Xefd!uqz0HFck@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ix zGP~y_i$^A@Yg-P>?|nOXeFUz0Sx@zxa^x!^ZsmI*6vNK&u%_TW)8gNaPrW$?^YX9z4%)1ui%_>H;UhJ z9`fxCDCaTZe1M)2NKcI4+2LB_%3=(BR{gjre@fuX2mZf+>vO2B0Z(L=>FmHXi0cw(>*GN;sXCgEoV{BgeB*#vEeLm2}9 z@JpNW zN&hF{RR322T;O-u<7Z3kj0gDbyu(O{fAr|%*ZD!;L3*f?@%an=OW;J%=wg2 zwE_IA;s5C4*SBwDIXP5~lL&vm5+&Ifk`_&FCd zvJ(k?Me#?t^?DEIResI6ky=S#H%A0Fku$Ji4!G|`p5=dkw$b8CtB}<@Xo(xHyNfeQ^JUhm z_i4m7n2EQ8#{aE12(LtbU*C+p%Gk>(8s-SnP5vo`=zOS + + + + + + + + + diff --git a/app-examples/unstyled_example/assets/gradient_underline.svg b/app-examples/unstyled_example/assets/gradient_underline.svg new file mode 100644 index 00000000..36ff3730 --- /dev/null +++ b/app-examples/unstyled_example/assets/gradient_underline.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/app-examples/unstyled_example/assets/icon.svg b/app-examples/unstyled_example/assets/icon.svg new file mode 100644 index 00000000..f7ee063b --- /dev/null +++ b/app-examples/unstyled_example/assets/icon.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/app-examples/unstyled_example/assets/logo_darkmode.svg b/app-examples/unstyled_example/assets/logo_darkmode.svg new file mode 100644 index 00000000..e90f7463 --- /dev/null +++ b/app-examples/unstyled_example/assets/logo_darkmode.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/app-examples/unstyled_example/assets/paneleft.svg b/app-examples/unstyled_example/assets/paneleft.svg new file mode 100644 index 00000000..ac9c5040 --- /dev/null +++ b/app-examples/unstyled_example/assets/paneleft.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/app-examples/unstyled_example/assets/text_logo_darkmode.svg b/app-examples/unstyled_example/assets/text_logo_darkmode.svg new file mode 100644 index 00000000..e395e3d7 --- /dev/null +++ b/app-examples/unstyled_example/assets/text_logo_darkmode.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/app-examples/unstyled_example/unstyled_example/__init__.py b/app-examples/unstyled_example/unstyled_example/__init__.py new file mode 100644 index 00000000..847433fd --- /dev/null +++ b/app-examples/unstyled_example/unstyled_example/__init__.py @@ -0,0 +1,3 @@ +# This file has been modified by the Nextpy Team in 2023 using AI tools and automation scripts. +# We have rigorously tested these modifications to ensure reliability and performance. Based on successful test results, we are confident in the quality and stability of these changes. + diff --git a/app-examples/unstyled_example/unstyled_example/unstyled_example.py b/app-examples/unstyled_example/unstyled_example/unstyled_example.py new file mode 100644 index 00000000..d7a037ea --- /dev/null +++ b/app-examples/unstyled_example/unstyled_example/unstyled_example.py @@ -0,0 +1,54 @@ +import nextpy as xt + + +class CounterState(xt.State): + value: int = 0 + + def change_value(self, amount): + self.value += amount + + +def create_button(label, amount): + return xt.unstyled.button( + label, + on_click=lambda: CounterState.change_value(amount) + ) + + +def index() -> xt.Component: + heading_color = xt.match( + CounterState.value, + (0, "red"), + (4, "blue"), + (8, "green"), + (12, "orange"), + (16, "lime"), + (20, "orange"), + "black" + ) + + return xt.unstyled.flex( + xt.unstyled.heading( + CounterState.value, + color="white", + background_color=heading_color, + as_="h2" + ), + xt.unstyled.flex( + create_button("decrement", -1), + create_button("increment", 1), + gap="2" + ), + align_items="center", + direction="column", + gap="2" + ) + + +# Global styles defined as a Python dictionary +style = { + "text_align": "center", +} + +app = xt.App(style=style) +app.add_page(index) diff --git a/app-examples/unstyled_example/xtconfig.py b/app-examples/unstyled_example/xtconfig.py new file mode 100644 index 00000000..0477aec0 --- /dev/null +++ b/app-examples/unstyled_example/xtconfig.py @@ -0,0 +1,5 @@ +import nextpy as xt + +config = xt.Config( + app_name="unstyled_example", +) \ No newline at end of file diff --git a/nextpy/__init__.py b/nextpy/__init__.py index 2d8a537a..d2f31aea 100644 --- a/nextpy/__init__.py +++ b/nextpy/__init__.py @@ -289,6 +289,7 @@ "nextpy.frontend.components.el": ["el"], "nextpy.frontend.components.moment.moment": ["MomentDelta"], "nextpy.frontend.page": ["page"], + "nextpy.frontend.components.proxy": ["animation", "unstyled"], "nextpy.frontend.style": ["color_mode", "style", "toggle_color_mode"], "nextpy.frontend.components.recharts": [ "area_chart", "bar_chart", "line_chart", "composed_chart", "pie_chart", @@ -300,7 +301,6 @@ "polar_angle_axis", "polar_grid", "polar_radius_axis", ], "nextpy.utils": ["utils"], - "nextpy.frontend.components.proxy": ["animation"], } @@ -354,6 +354,9 @@ def __getattr__(name: str) -> Type: module = importlib.import_module("nextpy.frontend.components.proxy") return module.animation + # Custom alias handling for 'unstyled' + if name == "unstyled": + return importlib.import_module("nextpy.frontend.components.proxy.unstyled") try: # Check for import of a module that is not in the mapping. @@ -371,4 +374,4 @@ def __getattr__(name: str) -> Type: getattr(module, name) if name != _MAPPING[name].rsplit(".")[-1] else module ) except ModuleNotFoundError: - raise AttributeError(f"module 'nextpy' has no attribute {name}") from None + raise AttributeError(f"module 'nextpy' has no attribute {name}") from None \ No newline at end of file diff --git a/nextpy/__init__.pyi b/nextpy/__init__.pyi index 1f049903..27d4b44b 100644 --- a/nextpy/__init__.pyi +++ b/nextpy/__init__.pyi @@ -1,4 +1,4 @@ -# This file has been modified by the Nextpy Team in 2023 using AI tools and automation scripts. +# This file has been modified by the Nextpy Team in 2023 using AI tools and automation scripts. # We have rigorously tested these modifications to ensure reliability and performance. Based on successful test results, we are confident in the quality and stability of these changes. from nextpy.backend import admin as admin @@ -257,7 +257,9 @@ from nextpy.frontend.components import center as center from nextpy.frontend.components import checkbox as checkbox from nextpy.frontend.components import checkbox_group as checkbox_group from nextpy.frontend.components import circular_progress as circular_progress -from nextpy.frontend.components import circular_progress_label as circular_progress_label +from nextpy.frontend.components import ( + circular_progress_label as circular_progress_label, +) from nextpy.frontend.components import circle as circle from nextpy.frontend.components import code as code from nextpy.frontend.components import code_block as code_block @@ -341,8 +343,12 @@ from nextpy.frontend.components import moment as moment from nextpy.frontend.components import multi_select as multi_select from nextpy.frontend.components import multi_select_option as multi_select_option from nextpy.frontend.components import next_link as next_link -from nextpy.frontend.components import number_decrement_stepper as number_decrement_stepper -from nextpy.frontend.components import number_increment_stepper as number_increment_stepper +from nextpy.frontend.components import ( + number_decrement_stepper as number_decrement_stepper, +) +from nextpy.frontend.components import ( + number_increment_stepper as number_increment_stepper, +) from nextpy.frontend.components import number_input as number_input from nextpy.frontend.components import number_input_field as number_input_field from nextpy.frontend.components import number_input_stepper as number_input_stepper @@ -365,7 +371,9 @@ from nextpy.frontend.components import progress as progress from nextpy.frontend.components import radio as radio from nextpy.frontend.components import radio_group as radio_group from nextpy.frontend.components import range_slider as range_slider -from nextpy.frontend.components import range_slider_filled_track as range_slider_filled_track +from nextpy.frontend.components import ( + range_slider_filled_track as range_slider_filled_track, +) from nextpy.frontend.components import range_slider_thumb as range_slider_thumb from nextpy.frontend.components import range_slider_track as range_slider_track from nextpy.frontend.components import responsive_grid as responsive_grid @@ -455,6 +463,7 @@ from nextpy.build.config import Config as Config from nextpy.build.config import DBConfig as DBConfig from nextpy import constants as constants from nextpy.constants import Env as Env + # from nextpy.frontend.custom_components import custom_components as custom_components from nextpy.frontend.components import el as el from nextpy.backend import event as event diff --git a/nextpy/frontend/components/__init__.py b/nextpy/frontend/components/__init__.py index 45a21556..11039d51 100644 --- a/nextpy/frontend/components/__init__.py +++ b/nextpy/frontend/components/__init__.py @@ -18,4 +18,3 @@ from .react_player import * from .recharts import * from .suneditor import * - diff --git a/nextpy/frontend/components/proxy/__init__.py b/nextpy/frontend/components/proxy/__init__.py index 66ef53aa..8c1c2423 100644 --- a/nextpy/frontend/components/proxy/__init__.py +++ b/nextpy/frontend/components/proxy/__init__.py @@ -1,8 +1,6 @@ -# This file has been modified by the Nextpy Team in 2023 using AI tools and automation scripts. -# We have rigorously tested these modifications to ensure reliability and performance. Based on successful test results, we are confident in the quality and stability of these changes. - """Contains proxy components.""" from .animation import animation +from .unstyled import * # Make sure this line is correctly importing headless -__all__ = ["animation"] +__all__ = ["animation", "headless"] \ No newline at end of file diff --git a/nextpy/frontend/components/proxy/unstyled.py b/nextpy/frontend/components/proxy/unstyled.py new file mode 100644 index 00000000..7816b1f4 --- /dev/null +++ b/nextpy/frontend/components/proxy/unstyled.py @@ -0,0 +1,26 @@ +"""Unstyled Components Alias.""" +# File: nextpy/frontend/components/proxy/unstyled.py + +import sys +from nextpy.frontend.components.radix.themes import * +from nextpy.frontend.components.radix.themes.components import * +from nextpy.frontend.components.radix.themes.layout import * +from nextpy.frontend.components.radix.themes.typography import * +from nextpy.frontend.components.radix.primitives import * + +class Unstyled: + def __getattr__(self, item): + # Check in each submodule for the component + for module in [themes, components, layout, typography, primitives]: + try: + return getattr(module, item) + except AttributeError: + continue + # If not found, raise an attribute error + raise AttributeError(f"No component named '{item}' in unstyled module") + +# Create an instance of the Unstyled class +unstyled = Unstyled() + +# Optionally, you can define __all__ for explicit exports +__all__ = [name for name in dir() if not name.startswith("_") and name != 'Unstyled']