metacubexd/src/components/ConnectionsTableDetailsModal.tsx

51 lines
1.3 KiB
TypeScript
Raw Normal View History

import { IconX } from '@tabler/icons-solidjs'
2023-09-10 17:55:53 +08:00
import { Component, Show } from 'solid-js'
2023-09-15 23:43:55 +08:00
import { MODAL } from '~/constants'
2023-09-10 17:55:53 +08:00
import { allConnections } from '~/signals'
import { Button } from './Button'
2023-09-10 17:55:53 +08:00
export const ConnectionsTableDetailsModal: Component<{
selectedConnectionID?: string
}> = (props) => {
const modalID = MODAL.CONNECTIONS_TABLE_DETAILS
2023-09-10 17:55:53 +08:00
return (
<dialog id={modalID} class="modal modal-bottom sm:modal-middle">
2023-09-10 17:55:53 +08:00
<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>
2023-09-10 17:55:53 +08:00
<Show when={props.selectedConnectionID}>
<pre>
<code>
{JSON.stringify(
allConnections().find(
2023-09-10 17:55:53 +08:00
({ id }) => id === props.selectedConnectionID,
),
null,
2,
)}
</code>
</pre>
</Show>
</div>
<form method="dialog" class="modal-backdrop">
<button />
</form>
</dialog>
)
}