Fix variables component

This commit is contained in:
Jeremy Thomas 2018-06-19 13:33:54 +01:00
parent dd59374591
commit f9f0b19e46
20 changed files with 97 additions and 136 deletions

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "base/_all.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "base/helpers.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "base/minireset.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "components/_all.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "components/level.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "components/media.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "elements/_all.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "elements/container.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "elements/other.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "grid/_all.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "grid/tiles.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "layout/_all.sass"
}

View file

@ -1,5 +0,0 @@
{
"by_name": {},
"list": [],
"file_path": "layout/hero.sass"
}

View file

@ -0,0 +1,41 @@
{
"by_name": {
"$control-radius": {
"name": "$control-radius",
"value": "$radius",
"type": "variable",
"computed_type": "size",
"computed_value": "4px"
},
"$control-radius-small": {
"name": "$control-radius-small",
"value": "$radius-small",
"type": "variable",
"computed_type": "size",
"computed_value": "2px"
},
"$control-border-width": {
"name": "$control-border-width",
"value": "1px",
"type": "size"
},
"$control-padding-vertical": {
"name": "$control-padding-vertical",
"value": "calc(0.375em - #{$control-border-width})",
"type": "size"
},
"$control-padding-horizontal": {
"name": "$control-padding-horizontal",
"value": "calc(0.625em - #{$control-border-width})",
"type": "size"
}
},
"list": [
"$control-radius",
"$control-radius-small",
"$control-border-width",
"$control-padding-vertical",
"$control-padding-horizontal"
],
"file_path": "utilities/controls.sass"
}

View file

@ -28,11 +28,15 @@
{% endcapture %}
{% include elements/anchor.html name=anchor_name %}
{% unless include.hide_anchor %}
{% include elements/anchor.html name=anchor_name %}
{% endunless %}
<div class="content">
<p>{{ content | strip }}</p>
</div>
{% unless include.hide_content %}
<div class="content">
<p>{{ content | strip }}</p>
</div>
{% endunless %}
<div class="table-container">
<table class="table {{ table_class }}">
@ -55,13 +59,8 @@
<tbody>
{% if include.variables_keys %}
{% for key in include.variables_keys %}
{% if include.responsiveness_variables %}
{% assign variable = site.data.variables.utilities.initial-variables.by_name[key] %}
{% include elements/variable-row.html variable=variable %}
{% else %}
{% assign variable = site.data.variables.elements.form.by_name[key] %}
{% include elements/variable-row.html variable=variable %}
{% endif %}
{% assign variable = site.data.variables[include.folder][include.file].by_name[key] %}
{% include elements/variable-row.html variable=variable %}
{% endfor %}
{% else %}
{% for variable_name in variables %}

View file

@ -730,4 +730,9 @@ meta:
</p>
</div>
{% include elements/variables.html type='element' variables_keys=page.variables_keys %}
{% include elements/variables.html
type='element'
variables_keys=page.variables_keys
folder='elements'
file='form'
%}

View file

@ -8,15 +8,15 @@ breadcrumb:
- documentation
- form
- form-general
variables_controls_keys:
- control-radius
- control-radius-small
- control-padding-vertical
- control-padding-horizontal
variables_form_keys:
- label-color
- label-weight
- help-size
variables_control_keys:
- $control-radius
- $control-radius-small
- $control-padding-vertical
- $control-padding-horizontal
variables_keys:
- $label-color
- $label-weight
- $help-size
---
{% capture example %}
@ -1029,49 +1029,23 @@ variables_form_keys:
{% include elements/snippet.html content=field_label_example horizontal=true more=true %}
{% include elements/anchor.html name="Variables" %}
{% capture custom_message %}
Form elements can be <strong>customized</strong> using the following generic variables. Simply set one or multiple of these variables <em>before</em> importing Bulma. <a href="{{ site.url }}/documentation/overview/customize/">Learn how</a>.
{% endcapture %}
<div class="content">
<p>
Form elements can be <strong>customized</strong> using the following generic variables. Simply set one or multiple of these variables <em>before</em> importing Bulma. <a href="{{ site.url }}/documentation/overview/customize/">Learn how</a>.
</p>
</div>
{% include elements/variables.html
type='element'
variables_keys=page.variables_control_keys
custom_message=custom_message
folder='utilities'
file='controls'
%}
<table class="table is-bordered">
<thead>
<tr>
<th>Name</th>
<th>Default value</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Default value</th>
</tr>
</tfoot>
<tbody>
{% for key in page.variables_controls_keys %}
{% assign variable = site.data.variables.utilities.controls.vars[key] %}
<tr>
<td>
<code>{{ variable.name }}</code>
</td>
<td>
<code>{{ variable.value }}</code>
</td>
</tr>
{% endfor %}
{% for key in page.variables_form_keys %}
{% assign variable = site.data.variables.elements.form.vars[key] %}
<tr>
<td>
<code>{{ variable.name }}</code>
</td>
<td>
<code>{{ variable.value }}</code>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% include elements/variables.html
type='element'
variables_keys=page.variables_keys
folder='elements'
file='form'
hide_anchor=true
hide_content=true
%}

View file

@ -478,4 +478,8 @@ meta:
</div>
</div>
{% include elements/variables.html type='element' variables_keys=page.variables_keys %}
{% include elements/variables.html type='element'
variables_keys=page.variables_keys
folder='elements'
file='form'
%}

View file

@ -234,5 +234,6 @@ $fullhd-enabled: false
type='element'
variables_keys=page.variables_keys
custom_message=custom_message
responsiveness_variables=true
folder='utilities'
file='initial-variables'
%}

View file

@ -11,9 +11,9 @@ function plugin() {
setImmediate(done);
Object.keys(files).forEach(file_path => {
if (file_path.startsWith('utilities')) {
return;
}
// if (file_path.startsWith('utilities')) {
// return;
// }
const {file_name, lines} = utils.getLines(files, file_path);
let variables = {
@ -38,7 +38,9 @@ function plugin() {
}
});
utils.writeFile(file_path, variables);
if (variables.list.length > 0) {
utils.writeFile(file_path, variables);
}
});
};
}