Skip to content

Commit

Permalink
[website] show render tab when split view
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxinghu committed Nov 1, 2023
1 parent 68a9675 commit 6a83fec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion website/src/components/magic.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useState, type ReactNode } from 'react'
import { useState, type ReactNode, useEffect } from 'react'
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'

interface TabView {
tab: string
view: ReactNode
}

const bp = 1024

const getTabClasses = (selected: boolean, ...extra: string[]) => {
const classes = [
'px-2 py-1 min-w-[80px]',
Expand All @@ -32,6 +34,17 @@ export default function Magic({
children: ReactNode
}) {
const [tabIndex, setTabIndex] = useState(0)

useEffect(() => {
const vw = Math.max(
document.documentElement.clientWidth || 0,
window.innerWidth || 0
)
if (vw >= bp) {
setTabIndex(1)
}
}, [])

return (
<Tabs
className="grid grid-cols-1 lg:grid-cols-2 grid-rows-[auto_1fr] h-full w-full"
Expand Down

0 comments on commit 6a83fec

Please sign in to comment.