Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit a0f7506

Browse files
committed
feat(accessibility): extend InputBase with autocomplete and aria attr
1 parent c61b438 commit a0f7506

File tree

6 files changed

+46
-15
lines changed

6 files changed

+46
-15
lines changed

dev/typescript/App.vue

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div id="app">
33
<div class="page container">
4-
<h1 class="title m-4">{{ title }}</h1>
5-
<div class="flex justify-between">
6-
<div class="card p-6 mr-4">
4+
<h1 class="title m-4 text-bg">{{ title }}</h1>
5+
<div class="flex flex-wrap justify-between">
6+
<div class="card p-6 w-full sm:w-1/2">
77
<dynamic-form
88
:form="form"
99
@submited="handleSubmit"
@@ -15,6 +15,7 @@
1515
>
1616
<div class="avocado-field">
1717
<input
18+
:id="control.name"
1819
v-if="control"
1920
class="form-control"
2021
v-model="control.value"
@@ -36,7 +37,7 @@
3637
Submit Form
3738
</button>
3839
</div>
39-
<div class="card p-6">
40+
<div class="p-6 w-full sm:w-1/3">
4041
<pre>{{ formValues }}</pre>
4142
</div>
4243
</div>
@@ -111,6 +112,7 @@ export default defineComponent({
111112
password: {
112113
label: 'Password',
113114
type: 'password',
115+
autocomplete: 'current-password',
114116
validations: [passwordValidator],
115117
} as PasswordInput,
116118
stock: {
@@ -241,6 +243,15 @@ export default defineComponent({
241243
});
242244
</script>
243245
<style lang="scss">
246+
.text-bg {
247+
background-image: linear-gradient(
248+
to top,
249+
#99ffd580 54%,
250+
transparent 54%,
251+
transparent 100%
252+
);
253+
width: fit-content;
254+
}
244255
.avocado-field {
245256
position: relative;
246257

src/components/dynamic-form/DynamicForm.vue

+8-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ export default defineComponent({
139139
140140
const formattedOptions = computed(() => {
141141
if (options?.form) {
142-
const { customClass, method, netlify, netlifyHoneypot } = options?.form;
142+
const {
143+
customClass,
144+
method,
145+
netlify,
146+
netlifyHoneypot,
147+
autocomplete,
148+
} = options?.form;
143149
return {
144150
class: [
145151
customClass,
@@ -148,6 +154,7 @@ export default defineComponent({
148154
method,
149155
'data-netlify': netlify,
150156
'data-netlify-honeypot': netlifyHoneypot,
157+
autocomplete: autocomplete ? 'on' : 'off',
151158
};
152159
} else {
153160
return;

src/components/number-input/NumberInput.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ export default defineComponent({
1818
id: props.control.name,
1919
name: props?.control?.name || '',
2020
type: props?.control?.type,
21-
disabled: props?.control?.disabled,
22-
placeholder: props?.control?.placeholder,
2321
class: ['form-control'],
24-
required: props.control.required,
25-
ariaRequired: props.control.required,
2622
value: props?.control?.value,
2723
min: props?.control?.min,
2824
max: props?.control?.max,
2925
step: props?.control?.step,
26+
disabled: props?.control?.disabled,
27+
placeholder: props?.control?.placeholder,
28+
required: props.control.required,
29+
autocomplete: props.control.autocomplete,
30+
ariaLabel: props.control.ariaLabel,
31+
ariaLabelledBy: props.control.ariaLabelledBy,
32+
ariaRequired: props.control.required,
3033
onFocus,
3134
onBlur,
3235
onChange,

src/components/text-area-input/TextAreaInput.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ export default defineComponent({
1616
h('textarea', {
1717
id: props.control.name,
1818
name: props?.control?.name || '',
19-
disabled: props?.control?.disabled,
20-
placeholder: props?.control?.placeholder,
21-
required: props.control.required,
22-
ariaRequired: props.control.required,
2319
class: ['form-control'],
2420
value: props?.control?.value,
2521
rows: props?.control?.rows,
2622
cols: props?.control?.cols,
23+
disabled: props?.control?.disabled,
24+
placeholder: props?.control?.placeholder,
25+
required: props.control.required,
26+
autocomplete: props.control.autocomplete,
27+
ariaLabel: props.control.ariaLabel,
28+
ariaLabelledBy: props.control.ariaLabelledBy,
29+
ariaRequired: props.control.required,
2730
onFocus,
2831
onBlur,
2932
onChange,

src/components/text-input/TextInput.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ export default defineComponent({
2727
id: props.control.name,
2828
name: props.control.name || '',
2929
type: props.control.type,
30+
class: ['form-control'],
31+
value: props?.control?.value,
3032
disabled: props.control.disabled,
3133
placeholder: props.control.placeholder,
3234
required: props.control.required,
35+
autocomplete: props.control.autocomplete,
3336
ariaRequired: props.control.required,
34-
class: ['form-control'],
35-
value: props?.control?.value,
37+
ariaLabel: props.control.ariaLabel,
38+
ariaLabelledBy: props.control.ariaLabelledBy,
3639
onFocus,
3740
onBlur,
3841
onChange,

src/core/models.ts

+4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ export interface FormValidation {
4242
export interface InputBase {
4343
name: string;
4444
label?: string;
45+
ariaLabel?: string;
46+
ariaLabelledBy?: string;
4547
required?: string;
4648
disabled?: boolean;
4749
customClass?: string;
4850
placeholder?: string;
51+
autocomplete?: string;
4952
validations?: FormValidation[];
5053
}
5154

@@ -124,4 +127,5 @@ export interface FormOptions {
124127
method?: string;
125128
netlify?: boolean;
126129
netlifyHoneypot?: string;
130+
autocomplete?: boolean;
127131
}

0 commit comments

Comments
 (0)