Skip to content

Commit

Permalink
Added class option for labels to appear above their field (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
aletail authored Oct 31, 2024
1 parent 36ff379 commit 7741861
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/en/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ $component-form-text-with-button-properties: (
## Form Process Animation
When a form is submitted all fields are disabled including the submit button. An animated icon is added next to the submit button as well.
You must opt-in for this to take effect, the form element must contain the following class: `fw-form-process-event` as well as the `fw-form` class.

## Label placements
By default, labels are placed inside the input box. To change this, simply add the `fw-form-label-above` class alongside the `fw-form` class. This adjustment moves labels above the fields, eliminating any animation when a field gains or loses focus.
9 changes: 9 additions & 0 deletions sass/components/form/components/_numeric.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@ $component-form-numeric-properties: $default-component-form-numeric-properties !
}
}
}

// Label above field
&.fw-form-label-above{
.field.numeric{
input, input[type='number']{
padding: 9px 50px;
}
}
}
}
18 changes: 18 additions & 0 deletions sass/components/form/components/_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ $component-form-select-properties: $default-component-form-select-properties !de
pointer-events: none;
}
}

// Label above field
&.fw-form-label-above{
.field.dropdown{
label{
position: relative;
transform: none;
&.labelShrunk{
transform: none;
}
}
select{
&.labelShrunk{
padding: 20px;
}
}
}
}
}
@-moz-document url-prefix() {
.fw-form{
Expand Down
18 changes: 18 additions & 0 deletions sass/components/form/components/_text-with-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ $component-form-text-with-button-properties: $default-component-form-text-with-b
border-radius: getThemeProperty(buttonBorderRadius, $component-form-text-with-button-properties);
}
}
}

// Label above field
&.fw-form-label-above{
.field.text-with-button{
label{
position: relative;
transform: none;
&.labelShrunk{
transform: none;
}
}
input{
padding: 20px;
&.labelShrunk{
padding: 20px;
}
}
}
}
}
19 changes: 19 additions & 0 deletions sass/components/form/components/_text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,23 @@ $component-form-text-properties: $default-component-form-text-properties !defaul
}
}
}

// Label above field
&.fw-form-label-above{
.field.text{
label{
position: relative;
transform: none;
&.labelShrunk{
transform: none;
}
}
input{
padding: 20px;
&.labelShrunk{
padding: 20px;
}
}
}
}
}
19 changes: 19 additions & 0 deletions sass/components/form/components/_textarea.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,23 @@ $component-form-textarea-properties: $default-component-form-textarea-properties
}
}
}

// Label above field
&.fw-form-label-above{
.field.textarea{
label{
position: relative;
transform: none;
&.labelShrunk{
transform: none;
}
}
textarea{
padding: 20px;
&.labelShrunk{
padding: 20px;
}
}
}
}
}

0 comments on commit 7741861

Please sign in to comment.