Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Refactor #2164

Merged
merged 35 commits into from Nov 20, 2023
Merged

HTML Refactor #2164

merged 35 commits into from Nov 20, 2023

Conversation

Alek99
Copy link
Contributor

@Alek99 Alek99 commented Nov 13, 2023

"""Welcome to Reflex! This file outlines the steps to create a basic app."""
from rxconfig import config

import reflex as rx

docs_url = "https://reflex.dev/docs/getting-started/introduction"
filename = f"{config.app_name}/{config.app_name}.py"


class State(rx.State):
    """The app state."""

    pass


def index():
    return rx.fragment(
        rx.el.footer(
            "\n",
            rx.el.div(
                "\n",
                rx.el.div(
                    "\n",
                    rx.el.div(
                        "\n",
                        rx.el.span("Unique", class_name="text-violet-500"),
                        "\n",
                        rx.el.span("Fund", class_name="dark:text-slate-400"),
                        "\n",
                        class_name="w-full text-lg font-extrabold md:w-fit md:text-left",
                    ),
                    "\n",
                    rx.el.p(
                        "\n        UniqueFund provides access to fast and reliable financing solutions for\n        SMEs.\n      ",
                        class_name="text-sm text-slate-600",
                    ),
                    "\n",
                    class_name="flex w-full flex-col space-y-4 text-center md:w-2/5 md:text-left",
                ),
                "\n",
                rx.el.div(
                    "\n",
                    rx.el.div("Company", class_name="text-sm font-semibold"),
                    "\n",
                    rx.el.ul(
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            About\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Terms of Service\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Privacy Policy\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Cookie Policy\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        class_name="text-sm",
                    ),
                    "\n",
                    class_name="w-full text-center text-slate-600 md:w-1/5 md:text-left",
                ),
                "\n",
                rx.el.div(
                    "\n",
                    rx.el.div("Solutions", class_name="text-sm font-semibold"),
                    "\n",
                    rx.el.ul(
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Business Line of Credit\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            SBA Loan\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Revenue Based Financing\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Invoice Factoring\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        class_name="text-sm",
                    ),
                    "\n",
                    class_name="w-full text-center text-slate-600 md:w-1/5 md:text-left",
                ),
                "\n",
                rx.el.div(
                    "\n",
                    rx.el.div("Partnership", class_name="text-sm font-semibold text-slate-600"),
                    "\n",
                    rx.el.ul(
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Loan Partner\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Affiliate\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        rx.el.li(
                            "\n",
                            rx.el.a(
                                "\n            Brand Guideline\n          ",
                                class_name="underline decoration-transparent underline-offset-4 transition hover:decoration-slate-700",
                                href="#",
                                rel="noopener noreferrer",
                                target="_blank",
                            ),
                            "\n",
                            class_name="pt-3",
                        ),
                        "\n",
                        class_name="text-sm",
                    ),
                    "\n",
                    class_name="w-full text-center text-slate-600 md:w-1/5 md:text-left",
                ),
                "\n",
                class_name="container mx-auto flex flex-col items-start space-y-12 px-8 pb-8 pt-12 md:flex-row md:space-y-0 md:space-x-12 md:px-12",
            ),
            "\n",
            rx.el.div(
                "\n    \u00a9\n    \n    2023\n    \n    UniqueFund. All rights reserved.\n  ",
                class_name="container mx-auto border-t border-slate-200 p-8 text-center text-sm text-slate-600 dark:border-slate-900 md:flex-row md:px-12",
            ),
            "\n",
            class_name="mt-28 bg-slate-50 dark:bg-black",
        )
    )

# Add state and page to the app.
app = rx.App()
app.add_page(index)
app.compile()

@Alek99 Alek99 marked this pull request as ready for review November 13, 2023 23:36
masenf
masenf previously approved these changes Nov 14, 2023
Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. I think documenting and maintaining this rx.el namespace is going to be good for people who want a truly lightweight app. With no chakra/radix components in use, then they wont be installed at all!

potential conflict with this recent PR: e761a04

The rx.el.element.Element.render method will still end up accidentally getting sx props because they will get added in _render and not removed here. I'm thinking that now is probably the time to have Component pass style as style and have ChakraComponent pass style as sx. Then we can stop special casing that here and in the radix tree.

"""Base class for common attributes."""

# Provides a hint for generating a keyboard shortcut for the current element.
access_key: Var_[Union[str, int, bool]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like to read this type as access_key: Var_[Attribute] or maybe Var_[HTMLAttribute].

something that reduces the complexity of what my brain has to grok to understand the line.

from .base import BaseHTML


class A(BaseHTML): # Inherits common attributes from BaseMeta
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class A(BaseHTML): # Inherits common attributes from BaseMeta
class A(BaseHTML):

@Alek99
Copy link
Contributor Author

Alek99 commented Nov 15, 2023

One question should I move the .el into the components directory?

@masenf
Copy link
Collaborator

masenf commented Nov 15, 2023

One question should I move the .el into the components directory?

I think it would make more sense in there, but I think we should still expose it as rx.el in the API

@@ -14,7 +14,7 @@

from reflex.utils import path_ops

from .constants import ELEMENT_TO_PROPS, ELEMENTS
from ..reflex.components.el.constants import ELEMENT_TO_PROPS, ELEMENTS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need a relative import, does the normal from reflex.components.el.constants work here?

Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome.

For future work, we still need to get event triggers defined on some of these, but I think we should roll with what is already a big improvement.


The Svg element is essentially a separate XML doc embedded in the HTML, and I don't know how we want to handle that, but as it is, i don't think we will be reverse compiling svg to reflex code anytime soon, nor do i think that's desirable from a perf perspective. We can probably just inline the svg code in the Svg element for the reverse compiler in the short term.

size: Text field size "1" - "3"
size: Specifies the visible width of a text control
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inherited HTML element description probably shouldn't take precedent over the description from the class

@picklelo picklelo merged commit 88a3276 into main Nov 20, 2023
45 checks passed
@masenf masenf deleted the alek/htmlref branch December 6, 2023 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants