Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom CSS (or Sass/SCSS/Less) to a page #27

Open
hagenburger opened this issue Aug 18, 2018 · 0 comments
Open

Add custom CSS (or Sass/SCSS/Less) to a page #27

hagenburger opened this issue Aug 18, 2018 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@hagenburger
Copy link
Owner

New feature

Allow page/code block-specific CSS.

Specification

<style>
  a { color: blue; }
</style>

Should add the text content of <style> to the contents of the document:

document.contents.add('css', '\n  a { color: blue; }\n')

Preprocessors

<style type="scss">
  a { color: lighten(blue, 10%); }
</style>

Should add the text content of <style> to the SCSS contents of the document:

document.contents.add('scss', '\n  a { color: lighten(blue, 10%); }\n')

The same must work for sass and less. Tbd: There should be a list of valid types which can be extended via plugin. If the type is not defined, it should raise an error.

Scoping

Often it is useful to add additional CSS to make an example look good in a style guide. A notification might have position: absolute but within the example it needs to be changed to position: relative. This change must not apply globally as the notification might be used outside of examples.

This could be solved by adding a class/ID to the code block and a scope to the <style>:

``` html .my-notification-example
<div class="my-notification error">
  An error happened.
</div>
```
<style scope=".my-notification-example">
  .my-notification {
    position: relative;
  }
</style>

That might be a bit too much to type. This should get a shortcut:

``` html
<div class="my-notification error">
  An error happened.
</div>
```
<style previous-element>
  .my-notification {
    position: relative;
  }
</style>

Tbd. previous-element is just a first idea and needs to be discussed. It could be used elsewhere:

# Headline [link](#url)

<style previous-element>
  a { color: red; }
</style>

This requires automatically generated IDs (#26).

@hagenburger hagenburger added the enhancement New feature or request label Aug 18, 2018
@hagenburger hagenburger added this to the v1.0.0 milestone Aug 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant