-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): initial tree editing breadcrumbs (#6677)
* feat(core): initial tree editing breadcrumbs * fix(core): remove comment
- Loading branch information
1 parent
12d401c
commit 0856eef
Showing
16 changed files
with
472 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
.../src/core/form/studio/tree-editing/__workshop__/TreeEditingBreadcrumbsMenuButtonStory.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// eslint-disable-next-line no-restricted-imports | ||
import {Button, Flex} from '@sanity/ui' | ||
import {useState} from 'react' | ||
import {type Path} from 'sanity' | ||
|
||
import {TreeEditingBreadcrumbsMenuButton} from '../components' | ||
import {type TreeEditingBreadcrumb} from '../types' | ||
|
||
const ITEMS: TreeEditingBreadcrumb[] = [...Array(100).keys()].map((index) => ({ | ||
title: `Item ${index}`, | ||
path: [`${index}-item`], | ||
children: [], | ||
})) | ||
|
||
export default function TreeEditingBreadcrumbsMenuButtonStory(): JSX.Element { | ||
const [selectedPath, setSelectedPath] = useState<Path>(['second-item']) | ||
|
||
return ( | ||
<Flex align="center" justify="center" height="fill"> | ||
<TreeEditingBreadcrumbsMenuButton | ||
items={ITEMS} | ||
onPathSelect={setSelectedPath} | ||
selectedPath={selectedPath} | ||
button={<Button text="Open menu" />} | ||
/> | ||
</Flex> | ||
) | ||
} |
41 changes: 41 additions & 0 deletions
41
...sanity/src/core/form/studio/tree-editing/__workshop__/TreeEditingBreadcrumbsMenuStory.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {Container, Flex} from '@sanity/ui' | ||
import {useState} from 'react' | ||
import {type Path} from 'sanity' | ||
|
||
import {TreeEditingBreadcrumbsMenu} from '../components' | ||
import {type TreeEditingBreadcrumb} from '../types' | ||
|
||
const items: TreeEditingBreadcrumb[] = [ | ||
{ | ||
title: 'First item', | ||
path: ['first-item'], | ||
children: [], | ||
}, | ||
{ | ||
title: 'Second item', | ||
path: ['second-item'], | ||
children: [], | ||
}, | ||
{ | ||
title: 'Third item', | ||
path: ['third-item'], | ||
children: [], | ||
}, | ||
] | ||
|
||
export default function TreeEditingBreadcrumbsMenuStory(): JSX.Element { | ||
const [selectedPath, setSelectedPath] = useState<Path>(['second-item']) | ||
|
||
return ( | ||
<Flex align="center" height="fill"> | ||
<Container width={0}> | ||
<TreeEditingBreadcrumbsMenu | ||
items={items} | ||
onPathSelect={setSelectedPath} | ||
selectedPath={selectedPath} | ||
textInputElement={null} | ||
/> | ||
</Container> | ||
</Flex> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.