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

[ENG-4001] Doc bash fixes for UI section #1056

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

picklelo
Copy link
Contributor

No description provided.

@picklelo picklelo marked this pull request as ready for review November 1, 2024 00:50
@picklelo picklelo changed the title Doc bash fixes for UI section [REF-4001] Doc bash fixes for UI section Nov 1, 2024
@picklelo picklelo changed the title [REF-4001] Doc bash fixes for UI section [ENG-4001] Doc bash fixes for UI section Nov 1, 2024
Copy link

linear bot commented Nov 1, 2024


## HTML Props
## Common Props

Components support many standard HTML properties as props. For example: the HTML [id]({"https://www.w3schools.com/html/html_id.asp"}) property is exposed directly as the prop `id`. The HTML [className]({"https://www.w3schools.com/jsref/prop_html_classname.asp"}) property is exposed as the prop `class_name` (note the Pythonic snake_casing!).

Copy link
Collaborator

Choose a reason for hiding this comment

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

might be nice for this example to actually define class-name-1 and class-name-2 so it is a bit more tangible what is happening here, as people coming from a non-web dev background might be like what is happening in this example?

Copy link
Collaborator

Choose a reason for hiding this comment

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

don't see any change here?

docs/components/props.md Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is confusing that some examples are using a lambda and other a separately defined function. I think in the docs we should only show one way to do it which should be the defining a separate function. Where we mention that you can do lambda functions we should show one easy example (the same color example with a lambda) to show what it looks like and that is it.

Copy link
Collaborator

@ElijahAhianyo ElijahAhianyo Nov 19, 2024

Choose a reason for hiding this comment

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

We can stick to using a separate function by default. However, for some cases, maybe it would make sense to show what using a lambda would look like. Typical example is the section on enumerating iterables where there's an index arg.
With the lamda, the index arg is explicitly stated whereas using with the case of defining a function, an extra arg/param would represent the index. Code below

Using Lamda:

class IterIndexState(rx.State):
    color: list[str] = [
        "red",
        "green",
        "blue",
    ]


def enumerate_foreach():
    return rx.vstack(
        rx.foreach(
            IterIndexState.color,
            lambda color, index: rx.box(
                rx.button(f"{index + 1}. {color}"),
                padding_y="0.5em",
            ),
        ),
    )

Using a defined function.

class IterIndexState(rx.State):
    color: list[str] = [
        "red",
        "green",
        "blue",
    ]


def create_button(color: rx.Var[str], index: int) -> rx.Component:
    return rx.button(
        f"{index + 1}. {color}",
        padding_y="0.5em",
    )


def enumerate_foreach():
    return rx.vstack(
        rx.foreach(
            IterIndexState.color,
            create_button,
        ),
    )
    ```

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think for this enumerating iterables example we should show both the examples with the defined function and the lambda so people know that they are identical and that they can do either

docs/pages/overview.md Outdated Show resolved Hide resolved
docs/pages/overview.md Outdated Show resolved Hide resolved
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.

3 participants