From b9bc39247dbb4522704e0f9a000a709a59f141a5 Mon Sep 17 00:00:00 2001 From: Janosh Riebesell Date: Sun, 19 Mar 2023 20:42:47 -0700 Subject: [PATCH] add precision prop to ColorBar fix ElementScatter max-height applying to element detail pages set container-type: inline-size on TableInset wrapper --- src/lib/ColorBar.svelte | 3 ++- src/lib/ElementScatter.svelte | 5 +---- src/lib/ScatterPlot.svelte | 2 +- src/lib/TableInset.svelte | 1 + src/routes/(demos)/element-tile/+page.svx | 2 -- src/routes/+page.svelte | 3 +++ src/routes/[slug]/+page.svelte | 7 +------ 7 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/lib/ColorBar.svelte b/src/lib/ColorBar.svelte index e7fc054..2772c65 100644 --- a/src/lib/ColorBar.svelte +++ b/src/lib/ColorBar.svelte @@ -13,6 +13,7 @@ export let tick_side: 'top' | 'bottom' | 'center' = `bottom` // TODO vertical not fully implemented yet export let orientation: 'horizontal' | 'vertical' = `horizontal` + export let precision: number = 1 $: if ( tick_labels?.length == 0 || @@ -64,7 +65,7 @@
{#each tick_labels || [] as tick_label, idx} - {pretty_num(tick_label, 1)} + {pretty_num(tick_label, precision)} {/each}
diff --git a/src/lib/ElementScatter.svelte b/src/lib/ElementScatter.svelte index 5fae77f..88fc50f 100644 --- a/src/lib/ElementScatter.svelte +++ b/src/lib/ElementScatter.svelte @@ -22,8 +22,6 @@ } -
{#if $active_element} @@ -50,6 +47,6 @@ width: max-content; box-sizing: border-box; border-radius: 3pt; - font-size: 2.3cqw; + font-size: min(2.3cqw, 12pt); } diff --git a/src/lib/ScatterPlot.svelte b/src/lib/ScatterPlot.svelte index 2e4e7ca..f4bde0f 100644 --- a/src/lib/ScatterPlot.svelte +++ b/src/lib/ScatterPlot.svelte @@ -147,7 +147,7 @@ font-weight: lighter; overflow: visible; z-index: 1; - font-size: 2.3cqw; + font-size: min(2.3cqw, 12pt); } line { stroke: gray; diff --git a/src/lib/TableInset.svelte b/src/lib/TableInset.svelte index 9dd8100..7017273 100644 --- a/src/lib/TableInset.svelte +++ b/src/lib/TableInset.svelte @@ -14,5 +14,6 @@ box-sizing: border-box; grid-row: 1 / span 3; grid-column: 3 / span 10; + container-type: inline-size; } diff --git a/src/routes/(demos)/element-tile/+page.svx b/src/routes/(demos)/element-tile/+page.svx index a3ee107..f89caa7 100644 --- a/src/routes/(demos)/element-tile/+page.svx +++ b/src/routes/(demos)/element-tile/+page.svx @@ -1,7 +1,5 @@ `ElementTile.svelte` automatically changes text color to ensure high contrast with its background. If its background is transparent, it traverses up the DOM tree to find the first element with non-transparent background color. This an, of course, go wrong e.g. if the tile is absolutely positioned outside its parent element. In that case, pass an explicit `text_color` prop and `text_color_threshold={null}` to `ElementTile` to override the automatic color selection. -```svelte example stackblitz code_above - ```svelte example stackblitz code_above