Skip to content

Instantly share code, notes, and snippets.

View Inviz's full-sized avatar

Yaroslaff Fedin Inviz

  • Idealic
  • Ubud, Bali
View GitHub Profile
engine = new GSS(document)
var lastWidth = 0;
onResize = function() {
if ((lastWidth > 900) ^ (window.innerWidth) > 900) {
if (window.innerWidth > 900) {
engine.solve({})
} else {
engine.solve({})
getGSS: ->
this.constructor.prototype.engine ||= new GSS
componentWillMount() {
engine = this.getGSS()
engine.data.merge({
'$my-component-id"foo"[width]': 33,
'$my-component-id"foo"[height]': 55,
})
@Inviz
Inviz / gist:e7f8c81b39f3c8134a16
Last active August 29, 2015 14:13
parser todo
1) Add ; as alternative to ,
a,b;c,d should parse to ;(,(a,b) ,(c,d))
2) Make VFL use ; in its block rules
3) Update vflHook logging.
- Fixes an issue, when it didnt log calls without ruleset
- Uses proper deferred logging (input & output)
- normalizes @horizontal to @h
@Inviz
Inviz / implicit nesting.coffee
Created January 7, 2015 13:14
implicit nesting
describe 'as nested commands', ->
it 'should return final matrix', ->
rotated = engine.intrinsic.Matrix::_mat4.create()
rotated = engine.intrinsic.Matrix::_mat4.rotateY(rotated, rotated, - 18 * (Math.PI / 180))
rotated = engine.intrinsic.Matrix::_mat4.rotateZ(rotated, rotated, 180 * (Math.PI / 180))
rotate = ['rotateZ', ['rotateY', -0.05], 0.5]
expect(engine.intrinsic.Command(rotate).solve(engine.intrinsic, rotate)).
to.eql rotated
describe 'bound to font-size', ->
it 'should be able to compute width', (done) ->
container.innerHTML = """
<style type="text/gss-ast">
["rule", ["tag", "span"], [
[">=", ["get", "width"], ["em", 10]],
[">=", ["get", "height"], ["em", ["get", "c"]]],
[">=", ["get", "c"], 2]
]]
# Run solution in multiple ticks
commit: (update) ->
until update.isDone()
# Process deferred operations, mutations and conditions
@triggerEvent('precommit', update)
@triggerEvent('commit', update)
# Process queue
if update.domains.length
it 'in mixed stylesheets', (done) ->
engine = GSS(container)
container.innerHTML = """
<div id="ship"></div>
<style type="text/gss" id="gss1">
[b] == 10; // &
^ {
"mast" {
x: == [b]; // ^^
* Rules
* Selectors and rules
* Variables and constraints
* Dimensions and positions (right, bottom)
* Intrinsic values
* Scope and virtuals
* Grids
* Selectors in grids
@Inviz
Inviz / output.js
Created November 17, 2014 03:25
1.gss
[t] == 500;
@if [t] >= 960 {
#b {
width: == 100;
}
}
@Inviz
Inviz / types.js
Last active August 29, 2015 14:09
WrapperCommand = GSS::Command.extend {
signature: [
left: ['DynamicCommand']
right: ['Number']
]
}, {
'wrapper': (a) ->
return ['wrapper', a]
}