Skip to content

Commit

Permalink
chore: biome
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben committed Dec 7, 2024
1 parent 5363247 commit 3abf931
Show file tree
Hide file tree
Showing 42 changed files with 335 additions and 296 deletions.
95 changes: 48 additions & 47 deletions src/app.css
Original file line number Diff line number Diff line change
@@ -1,78 +1,79 @@
* {
box-sizing: border-box;
box-sizing: border-box;
}

body {
--shadow-el1: 0 5px 5px -3px #0003, 0 8px 10px 1px #00000024,
0 3px 14px 2px #0000001f;
--shadow-el2: 0px 11px 15px -7px rgba(0, 0, 0, 0.2),
0px 24px 38px 3px rgba(0, 0, 0, 0.14),
0px 9px 46px 8px rgba(0, 0, 0, 0.12);
--shadow-el1: 0 5px 5px -3px #0003, 0 8px 10px 1px #00000024, 0 3px 14px 2px
#0000001f;
--shadow-el2:
0px 11px 15px -7px rgba(0, 0, 0, 0.2),
0px 24px 38px 3px rgba(0, 0, 0, 0.14),
0px 9px 46px 8px rgba(0, 0, 0, 0.12);

--full-height: calc(100vh - 64px);
--full-height: calc(100vh - 64px);
}

body[data-color-scheme="light"] {
--background: #fff;
--robot: #fff;
--on-background: #000;
--background-tint: #f1f1f1;
--primary: #06778f;
--primary-dark-tint: #035e72;
--on-primary: #fff;
--secondary: lightgray;
--on-secondary: black;
--on-secondary-muted: rgb(109, 109, 109);
--accent: #32a5a9;
--on-accent: #fff;
--text-muted: #d3d3d3;
--warning: #ffcc00;
--background: #fff;
--robot: #fff;
--on-background: #000;
--background-tint: #f1f1f1;
--primary: #06778f;
--primary-dark-tint: #035e72;
--on-primary: #fff;
--secondary: lightgray;
--on-secondary: black;
--on-secondary-muted: rgb(109, 109, 109);
--accent: #32a5a9;
--on-accent: #fff;
--text-muted: #d3d3d3;
--warning: #ffcc00;
}
body[data-color-scheme="dark"] {
--background: #24242b;
--robot: #303039;
--on-background: #fff;
--background-tint: #22222c;
--primary: #104d59;
--primary-dark-tint: #1c798b;
--on-primary: #fff;
--secondary: #303039;
--on-secondary: #fff;
--on-secondary-muted: rgb(190, 190, 190);
--accent: #32a5a9;
--on-accent: #fff;
--text-muted: #535361;
--background: #24242b;
--robot: #303039;
--on-background: #fff;
--background-tint: #22222c;
--primary: #104d59;
--primary-dark-tint: #1c798b;
--on-primary: #fff;
--secondary: #303039;
--on-secondary: #fff;
--on-secondary-muted: rgb(190, 190, 190);
--accent: #32a5a9;
--on-accent: #fff;
--text-muted: #535361;
--warning: #ffcc00;
}

body {
margin: 0;
background: var(--background-tint);
color: var(--on-background);
font-family: sans-serif;
overflow: hidden;
margin: 0;
background: var(--background-tint);
color: var(--on-background);
font-family: sans-serif;
overflow: hidden;
}

.blocklyToolboxCategory {
margin: 3px 0;
margin: 3px 0;
}
.blocklyTreeRow {
box-sizing: content-box;
box-sizing: content-box;
}

.injectionDiv > .blocklyFlyout {
transform: translate(80px, 0) !important;
transform: translate(80px, 0) !important;
}

table,
tr,
td {
border: none;
margin: 0;
border-spacing: 0;
border: none;
margin: 0;
border-spacing: 0;
}

.blocklySvg {
z-index: 0;
background-color: transparent !important;
z-index: 0;
background-color: transparent !important;
}
14 changes: 10 additions & 4 deletions src/lib/components/core/header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { robots } from "$domain/robots";
import AppState, { Screen, Theme } from "$state/app.svelte";
import BlocklyState from "$state/blockly.svelte";
import PopupState from "$state/popup.svelte";
import SerialState, { Prompt } from "$state/serial.svelte";
import WorkspaceState, { Mode } from "$state/workspace.svelte";
import SerialState, { Prompt } from "$state/serial.svelte"
import {
faComment,
faDownload,
Expand Down Expand Up @@ -78,7 +78,9 @@ async function newProject() {
function serialize() {
if (WorkspaceState.Mode === Mode.BLOCKS)
return JSON.stringify(serialization.workspaces.save(BlocklyState.workspace));
return JSON.stringify(
serialization.workspaces.save(BlocklyState.workspace),
);
return WorkspaceState.code;
}
Expand Down Expand Up @@ -129,7 +131,9 @@ async function openProject() {
WorkspaceState.code = await content.text();
} else {
if (WorkspaceState.Mode === Mode.BLOCKS) {
if (!loadWorkspaceFromString(await content.text(), BlocklyState.workspace)) {
if (
!loadWorkspaceFromString(await content.text(), BlocklyState.workspace)
) {
return;
}
} else {
Expand Down Expand Up @@ -233,7 +237,9 @@ async function blocks() {
}
WorkspaceState.tempSave();
BlocklyState.restore = JSON.parse(localStorage.getItem(`${WorkspaceState.robot.id}_content`))
BlocklyState.restore = JSON.parse(
localStorage.getItem(`${WorkspaceState.robot.id}_content`),
);
WorkspaceState.Mode = Mode.BLOCKS;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/Renderer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { onMount } from "svelte";
import Popup from "./Popup.svelte";
onMount(async () => {
await PopupState.setup()
await PopupState.setup();
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/About.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import contribute from "$assets/contribute-foundation.png";
import Button from "$components/ui/Button.svelte";
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Button from "$components/ui/Button.svelte";
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
Expand Down
22 changes: 16 additions & 6 deletions src/lib/components/core/popups/popups/Connect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { isCompatible } from "$domain/blockly/blockly";
import { type RobotDevice, type Selector, getSelector } from "$domain/robots";
import BlocklyState from "$state/blockly.svelte";
import PopupsState, { type PopupState } from "$state/popup.svelte";
import WorkspaceState, { Mode } from "$state/workspace.svelte";
import SerialState, { Prompt } from "$state/serial.svelte";
import WorkspaceState, { Mode } from "$state/workspace.svelte";
import { faUsb } from "@fortawesome/free-brands-svg-icons";
import * as Blockly from "blockly";
import { getContext } from "svelte";
Expand Down Expand Up @@ -52,20 +52,27 @@ $effect(() => {
.robots.find((robot) => robot.board === SerialState.board.board);
if (robotType) WorkspaceState.robot = robotType;
})
});
const warning = $derived(
SerialState.board && WorkspaceState.robot && SerialState.board.board !== WorkspaceState.robot.board
SerialState.board &&
WorkspaceState.robot &&
SerialState.board.board !== WorkspaceState.robot.board
? $_("INVALID_ROBOT", {
values: { robot: WorkspaceState.robot.name, board: SerialState.board.name },
values: {
robot: WorkspaceState.robot.name,
board: SerialState.board.name,
},
})
: undefined,
);
function checkEnabled(robot: RobotDevice): boolean {
if (WorkspaceState.Mode !== Mode.BLOCKS) return true;
return BlocklyState.workspace ? isCompatible(BlocklyState.workspace, robot) : true;
return BlocklyState.workspace
? isCompatible(BlocklyState.workspace, robot)
: true;
}
async function disabledSelect() {
Expand All @@ -80,7 +87,10 @@ async function disabledSelect() {
});
if (!value) return false;
Blockly.serialization.workspaces.load(JSON.parse(defaultProgram), BlocklyState.workspace);
Blockly.serialization.workspaces.load(
JSON.parse(defaultProgram),
BlocklyState.workspace,
);
WorkspaceState.handle = undefined;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/Credits.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { _ } from "svelte-i18n";
import contribute from "$assets/contribute-foundation.png";
import leaphyLogo from "$assets/leaphy-logo-color.svg";
import Button from "$components/ui/Button.svelte";
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import { getContext } from "svelte";
const popupState = getContext<PopupState>("state");
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/DriverInstall.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import install_drivers from "$assets/install_drivers.mp4";
import Button from "$components/ui/Button.svelte";
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/Examples.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { inFilter } from "$domain/robots";
import BlocklyState from "$state/blockly.svelte";
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import WorkspaceState from "$state/workspace.svelte";
import { serialization } from "blockly";
import { getContext, onMount } from "svelte";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/Explanation.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
import SvelteMarkdown from "svelte-markdown";
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/core/popups/popups/LanguageSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import leaphyLogo from "$assets/leaphy-logo-color.svg";
import english from "$assets/translations/en.svg";
import dutch from "$assets/translations/nl.svg";
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import { getContext } from "svelte";
import { locale } from "svelte-i18n";
const popupState = getContext<PopupState>("state");
function select(language: string) {
locale.set(language);
localStorage.setItem("language", language);
popupState.close()
popupState.close();
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/Prompt.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import Button from "$components/ui/Button.svelte";
import TextInput from "$components/ui/TextInput.svelte";
import { type PopupState } from "$state/popup.svelte";
import type { PopupState } from "$state/popup.svelte";
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
Expand Down
10 changes: 5 additions & 5 deletions src/lib/components/core/popups/popups/PythonUploader.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script lang="ts">
import {_} from "svelte-i18n";
import { _ } from "svelte-i18n";
import RobotSelector from "$components/start/RobotSelector.svelte";
import Button from "$components/ui/Button.svelte";
import ProgressBar from "$components/ui/ProgressBar.svelte";
import {type RobotDevice, robots} from "$domain/robots";
import {type PopupState} from "$state/popup.svelte";
import { type RobotDevice, robots } from "$domain/robots";
import type { PopupState } from "$state/popup.svelte";
import SerialState, { SUPPORTED_VENDOR_IDS } from "$state/serial.svelte";
import USBRequestState from "$state/upload.svelte";
import WorkspaceState from "$state/workspace.svelte";
import SerialState, { SUPPORTED_VENDOR_IDS } from "$state/serial.svelte"
import {getContext, onMount} from "svelte";
import { getContext, onMount } from "svelte";
import type MicroPythonIO from "../../../../micropython";
interface Props {
Expand Down
12 changes: 7 additions & 5 deletions src/lib/components/core/popups/popups/SerialMonitor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import Chart from "$components/ui/Chart.svelte";
import TextInput from "$components/ui/TextInput.svelte";
import WindowButton from "$components/ui/WindowButton.svelte";
import PopupsState from "$state/popup.svelte";
import SerialState, { Prompt } from "$state/serial.svelte"
import SerialState, { Prompt } from "$state/serial.svelte";
import { track } from "$state/utils";
import {
faArrowDown,
faBars,
Expand All @@ -18,7 +19,6 @@ import { tick } from "svelte";
import Fa from "svelte-fa";
import { _ } from "svelte-i18n";
import Windowed from "../Windowed.svelte";
import {track} from "$state/utils";
enum Mode {
TEXT = 0,
Expand All @@ -39,12 +39,14 @@ function formatDate(date: Date) {
}
$effect(() => {
track(SerialState.log.log)
track(SerialState.log.log);
if (!element) return;
tick().then(() => element.scroll({ top: element.scrollHeight, behavior: "smooth" }));
})
tick().then(() =>
element.scroll({ top: element.scrollHeight, behavior: "smooth" }),
);
});
let value = $state("");
function send(event: SubmitEvent) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/core/popups/popups/UploadLog.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { SUPPORTED_VENDOR_IDS } from "$state/serial.svelte";
import WorkspaceState from "$state/workspace.svelte";
import { SUPPORTED_VENDOR_IDS } from "$state/serial.svelte"
import { _ } from "svelte-i18n";
import Windowed from "../Windowed.svelte";
</script>
Expand Down
Loading

0 comments on commit 3abf931

Please sign in to comment.