feat: add a close button to the modal (#239)

* feat: add a close button to the modal

* fix: replace modal close icon
This commit is contained in:
Alpha 2023-09-19 00:35:58 +08:00 committed by GitHub
parent 2755f845a0
commit 737f1b0189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 16 deletions

View File

@ -109,6 +109,7 @@ export const ConnectionsSettingsModal = (props: {
onOrderChange: (value: ConnectionsTableColumnOrder) => void onOrderChange: (value: ConnectionsTableColumnOrder) => void
onVisibleChange: (value: ConnectionsTableColumnVisibility) => void onVisibleChange: (value: ConnectionsTableColumnVisibility) => void
}) => { }) => {
const modalID = MODAL.CONNECTIONS_SETTINGS
const [t] = useI18n() const [t] = useI18n()
const [activeKey, setActiveKey] = const [activeKey, setActiveKey] =
createSignal<CONNECTIONS_TABLE_ACCESSOR_KEY | null>(null) createSignal<CONNECTIONS_TABLE_ACCESSOR_KEY | null>(null)
@ -175,14 +176,26 @@ export const ConnectionsSettingsModal = (props: {
} }
return ( return (
<dialog <dialog id={modalID} class="modal modal-bottom sm:modal-middle">
id={MODAL.CONNECTIONS_SETTINGS}
class="modal modal-bottom sm:modal-middle"
>
<div <div
class="modal-box flex flex-col gap-4" class="modal-box flex flex-col gap-4"
onContextMenu={(e) => e.preventDefault()} 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> <div>
<ConfigTitle withDivider>{t('tableSize')}</ConfigTitle> <ConfigTitle withDivider>{t('tableSize')}</ConfigTitle>

View File

@ -1,16 +1,32 @@
import { IconX } from '@tabler/icons-solidjs'
import { Component, Show } from 'solid-js' import { Component, Show } from 'solid-js'
import { MODAL } from '~/constants' import { MODAL } from '~/constants'
import { allConnections } from '~/signals' import { allConnections } from '~/signals'
import { Button } from './Button'
export const ConnectionsTableDetailsModal: Component<{ export const ConnectionsTableDetailsModal: Component<{
selectedConnectionID?: string selectedConnectionID?: string
}> = (props) => { }> = (props) => {
const modalID = MODAL.CONNECTIONS_TABLE_DETAILS
return ( return (
<dialog <dialog id={modalID} class="modal modal-bottom sm:modal-middle">
id={MODAL.CONNECTIONS_TABLE_DETAILS}
class="modal modal-bottom sm:modal-middle"
>
<div class="modal-box"> <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}> <Show when={props.selectedConnectionID}>
<pre> <pre>
<code> <code>

View File

@ -1,9 +1,10 @@
import { useI18n } from '@solid-primitives/i18n' import { useI18n } from '@solid-primitives/i18n'
import { IconX } from '@tabler/icons-solidjs'
import { For } from 'solid-js' import { For } from 'solid-js'
import { ConfigTitle } from '~/components' import { Button, ConfigTitle } from '~/components'
import { import {
LOG_LEVEL,
LOGS_TABLE_MAX_ROWS_LIST, LOGS_TABLE_MAX_ROWS_LIST,
LOG_LEVEL,
MODAL, MODAL,
TAILWINDCSS_SIZE, TAILWINDCSS_SIZE,
} from '~/constants' } from '~/constants'
@ -17,11 +18,27 @@ import {
} from '~/signals' } from '~/signals'
export const LogsSettingsModal = () => { export const LogsSettingsModal = () => {
const modalID = MODAL.LOGS_SETTINGS
const [t] = useI18n() const [t] = useI18n()
return ( 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="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> <div>
<ConfigTitle withDivider>{t('tableSize')}</ConfigTitle> <ConfigTitle withDivider>{t('tableSize')}</ConfigTitle>

View File

@ -1,6 +1,7 @@
import { useI18n } from '@solid-primitives/i18n' import { useI18n } from '@solid-primitives/i18n'
import { IconX } from '@tabler/icons-solidjs'
import { For } from 'solid-js' 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 { MODAL, PROXIES_ORDERING_TYPE, PROXIES_PREVIEW_TYPE } from '~/constants'
import { import {
autoCloseConns, autoCloseConns,
@ -18,14 +19,27 @@ import {
} from '~/signals' } from '~/signals'
export const ProxiesSettingsModal = () => { export const ProxiesSettingsModal = () => {
const modalID = MODAL.PROXIES_SETTINGS
const [t] = useI18n() const [t] = useI18n()
return ( return (
<dialog <dialog id={modalID} class="modal modal-bottom sm:modal-middle">
id={MODAL.PROXIES_SETTINGS}
class="modal modal-bottom sm:modal-middle"
>
<div class="modal-box flex flex-col gap-4"> <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> <div>
<ConfigTitle withDivider>{t('autoCloseConns')}</ConfigTitle> <ConfigTitle withDivider>{t('autoCloseConns')}</ConfigTitle>