Page MenuHomePhabricator

Add "Overview" to components section
Closed, ResolvedPublic3 Estimated Story Points

Description

Summary

With T309109 and T317198, we are refactoring the site architecture to create top-level nav sections for design tokens, components, and icons. Each section will have its own sidebar.

Design tokens and icons already have an overview page, which is the first item in the sidebar:

image.png (402×996 px, 92 KB)

image.png (388×1 px, 59 KB)

To maintain consistency and better pair component usage information with the component section, the components section should also have its own overview page.

Challenges

The packages/codex-docs/docs/components directory is automatically emptied and repopulated by the build script (see package.json in the docs package). Therefore, we can't add an overview.md file to that directory and expect it to persist (it would also be gitignored, but that's easy to fix).

We should also keep T317160 in mind, which may involve including mixin demo pages with the components. A solution that works for the overview page might not be sufficient to support mixin pages, which will need to live alongside component pages but won't be generated via vue-docgen-cli.

Content

My initial proposal for content is this:

# Components

Components are the interactive building blocks of our design system, used to create consistent and powerful user interfaces.

The Codex library contains fully interactive components built with [Vue 3](https://vuejs.org/). In
the future, some CSS-only components will be provided via [Less mixins](https://lesscss.org/features/#mixins-feature).

Each component in Codex has a demo page where you can interact with working examples, see code samples, and read detailed usage information.

## Resources

- Learn how to [use Codex components](../using-codex/usage.html#using-components)
- Learn how to [contribute or request a component](../contributing/overview.html)

We also might consider adding the following:

Event Timeline

It's not vue-docgen-cli that empties the packages/codex-docs/docs/components directory, we do that ourselves in packages/codex-docs/package.json:

"docgen:build": "node -e \"require( 'fs-extra' ).emptyDir( 'docs/components/' );\" && vue-docgen",

Volker added this in https://gerrit.wikimedia.org/r/c/design/codex/+/739046 to prevent errors when switching between branches that do/don't have a given component.

Catrope triaged this task as High priority.Sep 12 2022, 8:30 AM
AnneT changed the task status from Open to In Progress.Sep 15 2022, 8:39 PM
AnneT claimed this task.

Change 832569 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[design/codex@main] docs: Move generated components demos and add an overview page

https://gerrit.wikimedia.org/r/832569

I've opened a patch that demonstrates the following strategy:

  • Generated component demo pages are now output into packages/codex-docs/docs/components/demos/, which is gitignored. This directory is the only thing that gets emptied by the docgen:build script.
  • That way, I can add an overview page at packages/codex-docs/docs/components/
  • I've adjusted the docgen config, vite alias, and links accordingly

This method would allow for a couple of options for documenting component mixins:

Option 1: Copy mixin demo pages into docs/components/demos

Process:

  • As component demos are set up in packages/codex-docs/component-demos, so mixin demos will be set up in packages/codex-docs/mixin-demos
  • These mixin demos will take a similar form as the component ones, a markdown file explaining the mixin and providing examples as Vue components
  • We write a script that copies all files matching the pattern mixin-demos/[mixin-name]/[mixin-name].md into docs/components/demos at the end of the docgen:build script

Upside: component mixins live alongside components and have the same path
Downside: no HMR out of the box; we'd have to write a script to watch these files for changes and copy them over when they do

Option 2: Static mixin files in a separate directory

Process:

  • We set up docs/components/mixins as a directory for static mixin demo pages
  • We either list them in a separate section in the sidebar, or mix them into the list of components

Upside: HMR, extremely easy
Downside: mixin demo pages have a different path than component demo pages


These are all really simple/straightforward solutions. If anyone has an idea for something fancier, feel free to propose it!

ldelench_wmf subscribed.

Feel free to move out of "Code Review" if that's not accurate.

For now I think option 2 is probably best because it's simpler. If we end up using or building a tool to generate part of the documentation for something that isn't a component (e.g. mixins, composables or types), then I think option 1 makes more sense, because then you need to separate the hand-written source from the generated output.

Change 832569 merged by jenkins-bot:

[design/codex@main] docs: Move generated components demos and add an overview page

https://gerrit.wikimedia.org/r/832569

On

Moving the "Using components" section from the usage docs to here

The current navigation structure is confusing.

image.png (462×496 px, 34 KB)

I do like the usage being so prominent though. It's the first thing a new dev wants to know. I'd therefore rather update the first item, calling it maybe ”Codex introduction” or “Codex overview” as we've been using that term several times? I'd also leave the path “/using-codex/”
And continue linking back to the “Usage” page.

@Volker_E can you please re-post your comment in T317198? That's where the decisions were made around the structure of that part of the docs.

Closing this as a solution was implemented for the overview page; will post options for mixins in that task.

Change 849191 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/core@master] Update Codex from v0.2.1 to v0.2.2

https://gerrit.wikimedia.org/r/849191

Change 849191 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v0.2.1 to v0.2.2

https://gerrit.wikimedia.org/r/849191