Code format
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
import { onMount } from 'svelte'
|
||||
import { type Food, FoodService } from '$lib/database/food'
|
||||
import type { Writable } from 'svelte/store'
|
||||
|
||||
let food: Food[] = []
|
||||
onMount(async () => {
|
||||
|
@@ -12,7 +12,8 @@ const FoodService = {
|
||||
async GetAll() {
|
||||
return await db.select<Food[]>('SELECT rowid, food, amount, per100, energy FROM food ORDER BY date DESC')
|
||||
},
|
||||
async SetAll(data: Food[]) {}
|
||||
async SetAll(data: Food[]) {
|
||||
}
|
||||
}
|
||||
|
||||
export {FoodService}
|
||||
export { FoodService }
|
||||
|
@@ -2,28 +2,26 @@
|
||||
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI_INVOKE__<T>(cmd: string, args?: Record<string, unknown>): Promise<T>;
|
||||
}
|
||||
interface Window {
|
||||
__TAURI_INVOKE__<T>(cmd: string, args?: Record<string, unknown>): Promise<T>;
|
||||
}
|
||||
}
|
||||
|
||||
// Function avoids 'window not defined' in SSR
|
||||
const invoke = () => window.__TAURI_INVOKE__;
|
||||
const invoke = () => window.__TAURI_INVOKE__
|
||||
|
||||
export function helloTauri() {
|
||||
return invoke()<string>("hello_tauri")
|
||||
return invoke()<string>('hello_tauri')
|
||||
}
|
||||
|
||||
export function hash256sum(hashInput: string) {
|
||||
return invoke()<string>("hash256sum", { hashInput })
|
||||
return invoke()<string>('hash256sum', { hashInput })
|
||||
}
|
||||
|
||||
export function storeSetKey(key: string, value: string) {
|
||||
return invoke()<null>("store_set_key", { key,value })
|
||||
return invoke()<null>('store_set_key', { key, value })
|
||||
}
|
||||
|
||||
export function storeReadKey(key: string) {
|
||||
return invoke()<string | null>("store_read_key", { key })
|
||||
return invoke()<string | null>('store_read_key', { key })
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<script lang="ts">
|
||||
import Router from 'svelte-spa-router'
|
||||
import Router from 'svelte-spa-router'
|
||||
|
||||
import Home from '$lib/router/routes/Home.svelte'
|
||||
import IPC from '$lib/router/routes/IPC.svelte'
|
||||
import Versions from '$router/routes/Versions.svelte'
|
||||
import Home from '$lib/router/routes/Home.svelte'
|
||||
import IPC from '$lib/router/routes/IPC.svelte'
|
||||
import Versions from '$router/routes/Versions.svelte'
|
||||
|
||||
const routes = {
|
||||
'/': Home,
|
||||
'/#ipc': IPC,
|
||||
'/#versions': Versions
|
||||
}
|
||||
const routes = {
|
||||
'/': Home,
|
||||
'/#ipc': IPC,
|
||||
'/#versions': Versions
|
||||
}
|
||||
</script>
|
||||
|
||||
<Router {routes} />
|
||||
|
@@ -1,14 +1,14 @@
|
||||
<section class="h-full flex-col flex items-center justify-center gap-y-8">
|
||||
<h1 class="text-6xl">Welcome</h1>
|
||||
<h2 class="flex items-center text-3xl [&_img]:h-12">
|
||||
This is a  
|
||||
<span>
|
||||
<img src="/svelte_logo.svg" alt="svelte logo" />
|
||||
<h1 class="text-6xl">Welcome</h1>
|
||||
<h2 class="flex items-center text-3xl [&_img]:h-12">
|
||||
This is a  
|
||||
<span>
|
||||
<img alt="svelte logo" src="/svelte_logo.svg" />
|
||||
</span>
|
||||
 - 
|
||||
<span>
|
||||
<img src="/tauri_logo.svg" alt="svelte logo" />
|
||||
 - 
|
||||
<span>
|
||||
<img alt="svelte logo" src="/tauri_logo.svg" />
|
||||
</span>
|
||||
  Template
|
||||
</h2>
|
||||
  Template
|
||||
</h2>
|
||||
</section>
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import CallTauri from '$lib/components/IPC/CallTauri.svelte'
|
||||
import HashString from '$lib/components/IPC/HashString.svelte'
|
||||
import KeyValuePair from '$lib/components/IPC/KeyValuePair.svelte'
|
||||
import CallTauri from '$lib/components/IPC/CallTauri.svelte'
|
||||
import HashString from '$lib/components/IPC/HashString.svelte'
|
||||
import KeyValuePair from '$lib/components/IPC/KeyValuePair.svelte'
|
||||
</script>
|
||||
|
||||
<div class="h-full flex flex-col items-center justify-center gap-y-8">
|
||||
<CallTauri />
|
||||
<HashString />
|
||||
<KeyValuePair />
|
||||
<CallTauri />
|
||||
<HashString />
|
||||
<KeyValuePair />
|
||||
</div>
|
||||
|
@@ -1,34 +1,35 @@
|
||||
<script lang="ts">
|
||||
import { getTauriVersion, getVersion, getName } from '@tauri-apps/api/app'
|
||||
type Versions = {
|
||||
tauri: string
|
||||
app: string
|
||||
name: string
|
||||
}
|
||||
import { getName, getTauriVersion, getVersion } from '@tauri-apps/api/app'
|
||||
|
||||
const getVersions = async (): Promise<Versions> => {
|
||||
const [name, tauri, app] = await Promise.all([
|
||||
getName(),
|
||||
getTauriVersion(),
|
||||
getVersion()
|
||||
])
|
||||
return {
|
||||
tauri,
|
||||
app,
|
||||
name
|
||||
}
|
||||
}
|
||||
type Versions = {
|
||||
tauri: string
|
||||
app: string
|
||||
name: string
|
||||
}
|
||||
|
||||
const getVersions = async (): Promise<Versions> => {
|
||||
const [name, tauri, app] = await Promise.all([
|
||||
getName(),
|
||||
getTauriVersion(),
|
||||
getVersion()
|
||||
])
|
||||
return {
|
||||
tauri,
|
||||
app,
|
||||
name
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<section class="h-full flex flex-col items-center justify-center gap-10">
|
||||
<h1 class="text-5xl font-extrabold italic">Versions</h1>
|
||||
<ul class="flex flex-col gap-2">
|
||||
{#await getVersions() then versions}
|
||||
{#each Object.entries(versions) as [key, val]}
|
||||
<li class="text-xl font-bold">
|
||||
{key} - {val}
|
||||
</li>
|
||||
{/each}
|
||||
{/await}
|
||||
</ul>
|
||||
<h1 class="text-5xl font-extrabold italic">Versions</h1>
|
||||
<ul class="flex flex-col gap-2">
|
||||
{#await getVersions() then versions}
|
||||
{#each Object.entries(versions) as [key, val]}
|
||||
<li class="text-xl font-bold">
|
||||
{key} - {val}
|
||||
</li>
|
||||
{/each}
|
||||
{/await}
|
||||
</ul>
|
||||
</section>
|
||||
|
@@ -4,59 +4,59 @@ import { cubicOut } from 'svelte/easing'
|
||||
import type { TransitionConfig } from 'svelte/transition'
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
type FlyAndScaleParams = {
|
||||
y?: number
|
||||
x?: number
|
||||
start?: number
|
||||
duration?: number
|
||||
y?: number
|
||||
x?: number
|
||||
start?: number
|
||||
duration?: number
|
||||
}
|
||||
|
||||
export const flyAndScale = (
|
||||
node: Element,
|
||||
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 }
|
||||
node: Element,
|
||||
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 }
|
||||
): TransitionConfig => {
|
||||
const style = getComputedStyle(node)
|
||||
const transform = style.transform === 'none' ? '' : style.transform
|
||||
const style = getComputedStyle(node)
|
||||
const transform = style.transform === 'none' ? '' : style.transform
|
||||
|
||||
const scaleConversion = (
|
||||
valueA: number,
|
||||
scaleA: [number, number],
|
||||
scaleB: [number, number]
|
||||
) => {
|
||||
const [minA, maxA] = scaleA
|
||||
const [minB, maxB] = scaleB
|
||||
const scaleConversion = (
|
||||
valueA: number,
|
||||
scaleA: [number, number],
|
||||
scaleB: [number, number]
|
||||
) => {
|
||||
const [minA, maxA] = scaleA
|
||||
const [minB, maxB] = scaleB
|
||||
|
||||
const percentage = (valueA - minA) / (maxA - minA)
|
||||
const valueB = percentage * (maxB - minB) + minB
|
||||
const percentage = (valueA - minA) / (maxA - minA)
|
||||
const valueB = percentage * (maxB - minB) + minB
|
||||
|
||||
return valueB
|
||||
}
|
||||
return valueB
|
||||
}
|
||||
|
||||
const styleToString = (
|
||||
style: Record<string, number | string | undefined>
|
||||
): string => {
|
||||
return Object.keys(style).reduce((str, key) => {
|
||||
if (style[key] === undefined) return str
|
||||
return str + `${key}:${style[key]};`
|
||||
}, '')
|
||||
}
|
||||
const styleToString = (
|
||||
style: Record<string, number | string | undefined>
|
||||
): string => {
|
||||
return Object.keys(style).reduce((str, key) => {
|
||||
if (style[key] === undefined) return str
|
||||
return str + `${key}:${style[key]};`
|
||||
}, '')
|
||||
}
|
||||
|
||||
return {
|
||||
duration: params.duration ?? 200,
|
||||
delay: 0,
|
||||
css: t => {
|
||||
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0])
|
||||
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0])
|
||||
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1])
|
||||
return {
|
||||
duration: params.duration ?? 200,
|
||||
delay: 0,
|
||||
css: t => {
|
||||
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0])
|
||||
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0])
|
||||
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1])
|
||||
|
||||
return styleToString({
|
||||
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,
|
||||
opacity: t
|
||||
})
|
||||
},
|
||||
easing: cubicOut
|
||||
}
|
||||
return styleToString({
|
||||
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,
|
||||
opacity: t
|
||||
})
|
||||
},
|
||||
easing: cubicOut
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user