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

fixing breakpoint #1448

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 fastn-js/js/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ class Node2 {
if (fastn_utils.isNull(staticValue)) {
return;
}
ftd.breakpoint_width.set("mobile", fastn_utils.getStaticValue(staticValue));
ftd.breakpoint_width.set(fastn_utils.getStaticValue(staticValue));
} else if (kind === fastn_dom.PropertyKind.Css) {
let css_list = staticValue.map(obj => fastn_utils.getStaticValue(obj.item));
css_list.forEach((css) => {
Expand Down
3 changes: 1 addition & 2 deletions fastn-js/js/fastn.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ class RecordInstance {
}

this.#fields = fields;
}
if (this.#fields[key] === undefined) {
}else if (this.#fields[key] === undefined) {
this.#fields[key] = fastn.mutable(null);
this.#fields[key].setWithoutUpdate(value);
} else {
Expand Down
13 changes: 13 additions & 0 deletions fastn-js/js/virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,22 @@ class Document2 {

fastn_virtual.document = new Document2();

function addClosureToBreakpointWidth() {
let closure = fastn.closureWithoutExecute(function() {
let current = ftd.get_device();
let lastDevice = ftd.device.get();
if (current === lastDevice) {
return;
}
console.log("last_device", lastDevice, "current_device", current);
ftd.device.set(current);
});

ftd.breakpoint_width.addClosure(closure);
}

fastn_virtual.hydrate = function(main) {
addClosureToBreakpointWidth();
let current_device = ftd.get_device();
let found_device = ftd.device.get();
if (current_device !== found_device) {
Expand Down
9 changes: 9 additions & 0 deletions ftd/t/js/72-document-breakpoint.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- ftd.document:
breakpoint: 800

-- ftd.text:
color: red
text if { ftd.device == "mobile" }: Mobile text
text if { ftd.device == "desktop" }: Desktop text

-- end: ftd.document
101 changes: 101 additions & 0 deletions ftd/t/js/72-document-breakpoint.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading