chore: setup linting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { getContext, type Snippet } from "svelte";
|
||||
import { getContext, type Snippet } from 'svelte';
|
||||
|
||||
let index = $state(-1);
|
||||
let wrapper: HTMLDivElement;
|
||||
@@ -8,19 +8,17 @@
|
||||
|
||||
$effect(() => {
|
||||
if (index === -1) {
|
||||
index = getContext<() => number>("registerCell")();
|
||||
index = getContext<() => number>('registerCell')();
|
||||
}
|
||||
});
|
||||
|
||||
const sizes = getContext<{ value: string[] }>("sizes");
|
||||
const sizes = getContext<{ value: string[] }>('sizes');
|
||||
|
||||
let downSizes: string[] = [];
|
||||
let downWidth = 0;
|
||||
let mouseDown = false;
|
||||
let startX = 0;
|
||||
|
||||
function handleMouseDown(event: MouseEvent) {
|
||||
downSizes = [...sizes.value];
|
||||
mouseDown = true;
|
||||
startX = event.clientX;
|
||||
downWidth = wrapper.getBoundingClientRect().width;
|
||||
@@ -45,7 +43,8 @@
|
||||
role="button"
|
||||
tabindex="0"
|
||||
onmousedown={handleMouseDown}
|
||||
></div>
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="cell" bind:this={wrapper}>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { setContext, type Snippet } from "svelte";
|
||||
import { onMount, setContext, type Snippet } from 'svelte';
|
||||
|
||||
const { children, id } = $props<{ children?: Snippet; id?: string }>();
|
||||
|
||||
setContext("grid-id", id);
|
||||
onMount(() => {
|
||||
setContext('grid-id', id);
|
||||
});
|
||||
</script>
|
||||
|
||||
{@render children({ id })}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
<script lang="ts">
|
||||
import { setContext, getContext } from "svelte";
|
||||
import { localState } from "$lib/helpers/localState.svelte";
|
||||
import { localState } from '$lib/helpers/localState.svelte';
|
||||
import { getContext, setContext } from 'svelte';
|
||||
|
||||
const gridId = getContext<string>("grid-id") || "grid-0";
|
||||
const gridId = getContext<string>('grid-id') || 'grid-0';
|
||||
let sizes = localState<string[]>(gridId, []);
|
||||
|
||||
const { children } = $props();
|
||||
|
||||
let registerIndex = 0;
|
||||
setContext("registerCell", function () {
|
||||
setContext('registerCell', function() {
|
||||
let index = registerIndex;
|
||||
registerIndex++;
|
||||
if (registerIndex > sizes.value.length) {
|
||||
sizes.value = [...sizes.value, "1fr"];
|
||||
sizes.value = [...sizes.value, '1fr'];
|
||||
}
|
||||
return index;
|
||||
});
|
||||
|
||||
setContext("sizes", sizes);
|
||||
setContext('sizes', sizes);
|
||||
|
||||
const cols = $derived(
|
||||
sizes.value.map((size, i) => `${i > 0 ? "1px " : ""}` + size).join(" "),
|
||||
sizes.value.map((size, i) => `${i > 0 ? '1px ' : ''}` + size).join(' ')
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { withSubComponents } from "$lib/helpers";
|
||||
import Grid from "./Grid.svelte";
|
||||
import Row from "./Row.svelte";
|
||||
import Cell from "./Cell.svelte";
|
||||
import { withSubComponents } from '$lib/helpers';
|
||||
import Cell from './Cell.svelte';
|
||||
import Grid from './Grid.svelte';
|
||||
import Row from './Row.svelte';
|
||||
|
||||
export default withSubComponents(Grid, { Row, Cell });
|
||||
|
||||
Reference in New Issue
Block a user