Skip to content

Commit

Permalink
Merge pull request #861 from tradingstrategy-ai/860-fix-safari-tr-lin…
Browse files Browse the repository at this point in the history
…k-bug

fix Mobile Safari tr.targetable bug
  • Loading branch information
kenkunz authored Dec 9, 2024
2 parents 1272486 + be2db8c commit 1003f28
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
24 changes: 24 additions & 0 deletions src/lib/components/TargetableLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,28 @@ as the link target.
z-index: 2;
}
}
/* special case for targetable tr elements to address Mobile Safari bug */
:global(tr.targetable td:last-child) {
position: relative;
overflow: visible;
a {
--container-width: calc(100cqw - (2 * var(--container-margin)));
width: var(--table-width, var(--container-width));
left: auto;
}
/* revert special-case styles for responsive datatables below "small" breakpoint */
@media (--viewport-sm-down) {
:global(table.datatable.responsive) & {
position: static;
a {
width: auto;
left: 0;
}
}
}
}
</style>
1 change: 1 addition & 0 deletions src/lib/components/datatable/TableBody.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
}
</script>

<!-- --table-width needed for proper tr.targetable styling -->
<tbody {...attrs}>
{#each rows as row, pageRowIndex (row.id)}
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
Expand Down
28 changes: 15 additions & 13 deletions src/lib/momentum/MomentumTable.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<script lang="ts">
import UpDownCell from '$lib/components/UpDownCell.svelte';
import TargetableLink from '$lib/components/TargetableLink.svelte';
import { formatPriceChange } from '$lib/helpers/formatters';
interface MomentumPair {
<script lang="ts" module>
export type MomentumPair = {
chain_name: string;
chain_slug: string;
exchange_name: string;
Expand All @@ -12,10 +8,15 @@
pair_slug: string;
pair_symbol: string;
price_change_24h: number;
}
};
</script>

// Trading pairs to render in this momentum table
export let pairs: MomentumPair[];
<script lang="ts">
import UpDownCell from '$lib/components/UpDownCell.svelte';
import TargetableLink from '$lib/components/TargetableLink.svelte';
import { formatPriceChange } from '$lib/helpers/formatters';
let { pairs }: { pairs: MomentumPair[] } = $props();
</script>

<table class="momentum-table datatable">
Expand All @@ -37,10 +38,6 @@

<td class="pair">
{pair.pair_symbol}
<TargetableLink
href="/trading-view/{pair.chain_slug}/{pair.exchange_slug}/{pair.pair_slug}"
label="View pair details"
/>
</td>

<td class="exchange">
Expand All @@ -53,6 +50,11 @@

<td class="price-change">
<UpDownCell value={pair.price_change_24h} formatter={formatPriceChange} />

<TargetableLink
href="/trading-view/{pair.chain_slug}/{pair.exchange_slug}/{pair.pair_slug}"
label="View {pair.pair_symbol} pair details"
/>
</td>
</tr>
{/each}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
export let loading = false;
export let rows: TradingEntityRow[];
export let getHref: Formatter<TradingEntityRow>;
let offsetWidth: number;
</script>

<table class="trading-entities-table datatable" class:loading>
<!-- --table-width needed for proper tr.targetable styling -->
<table class="trading-entities-table datatable" class:loading bind:offsetWidth style:--table-width="{offsetWidth}px">
<tbody>
{#each rows as row}
<tr class="targetable">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import MomentumTable from '$lib/momentum/MomentumTable.svelte';
import { HeroBanner, Section } from '$lib/components';
export let data;
$: up = data.direction === 'up';
let { data } = $props();
let up = $derived(data.direction === 'up');
</script>

<svelte:head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { MomentumPair } from '$lib/momentum/MomentumTable.svelte';
import { fetchPublicApi } from '$lib/helpers/public-api';

export async function load({ params, fetch }) {
Expand All @@ -7,6 +8,6 @@ export async function load({ params, fetch }) {

return {
direction,
pairs: data[`top_${direction}_24h_min_liq_1m`]
pairs: data[`top_${direction}_24h_min_liq_1m`] as MomentumPair[]
};
}

0 comments on commit 1003f28

Please sign in to comment.