Skip to content

Commit

Permalink
feat(misc/tree): replace some states with URL state
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 authored Mar 14, 2024
1 parent c8f0d13 commit 8857a4a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/app/misc/tree/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useRef, useState } from 'react'
import { Download } from 'lucide-react'
import { parseAsBoolean, useQueryState } from 'nuqs'

import { downloadText } from '~/shared/lib/download-text'
import { Label } from '~/shared/components/label'
Expand All @@ -17,10 +18,22 @@ export default function Page() {
const [plainText, setPlainText] = useState(
'src\n app\n page.tsx\n components\n header.tsx'
)
const [fancy, setFancy] = useState(true)
const [fullPath, setFullPath] = useState(false)
const [rootDot, setRootDot] = useState(false)
const [trailingDirSlash, setTrailingDirSlash] = useState(false)
const [fancy, setFancy] = useQueryState(
'fancy',
parseAsBoolean.withDefault(true)
)
const [fullPath, setFullPath] = useQueryState(
'fullPath',
parseAsBoolean.withDefault(false)
)
const [rootDot, setRootDot] = useQueryState(
'rootDot',
parseAsBoolean.withDefault(false)
)
const [trailingDirSlash, setTrailingDirSlash] = useQueryState(
'trailingDirSlash',
parseAsBoolean.withDefault(false)
)

const charset: 'utf-8' | 'ascii' = fancy ? 'utf-8' : 'ascii'

Expand Down

0 comments on commit 8857a4a

Please sign in to comment.