Skip to content

Functional builders for vecty elements (not maintained right now)

License

Notifications You must be signed in to change notification settings

go-functional/functy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hi Gophers! Unfortunately, I don't have the time to maintain this library right now, so I can't add any features. I'll gladly accept pull requests if you're interested. Also, if you'd like to maintaining the library longer term, I'm also happy to welcome you as a contributor. If you're interested in either submitting a PR or being a longer term maintainer, please let me know on the Gophers Slack. My username there is arschles.

functy

Often times, vecty code will have lots of nested function calls and the code gets hard to read and manage. This module has convenience functions for building up vecty elements in a functional pattern.

Below is an example adapted from the vecty example code for rendering Markdown:

import (
    "github.com/go-functional/functy"
    "github.com/gopherjs/vecty/elem"
    "github.com/gopherjs/vecty"
)

// PageView is our main page component.
type PageView struct {
    vecty.Core
    Input string
}

// Render implements the vecty.Component interface.
func (p *PageView) Render() vecty.ComponentOrHTML {
    body := functy.Wrap(elem.Body)
    div := functy.Wrap(elem.Div).
        Markup(vecty.Style("float", "right"))
    textArea := functy.Wrap(elem.TextArea).
        Markup(vecty.Style("font-family", "monospace")).
        Markup(vecty.Property("rows", 14)).
        Markup(vecty.Property("cols", 70)).
        Markup(event.Input(func(e *vecty.Event) {
            p.Input = e.Target.Get("value").Strting()
            vecty.Rerender(p)
        }))
        Markup(elem.TextArea).
        Child(vecty.Text(p.Input))
    return functy.Wrap(elem.Body).Child(div.Child(textArea))
}

Inspired by:

And built on the shoulders of vecty, of course!

About

Functional builders for vecty elements (not maintained right now)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages