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

feat: add a ‘lib/demo/ui’ package #527

Merged
merged 4 commits into from
May 4, 2023
Merged

Conversation

moul
Copy link
Member

@moul moul commented Feb 18, 2023

The goals are to provide a way to:

  • build UIs with more go and less markdown,
  • make realms’ code more readable thanks to widgets (breadcrumb,
  • have consistent interfaces from a realm to another,
  • later, to support extended markdown options (Proposal: extend markdown rendering #439),
  • encourage people building/extending UI frameworks with a first one (of a long series?).

PS: I don’t like the current API, but I wanted to crash test something, then iterate.
I will probably switch to a single generic type Element structOrInterface{Prepend, Set, Append}.
Opinions are appreciated.

Demo:

import "gno.land/p/demo/ui"

func Render(path string) string {
	var dom ui.DOM
	dom.Title = "UI Demo"
	dom.Header.Append(ui.Breadcrumb(
		ui.Link{Text: "foo", Path: "foo"},
		ui.Link{Text: "bar", Path: "foo/bar"},
	))

	dom.Body.Append(
		ui.Paragraph("Simple UI demonstration."),
		ui.BulletList(
			ui.Text("a text"),
			ui.Link{Text: "a relative link", Path: "foobar"},
			ui.Text("another text"),
			ui.Bold("a bold text"),
			ui.Italic("italic text"),
			ui.Text("raw markdown with **bold** text in the middle."),
			ui.Code("some inline code"),
			ui.Link{Text: "a remote link", URL: "https://gno.land"},
		),
	)

	dom.Footer.Append(ui.Text("I'm the footer."))
	dom.Body.Append(ui.Text("another string."))
	dom.Body.Append(ui.Paragraph("a paragraph."), ui.HR())

	return dom.String()
}

Addresses #903

@moul moul self-assigned this Feb 18, 2023
@moul moul changed the title feat: add a demo/ui package and demo realm feat: add a ‘ui’ package Feb 18, 2023
Signed-off-by: Manfred Touron <[email protected]>
Signed-off-by: Manfred Touron <[email protected]>
@moul moul changed the title feat: add a ‘ui’ package feat: add a ‘lib/demo/ui’ package Mar 18, 2023
@moul moul mentioned this pull request Mar 18, 2023
@moul moul mentioned this pull request Apr 28, 2023
16 tasks
@tbruyelle
Copy link
Contributor

I like the simplicity of the API thanks to the stringer interface, I think it's good enough but probably I lack experience in writing complex Render methods to have a worthwhile opinion.

Can you elaborate a little bit more why would you prefer something like type Element structOrInterface{Prepend, Set, Append} ?

@moul
Copy link
Member Author

moul commented Apr 28, 2023

Thanks @tbruyelle 🙏

I may have gone overboard with defining too many structs/interfaces. Consolidating them into a single ui.Element struct could improve readability and reusability. Although I typically prefer breaking down larger structs, in this instance, combining them might be more advantageous.

As for the API, we can merge it now and create a competing alternative ui2 at a later time. What are your thoughts on this?

@tbruyelle
Copy link
Contributor

Yes I'm for merging it now, so we can easily complement @alexiscolin's work like for ui.Jumbotron().

Currently I had to rebase your branch and push it to my fork with the new commits, so how do you want to proceed for the PR? We can do it from my fork, or if you want it fron your fork, you can rebase and then cherry-pick my commit on jumbotron.

@moul moul marked this pull request as ready for review April 28, 2023 15:24
@moul moul requested a review from a team as a code owner April 28, 2023 15:24
Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

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

LGTM

@moul moul merged commit ff2189e into gnolang:master May 4, 2023
@moul moul deleted the dev/moul/ui branch May 4, 2023 16:46
peter7891 pushed a commit that referenced this pull request May 9, 2023
moul-bot pushed a commit that referenced this pull request May 19, 2023
@moul moul mentioned this pull request Jun 16, 2023
12 tasks
@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants