Skip to content

Commit

Permalink
feat(proxy): add back the render proxies in two columns option, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Oct 29, 2023
1 parent 0de2010 commit 62c0cd9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
15 changes: 15 additions & 0 deletions src/components/ProxiesSettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import {
latencyTestTimeoutDuration,
proxiesOrderingType,
proxiesPreviewType,
renderProxiesInTwoColumns,
setAutoCloseConns,
setHideUnAvailableProxies,
setLatencyTestTimeoutDuration,
setProxiesOrderingType,
setProxiesPreviewType,
setRenderProxiesInTwoColumns,
setUrlForLatencyTest,
setUrlIPv6SupportTest,
urlForIPv6SupportTest,
Expand Down Expand Up @@ -113,6 +115,19 @@ export const ProxiesSettingsModal: Component<{
</div>
</div>

<div>
<ConfigTitle withDivider>{t('renderInTwoColumns')}</ConfigTitle>

<div class="flex w-full justify-center">
<input
class="toggle"
type="checkbox"
checked={renderProxiesInTwoColumns()}
onChange={(e) => setRenderProxiesInTwoColumns(e.target.checked)}
/>
</div>
</div>

<div>
<ConfigTitle withDivider>{t('proxiesPreviewType')}</ConfigTitle>

Expand Down
10 changes: 5 additions & 5 deletions src/components/ProxyPreviewBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ export const ProxyPreviewBar = (props: {

return (
<div class="flex items-center gap-2 py-2">
<div class="flex flex-1 overflow-hidden rounded-2xl">
<div class="flex h-4 flex-1 items-center justify-center">
<div
class="h-2 bg-success"
class="h-2 overflow-hidden rounded-2xl bg-success"
style={{
width: `${(good() * 100) / all()}%`, // cant use tw class, otherwise dynamic classname won't be generated
}}
/>
<div
class="h-2 bg-warning"
class="h-2 overflow-hidden rounded-2xl bg-warning"
style={{
width: `${(middle() * 100) / all()}%`,
}}
/>
<div
class="h-2 bg-error"
class="h-2 overflow-hidden rounded-2xl bg-error"
style={{
width: `${(slow() * 100) / all()}%`,
}}
/>
<div
class="h-2 bg-neutral"
class="h-2 overflow-hidden rounded-2xl bg-neutral"
style={{
width: `${(notConnected() * 100) / all()}%`,
}}
Expand Down
20 changes: 15 additions & 5 deletions src/pages/Proxies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ProxiesSettingsModal,
ProxyNodeCard,
ProxyNodePreview,
RenderInTwoColumns,
SubscriptionInfo,
} from '~/components'
import {
Expand All @@ -23,6 +22,7 @@ import {
formatTimeFromNow,
hideUnAvailableProxies,
proxiesOrderingType,
renderProxiesInTwoColumns,
useProxies,
} from '~/signals'

Expand Down Expand Up @@ -143,7 +143,12 @@ export default () => {

<div class="flex-1 overflow-y-auto">
<Show when={activeTab() === ActiveTab.proxies}>
<RenderInTwoColumns>
<div
class={twMerge(
'grid grid-cols-1 place-items-start gap-2',
renderProxiesInTwoColumns() ? 'sm:grid-cols-2' : 'sm:grid-cols-1',
)}
>
<For each={proxies()}>
{(proxyGroup) => {
const sortedProxyNames = createMemo(() =>
Expand Down Expand Up @@ -222,11 +227,16 @@ export default () => {
)
}}
</For>
</RenderInTwoColumns>
</div>
</Show>

<Show when={activeTab() === ActiveTab.proxyProviders}>
<RenderInTwoColumns>
<div
class={twMerge(
'grid grid-cols-1 place-items-start gap-2',
renderProxiesInTwoColumns() ? 'sm:grid-cols-2' : 'sm:grid-cols-1',
)}
>
<For each={proxyProviders()}>
{(proxyProvider) => {
const sortedProxyNames = createMemo(() =>
Expand Down Expand Up @@ -318,7 +328,7 @@ export default () => {
)
}}
</For>
</RenderInTwoColumns>
</div>
</Show>
</div>

Expand Down
6 changes: 6 additions & 0 deletions src/signals/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export const [hideUnAvailableProxies, setHideUnAvailableProxies] =
storage: localStorage,
})

export const [renderProxiesInTwoColumns, setRenderProxiesInTwoColumns] =
makePersisted(createSignal(true), {
name: 'renderProxiesInTwoColumns',
storage: localStorage,
})

export const [urlForLatencyTest, setUrlForLatencyTest] = makePersisted(
createSignal('https://www.gstatic.com/generate_204'),
{ name: 'urlForLatencyTest', storage: localStorage },
Expand Down

0 comments on commit 62c0cd9

Please sign in to comment.