4466ba436b
## Description This PR ensures that the default prettier config is used for examples and templates. This config is compatible with `prettier@3` as well (upgrading prettier is bigger change that can be a future PR). ## Changes - Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will be needed upgrading to prettier@3) - Added `examples/.prettierrc.json` with default config (this will change every example) - Added `packages/create-next-app/templates/.prettierrc.json` with default config (this will change every template) ## Related - Fixes #54402 - Closes #54409
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import {
|
|
action,
|
|
observable,
|
|
computed,
|
|
runInAction,
|
|
makeObservable,
|
|
} from "mobx";
|
|
import { enableStaticRendering } from "mobx-react-lite";
|
|
|
|
enableStaticRendering(typeof window === "undefined");
|
|
|
|
export class Store {
|
|
lastUpdate = 0;
|
|
light = false;
|
|
|
|
constructor() {
|
|
makeObservable(this, {
|
|
lastUpdate: observable,
|
|
light: observable,
|
|
start: action,
|
|
hydrate: action,
|
|
timeString: computed,
|
|
});
|
|
}
|
|
|
|
start = () => {
|
|
this.timer = setInterval(() => {
|
|
runInAction(() => {
|
|
this.lastUpdate = Date.now();
|
|
this.light = true;
|
|
});
|
|
}, 1000);
|
|
};
|
|
|
|
get timeString() {
|
|
const pad = (n) => (n < 10 ? `0${n}` : n);
|
|
const format = (t) =>
|
|
`${pad(t.getUTCHours())}:${pad(t.getUTCMinutes())}:${pad(
|
|
t.getUTCSeconds(),
|
|
)}`;
|
|
return format(new Date(this.lastUpdate));
|
|
}
|
|
|
|
stop = () => clearInterval(this.timer);
|
|
|
|
hydrate = (data) => {
|
|
if (!data) return;
|
|
|
|
this.lastUpdate = data.lastUpdate !== null ? data.lastUpdate : Date.now();
|
|
this.light = !!data.light;
|
|
};
|
|
}
|