Skip to content

Commit 5cbb2f6

Browse files
committed
Apply PartialTransition to Netmask too
1 parent f45873d commit 5cbb2f6

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/components/blend/IPv4Network.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ to augment IPv4 with Network and Netmask visualization
5656
}
5757
</script>
5858

59-
<small class="absolute mt-0.6">
60-
<pre class="mx-2 text-gray-400">Netmask: {renderedMask}</pre>
59+
<small class="absolute mt-0.6 text-gray-400">
60+
<pre class="inline-block ml-2">Netmask:</pre>
61+
<div class="inline-block">
62+
<PartialTransition notation={renderedMask} fstDelimiter={' = '} />
63+
</div>
6164
</small>
6265
<small class="opacity-0">placeholder</small>
6366
<div class="relative">

src/components/parts/PartialTransition.svelte

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,36 @@ To apply partial fade transition currently for IPv4 Addresses
55
import type { TransitionConfig } from 'svelte/transition';
66
import { fade } from 'svelte/transition';
77
8+
export let fstDelimiter = '/';
9+
export let sndDelimiter = '.';
10+
11+
// this is a bit of involved workaround to show wrapped spaces properly in the fstDelimiter
12+
$: isFstDelimiterWrappedBySpaces =
13+
fstDelimiter.at(0) === fstDelimiter.at(-1) && fstDelimiter.at(0) === ' ';
14+
815
// eslint-disable-next-line @typescript-eslint/no-explicit-any
916
export let transition: (...args: any[]) => TransitionConfig = fade;
1017
export let mono = true;
1118
1219
export let notation = '0.0.0.0/0';
13-
$: splits = notation.split('/');
20+
$: splits = notation.split(fstDelimiter);
1421
$: address = splits[0];
15-
$: chunks = address.split('.');
22+
$: chunks = address.split(sndDelimiter);
1623
$: prefix = splits[1];
1724
$: texts = prefix ? [...chunks, prefix] : chunks;
1825
</script>
1926

20-
<!-- safe list class="font-mono" -->
27+
<!-- \00A0 = &nbsp; - https://github.com/sveltejs/svelte/issues/3014#issuecomment-501143936 -->
28+
<!-- safe list class="font-mono first:hidden before:content-['\00A0'] after:content-['\00A0']" -->
2129
<div class="flex" class:font-mono={mono}>
2230
{#each texts as text, idx}
23-
<div class="first:hidden">{idx < 4 ? '.' : '/'}</div>
31+
<div
32+
class={["before:content-['\\00A0'] after:content-['\\00A0']", 'first:hidden']
33+
.slice(idx > 3 && isFstDelimiterWrappedBySpaces ? 0 : 1)
34+
.join(' ')}
35+
>
36+
{idx < 4 ? sndDelimiter : fstDelimiter.trim()}
37+
</div>
2438
<div class="relative">
2539
<div class="opacity-0">
2640
{text}

0 commit comments

Comments
 (0)