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

Refactor Styling #140

Merged
merged 23 commits into from
Oct 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f8fb50f
Start refactoring styling (parsing).
gdotdesign Sep 25, 2019
512554c
Started style builder.
gdotdesign Sep 25, 2019
8d7a2cc
Merge branch 'master' into refactor-styling
gdotdesign Sep 25, 2019
7605cec
Implement proper style builder.
gdotdesign Oct 16, 2019
ea0bf8a
Use StyleBuilder in the compiler as well.
gdotdesign Oct 17, 2019
f8ced07
Naive implementation of if expression for CSS.
gdotdesign Oct 22, 2019
93de982
Make else branch optional for CSS if.
gdotdesign Oct 23, 2019
00ad488
Move static variables compiling to style builder.
gdotdesign Oct 23, 2019
b031a64
Refactor variable compiler of style builder into it's own class.
gdotdesign Oct 23, 2019
30f9b93
Merge branch 'master' into refactor-styling
gdotdesign Oct 23, 2019
2942d82
Add fallback value to variables.
gdotdesign Oct 23, 2019
5e521f1
Use a function instead of a get for styles.
gdotdesign Oct 24, 2019
4a53b55
Allow multiple styles on HTML elements.
gdotdesign Oct 24, 2019
dc49c0d
Implemented case for css.
gdotdesign Oct 25, 2019
380275a
Unify compiling of dynamic CSS definitions.
gdotdesign Oct 25, 2019
cfbd87d
Allow arguments on styles.
gdotdesign Oct 25, 2019
605e3d5
Implement type checking and compiling of style arguments.
gdotdesign Oct 25, 2019
962d7c4
Use $ instead of _ for style functions and use selector id instead of…
gdotdesign Oct 25, 2019
0770911
Use "#{...}" for CSS interpolaction instealof "{...}"
gdotdesign Oct 25, 2019
9ca79e8
Use new interpolation in tests.
gdotdesign Oct 25, 2019
3a53f35
Try to fix CSS definition vs CSS interpolation ambiguousity.
gdotdesign Oct 25, 2019
1c0d00e
Resolve CSS definition vs CSS selector ambiguity.
gdotdesign Oct 26, 2019
227a209
Add semicolon to JS statements.
gdotdesign Oct 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build:
crystal build src/mint.cr -o mint -p && mv mint ~/.bin/mint && mint

test:
crystal spec -p && bin/ameba
crystal spec -p --error-trace && bin/ameba

test-core:
crystal build src/mint.cr -o mint -p && cd core && ../mint test -b firefox && cd .. && rm mint
Expand Down
2 changes: 1 addition & 1 deletion core/tests/Dom.mint
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ component Test.Dom.Focus {
state shown : Bool = false

style input {
display: {display};
display: #{display};
}

get display : String {
Expand Down
10 changes: 5 additions & 5 deletions spec/compilers/access
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ const A = _R({
"name",
Decoder.string
]
})
});

class B extends _C {
render() {
let a = new A({
name: `test`
})
});

return a.name
return a.name;
}
}
};

B.displayName = "Main"
B.displayName = "Main";
32 changes: 16 additions & 16 deletions spec/compilers/access_call
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@ component Main {
--------------------------------------------------------------------------------
class C extends _E {
constructor(_0) {
super()
this._0 = _0
this.length = 1
super();
this._0 = _0;
this.length = 1;
}
}
};

class A extends _C {
a(b) {
return b
return b;
}

render() {
return _h("div", {})
return _h("div", {});
}
}
};

A.displayName = "Test"
A.displayName = "Test";

class B extends _C {
c() {
return (() => {
const _ = (() => {
const _ = this._test
return _s(_,(_) => _.a)
})()
const _ = this._test;
return _s(_,(_) => _.a);
})();

return _s(_,(_) => _(`asd`))
})()
return _s(_,(_) => _(`asd`));
})();
}

render() {
Expand All @@ -63,8 +63,8 @@ class B extends _C {
_h(A, {
ref: (instance) => { this._test = new C(instance) }
})
])
]);
}
}
};

B.displayName = "Main"
B.displayName = "Main";
12 changes: 6 additions & 6 deletions spec/compilers/argument
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ component Main {
--------------------------------------------------------------------------------
class A extends _C {
a(c, b) {
return b
return b;
}

render() {
return (() => {
this.a(``, 0)
return ``
})()
this.a(``, 0);
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
16 changes: 8 additions & 8 deletions spec/compilers/array_access
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ component Main {
--------------------------------------------------------------------------------
class A extends _C {
a() {
return _at([`Hello`, `Blah`, `Joe`], 1)
return _at([`Hello`, `Blah`, `Joe`], 1);
}

b() {
return _at([], 1)
return _at([], 1);
}

render() {
return (() => {
this.a()
this.b()
return ``
})()
this.a();
this.b();
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
12 changes: 6 additions & 6 deletions spec/compilers/array_literal
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ component Main {
--------------------------------------------------------------------------------
class A extends _C {
a() {
return [`Hello`, `Blah`, `Joe`]
return [`Hello`, `Blah`, `Joe`];
}

render() {
return (() => {
this.a()
return ``
})()
this.a();
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
12 changes: 6 additions & 6 deletions spec/compilers/bool_literal_false
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ component Main {
--------------------------------------------------------------------------------
class A extends _C {
a() {
return false
return false;
}

render() {
return (() => {
this.a()
return ``
})()
this.a();
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
12 changes: 6 additions & 6 deletions spec/compilers/bool_literal_true
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ component Main {
--------------------------------------------------------------------------------
class A extends _C {
a() {
return true
return true;
}

render() {
return (() => {
this.a()
return ``
})()
this.a();
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
16 changes: 8 additions & 8 deletions spec/compilers/case
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ component Main {
class A extends _C {
a() {
return (() => {
let b = `Hello`
let b = `Hello`;

if (_compare(b, `test`)) {
return true
} else if (_compare(b, `Hello`)) {
return false
} else {
return false
}
})()
};
})();
}

render() {
return (() => {
this.a()
return ``
})()
this.a();
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
44 changes: 22 additions & 22 deletions spec/compilers/case_with_enum_destructuring
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,46 @@ component Main {
--------------------------------------------------------------------------------
class B extends _E {
constructor(_0) {
super()
this._0 = _0
this.length = 1
super();
this._0 = _0;
this.length = 1;
}
}
};

class C extends _E {
constructor(_0) {
super()
this._0 = _0
this.length = 1
super();
this._0 = _0;
this.length = 1;
}
}
};

class A extends _C {
a(b) {
return (() => {
let c = b
let c = b;

if (c instanceof C) {
const d = c._0
const d = c._0;

return (() => {
let e = d
let e = d;

if (e instanceof B) {
const f = e._0
return f
}
})()
}
})()
const f = e._0;
return f;
};
})();
};
})();
}

render() {
return (() => {
this.a(new C(new B(``)))
return ``
})()
this.a(new C(new B(``)));
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
36 changes: 18 additions & 18 deletions spec/compilers/catch
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,44 @@ component Main {
--------------------------------------------------------------------------------
const B = new(class extends _M {
c(e) {
return
return;
}
})
});

class A extends _C {
a() {
return (async () => {
let _ = null
let _ = null;

try {
let b = await (async () => {
try {
return await B.c(`hello`)
} catch (_error) {
let d = _error
_ = null
throw new DoError()
let d = _error;
_ = null;
throw new DoError();
}
})()
})();

_ = await null
_ = await null;
} catch (_error) {
if (!(_error instanceof DoError)) {
console.warn(`Unhandled error in sequence expression:`)
console.warn(_error)
console.warn(`Unhandled error in sequence expression:`);
console.warn(_error);
}
}
};

return _
})()
return _;
})();
}

render() {
return (() => {
this.a()
return ``
})()
this.a();
return ``;
})();
}
}
};

A.displayName = "Main"
A.displayName = "Main";
6 changes: 3 additions & 3 deletions spec/compilers/component
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ component Main {
--------------------------------------------------------------------------------
class A extends _C {
render() {
return _h("div", {})
return _h("div", {});
}
}
};

A.displayName = "Main"
A.displayName = "Main";
Loading