Git Product home page Git Product logo

casscade's Introduction

Casscade - (Experimental) Cassowary constraint-based layouts using Houdini CSS layout worklets

This is a very, very experimental, borderline proof of concept implementation of Houdini layout worklets for CSS that provide linear constraint solving for block containers with block children.

At the time of writing, the system is quite crude. There is no developer sugar, so the constraints are quite verbose.

The parent element is given display: layout(casscade), and each child is given a --name: some-name property. The parent then defines --rule: ..., where ... is a set of linear constraints.

The constraint syntax sports complete expression parsing and can refer to child elements directly by their --names. The terminating identifier in a term must be a symbol - a built-in variable supplied by Casscade.

All element names must be lowercase. All symbols are uppercase.

Symbols include:

  • L, R, T and B for left/right/top/bottom respectively
  • W and H for width/height
  • M and C for (vertical) middle and (horizontal) center, respectively

These symbols can then be used in the --rule constraints to relate element metrics to one another.

For example, to position #lower below #upper with 5 pixels of vertical gap and align their horizontal centers, one might write the following styles:

#parent > #upper { --name: upper; }
#parent > #lower { --name: lower; }

#parent {
	display: layout(casscade);

	--rule:
		/* baseline positioning */
		upper.L == 0, upper.T == 0,

		/* vertical positioning */
		lower.T == upper.B + 5,

		/* align centers */
		lower.C == upper.C;
}

The example in this repository should render like the following:

four boxes stacked on top of each other with their horzontal centers aligned

Building

Clone, npm i and then npm run build. Serve with your favorite static web server.

You'll need a browser listed as supporting some version of the Layout API. A list can be found on ishoudinireadyyet.com.

License

Casscade is released under the MIT License.

casscade's People

Contributors

qix- avatar

Stargazers

Andrew Elgert avatar lifeng1992 avatar Tyler Davis Mitchell avatar Elliot Fiske avatar zhanba avatar Jordan Pittman avatar

Watchers

 avatar  avatar

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.