stylemark icon indicating copy to clipboard operation
stylemark copied to clipboard

Passing head HTML information from an individual component

Open nicetransition opened this issue 7 years ago • 7 comments

I do not believe this exists, if it does I can't find it in the source code or any documentation. Is there currently a way to pass code to head of a component? For example headHtml called out in the YAML block.

If not, I can work on an update

Let me know before I make this update, thanks!

/*
---
name: Button
category: Components
headHtml: <link rel="stylesheet" href="specific-css.css" />
---

Buttons can be used with `<a>`, `<button>`, and `<input>` elements.

Types of buttons:
- Default: Standard button
- Primary: Provides extra visual weight and identifies the primary action in a set of buttons
- Success: Indicates a successful or positive action

```types.html
<button class="btn btn-default">Default</button>
<button class="btn btn-primary">Primary</button>
<button class="btn btn-success">Success</button>
```
*/
.btn {
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    …
}
.btn-default {
    …
}

nicetransition avatar Mar 22 '18 04:03 nicetransition

That feature does not currently exist and it looks useful, so feel free to add!

Implementation note: Make sure to treat that as a multi line block YAML field (using a pipe):

headHtml: |
  <link ...>
  <script>...</script>

mpetrovich avatar Mar 22 '18 13:03 mpetrovich

siccck I should be able to get on this tonight - any dev/contribution reference docs for this project?

Looking forward to contributing ~

nicetransition avatar Mar 22 '18 18:03 nicetransition

PR for review :)

~ didn't know how you handle versions/changelog and documentation for THIS @mpetrovich

nicetransition avatar Mar 23 '18 05:03 nicetransition

I added one more thing:

  • head - gets added to <head/>
  • headHtml -Overwrites the headHtml from the ".stylemark.yml" file and replaces it with content from component. Can also be used to remove the defined headHtml from the ".stylemark.yml" file.
---
name: Component Name Here
category: Category Name Here
head: <link rel="stylesheet" href=“extend-head-area.css" />
headHtml: <link rel="stylesheet" href="overrite-headHtml.css" />
---

also include multi line

---
name: Component Name Here
category: Category Name Here
head:  |
  <link rel="stylesheet" href="extra-css-in-head.css">
  <script src="extra-js-in-head.js"></script>
headHtml: <link rel="stylesheet" href="overrite-headHtml.css" />
---

it's available in #26

I'm not sure why it's failing. @mpetrovich any thoughts?

nicetransition avatar Mar 24 '18 22:03 nicetransition

After revisiting this, I wonder if this can already be accomplished with external asset references in the examples:

```example:path/to/file.css
```

Is the intention to include a CSS file for a specific rendered example? or for all of a component’s examples?

mpetrovich avatar Jun 04 '18 02:06 mpetrovich

It's to inject one or many CSS files to a specific component that is then rendered

nicetransition avatar Jun 08 '18 18:06 nicetransition

Ah, so the latter—it should be included for ALL the examples in that component's docs. I totally misunderstood this feature request initially.

mpetrovich avatar Jun 08 '18 20:06 mpetrovich