From 10dfb6eac3868ae7e580d5688b57e1685af0345e Mon Sep 17 00:00:00 2001 From: Jeremy Thomas Date: Tue, 14 Mar 2017 23:19:43 +0000 Subject: [PATCH] Add new blog post --- docs/_posts/2017-03-10-new-field-element.md | 126 ++++++++++++++++++++ docs/css/bulma-docs.css | 3 +- sass/elements/form.sass | 3 +- 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 docs/_posts/2017-03-10-new-field-element.md diff --git a/docs/_posts/2017-03-10-new-field-element.md b/docs/_posts/2017-03-10-new-field-element.md new file mode 100644 index 00000000..6899adf8 --- /dev/null +++ b/docs/_posts/2017-03-10-new-field-element.md @@ -0,0 +1,126 @@ +--- +layout: post +title: "New field element (for better controls)" +published: true +introduction: "

The .control element has been a very versatile container for form controls. But it came at a cost: it was difficult to combine its block characteristics with its inline variations.

" +--- + +**TL;DR: there's a new `.field` container, and `.control` has been re-purposed.** + +Since the beginning, the `.control` has been a very **versatile** element that allowed: + +* to **space** controls vertically +* to include an **icon** alongside inputs, buttons, textareas... +* to append a **loading spinner** +* to create **horizontal forms** +* to create **control addons** +* to create **control groups** + +## The problem + +The `.control` element acted as both a _block_ container (for spacing, for other controls in a horizontal form), but also an _inline_ container (for adding an icon, a loader, an addon, and grouping). +It led to issues where you couldn't: + +* add a help text horizontally +* add multiple icons or loaders in a group of controls +* add a different icon on addons + +## The solution + +The new `.field` element becomes the **block** container for `.control` elements. As a result, it inherits the `.has-addons`, `.is-grouped`, and `.is-horizontal` modifiers. + +Furthermore `.control` element can only contain a `.button`, `.input`, `.select`, or `.textarea`, and eventually a `.icon`. It can **no longer** contain a `.help` element or other `.control`. + +But it allows more elaborate designs. + +{% highlight sass %} +// Before +.control + .has-addons + .has-icon + .is-grouped + .is-horizontal + .is-loading +.control-label + +// After +.control + .has-icon + .is-loading +.field + .has-addons + .is-grouped + .is-horizontal +.field-label +.field-body +{% endhighlight %} + +{% highlight html %} + + +

+ + + + + This username is available +

+ + +
+ +

+ + + + +

+

This username is available

+
+{% endhighlight %} + +## Examples + +Addons with multiple icons or states. + +
+

+ + + + +

+

+ + + + +

+

+ +

+
+ +Horizontal form with help text + +
+
+ +
+
+
+

+ +

+
+
+

+ + + + +

+

This email is correct

+
+
+
diff --git a/docs/css/bulma-docs.css b/docs/css/bulma-docs.css index 582b2108..49b56553 100644 --- a/docs/css/bulma-docs.css +++ b/docs/css/bulma-docs.css @@ -1797,7 +1797,8 @@ input[type="submit"].button { .label { color: #363636; display: block; - font-weight: bold; + font-size: 1rem; + font-weight: 700; } .label:not(:last-child) { diff --git a/sass/elements/form.sass b/sass/elements/form.sass index 0388f2df..602d0a80 100644 --- a/sass/elements/form.sass +++ b/sass/elements/form.sass @@ -145,7 +145,8 @@ $input-radius: $radius !default .label color: $input display: block - font-weight: bold + font-size: $size-normal + font-weight: $weight-bold &:not(:last-child) margin-bottom: 0.5em