Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas: Grid and Layout #6438

Draft
wants to merge 97 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
5ed0b73
remove referenced columns, gap
lovincyrus Dec 24, 2024
fc22072
row based component addition, change default size
lovincyrus Dec 24, 2024
eebc19c
fix find available pos logic, default size tweaks, select new compone…
lovincyrus Dec 24, 2024
1cbc678
wip
lovincyrus Dec 24, 2024
f3570c4
disallow dragging in grid
lovincyrus Dec 24, 2024
76787a8
comment out resize handle
lovincyrus Dec 24, 2024
0170d6a
drag n drop, w/ ghost line
lovincyrus Dec 25, 2024
3449171
fix regression
lovincyrus Dec 25, 2024
6f568ff
data selected style
lovincyrus Dec 25, 2024
20770d1
ability to drag to new row
lovincyrus Dec 25, 2024
57744a7
remove local z index
lovincyrus Dec 25, 2024
f1bc9be
clean up
lovincyrus Dec 25, 2024
cd39a0e
clean up
lovincyrus Dec 25, 2024
e94769d
simplify handle drop with helpers
lovincyrus Dec 25, 2024
b13893d
check if dragged item is full width when dropping in bottom pos
lovincyrus Dec 25, 2024
786878b
wip
lovincyrus Dec 26, 2024
fa50149
open inspector when a canvas item is selected
lovincyrus Dec 26, 2024
cf94c93
null check and clean up in sliding words
lovincyrus Dec 26, 2024
3273acb
tweak other components' default size
lovincyrus Dec 26, 2024
35268a2
removed, in favor of group items by row
lovincyrus Dec 26, 2024
1f252da
scroll into view after adding new component
lovincyrus Dec 26, 2024
96b75d0
add more data-attributes
lovincyrus Dec 26, 2024
7c9e68a
data-row-index, data-column-index
lovincyrus Dec 26, 2024
715a1a8
remove resize handle
lovincyrus Dec 26, 2024
8e8695a
compact grid upon item removal
lovincyrus Dec 26, 2024
7c6be94
left aligned on deletion
lovincyrus Dec 26, 2024
f301129
left align when drag and drop
lovincyrus Dec 26, 2024
2ce9056
add drag handle
lovincyrus Dec 26, 2024
04b738f
null check markdown
lovincyrus Dec 26, 2024
aeb8097
fix handledrop with bottom, left, right
lovincyrus Dec 26, 2024
6d97ff8
update selected index to follow the dropped item
lovincyrus Dec 26, 2024
6084c72
types
lovincyrus Dec 26, 2024
7b1a291
move helpers to util
lovincyrus Dec 26, 2024
b4f4a85
only allowed to drag around when dragging draghandle
lovincyrus Dec 26, 2024
3ee0480
tweak padding, pos of drag handle
lovincyrus Dec 27, 2024
1e54450
GhostLine to DropTargetLine
lovincyrus Dec 27, 2024
d9da03f
data-hovered in Component
lovincyrus Dec 27, 2024
88a7901
shadow tweak
lovincyrus Dec 27, 2024
11ef891
tweak drag handle
lovincyrus Dec 27, 2024
98007d1
layout shift border fix when selected
lovincyrus Dec 27, 2024
53a30aa
row container
lovincyrus Dec 28, 2024
c1150c5
wip
lovincyrus Dec 28, 2024
25b5743
comments
lovincyrus Dec 28, 2024
478c5f2
fixme
lovincyrus Dec 28, 2024
8597aee
wip
lovincyrus Dec 31, 2024
0cb8749
nit
lovincyrus Dec 31, 2024
176340d
fix drop target line, drop position
lovincyrus Jan 2, 2025
1f47fd1
rebase fix
lovincyrus Jan 2, 2025
debc4df
rebase fix
lovincyrus Jan 2, 2025
1c66871
use new items when dispatching update
lovincyrus Jan 2, 2025
69c0359
row resize handle
lovincyrus Jan 2, 2025
eeefe54
resize row height polish
lovincyrus Jan 2, 2025
773a7a6
nit
lovincyrus Jan 2, 2025
f977e33
enforce resizing row cursor
lovincyrus Jan 2, 2025
ff37af4
col resize handle
lovincyrus Jan 2, 2025
e28720c
spread components evenly
lovincyrus Jan 3, 2025
844549c
update yaml after deleting
lovincyrus Jan 3, 2025
e6c1253
col resize improvement
lovincyrus Jan 3, 2025
8dace13
add a placeholder component min width when resizing col
lovincyrus Jan 3, 2025
bfe0e06
redistribute when adding
lovincyrus Jan 3, 2025
6a99f23
clean up
lovincyrus Jan 4, 2025
92cc730
clean up
lovincyrus Jan 4, 2025
519edf2
disable redistributing when adding component
lovincyrus Jan 4, 2025
fc2718e
embed to disable interactivity
lovincyrus Jan 5, 2025
9e07fb5
remove top pos usage
lovincyrus Jan 5, 2025
7e3fac1
disable redistribute in deleteComponent
lovincyrus Jan 5, 2025
a932982
lint
lovincyrus Jan 5, 2025
266c897
fix drop targets
lovincyrus Jan 5, 2025
a45b761
Revert "fix drop targets"
lovincyrus Jan 6, 2025
5052495
clean up
lovincyrus Jan 6, 2025
2d05a70
row to top
lovincyrus Jan 6, 2025
0005e5c
use transform for positioning
lovincyrus Jan 6, 2025
79920e8
items dropping fix, clean up
lovincyrus Jan 7, 2025
4524b2f
types, open inspector
lovincyrus Jan 7, 2025
01ac12a
nit
lovincyrus Jan 7, 2025
3fab5d3
spread evenly on click
lovincyrus Jan 7, 2025
23d9a86
floating button group
lovincyrus Jan 7, 2025
8b079d2
row resizer
lovincyrus Jan 7, 2025
7695f28
column resizer
lovincyrus Jan 7, 2025
c2d2db8
clean up
lovincyrus Jan 7, 2025
2815fcf
empty state items
lovincyrus Jan 7, 2025
d72bb0d
cherry pick fix
lovincyrus Jan 16, 2025
6ca0358
skip test
lovincyrus Jan 16, 2025
cac99c9
lint
lovincyrus Jan 16, 2025
b7973cc
visual tweaks
lovincyrus Jan 16, 2025
f92ef63
visual tweaks
lovincyrus Jan 16, 2025
1cf1e7d
rebase fixes
lovincyrus Jan 17, 2025
264821b
white bg in blank canvas
lovincyrus Jan 18, 2025
c970947
context menu add component initial
lovincyrus Jan 18, 2025
1bc65a9
chart icon in blank menu items
lovincyrus Jan 18, 2025
b0d6aa8
other menu canva icons
lovincyrus Jan 18, 2025
76d4345
add component to blank canvas
lovincyrus Jan 18, 2025
b3dd89a
icons to add component menu
lovincyrus Jan 18, 2025
4038124
move blank canvas one level down
lovincyrus Jan 18, 2025
399377c
move addComponent to canvas, wip
lovincyrus Jan 18, 2025
b409211
wip
lovincyrus Jan 18, 2025
9250aa4
wip
lovincyrus Jan 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions web-admin/src/features/embeds/CanvasEmbed.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
export let instanceId: string;
export let canvasName: string;

// TODO: Remove later
let columns = 20;
let gap = 1;
$: canvasQuery = useResource(instanceId, canvasName, ResourceKind.Canvas);

$: canvas = $canvasQuery.data?.canvas.spec;

$: ({ items = [] } = canvas || { items: [], columns: 24, gap: 2 });
$: ({ items = [] } = canvas || { items: [] });
</script>

<CanvasDashboardEmbed {columns} {items} {gap} />
<CanvasDashboardEmbed {items} />
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@

$: canvas = $canvasQuery.data?.canvas.spec;

// TODO: Remove later
let columns = 20;
let gap = 1;
$: ({ items = [] } = canvas || { items: [], columns: 24, gap: 2 });
$: ({ items = [] } = canvas || { items: [] });
</script>

<CanvasDashboardEmbed {columns} {items} {gap} />
<CanvasDashboardEmbed {items} />
10 changes: 9 additions & 1 deletion web-common/src/components/tooltip/SlidingWords.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@
let mounted = false;
let duration = 0;
let timer;
let element;
let element: HTMLElement | null = null;

let thingWidth = tweened(0, { duration: 50 });

onMount(() => {
if (!element) return;

const obs = new ResizeObserver(() => {
if (!element) return;
const bbox = element.getBoundingClientRect();
thingWidth.set(bbox.width);
});

obs.observe(element);
thingWidth.set(element.getBoundingClientRect().width, { duration: 0 });
mounted = true;

return () => {
obs.disconnect();
};
});

function setDuration() {
Expand Down
62 changes: 62 additions & 0 deletions web-common/src/features/canvas/BlankCanvas.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<script lang="ts">
import { PlusCircleIcon } from "lucide-svelte";
import {
ContextMenu,
ContextMenuContent,
ContextMenuItem,
ContextMenuTrigger,
} from "@rilldata/web-common/components/context-menu";
import type { CanvasComponentType } from "./components/types";
import type { ComponentType, SvelteComponent } from "svelte";
import ChartIcon from "./icons/ChartIcon.svelte";
import TableIcon from "./icons/TableIcon.svelte";
import TextIcon from "./icons/TextIcon.svelte";
import BigNumberIcon from "./icons/BigNumberIcon.svelte";
import { createEventDispatcher } from "svelte";

const dispatch = createEventDispatcher();

const menuItems: {
id: CanvasComponentType;
label: string;
icon: ComponentType<SvelteComponent>;
}[] = [
{ id: "bar_chart", label: "Chart", icon: ChartIcon },
{ id: "table", label: "Table", icon: TableIcon },
{ id: "markdown", label: "Text", icon: TextIcon },
{ id: "kpi", label: "KPI", icon: BigNumberIcon },
{ id: "image", label: "Image", icon: ChartIcon },
];

function handleAddComponent(componentType: CanvasComponentType) {
console.log("[BlankCanvas] handleAddComponent", componentType);
dispatch("add", { type: componentType });
}
</script>

<div class="size-full p-2 bg-white">
<ContextMenu>
<ContextMenuTrigger>
<button
type="button"
class="flex flex-col items-center gap-2 p-8 rounded-[6px] border border-slate-200 w-full"
>
<PlusCircleIcon class="w-6 h-6 text-slate-500" />
<span class="text-sm font-medium text-slate-500">Add a component</span>
</button>
</ContextMenuTrigger>
<ContextMenuContent>
{#each menuItems as item}
<ContextMenuItem
on:click={() => handleAddComponent(item.id)}
class="text-gray-700 text-xs"
>
<div class="flex flex-row gap-x-2">
<svelte:component this={item.icon} />
<span class="text-gray-700 text-xs font-normal">{item.label}</span>
</div>
</ContextMenuItem>
{/each}
</ContextMenuContent>
</ContextMenu>
</div>
Loading
Loading