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

View File

@@ -730,4 +730,9 @@ meta:
</p> </p>
</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

@@ -8,15 +8,15 @@ breadcrumb:
- documentation - documentation
- form - form
- form-general - form-general
variables_controls_keys: variables_control_keys:
- control-radius - $control-radius
- control-radius-small - $control-radius-small
- control-padding-vertical - $control-padding-vertical
- control-padding-horizontal - $control-padding-horizontal
variables_form_keys: variables_keys:
- label-color - $label-color
- label-weight - $label-weight
- help-size - $help-size
--- ---
{% capture example %} {% capture example %}
@@ -1029,49 +1029,23 @@ variables_form_keys:
{% include elements/snippet.html content=field_label_example horizontal=true more=true %} {% 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"> {% include elements/variables.html
<p> type='element'
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>. variables_keys=page.variables_control_keys
</p> custom_message=custom_message
</div> folder='utilities'
file='controls'
%}
<table class="table is-bordered"> {% include elements/variables.html
<thead> type='element'
<tr> variables_keys=page.variables_keys
<th>Name</th> folder='elements'
<th>Default value</th> file='form'
</tr> hide_anchor=true
</thead> hide_content=true
<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>

View File

@@ -478,4 +478,8 @@ meta:
</div> </div>
</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' type='element'
variables_keys=page.variables_keys variables_keys=page.variables_keys
custom_message=custom_message custom_message=custom_message
responsiveness_variables=true folder='utilities'
file='initial-variables'
%} %}

View File

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