Skip to content

Add accessible <FileTree> component to replace ASCII art#2178

Merged
delucis merged 12 commits into
mainfrom
chris/file-trees
Dec 16, 2022
Merged

Add accessible <FileTree> component to replace ASCII art#2178
delucis merged 12 commits into
mainfrom
chris/file-trees

Conversation

@delucis
Copy link
Copy Markdown
Member

@delucis delucis commented Dec 14, 2022

Summary

Authoring

Once you import the FileTree component into your file, authoring looks like this:

<FileTree>
- src/
  - pages/
    - **index.astro**
- astro.config.mjs This is the Astro config file
- package.json
</FileTree>
  1. A file or directory can be marked as highlighted by bolding it: **index.astro**.
  2. Any text following the first space in an item is treated as a comment and styled accordingly, see the astro.config entry above.

Screenshots

Here’s a before/after from the manual install guide:

Before After
image image

How does this work

The <FileTree> component expects to be passed an unordered list. It passes this list through a rehype pipeline that wraps directories in a <details> element to make them collapsible.

Each filename is passed to a utility based on the Seti UI VS Code icon system to get an icon for the detected file type. This is injected as an inline SVG.

This pipeline also separates the comments and interprets the bold filename as highlighted.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 14, 2022

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit ba8ac99
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/639ccda49218d5000942b80b
😎 Deploy Preview https://deploy-preview-2178--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@delucis delucis added the site improvement Some thing that improves the website functionality - ask @delucis for help! label Dec 14, 2022
@delucis delucis self-assigned this Dec 14, 2022
@sarah11918
Copy link
Copy Markdown
Member

Super excited for this @delucis! I tested all the docs pages, at various screen sizes and on my phone, and it all looks AMAZINGLY good to me! 🥳

Copy link
Copy Markdown
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so cool!

Copy link
Copy Markdown
Member

@yanthomasdev yanthomasdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with NVDA, it's perfect! Great work @delucis 🙌

Comment thread src/pages/en/core-concepts/project-structure.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

site improvement Some thing that improves the website functionality - ask @delucis for help!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[A11Y] File lists are currently inaccessible ASCII art representations

4 participants