mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-29 07:30:32 +01:00
Also show MultiButton for 3 options
This commit is contained in:
parent
1f1a919c77
commit
007bdad70a
1 changed files with 10 additions and 1 deletions
|
@ -21,6 +21,14 @@ function labelFromFieldName(fieldName) {
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function optionsLabelLength(options) {
|
||||||
|
let sum = 0;
|
||||||
|
options.forEach(([_, label]) => {
|
||||||
|
sum += label.length
|
||||||
|
})
|
||||||
|
return sum
|
||||||
|
}
|
||||||
|
|
||||||
/** Display any field from the Mapbox GL style spec and
|
/** Display any field from the Mapbox GL style spec and
|
||||||
* choose the correct field component based on the @{fieldSpec}
|
* choose the correct field component based on the @{fieldSpec}
|
||||||
* to display @{value}. */
|
* to display @{value}. */
|
||||||
|
@ -56,7 +64,8 @@ export default class SpecField extends React.Component {
|
||||||
)
|
)
|
||||||
case 'enum':
|
case '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)])
|
||||||
if(options.length < 3) {
|
|
||||||
|
if(options.length <= 3 && optionsLabelLength(options) <= 20) {
|
||||||
return <MultiButtonInput
|
return <MultiButtonInput
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
options={options}
|
options={options}
|
||||||
|
|
Loading…
Reference in a new issue