Skip to content

Commit

Permalink
fix: unify card style & pretty bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso committed Nov 26, 2024
1 parent 60cb6fe commit 77bb99b
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 120 deletions.
4 changes: 2 additions & 2 deletions src/components/connections/ConnectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default defineComponent<{

if (isLargeScreen.value && compactConnectionCard.value) {
return (
<div class="card w-full flex-row items-center justify-between gap-1 bg-base-100 px-2 py-1 shadow-xl">
<div class="card w-full flex-row items-center justify-between gap-1 rounded-xl bg-base-100 px-2 py-1 shadow-lg">
{host}
{chians}
{connectionCompact}
Expand All @@ -128,7 +128,7 @@ export default defineComponent<{
)
} else {
return (
<div class="card w-full gap-[1px] bg-base-100 px-2 py-[1px] shadow-xl">
<div class="card w-full gap-[1px] rounded-xl bg-base-100 px-2 py-[1px] shadow-lg">
<div class="flex flex-row items-center gap-1 px-1">
{host}
{flex1}
Expand Down
188 changes: 93 additions & 95 deletions src/components/connections/ConnectionTable.vue
Original file line number Diff line number Diff line change
@@ -1,114 +1,112 @@
<template>
<div class="h-full w-full overflow-auto">
<table class="table table-zebra table-xs overflow-hidden shadow-md">
<thead class="sticky top-0 bg-base-100">
<tr
v-for="headerGroup in table.getHeaderGroups()"
:key="headerGroup.id"
<table class="table table-zebra table-xs overflow-hidden rounded-lg shadow-lg">
<thead class="bg-base-100">
<tr
v-for="headerGroup in table.getHeaderGroups()"
:key="headerGroup.id"
>
<th
v-for="header in headerGroup.headers"
:key="header.id"
:colSpan="header.colSpan"
:class="header.column.getCanSort() ? 'cursor-pointer select-none' : ''"
@click="header.column.getToggleSortingHandler()?.($event)"
>
<th
v-for="header in headerGroup.headers"
:key="header.id"
:colSpan="header.colSpan"
:class="header.column.getCanSort() ? 'cursor-pointer select-none' : ''"
@click="header.column.getToggleSortingHandler()?.($event)"
>
<div class="flex items-center gap-1">
<button
v-if="header.column.getCanGroup()"
class="cursor-pointer"
@click.stop="() => header.column.getToggleGroupingHandler()()"
>
<MagnifyingGlassMinusIcon
v-if="header.column.getIsGrouped()"
class="h-4 w-4"
/>
<MagnifyingGlassPlusIcon
v-else
class="h-4 w-4"
/>
</button>
<FlexRender
v-if="!header.isPlaceholder"
:render="header.column.columnDef.header"
:props="header.getContext()"
>
</FlexRender>
<ArrowUpCircleIcon
<div class="flex items-center gap-1">
<button
v-if="header.column.getCanGroup()"
class="cursor-pointer"
@click.stop="() => header.column.getToggleGroupingHandler()()"
>
<MagnifyingGlassMinusIcon
v-if="header.column.getIsGrouped()"
class="h-4 w-4"
v-if="header.column.getIsSorted() === 'asc'"
/>
<ArrowDownCircleIcon
<MagnifyingGlassPlusIcon
v-else
class="h-4 w-4"
v-if="header.column.getIsSorted() === 'desc'"
/>
</div>
</th>
</tr>
</thead>
<tbody>
<tr
v-for="row in table.getRowModel().rows"
:key="row.id"
class="h-9 hover:!bg-primary hover:text-primary-content"
</button>
<FlexRender
v-if="!header.isPlaceholder"
:render="header.column.columnDef.header"
:props="header.getContext()"
>
</FlexRender>
<ArrowUpCircleIcon
class="h-4 w-4"
v-if="header.column.getIsSorted() === 'asc'"
/>
<ArrowDownCircleIcon
class="h-4 w-4"
v-if="header.column.getIsSorted() === 'desc'"
/>
</div>
</th>
</tr>
</thead>
<tbody>
<tr
v-for="row in table.getRowModel().rows"
:key="row.id"
class="h-9 hover:!bg-primary hover:text-primary-content"
>
<td
v-for="cell in row.getVisibleCells()"
:key="cell.id"
class="text-sm"
>
<td
v-for="cell in row.getVisibleCells()"
:key="cell.id"
class="text-sm"
<div
:class="
twMerge(
'flex items-center gap-2 whitespace-nowrap',
[
CONNECTIONS_TABLE_ACCESSOR_KEY.Download,
CONNECTIONS_TABLE_ACCESSOR_KEY.DlSpeed,
CONNECTIONS_TABLE_ACCESSOR_KEY.Upload,
CONNECTIONS_TABLE_ACCESSOR_KEY.UlSpeed,
].includes(cell.column.id as CONNECTIONS_TABLE_ACCESSOR_KEY) && 'w-14',
)
"
>
<div
:class="
twMerge(
'flex items-center gap-2 whitespace-nowrap',
[
CONNECTIONS_TABLE_ACCESSOR_KEY.Download,
CONNECTIONS_TABLE_ACCESSOR_KEY.DlSpeed,
CONNECTIONS_TABLE_ACCESSOR_KEY.Upload,
CONNECTIONS_TABLE_ACCESSOR_KEY.UlSpeed,
].includes(cell.column.id as CONNECTIONS_TABLE_ACCESSOR_KEY) && 'w-14',
)
"
>
<template v-if="cell.column.getIsGrouped()">
<template v-if="row.getCanExpand()">
<button
@click="() => row.getToggleExpandedHandler()()"
class="cursor-pointer"
>
<MagnifyingGlassMinusIcon
v-if="row.getIsExpanded()"
class="h-4 w-4"
/>
<MagnifyingGlassPlusIcon
v-else
class="h-4 w-4"
/>
</button>
<FlexRender
:render="cell.column.columnDef.cell"
:props="cell.getContext()"
<template v-if="cell.column.getIsGrouped()">
<template v-if="row.getCanExpand()">
<button
@click="() => row.getToggleExpandedHandler()()"
class="cursor-pointer"
>
<MagnifyingGlassMinusIcon
v-if="row.getIsExpanded()"
class="h-4 w-4"
/>
<div v-if="cell.column.getIsGrouped()">({{ row.subRows.length }})</div>
</template>
</template>
<template v-else-if="cell.getIsAggregated()">
<MagnifyingGlassPlusIcon
v-else
class="h-4 w-4"
/>
</button>
<FlexRender
:render="cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell"
:render="cell.column.columnDef.cell"
:props="cell.getContext()"
/>
<div v-if="cell.column.getIsGrouped()">({{ row.subRows.length }})</div>
</template>
</template>
<template v-else-if="cell.getIsAggregated()">
<FlexRender
v-else-if="!cell.getIsPlaceholder()"
:render="cell.column.columnDef.cell"
:render="cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell"
:props="cell.getContext()"
/>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<FlexRender
v-else-if="!cell.getIsPlaceholder()"
:render="cell.column.columnDef.cell"
:props="cell.getContext()"
/>
</div>
</td>
</tr>
</tbody>
</table>
</template>

<script setup lang="ts">
Expand Down
4 changes: 2 additions & 2 deletions src/components/connections/TableSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div
v-for="item in connectionTableColumns"
:key="item"
class="flex cursor-move items-center rounded bg-neutral px-2 text-neutral-content shadow"
class="flex cursor-move items-center rounded bg-neutral px-2 text-neutral-content shadow-lg"
>
{{ $t(item) }}
</div>
Expand All @@ -25,7 +25,7 @@
<div
v-for="item in restOfColumns"
:key="item"
class="flex cursor-move items-center rounded bg-neutral px-2 text-neutral-content shadow"
class="flex cursor-move items-center rounded bg-neutral px-2 text-neutral-content shadow-lg"
>
{{ $t(item) }}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/proxies/ProxyGroup.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="collapse collapse-arrow bg-base-100 shadow-md">
<div class="collapse collapse-arrow bg-base-100 shadow-lg">
<div class="collapse-title">
<div class="flex items-center gap-2">
<div class="text-lg font-medium sm:text-xl">
Expand All @@ -23,7 +23,7 @@
<div
v-for="node in sortedProxies"
:key="node"
class="flex h-4 w-4 items-center justify-center rounded-full shadow-sm"
class="flex h-4 w-4 items-center justify-center rounded-full shadow-lg"
:class="getBgColor(getLatencyByName(node))"
>
<div
Expand Down
8 changes: 4 additions & 4 deletions src/components/proxies/ProxyProvider.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="collapse collapse-arrow bg-base-100 shadow-md">
<div class="collapse collapse-arrow bg-base-100 shadow-lg">
<div class="collapse-title">
<div class="flex items-center gap-2">
<div class="text-lg font-medium sm:text-xl">
Expand Down Expand Up @@ -48,7 +48,7 @@
<div
v-for="node in sortedProxies"
:key="node"
class="flex h-4 w-4 items-center justify-center rounded-full shadow-sm"
class="flex h-4 w-4 items-center justify-center rounded-full shadow-lg"
:class="getBgColor(getLatencyByName(node))"
></div>
</div>
Expand Down Expand Up @@ -129,8 +129,8 @@ watch(showCollapse, (value) => {
const getSubscriptionsInfo = (subscriptionInfo: SubscriptionInfo) => {
const { Download = 0, Upload = 0, Total = 0, Expire = 0 } = subscriptionInfo
const total = prettyBytesHelper(Total)
const used = prettyBytesHelper(Download + Upload)
const total = prettyBytesHelper(Total, { binary: true })
const used = prettyBytesHelper(Download + Upload, { binary: true })
const percentage = toFinite((((Download + Upload) / Total) * 100).toFixed(2))
const expirePrefix = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/rules/RuleCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="card w-full flex-row gap-1 bg-base-100 p-2 text-sm shadow-xl">
<div class="card w-full flex-row gap-1 rounded-xl bg-base-100 p-2 text-sm shadow-lg">
<div class="w-20 text-primary">{{ rule.proxy }}</div>
<div class="flex-1">{{ rule.payload }}</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/rules/RuleProvider.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<div>
<div class="card w-full flex-row items-center gap-1 bg-base-100 p-1 px-2 text-sm shadow-xl">
<div
class="card w-full flex-row items-center gap-1 rounded-xl bg-base-100 p-1 px-2 text-sm shadow-lg"
>
<span class="w-48 flex-1 text-primary">
{{ ruleProvider.name }} ({{ ruleProvider.ruleCount }})
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar/CommonCtrl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
prettyBytesHelper(uploadSpeedTotal)
}}/s)
</div>
<div>{{ $t('memoryUsage') }}: {{ prettyBytesHelper(memory) }}</div>
<div>{{ $t('memoryUsage') }}: {{ prettyBytesHelper(memory, { binary: true }) }}</div>
<div class="flex gap-1">
{{ $t('version') }}:
{{ version }}
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar/ConnectionCtrl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
>
{{ $t('sortBy') }}:
<select
class="select select-bordered select-sm"
class="select select-bordered select-sm w-52"
v-model="connectionSortType"
>
<option
Expand Down
1 change: 0 additions & 1 deletion src/components/sidebar/SpeedCharts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ onMounted(() => {
formatter: (value: number) => {
return `${prettyBytesHelper(value, {
maximumFractionDigits: 1,
binary: false,
})}/s`
},
color: color,
Expand Down
2 changes: 1 addition & 1 deletion src/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { computed } from 'vue'

export const prettyBytesHelper = (bytes: number, opts?: Options) => {
return prettyBytes(bytes, {
binary: true,
binary: false,
...opts,
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/ConnectionsPage.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div class="h-full overflow-y-auto overflow-x-hidden p-2">
<div class="h-full overflow-auto p-2">
<template v-if="useConnectionCard">
<template v-if="!renderConnections.length">
<div class="card w-full flex-row gap-1 bg-base-100 p-2 text-sm shadow-xl">
<div class="card w-full flex-row gap-1 rounded-xl bg-base-100 p-2 text-sm shadow-lg">
{{ $t('noContent') }}
</div>
</template>
Expand Down
6 changes: 3 additions & 3 deletions src/views/LogsPage.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<div class="flex h-full flex-col gap-[2px] overflow-y-auto overflow-x-hidden p-2">
<div class="flex h-full flex-col gap-1 overflow-y-auto overflow-x-hidden p-2">
<template v-if="!renderLogs.length">
<div class="card w-full flex-row gap-1 bg-base-100 p-2 text-sm shadow-xl">
<div class="card w-full flex-row gap-1 rounded-xl bg-base-100 p-2 text-sm shadow-lg">
{{ $t('noContent') }}
</div>
</template>
<div
v-for="log in renderLogs"
:key="log.seq"
class="card w-full flex-row gap-1 bg-base-100 p-2 text-sm shadow-xl"
class="card w-full flex-row gap-1 rounded-xl bg-base-100 p-2 text-sm shadow-lg"
>
<span>{{ log.seq }}</span>
<span :class="textColorMapForType[log.type]">{{ log.type }}</span>
Expand Down
2 changes: 1 addition & 1 deletion src/views/RulesPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex h-full flex-col gap-[2px] overflow-y-auto overflow-x-hidden p-2">
<div class="flex h-full flex-col gap-1 overflow-y-auto overflow-x-hidden p-2">
<template v-if="rulesTabShow === RULE_TAB_TYPE.PROVIDER">
<RuleProvider
v-for="ruleProvider in ruleProviderList"
Expand Down
Loading

0 comments on commit 77bb99b

Please sign in to comment.