-
Notifications
You must be signed in to change notification settings - Fork 22
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
Feature Request: YAML front-matter syntax to extend Page Object #34
Comments
You may want to investigate Assemble, which does exactly this sort of thing. I don't feel that YAML belongs within the scope of this project, but there is no reason you couldn't accomplish object-specific asset inclusion like this: /*
Alerts
======
Creates an alert box notification using the `.alert-` prefix.
The following options are available:
<div class="alert-success">Success</div>
<div class="alert-warning">Warning</div>
<div class="alert-error">Error</div>
<link rel="stylesheet" href="public/styleguide/article_styles.css" />
*/ |
Maybe you misunderstood this. I want to find a way to get control to the generated output. The case is. If for example, if you fetch the assets via wildcards in sassdown: {
styleguide: {
options: {
assets: [
'public/css/**/*.min.css',
'public/js/*.min.js'
],
},
}
}, I don't want to load all assets here. But in general what do you think of extending the Page Object in some way? It's about find a smart technique to extend the page object with optional syntax. Could also be something else. I only referenced YAML front matter because it was already used in the styleguide context (by trulia) or in some other popular syntax sugar projects. |
You can use Grunt globbing patterns to exclude files you do not wish to match. For example:
I understand that, but what is it you would like to extend it with - that cannot be done using Markdown/HTML? My issue is including another type of syntax to the documentation; the original point was to keep it simple with just Markdown. |
hehe.. argh you don't get me yet. ☀️ I want that sassdown include that assets specified by the wildcard. Think of a really large site with various different page styles. e.g.
Now you would document for example "Alerts" in the shop Context. So for this case it is necessary not to load all stylesheets for the documented section in the styleguide to display the alerts generated with the Next document section is Alerts in the Community context... |
No, I'm afraid I don't quite follow? |
Use Case: Imagine a really large website, with various CSS-Styles organized in separate stylesheets files (e.g. checkout.css, product.css, shop.css, community.css) Separated because from context to context Modules (e.g. Alerts) had different styles for example in community.css or checkout.css sassdown: Common setup. Nothing special. Load Documentation Task: I would document the "Alerts" Module inside the community.css context AND also document "Alerts" inside the checkout.css context. Goal: Find a smart technique to extend the page object with optional data. Somehow. To get control or change for example asset loading inside the generated iframe. Or add optional attributes ( Proactive: I did a research and find tools and the YAML front-matter technique and thought this would be a idea and a possible way to start a discussion. These examples are only two Use Cases. Think global, think big about optional metadata for the page object that can control / extend the handlebars template. |
I understand. What you want is something like: #page-foo .alert {
width: 50%;
}
#page-bar .alert {
width: 100%;
} However I don't feel this needs to be appended to a /*
Alerts
======
Creates an alert box notification using the `.alert-` prefix. The following options are available:
<div id="page-foo">
<div class="alert-success">Success</div>
<div class="alert-warning">Warning</div>
<div class="alert-error">Error</div>
</div>
*/ Better still, you could modify the CSS to allow for a more modular approach, like so: @mixin alert($colour){
color: darken($colour, 50%);
background: $colour;
border-radius: 5px;
margin-bottom: 1em;
padding: 1em;
// Allow for page variants
&.type-foo { width: 50%; }
&.type-bar { width: 100%; }
}
.alert-success { @include alert(#e2f3c1) }
.alert-warning { @include alert(#fceabe) }
.alert-error { @include alert(#ffdcdc) } ... and then structure your HTML like so: <div class="alert-success type-foo">Success</div>
<div class="alert-warning type-bar">Warning</div> |
But, that said, if you really want to include page-specific markup on the results iframe, you can do that by modifying the existing Handlebars template file (or creating your own!). Nothing stops you doing this; in fact, it would be your best option. Handlebars is meant to be extensible. |
Jep now you get me. Thank you for your structure concept. It is one of many ways, as always ;-) In my project I had large legacy components also strict structure that could not be changed easily. For this project I've found a workaround and modified the handlebar template. This works good. So fine on this side. One main purpose of this feature request was to share thoughts and pitfalls with sassdown. I really enjoyed building the styleguide with it. On my research I tried some other styleguide concepts and ways. Only wanted to mention these, here inside this repo and start a discussion. Sometimes maintainers didn't know their competitors and other concepts. These are no negative words, don't get me wrong here ☀️ |
Thank you for your comments and feedback. Sorry for misunderstanding the original question. I have marked this issue under the feature and enhancement labels - it may be something I revisit later in time. If you have other ideas, feel free to let me know :-) |
Sorry for the second feature request in this week. Like to share my thought...
This time, it is a feature I saw on the trulia/hologram styleguide repository. They use YAML front-matter syntax to specify vars or custom metadata.
YAML front matter is quite popular, read more:
Think of this optional section that is placed at the beginning of an documentation block. It is for optional metadata that will be extend the Page Object in some way.
Goal is to access this variable section somewhere in the handlebar templates.
In this Example you define metadata for the iframe context in the template.hbs.
I would be cool if it's possible to extend the generated iframe with this parameters.
This then can be parsed with something like this. (I am a handlebar noob)
Hope you can guess the wanted result. Want to filter the inclusion of specific assest and define a custom body class attribute.
What do you think? :]
Greets,
m5o
The text was updated successfully, but these errors were encountered: