Browse Source

Fix variables component

Jeremy Thomas 7 năm trước cách đây
mục cha
commit
f9f0b19e46

+ 0 - 5
docs/_data/variables/base/_all.json

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

+ 0 - 5
docs/_data/variables/base/helpers.json

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

+ 0 - 5
docs/_data/variables/base/minireset.json

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

+ 0 - 5
docs/_data/variables/components/_all.json

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

+ 0 - 5
docs/_data/variables/components/level.json

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

+ 0 - 5
docs/_data/variables/components/media.json

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

+ 0 - 5
docs/_data/variables/elements/_all.json

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

+ 0 - 5
docs/_data/variables/elements/container.json

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

+ 0 - 5
docs/_data/variables/elements/other.json

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

+ 0 - 5
docs/_data/variables/grid/_all.json

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

+ 0 - 5
docs/_data/variables/grid/tiles.json

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

+ 0 - 5
docs/_data/variables/layout/_all.json

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

+ 0 - 5
docs/_data/variables/layout/hero.json

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

+ 41 - 0
docs/_data/variables/utilities/controls.json

@@ -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"
+}

+ 10 - 11
docs/_includes/elements/variables.html

@@ -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">
-  <p>{{ content | strip }}</p>
-</div>
+{% unless include.hide_content %}
+  <div class="content">
+    <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.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 %}
         {% endfor %}
       {% else %}
       {% else %}
         {% for variable_name in variables %}
         {% for variable_name in variables %}

+ 6 - 1
docs/documentation/form/file.html

@@ -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'
+%}

+ 28 - 54
docs/documentation/form/general.html

@@ -8,15 +8,15 @@ breadcrumb:
 - documentation
 - documentation
 - form
 - form
 - form-general
 - 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 %}
 {% 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" %}
-
-<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>
+{% 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 %}
 
 
-<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_control_keys
+  custom_message=custom_message
+  folder='utilities'
+  file='controls'
+%}
+
+{% include elements/variables.html
+  type='element'
+  variables_keys=page.variables_keys
+  folder='elements'
+  file='form'
+  hide_anchor=true
+  hide_content=true
+%}

+ 5 - 1
docs/documentation/form/input.html

@@ -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'
+%}

+ 2 - 1
docs/documentation/overview/responsiveness.html

@@ -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'
 %}
 %}

+ 6 - 4
docs/scripts/plugins/03-read-other-variables.js

@@ -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')) {
-        return;
-      }
+      // if (file_path.startsWith('utilities')) {
+      //   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);
+      }
     });
     });
   };
   };
 }
 }