Skip to content

Commit

Permalink
fix: AnchorGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskang committed Oct 30, 2023
1 parent bb78ca7 commit 29b5d02
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 54 deletions.
106 changes: 54 additions & 52 deletions packages/docs/core/App.tsx
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
import { useState } from 'react'
import Button from '../pages/Button.mdx'
import { Anchor, AnchorGroup } from '@zonda/react'
import { AnchorGroup } from '@zonda/react'

function App() {
const [currKey, setCurrKey] = useState('assadfas')
const onChange = (key: string) => setCurrKey(key)
return (
<div className="max-w-8xl mx-auto px-4 sm:px-6 md:px-8">
<div className="fixed inset-0 left-[max(0px,calc(50%-45rem))] right-auto top-[3.8125rem] z-20 hidden w-[19rem] overflow-y-auto pb-10 pl-8 pr-6 lg:block ">
<AnchorGroup selectedKey={currKey} onChange={onChange}

items={[
{
title:'Getting Started',
children: [
{
title: 'Installation',
key: '/docs/getting-started/installation',
},
{
title: 'Core Concepts',
key: '/docs/getting-started/core-concepts',
children: [
{ title: 'assadfas', key: 'assadfas' },
{ title: 'assadfas2', key: 'assadfas2' },
{ title: 'assadfas3', key: 'assadfas3' },
],
},
{
title: 'Getting Started',
key: '/docs/getting-started/getting-started',
},
]
},{
title:'Array',
children: [
{
title: 'alphabetical',
key: '/docs/array/alphabetical',
},
{
title: 'boil',
key: '/docs/array/boil',
},
{
title: 'cluster',
key: '/docs/array/cluster',
},
{
title: 'counting',
key: '/docs/array/counting',
},
{
title: 'diff',
key: '/docs/array/diff',
},
]
}
]}
<AnchorGroup
selectedKey={currKey}
onChange={onChange}
items={[
{
title: 'Getting Started',
children: [
{
title: 'Installation',
key: '/docs/getting-started/installation',
},
{
title: 'Core Concepts',
key: '/docs/getting-started/core-concepts',
children: [
{ title: 'assadfas', key: 'assadfas' },
{ title: 'assadfas2', key: 'assadfas2' },
{ title: 'assadfas3', key: 'assadfas3' },
],
},
{
title: 'Getting Started',
key: '/docs/getting-started/getting-started',
},
],
},
{
title: 'Array',
children: [
{
title: 'alphabetical',
key: '/docs/array/alphabetical',
},
{
title: 'boil',
key: '/docs/array/boil',
},
{
title: 'cluster',
key: '/docs/array/cluster',
},
{
title: 'counting',
key: '/docs/array/counting',
},
{
title: 'diff',
key: '/docs/array/diff',
},
],
},
]}
/>
</div>
</div>
<div className="lg:pl-[19.5rem]">
<div className="mx-auto max-w-3xl pt-10 xl:ml-0 xl:mr-[15.5rem] xl:max-w-none xl:pr-16">
<div className="prose prose-sm flex-1">
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Anchor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface AnchorGroupProps extends Omit<HTMLAttributes<HTMLDivElement>,'o
selectedKey?: string
onChange?: (key: string) => void
items: {
key: string
key?: string
title: string
children: AnchorItem[]
}[]
Expand All @@ -99,7 +99,7 @@ export const AnchorGroup = (props: AnchorGroupProps) => {
const { items, className, style } = props
const [value, setValue] = useControllableValue<string>(props, {
valuePropName: 'selectedKey',
})
})
const onChange = (key: string) => {
setValue(key)
}
Expand Down

0 comments on commit 29b5d02

Please sign in to comment.