Elucidate
A library that makes it a breeze to "shed light" on your Vue component.
Installation (Yarn)
yarn add vue-elucidate
Installation (in a Vue project)
Usage
The <elucidate>
component takes two props, component
and example
.
The former is, quite literally, a single Vue component (either imported into your current app, or defined inline), or an array of Vue components.
The latter is either a single example object shaped thusly, or an array of example objects shaped thusly:
Key | Value |
---|---|
markup |
An HTML code snippet that you would like to document |
props |
An object defining the props referenced by your HTML code snippet |
methods |
An object defining the methods referenced by your HTML code snippet |
name |
(OPTIONAL) A display name for the given component if part of an array of examples |
How does it work?
Let's assume you have a component named custom-button
. It's defined in custom-button.vue
thusly:
Elucidate works by:
- Rendering an example code snippet, e.g.,
<custom-button size="small">Hello</custom-button>
- Documenting that snippet, as well as any props/functions that were passed to it
- Documenting all of the props exposed by
<custom-button>
, in this casevariant
andsize
.
So, the following code:
...would produce the following result:
Customization
Elucidate is very customizable. I've included some light CSS here and there to make things look half-way decent. Here are a few guidelines for customization.
BYOCSS
Elucidate uses Prism JS for syntax highlighting. Elucidate doesn't ship out-of-the-box with a particular syntax highlighting theme, so feel free to pick one from Prism Themes
Default CSS
Include Elucidate's default styles by including the following line of code in your project:
import 'vue-elucidate/dist/style.css'
Elucidate maintains a light footprint, and affords you the following classes for purposes of customization:
To-Do
- [ ] Test Coverage
- [x] Accommodate multiple components in a single example
- [x] Accommodate multiple examples
- [ ] Investigate slot-based API for further customization of sub-components