Skip to content

Commit c3d4a56

Browse files
committed
Enhanced UX for IPv4Chart
1 parent 6436fcd commit c3d4a56

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

src/components/blend/IPv4.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Represent IPv4 address including prefix notation
7373
<div class="grow" />
7474
</div>
7575
<!-- main -->
76-
<div class="flex lt-sm:overflow-x-auto px-2 mx--2">
76+
<div class="flex lt-sm:overflow-x-auto px-2 mx--2 pb-2">
7777
<div class="grow" />
7878
<div>
7979
<div class="flex lt-sm:hidden" class:invisible={showingWholeInput}>

src/components/parts/IPv4Chart.svelte

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ Visualize various IPv4 related info
5757
$: isAddressNetwork = network === address;
5858
$: isAddressBroadcast = broadcast === address;
5959
$: isAddressHost = !isAddressNetwork && !isAddressBroadcast;
60+
61+
$: showCursorAtTheEnd = startInPercent > 84;
62+
$: showCursorAtTheEndForXS = startInPercent > 74;
63+
$: showCursorInTheMiddle = startInPercent > 69;
64+
$: showCursorInTheMiddleForSM = startInPercent > 59;
65+
$: showCursorInTheMiddleForXS = startInPercent > 49;
6066
</script>
6167

6268
<div class="flex">
6369
<div class="grow" />
6470
<div class="w-full sm:w-[94%]">
65-
<div class="text-gray-400 my-3">
71+
<div class="text-gray-400 mt-1 mb-3">
6672
<span class="i-bi-bar-chart inline-block text-gray-400 translate-y-0.5" />
6773
<span class="text-gray-200">
6874
<span class="text-gray-300"> IPv4 </span>
@@ -107,37 +113,54 @@ Visualize various IPv4 related info
107113
<div class="w-full flex text-cyan items-center mt-2">
108114
<div class="min-w-6" style:width={`${startInPercent}%`}>
109115
<button
110-
class="i-bi-arrow-bar-left"
116+
class="btn btn-xs btn-outline btn-square rounded-lg pb-0.5 text-cyan mx-1 my-0.5 hover:bg-cyan hover:color:white hover:border-white"
111117
on:click={() => {
112118
address = newAddressFrom(address, mask, network - networkUnit);
113119
}}
114-
/>
120+
>
121+
&#60;
122+
</button>
115123
</div>
116124

117-
<div
118-
class="flex items-center"
119-
class:flex-row-reverse={startInPercent > (prefix < 3 ? 74 : 85)}
120-
>
121-
<div class="flex items-center mx--2">
125+
<!-- safe list class="order-2 mr-1 lt-sm:order-2 lt-sm:mr-1 lt-xs:order-2 lt-xs:mr-1 !order-4 !mx-0 lt-xs:!order-4 lt-xs:!mx-0" -->
126+
<div class="flex items-center ml-4">
127+
<div
128+
class="flex items-center mx--2 text-gray"
129+
class:order-2={showCursorInTheMiddle}
130+
class:mr-1={showCursorInTheMiddle}
131+
class:lt-sm:order-2={showCursorInTheMiddleForSM}
132+
class:lt-sm:mr-1={showCursorInTheMiddleForSM}
133+
class:lt-xs:order-2={showCursorInTheMiddleForXS}
134+
class:lt-xs:mr-1={showCursorInTheMiddleForXS}
135+
class:!order-4={showCursorAtTheEnd}
136+
class:!mx-0={showCursorAtTheEnd}
137+
class:lt-xs:!order-4={showCursorAtTheEndForXS}
138+
class:lt-xs:!mx-0={showCursorAtTheEndForXS}
139+
>
122140
<div class="i-bi-arrow-down ml-1" />
123141
<div class="i-bi-zoom-in mr-1" />
124142
</div>
125-
<div class="mx-2 text-sm flex">
126-
<PartialTransition notation={addressCount.toLocaleString()} />
143+
<div class="order-1 mx-2 text-sm flex lt-xs:text-xs">
144+
<PartialTransition notation={renderedNetwork} />
127145
</div>
146+
<small class="order-3 lt-xs:text-[0.5rem] before:content-['('] after:content-[')'] flex">
147+
<PartialTransition notation={addressCount.toLocaleString()} />
148+
</small>
128149
</div>
129150
<div class="grow flex ml-2">
130151
<div class="grow" />
131152
<button
132-
class="i-bi-arrow-bar-right"
153+
class="btn btn-xs btn-outline btn-square rounded-lg pb-0.5 text-cyan mx-1 my-0.5 hover:bg-cyan hover:color:white hover:border-white"
133154
on:click={() => {
134155
address = newAddressFrom(address, mask, network + networkUnit);
135156
}}
136-
/>
157+
>
158+
&#62;
159+
</button>
137160
</div>
138161
</div>
139162
<div
140-
class="mt-2 h-2 w-full rounded-sm bg-cyan flex"
163+
class="mt-3 h-2 w-full rounded-sm bg-cyan flex"
141164
style:--un-bg-opacity={`${opacityForDetailInPercent}%`}
142165
>
143166
<div class="h-full" style:width={`${beforeIP}%`} />
@@ -191,25 +214,29 @@ Visualize various IPv4 related info
191214
<div class="flex-1 text-left text-gray text-xs lt-xs:text-[0.5rem]">
192215
<PartialTransition notation={renderedNetworkWithouPrefix} />
193216
</div>
194-
<div class="flex-1 text-center flex text-lime-600 items-center">
217+
<div class="flex-1 text-center flex text-lime-600 items-center mt-1">
195218
<div class="grow" />
196219
<button
197-
class="i-bi-arrow-bar-left mx-1"
220+
class="btn btn-xs btn-outline btn-square rounded-lg pb-0.5 text-lime-600 mx-1 my-0.5 hover:bg-lime-600 hover:color:white hover:border-white"
198221
on:click={() => {
199222
address = address - 1;
200223
}}
201-
/>
224+
>
225+
&#60;
226+
</button>
202227
<div class="xs:w-32 flex text-sm lt-xs:text-[0.5rem]">
203228
<div class="grow" />
204229
<PartialTransition notation={renderedAddress} />
205230
<div class="grow" />
206231
</div>
207232
<button
208-
class="i-bi-arrow-bar-right mx-1"
233+
class="btn btn-xs btn-outline btn-square rounded-lg pb-0.5 text-lime-600 mx-1 my-0.5 hover:bg-lime-600 hover:color:white hover:border-white"
209234
on:click={() => {
210235
address = address + 1;
211236
}}
212-
/>
237+
>
238+
&#62;
239+
</button>
213240
<div class="grow" />
214241
</div>
215242
<div class="flex-1 text-right text-gray flex text-xs lt-xs:text-[0.5rem]">

0 commit comments

Comments
 (0)