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

Add icons and onclick event handler to Navbar components #44

Merged
merged 3 commits into from
Sep 8, 2024

Conversation

micolous
Copy link
Contributor

@micolous micolous commented Sep 2, 2024

Add icons and onclick event handler to Navbar components.

This lets you use a Navbar to trigger other functions in the app.

I've added these to the basics example as well:

Screenshot 2024-09-02 at 13 57 12

Clicking them logs the event to the debug console, like the forms example does.

Misc changes:

  • NavDropdownItemProps: make url an Option, like NavItemProperties::url. Yew automatically converts existing usages.
  • NavDropdownItemProps: don't implement Eq, which is incompatible with Callback.
  • Fix spelling on basics example: Accordian -> Accordion
  • Trim trailing whitespace characters from end-of-line in navbar.rs (which unfortunately made things a bit noisy)

Copy link
Owner

@isosphere isosphere left a comment

Choose a reason for hiding this comment

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

Looks good, but what's with the quoted space characters when matching props.icon?

onclick={props.onclick.clone()}
>
if let Some(icon) = props.icon {
{icon}{" "}
Copy link
Owner

Choose a reason for hiding this comment

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

What's with the quoted space character?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd done that to provide a little bit of extra space between the icon an the text.

Without the space, it looks like this:

Screenshot 2024-09-08 at 10 49 59

I've also tried using the icon link helper, but that looks the same.

I tried switching build::bootstrap_icons() to use the same <svg class=...><use ...> syntax as the examples on that page:

sorted_icons.insert(lower_kebab_case, format!(
    "    pub const {upper_snake_case}: BI = BI(\"<svg class=\\\"bi\\\" aria-hidden=\\\"true\\\"><use xlink:href=\\\"#{lower_kebab_case}\\\"></use></svg>\");\n"
));

...but it looks like that Bootstrap Icons' SVG sprite sheet needs either embedding or re-hosting on the same domain to work correctly... so that's entirely broken:

Screenshot 2024-09-08 at 11 04 42

…xample.

Misc changes:

* `NavDropdownItemProps`: make `url` an `Option`, like `NavItemProperties`.
* `NavDropdownItemProps`: don't implement `Eq` (incompatible with `Callback`).
* Trim trailing whitespace characters from end-of-line.
@isosphere isosphere merged commit c94c700 into isosphere:main Sep 8, 2024
1 check passed
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.

2 participants