mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-03 10:58:12 +08:00
* Make `tauri build` just work * Move folder: frontend/wasm -> wasm * Create SvelteKit project with 'npx create-svelte' * Move wasm-communication into seperate npm package * Use wasm-pack directly and pack package.json * Got it to work * Add primitive build script for wasm npm module * Fix wasm build script (python) * Clean up glue code * Rewrite wasm build script in node.js * Add serde-reflection to trace types * Add traced types * Generate typescript (.d.ts) from Rust types * Update .d.ts * Finalize TS types * Add script to update .d.ts * Add watch command to build wasm-bindgen * Make wasm work again * Add sass; fix build script for windows * Describe requirement for wasm-pack * Add license * Copy and reorganize vue components * translate LayoutCol.vue * Split app.scss into pieces * Translate LayoutRow.svelte * Rename scss files * Fix compile issues on Windows * WIP port TitleBar * Support classes for LayoutCol/Row * Restructure based on Vue codebase * Port all components in window folder * Port FloatingMenu * Port Document panel component * Update readme after folder move * Update typegen: print discriminant by default * Update typegen: Merge from branch 'tailwind' 4f14fedb Fixes bigint & bytes * Made Vue/webpack/eslint to accept wasm package at new location This is quite a hack. Those two packages are both named the same. Yes, it's an npm package inside another npm package. - frontend/src/wasm-communication/ - frontend-svelte/glue/ 'wasm/pkg/index.js' imports the correct one registered when linking. * Port LayerTree * Port NodeGraph * Port Properties * Port components in /floating-menus * Finish porting all Vue -> Svelte components * Change import prefix * Revert type generation * Revert moved wasm folder * Revert all of @locriacyber's work on this branch - Remove Vite and restore Webpack - Remove SvelteKit - Remove everything except the components I ported to Svelte - Restore all frontend files from Vue code, now altered for Svelte * Convert Vue's 'reactive' and 'provide' to Svelte's stores and contexts * Fix event emitting and bi-di data flow * Undo removal of 'update:' events * Fix 'update:' event dispatching * Fix usage in parent of bi-di component props * Fix component typing, more progress towards no errors * The page builds and opens! * Add loading spinner and remove postcss dependency * Make the basics of document editing work * Fix rebase history Co-authored-by: Locria Cyber <74560659+locriacyber@users.noreply.github.com>
117 lines
3.3 KiB
Svelte
117 lines
3.3 KiB
Svelte
<script lang="ts">
|
|
import { createEventDispatcher } from "svelte";
|
|
|
|
import { type PivotPosition } from "@/wasm-communication/messages";
|
|
|
|
// emits: ["update:position"],
|
|
const dispatch = createEventDispatcher<{ position: PivotPosition }>();
|
|
|
|
export let position: string;
|
|
export let disabled = false;
|
|
|
|
function setPosition(newPosition: PivotPosition) {
|
|
dispatch("position", newPosition);
|
|
}
|
|
</script>
|
|
|
|
<div class="pivot-assist" class:disabled>
|
|
<button on:click={() => setPosition("TopLeft")} class="row-1 col-1" class:active={position === "TopLeft"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("TopCenter")} class="row-1 col-2" class:active={position === "TopCenter"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("TopRight")} class="row-1 col-3" class:active={position === "TopRight"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("CenterLeft")} class="row-2 col-1" class:active={position === "CenterLeft"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("Center")} class="row-2 col-2" class:active={position === "Center"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("CenterRight")} class="row-2 col-3" class:active={position === "CenterRight"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("BottomLeft")} class="row-3 col-1" class:active={position === "BottomLeft"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("BottomCenter")} class="row-3 col-2" class:active={position === "BottomCenter"} tabindex="-1" {disabled}><div /></button>
|
|
<button on:click={() => setPosition("BottomRight")} class="row-3 col-3" class:active={position === "BottomRight"} tabindex="-1" {disabled}><div /></button>
|
|
</div>
|
|
|
|
<style lang="scss" global>
|
|
.pivot-assist {
|
|
position: relative;
|
|
flex: 0 0 auto;
|
|
width: 24px;
|
|
height: 24px;
|
|
--pivot-border-color: var(--color-5-dullgray);
|
|
--pivot-fill-active: var(--color-e-nearwhite);
|
|
|
|
button {
|
|
position: absolute;
|
|
width: 5px;
|
|
height: 5px;
|
|
margin: 0;
|
|
padding: 0;
|
|
background: var(--color-1-nearblack);
|
|
border: 1px solid var(--pivot-border-color);
|
|
|
|
&.active {
|
|
border-color: transparent;
|
|
background: var(--pivot-fill-active);
|
|
}
|
|
|
|
&.col-1::before,
|
|
&.col-2::before {
|
|
content: "";
|
|
pointer-events: none;
|
|
width: 2px;
|
|
height: 0;
|
|
border-top: 1px solid var(--pivot-border-color);
|
|
position: absolute;
|
|
top: 1px;
|
|
right: -3px;
|
|
}
|
|
|
|
&.row-1::after,
|
|
&.row-2::after {
|
|
content: "";
|
|
pointer-events: none;
|
|
width: 0;
|
|
height: 2px;
|
|
border-left: 1px solid var(--pivot-border-color);
|
|
position: absolute;
|
|
bottom: -3px;
|
|
right: 1px;
|
|
}
|
|
|
|
&.row-1 {
|
|
top: 3px;
|
|
}
|
|
&.col-1 {
|
|
left: 3px;
|
|
}
|
|
|
|
&.row-2 {
|
|
top: 10px;
|
|
}
|
|
&.col-2 {
|
|
left: 10px;
|
|
}
|
|
|
|
&.row-3 {
|
|
top: 17px;
|
|
}
|
|
&.col-3 {
|
|
left: 17px;
|
|
}
|
|
|
|
// Click targets that extend 1px beyond the borders of each square
|
|
div {
|
|
width: 100%;
|
|
height: 100%;
|
|
padding: 2px;
|
|
margin: -2px;
|
|
}
|
|
}
|
|
|
|
&:not(.disabled) button:not(.active):hover {
|
|
border-color: transparent;
|
|
background: var(--color-6-lowergray);
|
|
}
|
|
|
|
&.disabled button {
|
|
--pivot-border-color: var(--color-4-dimgray);
|
|
--pivot-fill-active: var(--color-8-uppergray);
|
|
}
|
|
}
|
|
</style>
|