Skip to content

Commit

Permalink
Merge pull request #749 from CityOfBoston/DIG-4058
Browse files Browse the repository at this point in the history
DIG-4058: Text Box treatments for data entry states and required fields
  • Loading branch information
phillipbentonkelly authored Apr 3, 2024
2 parents b309779 + 14b8262 commit 1d566ce
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
22 changes: 22 additions & 0 deletions components/base/form/textbox/textbox--input-states.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{#each states as |textbox|}}
<label class="txt">
<span class="txt-l">
{{label}}
{{#if required}}
<span class="t--req">Required</span>
{{/if}}
{{#if soft-required}}
<span class="t--req">Required</span>
{{/if}}
</span>
<input
type="{{#if type}}{{type}}{{else}}text{{/if}}"
value="{{#if value}} {{value}}{{/if}}"
placeholder="{{placeholder}}"
class="txt-f{{#if error }} txt-f--err{{#if soft-required}} txt-f--sr{{/if}}{{/if}}{{#if classes}} {{classes}}{{/if}}"
>
{{#if error }}
<div class="t--subinfo t--err m-t100">{{ error }}</div>
{{/if}}
</label>
{{/each}}
12 changes: 12 additions & 0 deletions components/base/form/textbox/textbox.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ context:
id: password
type: password
value: "password"
states:
- label: Default
type: text
- label: Input Label
required: true
- label: Soft Require - Required/Validation on Submit
error: Please enter an email address
soft-required: true
- label: Error
placeholder: Your email address
value: "Not an email address string"
error: Please enter an email address
variants:
- name: Combo
context:
Expand Down
9 changes: 8 additions & 1 deletion components/base/form/textbox/textbox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
<div class="txt">
<label for="{{id}}" class="txt-l{{#if error }} t--err{{/if}}">{{label}}</label>
{{#if ../inputType }}
<input id="{{id}}" type="{{#if type}}{{type}}{{else}}text{{/if}}" value="{{value}}" placeholder="{{placeholder}}" class="txt-f{{#if error }} txt-f--err{{/if}}{{#if classes}} {{classes}}{{/if}}"{{#if size }} size="{{ size }}"{{/if}}>
<input
id="{{id}}"
type="{{#if type}}{{type}}{{else}}text{{/if}}"
value="{{value}}"
placeholder="{{placeholder}}"
class="txt-f{{#if error }} txt-f--err{{/if}}{{#if classes}} {{classes}}{{/if}}"{{#if size }}
size="{{ size }}"{{/if}}
>
{{/if}}
{{#if ../textareaType }}
<textarea id="{{id}}" placeholder="{{placeholder}}" class="txt-f" rows="10">{{value}}</textarea>
Expand Down
11 changes: 11 additions & 0 deletions stylesheets/components/form/_textbox.styl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
padding-left: $sizing-300
padding-right: $sizing-300

&--sr
border-width: $border-150
border-color: $error-border-color

&--focused
box-shadow: 0 0 0 3px $focus-indicator-color
border-color: $focus-indicator-color

&--sm
field-height-sm = "calc(%srem + %s * 2)" % ($line-height-400 $border-200)

Expand Down Expand Up @@ -92,10 +100,13 @@

&:focus
box-shadow: 0 0 0 3px $focus-indicator-color
border-color: $focus-indicator-color

&--combo
border-right: 0
float: left
:focus
outline: none;

&-l
color: $charles-blue
Expand Down

0 comments on commit 1d566ce

Please sign in to comment.