GithubHelp home page GithubHelp logo

kjk / flex Goto Github PK

View Code? Open in Web Editor NEW
329.0 329.0 21.0 499 KB

Go implementation of CSS flexbox layout algorithm, port of Facebook's Yoga

Home Page: https://blog.kowalczyk.info/article/9/tutorial-on-using-github.comkjkflex-go-package.html

License: Other

Go 100.00%

flex's People

Contributors

crackcomm avatar ferhatelmas avatar kjk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flex's Issues

Layout params are set to NaN

package main

import (
	"github.com/kjk/flex"
)

func main() {
	root := flex.NewNode()
	root.StyleSetWidth(500)
	root.StyleSetHeight(120)
	root.StyleSetFlexDirection(flex.FlexDirectionRow)
	root.StyleSetPadding(flex.EdgeAll, 20)

	image := flex.NewNode()
	image.StyleSetWidth(80)
	image.StyleSetMargin(flex.EdgeEnd, 20)

	text := flex.NewNode()
	text.StyleSetHeight(25)
	text.StyleSetAlignSelf(flex.AlignCenter)
	text.StyleSetFlexGrow(1)

	root.InsertChild(image, 0)
	root.InsertChild(text, 1)

	flex.NodePrint(root, flex.PrintOptionsLayout|flex.PrintOptionsChildren|flex.PrintOptionsStyle)
}
>> go run main.go
<div layout="width: NaN; height: NaN; top: 0; left: 0;" style="flex-direction: ; width: 500px; height: 120px; " >
  <div layout="width: NaN; height: NaN; top: 0; left: 0;" style="width: 80px; " ></div>
  <div layout="width: NaN; height: NaN; top: 0; left: 0;" style="align-self: ; flex-grow: 1; height: 25px; " ></div>
</div>

Cssgrid

I am really interested in using this for golang apps with OpenGL Like Shiny and glfw.

Do you happen to know if Facebook or other have an implementation of the newer cssgrid ?
I find it more powerful than CSS flexbox for many reasons.

Padding style

Hey @kjk please let me know if I understand it correctly:

Is padding a CSS padding attribute? When I use:

navigation := flex.NewNodeWithConfig(config)
navigation.StyleSetHeight(60)
navigation.StyleSetPadding(flex.EdgeAll, 20)
navigation.StyleSetFlexDirection(flex.FlexDirectionRow)

for index := 0; index < 5; index++ {
    child := flex.NewNodeWithConfig(config)
    child.StyleSetPadding(flex.EdgeAll, 20)
    navigation.InsertChild(child, index)
}

I thought I'd receive padding: 20px, here is the output:

<div layout="width: 240; height: 60; top: 0; left: 0;" style="flex-direction: row; height: 60px; ">
    <div layout="width: 40; height: 40; top: 20; left: 20;" style=""></div>
    <div layout="width: 40; height: 40; top: 20; left: 60;" style=""></div>
    <div layout="width: 40; height: 40; top: 20; left: 100;" style=""></div>
    <div layout="width: 40; height: 40; top: 20; left: 140;" style=""></div>
    <div layout="width: 40; height: 40; top: 20; left: 180;" style=""></div>  
  </div>

Let me know if I understand it correctly or I misused it, thanks.

complete source

Any plans to catch up with Yoga?

I'm currently using some C bindings which I assembled and enhanced from different sources. However, it's working but the pure go version is of course much nicer.

Any plans to catch up with the Yoga development? I didn't diff yet to see if Yoga moved forward in the CSS algorithm area at all.

integration with lxn/walk

Does the layout algorithm can be used in combination with walk?
Is this your intention?

It could be either integrated or used as an external package, where walk would have to call into for every layout call.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.