File tree Expand file tree Collapse file tree 7 files changed +52
-15
lines changed
source/_patterns/01-elements Expand file tree Collapse file tree 7 files changed +52
-15
lines changed Original file line number Diff line number Diff line change 110110 --formElement---borderColor : #{$db-color-red-500 } ;
111111 }
112112}
113+
114+ // counter styling
115+ %form-element-counter {
116+ margin-top : to-rem ($pxValue : 12 );
117+
118+ // TODO: add CSS anchor positioning
119+
120+ // Description styles
121+ // TODO: This probably still needs to get further changed to a general "hint" pattern or similar
122+ & ,
123+ & + .description {
124+ color : $db-color-cool-gray-500 ;
125+ font-size : to-rem ($pxValue : 14 );
126+ padding : to-rem ($pxValue : 6 ) to-rem ($pxValue : 10 );
127+ }
128+ }
Original file line number Diff line number Diff line change 1111 {{{ validation }}}
1212 {{ #if datalist }} list =" datalist{{ id }} " {{ /if }}
1313 aria-labelledby =" {{ id }} -label"
14- {{ #if variant }} data-variant =" {{ variant }} " {{ /if }} >
14+ {{ #if variant }} data-variant =" {{ variant }} " {{ /if }}
15+ {{ #if maxlength }} maxlength =" {{ maxlength }} "
16+ oninput =" result_{{ id }} .value=this.value.length+'/'+this.attributes.maxlength.value" {{ /if }} >
1517<label class =" elm-label"
1618 for =" {{ id }} "
1719 aria-hidden =" true"
2325 <option {{ #if value }} value =" {{ value }} " {{ /if }} >{{ text }} </option >
2426 {{ /each }}
2527</datalist >{{ /if }}
28+ {{ #if maxlength }} <output for =" {{ id }} " id =" result_{{ id }} " ></output >{{ /if }}
Original file line number Diff line number Diff line change 145145 @extend %form-element-validation ;
146146 @extend %form-element-validation-programmatic ;
147147 /* stylelint-enable order/order */
148+
149+ & :is(
150+ [type = " email" ],
151+ [type = " password" ],
152+ [type = " search" ],
153+ [type = " tel" ],
154+ [type = " text" ],
155+ [type = " url" ]
156+ )
157+ + label
158+ + output {
159+ @extend %form-element-counter ;
160+ }
148161 }
149162
150163 & [type = " search" ] {
Original file line number Diff line number Diff line change 1+ {
2+ "type" : " text" ,
3+ "placeholder" : " Projekt Name" ,
4+ "id" : " input16" ,
5+ "label" : " Textlabel" ,
6+ "maxlength" : " 100"
7+ }
Original file line number Diff line number Diff line change 1+ ---
2+ title : Input - maxlength
3+ order : 12
4+ hidden : true
5+ ---
6+
7+ To set the maximum length of allowed characters on an input element, you could use the ` maxlength ` -attribute on the input field. This would additionally provide a visual counter.
8+
9+ Please keep in mind that you'll probably have to position the output element yourself in relation to the context of e.g. a wrapping HTML element; we'll have a future solution by CSS Anchor Positioning as well.
Original file line number Diff line number Diff line change 66 {{ #if disabled }} disabled{{ /if }}
77 {{ #if describedbyid }} aria-describedby =" {{ describedbyid }} " {{ /if }}
88 {{{ validation }}}
9- {{ #if maxlength }} maxlength =" {{ maxlength }} "
109 {{ #if invalid }} aria-invalid =" {{ invalid }} " {{ /if }}
10+ {{ #if maxlength }} maxlength =" {{ maxlength }} "
1111 oninput =" result_{{ id }} .value=this.value.length+'/'+this.attributes.maxlength.value" {{ /if }}
1212 {{ #if variant }} data-variant =" {{ variant }} " {{ /if }} >{{ value }} </textarea >
1313{{ #if maxlength }} <output for =" {{ id }} " id =" result_{{ id }} " ></output >{{ /if }}
Original file line number Diff line number Diff line change 6161 }
6262 }
6363
64- // TODO: Evaluate whether those could get moved to ../_form-elements.scss
6564 & + output {
66- // amount of signs output
67- float : right ;
68-
69- margin-top : to-rem ($pxValue : 12 );
65+ @extend %form-element-counter ;
7066
71- // Description styles
72- // TODO: This probably still needs to get further changed to a general "hint" pattern or similar
73- & ,
74- & + .description {
75- color : $db-color-cool-gray-500 ;
76- font-size : to-rem ($pxValue : 14 );
77- padding : to-rem ($pxValue : 6 ) to-rem ($pxValue : 10 );
78- }
67+ float : right ;
7968 }
8069
8170 // ### Style variations
You can’t perform that action at this time.
0 commit comments