Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a close button to the modal #239

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/components/ConnectionsSettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const ConnectionsSettingsModal = (props: {
onOrderChange: (value: ConnectionsTableColumnOrder) => void
onVisibleChange: (value: ConnectionsTableColumnVisibility) => void
}) => {
const modalID = MODAL.CONNECTIONS_SETTINGS
const [t] = useI18n()
const [activeKey, setActiveKey] =
createSignal<CONNECTIONS_TABLE_ACCESSOR_KEY | null>(null)
Expand Down Expand Up @@ -175,14 +176,26 @@ export const ConnectionsSettingsModal = (props: {
}

return (
<dialog
id={MODAL.CONNECTIONS_SETTINGS}
class="modal modal-bottom sm:modal-middle"
>
<dialog id={modalID} class="modal modal-bottom sm:modal-middle">
<div
class="modal-box flex flex-col gap-4"
onContextMenu={(e) => e.preventDefault()}
>
<div class="sticky top-0 z-50 flex items-center justify-end">
<Button
class="btn-circle btn-sm"
onClick={() => {
const modal = document.querySelector(
`#${modalID}`,
) as HTMLDialogElement | null

modal?.close()
}}
>
<IconX size={20} />
</Button>
</div>

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

Expand Down
24 changes: 20 additions & 4 deletions src/components/ConnectionsTableDetailsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import { IconX } from '@tabler/icons-solidjs'
import { Component, Show } from 'solid-js'
import { MODAL } from '~/constants'
import { allConnections } from '~/signals'
import { Button } from './Button'

export const ConnectionsTableDetailsModal: Component<{
selectedConnectionID?: string
}> = (props) => {
const modalID = MODAL.CONNECTIONS_TABLE_DETAILS

return (
<dialog
id={MODAL.CONNECTIONS_TABLE_DETAILS}
class="modal modal-bottom sm:modal-middle"
>
<dialog id={modalID} class="modal modal-bottom sm:modal-middle">
<div class="modal-box">
<div class="sticky top-0 z-50 flex items-center justify-end">
<Button
class="btn-circle btn-sm"
onClick={() => {
const modal = document.querySelector(
`#${modalID}`,
) as HTMLDialogElement | null

modal?.close()
}}
>
<IconX size={20} />
</Button>
</div>

<Show when={props.selectedConnectionID}>
<pre>
<code>
Expand Down
23 changes: 20 additions & 3 deletions src/components/LogsSettingsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useI18n } from '@solid-primitives/i18n'
import { IconX } from '@tabler/icons-solidjs'
import { For } from 'solid-js'
import { ConfigTitle } from '~/components'
import { Button, ConfigTitle } from '~/components'
import {
LOG_LEVEL,
LOGS_TABLE_MAX_ROWS_LIST,
LOG_LEVEL,
MODAL,
TAILWINDCSS_SIZE,
} from '~/constants'
Expand All @@ -17,11 +18,27 @@ import {
} from '~/signals'

export const LogsSettingsModal = () => {
const modalID = MODAL.LOGS_SETTINGS
const [t] = useI18n()

return (
<dialog id={MODAL.LOGS_SETTINGS} class="modal modal-bottom sm:modal-middle">
<dialog id={modalID} class="modal modal-bottom sm:modal-middle">
<div class="modal-box flex flex-col gap-4">
<div class="sticky top-0 z-50 flex items-center justify-end">
<Button
class="btn-circle btn-sm"
onClick={() => {
const modal = document.querySelector(
`#${modalID}`,
) as HTMLDialogElement | null

modal?.close()
}}
>
<IconX size={20} />
</Button>
</div>

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

Expand Down
24 changes: 19 additions & 5 deletions src/components/ProxiesSettingsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useI18n } from '@solid-primitives/i18n'
import { IconX } from '@tabler/icons-solidjs'
import { For } from 'solid-js'
import { ConfigTitle } from '~/components'
import { Button, ConfigTitle } from '~/components'
import { MODAL, PROXIES_ORDERING_TYPE, PROXIES_PREVIEW_TYPE } from '~/constants'
import {
autoCloseConns,
Expand All @@ -18,14 +19,27 @@ import {
} from '~/signals'

export const ProxiesSettingsModal = () => {
const modalID = MODAL.PROXIES_SETTINGS
const [t] = useI18n()

return (
<dialog
id={MODAL.PROXIES_SETTINGS}
class="modal modal-bottom sm:modal-middle"
>
<dialog id={modalID} class="modal modal-bottom sm:modal-middle">
<div class="modal-box flex flex-col gap-4">
<div class="sticky top-0 z-50 flex items-center justify-end">
<Button
class="btn-circle btn-sm"
onClick={() => {
const modal = document.querySelector(
`#${modalID}`,
) as HTMLDialogElement | null

modal?.close()
}}
>
<IconX size={20} />
</Button>
</div>

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

Expand Down