-
Notifications
You must be signed in to change notification settings - Fork 185
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
base: main
Are you sure you want to change the base?
Conversation
|
||
## 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!). | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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,
),
)
```
There was a problem hiding this comment.
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
d918b2a
to
b349f72
Compare
No description provided.