Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Out React Spectrum Tree View #876

Open
curran opened this issue Oct 29, 2024 · 1 comment
Open

Test Out React Spectrum Tree View #876

curran opened this issue Oct 29, 2024 · 1 comment

Comments

@curran
Copy link
Contributor

curran commented Oct 29, 2024

This looks like an amazing tree navigator UI widget that has full accessibility!

adobe/react-spectrum#2396 (comment)

I wonder if we could use it to replace the current infra for the sidebar with collapsible folders.

@curran
Copy link
Contributor Author

curran commented Oct 29, 2024

https://react-spectrum.adobe.com/react-aria/Tree.html#tree

import {
  UNSTABLE_Tree as Tree,
  UNSTABLE_TreeItem as TreeItem,
  UNSTABLE_TreeItemContent as TreeItemContent,
  Button,
  Collection
} from 'react-aria-components';
import {MyCheckbox} from './Checkbox';

let items = [
  {id: 1, title: 'Documents', children: [
    {id: 2, title: 'Project', children: [
      {id: 3, title: 'Weekly Report', children: []}
    ]}
  ]},
  {id: 4, title: 'Photos', children: [
    {id: 5, title: 'Image 1', children: []},
    {id: 6, title: 'Image 2', children: []}
  ]}
];

<Tree aria-label="Files" selectionMode="multiple" items={items}>
  {function renderItem(item) {
    return (
      <TreeItem textValue={item.title}>
        <TreeItemContent>
          {item.children.length ? <Button slot="chevron">
            <svg viewBox="0 0 24 24">
              <path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
            </svg>
          </Button> : null}
          <MyCheckbox slot="selection" />
          {item.title}
          <Button aria-label="Info"></Button>
        </TreeItemContent>
        <Collection items={item.children}>
          {renderItem}
        </Collection>
      </TreeItem>
    );
  }}
</Tree>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant