cloudfour / drizzle

A streamlined tool for developing, documenting and presenting UI pattern libraries.
https://cloudfour.com/thinks/introducing-drizzle/
MIT License
666 stars 32 forks source link

Adding arbitrary code samples to patterns #90

Open yodasw16 opened 7 years ago

yodasw16 commented 7 years ago

Is there a way to add arbitrary code samples to a pattern template? A few examples:

erikjung commented 7 years ago

@yodasw16 We have also experienced the need for this kind of flexibility.

Are you thinking that this would be a new property defined in the front-matter of a pattern with the arbitrary code provided as a fenced code block?

As a temporary workaround, you can always include code samples within the notes front-matter property (since it is parsed as Markdown), and use the sourceless flag to hide the default code sample. Example:

name: Button
sourceless: true
notes: |
  This is a button. Here is some code:
  ```html
  <button class="Button">Wooo</button>
  ```
  ```css
  .Button { }
  ```

Although you may need to add a little CSS to properly style the <pre> and/or <code> elements output by the Markdown engine.

yodasw16 commented 7 years ago

Yeah, I think it would have to either be a property in the front-matter or for things like showing css or js maybe having another file in the directory that get's pulled in to another <pre><code>. Not sure how that would work, but it would be useful.