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 missing 'hidden' attribute #224

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

glsubri
Copy link
Contributor

@glsubri glsubri commented Oct 9, 2024

Hey @markuswustenberg

I realised today that gomponents had no hidden attribute. So I thought I could add it.

However, quickly going through MDN, I realised that it could also take the 'until-found' string value (see MDN docs).

I think it would be nicer to have something like this:

func Hidden() g.Node {
	return g.Attr("hidden")
}

func HiddenUntilFound() g.Node {
	return g.Attr("hidden", "until-found")
}

func example() g.Node {
	return Div(
		Hidden(),
	)
}

Instead of

func Hidden(v string) g.Node {
	return g.Attr("hidden", v)
}

func example() g.Node {
	return Div(
		Hidden(""),
	)
}

I know that it deviates a bit from the way you've written the other attributes but this feels nicer to me.

What do you think ?

@markuswustenberg
Copy link
Member

@glsubri thanks for this!

HTML is just the gift that keeps on giving with new surprises. 😅

I value consistency a lot, so I would lean towards adding just:

func Hidden(v string) g.Node {
	return g.Attr("hidden", v)
}

And letting the user figure it out according to the docs. Since hidden, hidden="", and hidden="hidden" are equivalent, I wouldn't mind the additional empty string argument.

Thoughts?

@glsubri
Copy link
Contributor Author

glsubri commented Oct 10, 2024

Hey @markuswustenberg

Works for me. I've made the changes 👍

@markuswustenberg
Copy link
Member

Thanks!

@markuswustenberg markuswustenberg merged commit 05d5660 into maragudk:main Oct 10, 2024
7 checks passed
@glsubri glsubri deleted the add-hidden-attribute branch October 10, 2024 12:32
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