Skip to content

Commit

Permalink
update unstyed
Browse files Browse the repository at this point in the history
  • Loading branch information
anubrag committed Jan 18, 2024
1 parent c388542 commit 041b285
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 12 deletions.
4 changes: 4 additions & 0 deletions app-examples/unstyled_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.db
*.py[cod]
.web
__pycache__/
Binary file not shown.
10 changes: 10 additions & 0 deletions app-examples/unstyled_example/assets/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app-examples/unstyled_example/assets/gradient_underline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app-examples/unstyled_example/assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app-examples/unstyled_example/assets/logo_darkmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions app-examples/unstyled_example/assets/paneleft.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app-examples/unstyled_example/assets/text_logo_darkmode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app-examples/unstyled_example/unstyled_example/__init__.py
Original file line number Diff line number Diff line change
@@ -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.

54 changes: 54 additions & 0 deletions app-examples/unstyled_example/unstyled_example/unstyled_example.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions app-examples/unstyled_example/xtconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import nextpy as xt

config = xt.Config(
app_name="unstyled_example",
)
7 changes: 5 additions & 2 deletions nextpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -300,7 +301,6 @@
"polar_angle_axis", "polar_grid", "polar_radius_axis",
],
"nextpy.utils": ["utils"],
"nextpy.frontend.components.proxy": ["animation"],
}


Expand Down Expand Up @@ -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.
Expand All @@ -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
19 changes: 14 additions & 5 deletions nextpy/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion nextpy/frontend/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
from .react_player import *
from .recharts import *
from .suneditor import *

6 changes: 2 additions & 4 deletions nextpy/frontend/components/proxy/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
Loading

0 comments on commit 041b285

Please sign in to comment.