Skip to content

Commit

Permalink
bugifx
Browse files Browse the repository at this point in the history
  • Loading branch information
el3um4s committed Jul 17, 2021
1 parent f210de0 commit c34c509
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 111 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# MEMENTO SvelteKit Electron TypeScript
Template to create a desktop app with SvelteKit, Electron and TypeScript (with electron-updater, electron-reload and electron-builder)

**This project is still under development: the `todos` section doesn't work!**

## Get Started

This is a project template for [Svelte](https://svelte.dev) and [Electron](https://www.electronjs.org/) apps. It lives at https://github.com/el3um4s/memento-sveltekit-electron-typescript.
Expand Down
1 change: 0 additions & 1 deletion electron/configureDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class ConfigureDev {
_build_Dist() { exec("npm run svelte:build"); }
_watch_Dist() { require("electron-reload")(path.join(__dirname, "www")); }
_serve_Dist() {
// this.loadURL = serve({ directory: pathOnDisk, scheme: "html" });
this.loadURL = serve({ directory: "dist/www" });
}

Expand Down
2 changes: 1 addition & 1 deletion electron/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Main {

app.on('ready', () => {

let loading = new BrowserWindow({show: false, frame: false})
let loading = new BrowserWindow({show: false, frame: false, width: 300, height:300, transparent:true})

loading.once('show', async () => {
this.window = await this.createWindow();
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Memento: how to use Svelte with Electron and TypeScript",
"author": "Samuele de Tomasi <[email protected]>",
"license": "MIT",
"version": "0.0.3",
"version": "0.0.4",
"main": "dist/index.js",
"scripts": {
"nodemon": "nodemon",
Expand Down
69 changes: 0 additions & 69 deletions svelte/src/lib/form.ts

This file was deleted.

39 changes: 6 additions & 33 deletions svelte/src/routes/todos/index.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
<!-- <script context="module" lang="ts">
import { enhance } from '$lib/form';
// import type { Load } from '@sveltejs/kit';
// see https://kit.svelte.dev/docs#loading
// export const load: Load = async () => {
// globalThis.api.fileSystem.send('readFile', 'todos.json');
// let todos = [];
// await globalThis.api.fileSystem.receive('getFile', (data) => {
// console.log('globalThis.api.fileSystem.receive');
// console.log(data);
// todos = data;
// });
// console.log('TODO DATA LOAD');
// console.log(todos);
// return {
// props: { todos }
// };
// };
</script> -->
<script lang="ts">
import { slide } from 'svelte/transition';
import { scale } from 'svelte/transition';
import { slide, fade } from 'svelte/transition';
import { flip } from 'svelte/animate';
type Todo = {
Expand All @@ -30,9 +9,9 @@
done: boolean;
};
const fileName = 'todos.json';
export let todos: Todo[] = [];
let todo: string;
const fileName = 'todos.json';
globalThis.api.fileSystem.send('readFile', fileName);
globalThis.api.fileSystem.receive('getFile', (data) => {
Expand All @@ -53,7 +32,7 @@
}
}
function toggleDone(uid) {
function toggleDone(uid: string) {
todos = todos.map((t) => {
if (t.uid === uid) {
return { ...t, done: !t.done };
Expand All @@ -64,12 +43,12 @@
saveTodos();
}
function deleteTodo(uid) {
function deleteTodo(uid: string) {
todos = todos.filter((t) => t.uid !== uid);
saveTodos();
}
function updateTodo(uid, text) {
function updateTodo(uid: string, text: string) {
todos = todos.map((t) => {
if (t.uid === uid) {
return { ...t, text };
Expand Down Expand Up @@ -99,14 +78,8 @@
<form class="new" on:submit|preventDefault={saveNewTodo}>
<input name="text" aria-label="Add todo" placeholder="+ tap to add a todo" bind:value={todo} />
</form>

{#each todos as todo (todo.uid)}
<div
class="todo"
class:done={todo.done}
transition:scale|local={{ start: 0.7 }}
animate:flip={{ duration: 200 }}
>
<div class="todo" class:done={todo.done} transition:slide animate:flip={{ duration: 400 }}>
<form on:submit|preventDefault on:click={() => toggleDone(todo.uid)}>
<input type="hidden" name="done" value={todo.done ? '' : 'true'} />
<button class="toggle" aria-label="Mark todo as {todo.done ? 'not done' : 'done'}" />
Expand Down
17 changes: 16 additions & 1 deletion svelte/static/loading.html
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
loading
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loading</title>
</head>
<body>
<div style="width:100%; text-align: center;">
<div style="width: 256px; height: 256px; border-radius: 100%; background-color: rgb(240,240,240);">
<img width="256px" src="loading.png"/>
</div>
</div>
</body>
</html>
Binary file added svelte/static/loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion svelte/static/todos.json

This file was deleted.

0 comments on commit c34c509

Please sign in to comment.