fix: snake_case for PackageFile, refactored Modal into 2 components

This commit is contained in:
LynithDev 2024-06-02 21:02:28 +02:00
parent 718f1c00de
commit 366637c25f
6 changed files with 57 additions and 30 deletions

View file

@ -57,7 +57,7 @@ prisma-client-rust-cli = { git = "https://github.com/brendonovich/prisma-client-
], default-features = false }
prisma-client-rust-sdk = { git = "https://github.com/brendonovich/prisma-client-rust", rev = "4f9ef9d38ca732162accff72b2eb684d2f120bab", features = [ "sqlite" ], default-features = false }
interpulse = { git = "https://github.com/pulseflow/workers", rev = "dd85302dddc14861b60829cf8c71f52ffd6a7851" }
interpulse = { git = "https://github.com/pulseflow/workers", rev = "909a08897a5dc6f9e13729c3e6c622f045496801", features = [ "specta" ] }
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", features = [
@ -82,7 +82,7 @@ uuid = { version = "1.8", features = [
"serde",
"v4"
] }
tokio = { version = "1.37", features = [ "full" ] }
tokio = { version = "1.38", features = [ "full" ] }
async-tungstenite = { version = "0.25", features = [
"tokio-runtime",
"tokio-rustls-native-certs"

View file

@ -6,6 +6,7 @@ use async_zip::tokio::read::fs::ZipFileReader;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sha2::Digest;
use specta::specta;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use tokio::io::AsyncReadExt;
@ -267,7 +268,7 @@ pub enum PackageDependency {
/// The Client/Server side type of a [`Package`].
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
// #[serde(rename_all = "kebab-case")]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "tauri", derive(specta::Type))]
pub enum PackageSide {
Required,
@ -279,7 +280,7 @@ pub enum PackageSide {
/// The file type of a [`Package`].
#[cfg_attr(feature = "tauri", derive(specta::Type))]
#[derive(Serialize, Deserialize, Clone, Debug)]
// #[serde(rename_all = "kebab-case")]
#[serde(rename_all = "snake_case")]
pub enum PackageFile {
RequiredPack,
OptionalPack,

View file

@ -16,7 +16,7 @@ function App(props: ParentProps) {
return (
<main class="flex flex-col bg-primary w-full min-h-screen overflow-hidden h-screen max-h-screen text-fg-primary">
<ErrorBoundary><WindowFrame /></ErrorBoundary>
<WindowFrame />
<div class="flex flex-col px-8">
<Navbar />
</div>

View file

@ -40,7 +40,7 @@ function WindowFrame() {
});
return (
<div data-tauri-drag-region class="flex flex-row justify-between items-center w-screen h-8 bg-secondary gap-0.5 pr-0.5">
<div data-tauri-drag-region class="z-[99999] flex flex-row justify-between items-center w-screen h-8 bg-secondary gap-0.5 pr-0.5">
<div class="flex flex-row items-center">
<TitlebarButton icon={ChevronLeftIcon} onClick={() => history.back()} />
</div>

View file

@ -0,0 +1,32 @@
import type {
Accessor,
ParentProps,
Setter,
} from 'solid-js';
import { Portal } from 'solid-js/web';
type FullscreenOverlayProps = {
visible: Accessor<boolean>;
setVisible: Setter<boolean>;
} & ParentProps;
function FullscreenOverlay(props: FullscreenOverlayProps) {
function onBackdropClick() {
props.setVisible(false);
}
return (
<Portal>
<div class={`fixed z-[1000] top-0 left-0 w-screen h-screen bg-black/60 backdrop-blur-sm backdrop-grayscale transition-opacity ${props.visible() ? 'opacity-100 pointer-events-auto' : 'opacity-0 pointer-events-none'}`}>
<div class="absolute w-full h-full" onClick={() => onBackdropClick()} />
<div class="absolute top-0 left-0 w-screen h-screen">
{props.children}
</div>
</div>
</Portal>
);
}
export default FullscreenOverlay;

View file

@ -5,8 +5,8 @@ import type {
Setter,
} from 'solid-js';
import { For, mergeProps } from 'solid-js';
import { Portal } from 'solid-js/web';
import Button from '../base/Button';
import FullscreenOverlay from './FullscreenOverlay';
type ModalButtonProps = string | JSX.Element;
@ -36,33 +36,27 @@ type ModalProps = {
function Modal(props: ModalProps) {
const merged: ModalProps = mergeProps({ buttons: ['Ok'] }, props);
function onBackdropClick() {
props.setVisible(false);
}
return (
<Portal>
<div class={`fixed z-[1000] top-0 left-0 w-screen h-screen bg-black/60 backdrop-blur-sm backdrop-grayscale transition-all ${props.visible() ? 'opacity-100 pointer-events-auto' : 'opacity-0 pointer-events-none'}`}>
<div class="absolute w-full h-full" onClick={() => onBackdropClick()} />
<div class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2">
<div class="bg-primary border border-white/5 p-4 rounded-lg text-center flex flex-col gap-y-2">
<h2>{props.title}</h2>
<div class="flex flex-col">
{props.children}
</div>
<div class="flex flex-row gap-x-4 [&>*]:flex-1">
<For each={merged.buttons}>
{button => (
<ModalButton props={button} />
)}
</For>
</div>
<FullscreenOverlay
visible={props.visible}
setVisible={props.setVisible}
>
<div class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2">
<div class="bg-primary border border-white/5 p-4 rounded-lg text-center flex flex-col gap-y-2 min-w-xs">
<h2>{props.title}</h2>
<div class="flex flex-col">
{props.children}
</div>
<div class="flex flex-row gap-x-4 [&>*]:flex-1">
<For each={merged.buttons}>
{button => (
<ModalButton props={button} />
)}
</For>
</div>
</div>
</div>
</Portal>
</FullscreenOverlay>
);
}