mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 15:28:04 +08:00
* [wip]feat: add snapping options
* [wip]fix: use svelte component for optionsWidget
* fix: use apt PopoverButton types
* refactor: minor formatting improvements
* Fix popover layout
* [wip]feat: attempt implementing CheckboxInputData struct
* fix: use correct Checkbox struct 's default method
* fix: revert adding CheckboxInputData struct
- This reverts commit 2a481887fc.
* feat: use checkboxes for snapping options
* feat: add label to dropdown checkbox elements
* fix: separate Snap dropdown menu elements
- move each element into separate row
* [wip]feat: modularize snapping states
- maintain individual snapping states for document
* fix: snapping checkboxes' behavior
- checkboxes now update internal snapping state
* refactor: update snap states individually
- this prevents out-of-sync states
- enables reusing existing snap state object
* feat: snap to boxes and nodes conditionally
* [wip]feat: attempt to invert checkbox on update
- attempt implementing mutable WidgetCallback struct
- attempt using above struct to invert checkbox state on update
* Fix widget diffing
* refactor: remove unused code
* feat: align checkboxes consistently with labels
* feat: use separators to stylize snapping menu
- removes need for custom CSS and label property
- ensures consistency across the application
* refactor: remove unneeded css
---------
Co-authored-by: hypercube <0hypercube@gmail.com>, TrueDoctor <dennis@kobert.dev>
38 lines
1.4 KiB
Svelte
38 lines
1.4 KiB
Svelte
<script lang="ts">
|
|
import { isWidgetColumn, isWidgetRow, isWidgetSection, LayoutGroup, type WidgetLayout } from "@graphite/wasm-communication/messages";
|
|
|
|
import WidgetSection from "@graphite/components/widgets/groups/WidgetSection.svelte";
|
|
import WidgetRow from "@graphite/components/widgets/WidgetRow.svelte";
|
|
|
|
export let layout: WidgetLayout;
|
|
let className = "";
|
|
export { className as class };
|
|
export let classes: Record<string, boolean> = {};
|
|
|
|
$: extraClasses = Object.entries(classes)
|
|
.flatMap((classAndState) => (classAndState[1] ? [classAndState[0]] : []))
|
|
.join(" ");
|
|
</script>
|
|
|
|
<!-- TODO: Refactor this component (together with `WidgetRow.svelte`) to be more logically consistent with our layout definition goals, in terms of naming and capabilities -->
|
|
<div class={`widget-layout ${className} ${extraClasses}`.trim()}>
|
|
{#each layout.layout as layoutGroup, index (index)}
|
|
{#if isWidgetColumn(layoutGroup) || isWidgetRow(layoutGroup)}
|
|
<WidgetRow widgetData={layoutGroup} layoutTarget={layout.layoutTarget} />
|
|
{:else if isWidgetSection(layoutGroup)}
|
|
<WidgetSection widgetData={layoutGroup} layoutTarget={layout.layoutTarget} />
|
|
{:else}
|
|
<span style="color: #d6536e">Error: The widget row that belongs here has an invalid layout group type</span>
|
|
{/if}
|
|
{/each}
|
|
</div>
|
|
|
|
<style lang="scss" global>
|
|
.widget-layout {
|
|
height: 100%;
|
|
flex: 0 0 auto;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
</style>
|