Skip to content

Commit

Permalink
Use idiomatic svelte syntax for setting attribute values
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Dec 3, 2024
1 parent beae8b4 commit 49cf1aa
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ export const App = () => {
const data = Array.from({ length: 1000 }).map((_, i) => sizes[i % 4] );
</script>
<VList {data} style={`height: 100vh;`} getKey={(_, i) => i}>
<VList {data} style="height: 100vh;" getKey={(_, i) => i}>
{#snippet children(item, index)}
<div
style={`
height: ${item}px;
style="
height: {item}px;
background: white;
border-bottom: solid 1px #ccc;
`}
"
>
{index}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/svelte/VList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
@component
Virtualized list component. See {@link VListProps} and {@link VListHandle}.
-->
<div {...rest} style={`${viewportStyle} ${rest.style || ""}`}>
<div {...rest} style="{viewportStyle} {rest.style || ''}">
<Virtualizer
bind:this={ref}
{data}
Expand Down
2 changes: 1 addition & 1 deletion src/svelte/WindowVirtualizer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
{children}
{item}
{index}
as={"div"}
as="div"
offset={rerender && store.$getItemOffset(index)}
hide={rerender && store.$isUnmeasuredItem(index)}
{horizontal}
Expand Down
6 changes: 3 additions & 3 deletions stories/svelte/Controls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
>
{#snippet children(item)}
<div
style={`
height: ${item.size};
style="
height: {item.size};
background: white;
border-bottom: solid 1px #ccc;
`}
"
>
{item.id}
</div>
Expand Down
8 changes: 4 additions & 4 deletions stories/svelte/Default.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
const data = Array.from({ length: 1000 }).map((_, i) => sizes[i % 4]!);
</script>

<VList {data} style={`height: 100vh;`} getKey={(_, i) => i}>
<VList {data} style="height: 100vh;" getKey={(_, i) => i}>
{#snippet children(item, index)}
<div
style={`
height: ${item}px;
style="
height: {item}px;
background: white;
border-bottom: solid 1px #ccc;
`}
"
>
{index}
</div>
Expand Down
10 changes: 5 additions & 5 deletions stories/svelte/HeaderAndFooter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
overflow-anchor: none;
`}
>
<div style={`background-color: burlywood; height: ${headerHeight}px;`}>
<div style="background-color: burlywood; height: {headerHeight}px;">
header
</div>
<Virtualizer {data} getKey={(_, i) => i} startMargin={headerHeight}>
{#snippet children(item, index)}
<div
style={`
height: ${item}px;
style="
height: {item}px;
background: white;
border-bottom: solid 1px #ccc;
`}
"
>
{index}
</div>
{/snippet}
</Virtualizer>
<div style={`background-color: steelblue; height: 600px;`}>footer</div>
<div style="background-color: steelblue; height: 600px;">footer</div>
</div>
8 changes: 4 additions & 4 deletions stories/svelte/Horizontal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
<div style="padding: 10px;">
<VList
{data}
style={`width: 100%; height: 200px;`}
style="width: 100%; height: 200px;"
getKey={(d) => d.id}
horizontal
>
{#snippet children(item)}
<div
style={`
width: ${item.size};
style="
width: {item.size};
background: white;
border-right: solid 1px #ccc;
`}
"
>
{item.id}
</div>
Expand Down
10 changes: 5 additions & 5 deletions stories/svelte/Nested.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
overflow-anchor: none;
`}
>
<div style={`background-color: burlywood; padding: ${outerPadding}px;`}>
<div style={`background-color: steelblue; padding: ${innerPadding}px;`}>
<div style="background-color: burlywood; padding: {outerPadding}px;">
<div style="background-color: steelblue; padding: {innerPadding}px;">
<Virtualizer
{data}
getKey={(_, i) => i}
Expand All @@ -30,11 +30,11 @@
>
{#snippet children(item, index)}
<div
style={`
height: ${item}px;
style="
height: {item}px;
background: white;
border-bottom: solid 1px #ccc;
`}
"
>
{index}
</div>
Expand Down
8 changes: 4 additions & 4 deletions stories/svelte/TableElement.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
let scrollRef: HTMLElement = $state();
</script>

<div bind:this={scrollRef} style={`height: 500px; overflow: auto;`}>
<div bind:this={scrollRef} style="height: 500px; overflow: auto;">
<table>
<thead>
<tr style={`height: ${headerHeight}px`}>
<tr style="height: {headerHeight}px">
{#each COLUMN_WIDTHS as width, index}
<th style={`width: ${width}px`}>Header{index}</th>
<th style="width: {width}px">Header{index}</th>
{/each}
</tr>
</thead>
Expand All @@ -29,7 +29,7 @@
>
{#snippet children(item)}
{#each COLUMN_WIDTHS as width, index}
<th style={`width: ${width}px`}>{item} {index}</th>
<th style="width: {width}px">{item} {index}</th>
{/each}
{/snippet}
</Virtualizer>
Expand Down
6 changes: 3 additions & 3 deletions stories/svelte/WindowVirtualizer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<WindowVirtualizer {data} getKey={(_, i) => i}>
{#snippet children(item, index)}
<div
style={`
height: ${item}px;
style="
height: {item}px;
background: white;
border-bottom: solid 1px #ccc;
`}
"
>
{index}
</div>
Expand Down

0 comments on commit 49cf1aa

Please sign in to comment.