Added aria-label to things that are otherwise labelled in the UI.

This commit is contained in:
orangemug 2020-06-10 18:16:43 +01:00
parent 6c751fe1c4
commit bfada7cace
8 changed files with 33 additions and 18 deletions

View file

@ -89,7 +89,7 @@ export default class FieldArray extends React.Component {
value={value[i]} value={value[i]}
required={containsValues ? true : false} required={containsValues ? true : false}
onChange={this.changeValue.bind(this, i)} onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label']} aria-label={this.props['aria-label'] || this.props.label}
/> />
} else { } else {
return <InputString return <InputString
@ -98,7 +98,7 @@ export default class FieldArray extends React.Component {
value={value[i]} value={value[i]}
required={containsValues ? true : false} required={containsValues ? true : false}
onChange={this.changeValue.bind(this, i)} onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label']} aria-label={this.props['aria-label'] || this.props.label}
/> />
} }
}) })

View file

@ -56,7 +56,6 @@ export default class InputAutocomplete extends React.Component {
}} }}
> >
<Autocomplete <Autocomplete
aria-label={this.props['aria-label']}
menuStyle={{ menuStyle={{
position: "fixed", position: "fixed",
overflow: "auto", overflow: "auto",
@ -68,6 +67,7 @@ export default class InputAutocomplete extends React.Component {
style: null style: null
}} }}
inputProps={{ inputProps={{
'aria-label': this.props['aria-label'],
className: "maputnik-string", className: "maputnik-string",
spellCheck: false spellCheck: false
}} }}

View file

@ -65,27 +65,30 @@ export default class FieldDynamicArray extends React.Component {
input = <InputUrl input = <InputUrl
value={v} value={v}
onChange={this.changeValue.bind(this, i)} onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/> />
} }
else if (this.props.type === 'number') { else if (this.props.type === 'number') {
input = <InputNumber input = <InputNumber
value={v} value={v}
onChange={this.changeValue.bind(this, i)} onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/> />
} }
else if (this.props.type === 'enum') { else if (this.props.type === 'enum') {
const options = Object.keys(this.props.fieldSpec.values).map(v => [v, capitalize(v)]); const options = Object.keys(this.props.fieldSpec.values).map(v => [v, capitalize(v)]);
input = <InputEnum input = <InputEnum
options={options} options={options}
value={v} value={v}
onChange={this.changeValue.bind(this, i)} onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/> />
} }
else { else {
input = <InputString input = <InputString
value={v} value={v}
onChange={this.changeValue.bind(this, i)} onChange={this.changeValue.bind(this, i)}
aria-label={this.props['aria-label'] || this.props.label}
/> />
} }

View file

@ -26,7 +26,8 @@ export default class InputEnum extends React.Component {
} }
render() { render() {
const {options, value, onChange, name} = this.props; const {options, value, onChange, name, label} = this.props;
console.log("this.props", this.props)
if(options.length <= 3 && optionsLabelLength(options) <= 20) { if(options.length <= 3 && optionsLabelLength(options) <= 20) {
return <InputMultiInput return <InputMultiInput
@ -34,14 +35,14 @@ export default class InputEnum extends React.Component {
options={options} options={options}
value={value || this.props.default} value={value || this.props.default}
onChange={onChange} onChange={onChange}
aria-label={this.props['aria-label']} aria-label={this.props['aria-label'] || label}
/> />
} else { } else {
return <InputSelect return <InputSelect
options={options} options={options}
value={value || this.props.default} value={value || this.props.default}
onChange={onChange} onChange={onChange}
aria-label={this.props['aria-label']} aria-label={this.props['aria-label'] || label}
/> />
} }
} }

View file

@ -44,7 +44,7 @@ export default class FieldFont extends React.Component {
key={i} key={i}
> >
<InputAutocomplete <InputAutocomplete
aria-label={this.props['aria-label']} aria-label={this.props['aria-label'] || this.props.name}
value={value} value={value}
options={this.props.fonts.map(f => [f, f])} options={this.props.fonts.map(f => [f, f])}
onChange={this.changeFont.bind(this, i)} onChange={this.changeFont.bind(this, i)}

View file

@ -65,6 +65,7 @@ export default class SingleFilterEditor extends React.Component {
return <div className="maputnik-filter-editor-single"> return <div className="maputnik-filter-editor-single">
<div className="maputnik-filter-editor-property"> <div className="maputnik-filter-editor-property">
<InputAutocomplete <InputAutocomplete
aria-label="key"
value={propertyName} value={propertyName}
options={Object.keys(this.props.properties).map(propName => [propName, propName])} options={Object.keys(this.props.properties).map(propName => [propName, propName])}
onChange={newPropertyName => this.onFilterPartChanged(filterOp, newPropertyName, filterArgs)} onChange={newPropertyName => this.onFilterPartChanged(filterOp, newPropertyName, filterArgs)}
@ -72,6 +73,7 @@ export default class SingleFilterEditor extends React.Component {
</div> </div>
<div className="maputnik-filter-editor-operator"> <div className="maputnik-filter-editor-operator">
<InputSelect <InputSelect
aria-label="function"
value={filterOp} value={filterOp}
onChange={newFilterOp => this.onFilterPartChanged(newFilterOp, propertyName, filterArgs)} onChange={newFilterOp => this.onFilterPartChanged(newFilterOp, propertyName, filterArgs)}
options={otherFilterOps} options={otherFilterOps}
@ -80,6 +82,7 @@ export default class SingleFilterEditor extends React.Component {
{filterArgs.length > 0 && {filterArgs.length > 0 &&
<div className="maputnik-filter-editor-args"> <div className="maputnik-filter-editor-args">
<InputString <InputString
aria-label="value"
value={filterArgs.join(',')} value={filterArgs.join(',')}
onChange={ v=> this.onFilterPartChanged(filterOp, propertyName, v.split(','))} onChange={ v=> this.onFilterPartChanged(filterOp, propertyName, v.split(','))}
/> />

View file

@ -6,14 +6,15 @@ import Fieldset from './Fieldset'
const typeMap = { const typeMap = {
color: Block, color: () => Block,
enum: Fieldset, enum: ({fieldSpec}) => (Object.keys(fieldSpec.values).length <= 3 ? Fieldset : Block),
number: Block, number: () => Block,
boolean: Block, boolean: () => Block,
array: Fieldset, array: () => Fieldset,
resolvedImage: Block, resolvedImage: () => Block,
number: Block, number: () => Block,
string: Block string: () => Block,
formatted: () => Block,
}; };
export default class SpecField extends React.Component { export default class SpecField extends React.Component {
@ -26,9 +27,14 @@ export default class SpecField extends React.Component {
const {props} = this; const {props} = this;
const fieldType = props.fieldSpec.type; const fieldType = props.fieldSpec.type;
let TypeBlock = typeMap[fieldType];
if (!TypeBlock) { const typeBlockFn = typeMap[fieldType];
let TypeBlock;
if (typeBlockFn) {
TypeBlock = typeBlockFn(props);
}
else {
console.warn("No such type for '%s'", fieldType); console.warn("No such type for '%s'", fieldType);
TypeBlock = Block; TypeBlock = Block;
} }

View file

@ -150,6 +150,7 @@ export default class ZoomProperty extends React.Component {
> >
<td> <td>
<InputNumber <InputNumber
aria-label="Zoom"
value={zoomLevel} value={zoomLevel}
onChange={changedStop => this.changeZoomStop(idx, changedStop, value)} onChange={changedStop => this.changeZoomStop(idx, changedStop, value)}
min={0} min={0}
@ -158,6 +159,7 @@ export default class ZoomProperty extends React.Component {
</td> </td>
<td> <td>
<InputSpec <InputSpec
aria-label="Output value"
fieldName={this.props.fieldName} fieldName={this.props.fieldName}
fieldSpec={this.props.fieldSpec} fieldSpec={this.props.fieldSpec}
value={value} value={value}