mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-14 17:23:26 +01:00
Remove JS input config
This commit is contained in:
parent
0908856b4f
commit
840778b64f
18 changed files with 108 additions and 173 deletions
|
@ -2,8 +2,6 @@ import React from 'react'
|
||||||
import Color from 'color'
|
import Color from 'color'
|
||||||
import ChromePicker from 'react-color/lib/components/chrome/Chrome'
|
import ChromePicker from 'react-color/lib/components/chrome/Chrome'
|
||||||
|
|
||||||
import input from '../../config/input.js'
|
|
||||||
|
|
||||||
function formatColor(color) {
|
function formatColor(color) {
|
||||||
const rgb = color.rgb
|
const rgb = color.rgb
|
||||||
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`
|
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import input from '../../config/input.js'
|
|
||||||
import colors from '../../config/colors.js'
|
|
||||||
import { margins, fontSizes } from '../../config/scales.js'
|
|
||||||
|
|
||||||
export default class DocLabel extends React.Component {
|
export default class DocLabel extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -10,45 +7,16 @@ export default class DocLabel extends React.Component {
|
||||||
React.PropTypes.string
|
React.PropTypes.string
|
||||||
]).isRequired,
|
]).isRequired,
|
||||||
doc: React.PropTypes.string.isRequired,
|
doc: React.PropTypes.string.isRequired,
|
||||||
style: React.PropTypes.object,
|
|
||||||
cursorTargetStyle: React.PropTypes.object,
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props)
|
|
||||||
this.state = { showDoc: false }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <label
|
return <label className="maputnik-doc-wrapper">
|
||||||
style={{
|
<div className="maputnik-doc-target">
|
||||||
...this.props.style
|
<span>{this.props.label}</span>
|
||||||
}}
|
<div className="maputnik-doc-popup">
|
||||||
className="maputnik-doc-wrapper"
|
{this.props.doc}
|
||||||
>
|
</div>
|
||||||
<span
|
</div >
|
||||||
onMouseOver={e => this.setState({showDoc: true})}
|
|
||||||
onMouseOut={e => this.setState({showDoc: false})}
|
|
||||||
className="maputnik-doc-target"
|
|
||||||
style={this.props.cursorTargetStyle}
|
|
||||||
>
|
|
||||||
{this.props.label}
|
|
||||||
</span>
|
|
||||||
<div style={{
|
|
||||||
backgroundColor: colors.gray,
|
|
||||||
padding: margins[1],
|
|
||||||
fontSize: 10,
|
|
||||||
position: 'absolute',
|
|
||||||
top: 20,
|
|
||||||
left: 0,
|
|
||||||
width: 120,
|
|
||||||
display: this.state.showDoc ? null : 'none',
|
|
||||||
zIndex: 3,
|
|
||||||
}}
|
|
||||||
className="maputnik-doc-popup"
|
|
||||||
>
|
|
||||||
{this.props.doc}
|
|
||||||
</div>
|
|
||||||
</label>
|
</label>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@ import capitalize from 'lodash.capitalize'
|
||||||
|
|
||||||
const iconProperties = ['background-pattern', 'fill-pattern', 'line-pattern', 'fill-extrusion-pattern', 'icon-image']
|
const iconProperties = ['background-pattern', 'fill-pattern', 'line-pattern', 'fill-extrusion-pattern', 'icon-image']
|
||||||
|
|
||||||
import input from '../../config/input.js'
|
|
||||||
|
|
||||||
function labelFromFieldName(fieldName) {
|
function labelFromFieldName(fieldName) {
|
||||||
let label = fieldName.split('-').slice(1).join(' ')
|
let label = fieldName.split('-').slice(1).join(' ')
|
||||||
if(label.length > 0) {
|
if(label.length > 0) {
|
||||||
|
|
|
@ -12,8 +12,6 @@ import DeleteIcon from 'react-icons/lib/md/delete'
|
||||||
import FunctionIcon from 'react-icons/lib/md/functions'
|
import FunctionIcon from 'react-icons/lib/md/functions'
|
||||||
|
|
||||||
import capitalize from 'lodash.capitalize'
|
import capitalize from 'lodash.capitalize'
|
||||||
import input from '../../config/input.js'
|
|
||||||
import colors from '../../config/colors.js'
|
|
||||||
|
|
||||||
function isZoomField(value) {
|
function isZoomField(value) {
|
||||||
return typeof value === 'object' && value.stops
|
return typeof value === 'object' && value.stops
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import input from '../../config/input.js'
|
|
||||||
import StringInput from './StringInput'
|
import StringInput from './StringInput'
|
||||||
import NumberInput from './NumberInput'
|
import NumberInput from './NumberInput'
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
import Autocomplete from 'react-autocomplete'
|
import Autocomplete from 'react-autocomplete'
|
||||||
import input from '../../config/input'
|
|
||||||
import colors from '../../config/colors'
|
|
||||||
import { margins, fontSizes } from '../../config/scales'
|
|
||||||
|
|
||||||
class AutocompleteInput extends React.Component {
|
class AutocompleteInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -17,20 +16,15 @@ class AutocompleteInput extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
|
const AutocompleteMenu = (items, value, style) => <div className={"maputnik-autocomplete-menu"} children={props.items} />
|
||||||
|
|
||||||
return <Autocomplete
|
return <Autocomplete
|
||||||
wrapperProps={{
|
wrapperProps={{
|
||||||
className: "maputnik-autocomplete",
|
className: "maputnik-autocomplete",
|
||||||
style: null
|
style: null
|
||||||
}}
|
}}
|
||||||
menuStyle={{
|
renderMenu={AutocompleteMenu}
|
||||||
border: 'none',
|
|
||||||
padding: '2px 0',
|
|
||||||
position: 'fixed',
|
|
||||||
overflow: 'auto',
|
|
||||||
maxHeight: '50%',
|
|
||||||
background: colors.gray,
|
|
||||||
zIndex: 3,
|
|
||||||
}}
|
|
||||||
inputProps={{
|
inputProps={{
|
||||||
className: "maputnik-string"
|
className: "maputnik-string"
|
||||||
}}
|
}}
|
||||||
|
@ -42,15 +36,10 @@ class AutocompleteInput extends React.Component {
|
||||||
renderItem={(item, isHighlighted) => (
|
renderItem={(item, isHighlighted) => (
|
||||||
<div
|
<div
|
||||||
key={item[0]}
|
key={item[0]}
|
||||||
style={{
|
className={classnames({
|
||||||
userSelect: 'none',
|
"maputnik-autocomplete-menu-item": true,
|
||||||
color: colors.lowgray,
|
"maputnik-autocomplete-menu-item-selected": isHighlighted,
|
||||||
cursor: 'default',
|
})}
|
||||||
background: isHighlighted ? colors.midgray : colors.gray,
|
|
||||||
padding: margins[0],
|
|
||||||
fontSize: fontSizes[5],
|
|
||||||
zIndex: 3,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{item[1]}
|
{item[1]}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import input from '../../config/input.js'
|
|
||||||
|
|
||||||
class CheckboxInput extends React.Component {
|
class CheckboxInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import AutocompleteInput from './AutocompleteInput'
|
import AutocompleteInput from './AutocompleteInput'
|
||||||
import input from '../../config/input.js'
|
|
||||||
import { margins } from '../../config/scales.js'
|
|
||||||
|
|
||||||
//TODO: Query available font stack dynamically
|
//TODO: Query available font stack dynamically
|
||||||
import fontStacks from '../../config/fontstacks.json'
|
import fontStacks from '../../config/fontstacks.json'
|
||||||
|
@ -35,17 +33,10 @@ class FontInput extends React.Component {
|
||||||
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)}
|
||||||
wrapperStyle={{
|
|
||||||
display: 'block',
|
|
||||||
marginBottom: i == this.values.length - 1 ? 0 : margins[2],
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
})
|
})
|
||||||
|
|
||||||
return <div style={{
|
return <div className="maputnik-font">
|
||||||
display: 'inline-block',
|
|
||||||
...this.props.style
|
|
||||||
}}>
|
|
||||||
{inputs}
|
{inputs}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import AutocompleteInput from './AutocompleteInput'
|
import AutocompleteInput from './AutocompleteInput'
|
||||||
import input from '../../config/input.js'
|
|
||||||
import { margins } from '../../config/scales.js'
|
|
||||||
|
|
||||||
|
|
||||||
class IconInput extends React.Component {
|
class IconInput extends React.Component {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import input from '../../config/input'
|
|
||||||
import DocLabel from '../fields/DocLabel'
|
import DocLabel from '../fields/DocLabel'
|
||||||
|
|
||||||
/** Wrap a component with a label */
|
/** Wrap a component with a label */
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import classnames from 'classnames'
|
||||||
import Button from '../Button'
|
import Button from '../Button'
|
||||||
|
|
||||||
import colors from '../../config/colors'
|
|
||||||
import { margins } from '../../config/scales'
|
|
||||||
import input from '../../config/input.js'
|
|
||||||
|
|
||||||
class MultiButtonInput extends React.Component {
|
class MultiButtonInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
value: React.PropTypes.string.isRequired,
|
value: React.PropTypes.string.isRequired,
|
||||||
options: React.PropTypes.array.isRequired,
|
options: React.PropTypes.array.isRequired,
|
||||||
style: React.PropTypes.object,
|
|
||||||
onChange: React.PropTypes.func.isRequired,
|
onChange: React.PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,21 +20,13 @@ class MultiButtonInput extends React.Component {
|
||||||
return <Button
|
return <Button
|
||||||
key={val}
|
key={val}
|
||||||
onClick={e => this.props.onChange(val)}
|
onClick={e => this.props.onChange(val)}
|
||||||
style={{
|
className={classnames({"maputnik-button-selected": val === selectedValue})}
|
||||||
marginRight: margins[0],
|
|
||||||
backgroundColor: val === selectedValue ? colors.midgray : colors.gray,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</Button>
|
</Button>
|
||||||
})
|
})
|
||||||
|
|
||||||
return <div style={{
|
return <div className="maputnik-multibutton">
|
||||||
display: 'inline-block',
|
|
||||||
...this.props.style,
|
|
||||||
}}
|
|
||||||
className="maputnik-multibutton"
|
|
||||||
>
|
|
||||||
{buttons}
|
{buttons}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import input from '../../config/input.js'
|
|
||||||
|
|
||||||
class NumberInput extends React.Component {
|
class NumberInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import input from '../../config/input.js'
|
|
||||||
|
|
||||||
class SelectInput extends React.Component {
|
class SelectInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import input from '../../config/input.js'
|
|
||||||
|
|
||||||
class StringInput extends React.Component {
|
class StringInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
import colors from './colors'
|
|
||||||
import { margins, fontSizes } from './scales'
|
|
||||||
|
|
||||||
const base = {
|
|
||||||
display: 'inline-block',
|
|
||||||
boxSizing: 'border-box',
|
|
||||||
fontSize: fontSizes[5],
|
|
||||||
lineHeight: 2,
|
|
||||||
paddingLeft: 5,
|
|
||||||
paddingRight: 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
const label = {
|
|
||||||
...base,
|
|
||||||
padding: null,
|
|
||||||
color: colors.lowgray,
|
|
||||||
userSelect: 'none',
|
|
||||||
}
|
|
||||||
|
|
||||||
const property = {
|
|
||||||
display: 'block',
|
|
||||||
margin: margins[2],
|
|
||||||
}
|
|
||||||
|
|
||||||
const input = {
|
|
||||||
...base,
|
|
||||||
border: 'none',
|
|
||||||
backgroundColor: colors.gray,
|
|
||||||
color: colors.lowgray,
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkbox = {
|
|
||||||
...base,
|
|
||||||
border: '1px solid rgb(36, 36, 36)',
|
|
||||||
backgroundColor: colors.gray,
|
|
||||||
color: colors.lowgray,
|
|
||||||
}
|
|
||||||
|
|
||||||
const select = {
|
|
||||||
...input,
|
|
||||||
height: '2.15em',
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
base,
|
|
||||||
label,
|
|
||||||
select,
|
|
||||||
input,
|
|
||||||
property,
|
|
||||||
checkbox,
|
|
||||||
}
|
|
|
@ -1,13 +1,4 @@
|
||||||
|
// MAP
|
||||||
.maputnik-icon-text {
|
|
||||||
padding-left: $margin-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.maputnik-icon-action {
|
|
||||||
display: inline;
|
|
||||||
margin-left: $margin-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.maputnik-map {
|
.maputnik-map {
|
||||||
position: fixed !important;
|
position: fixed !important;
|
||||||
top: 40px;
|
top: 40px;
|
||||||
|
@ -17,21 +8,43 @@
|
||||||
width: 75%;
|
width: 75%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.maputnik-doc-target {
|
// DOC LABEL
|
||||||
cursor: help;
|
.maputnik-doc {
|
||||||
|
&-target {
|
||||||
|
cursor: help;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-wrapper{
|
||||||
|
display: inline-block;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: $font-size-6;
|
||||||
|
line-height: 2;
|
||||||
|
color: $color-lowgray;
|
||||||
|
user-select: none;
|
||||||
|
position: relative;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-popup {
|
||||||
|
display: none;
|
||||||
|
color: $color-lowgray;
|
||||||
|
background-color: $color-gray;
|
||||||
|
padding: $margin-2;
|
||||||
|
font-size: 10px;
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
left: 0px;
|
||||||
|
width: 120px;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.maputnik-doc-wrapper {
|
.maputnik-doc-target:hover .maputnik-doc-popup {
|
||||||
display: inline-block;
|
display: block;
|
||||||
box-sizing: border-box;
|
|
||||||
font-size: $font-size-6;
|
|
||||||
line-height: 2;
|
|
||||||
color: $color-lowgray;
|
|
||||||
user-select: none;
|
|
||||||
position: relative;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BUTTON
|
||||||
|
|
||||||
.maputnik-button {
|
.maputnik-button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: $color-midgray;
|
background-color: $color-midgray;
|
||||||
|
@ -59,12 +72,16 @@
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
label, svg {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
svg {
|
svg {
|
||||||
fill: $color-white;
|
fill: $color-white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INPUT BLOCK
|
||||||
.maputnik-input-block {
|
.maputnik-input-block {
|
||||||
margin: $margin-3;
|
margin: $margin-3;
|
||||||
|
|
||||||
|
@ -82,7 +99,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.maputnik-action-block {
|
.maputnik-action-block {
|
||||||
.maputnik-input-block-label {
|
.maputnik-input-block-label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -95,6 +111,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SPACE HELPER
|
||||||
.maputnik-space {
|
.maputnik-space {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,16 @@
|
||||||
height: 24px;
|
height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MULTIBUTTON
|
||||||
|
.maputnik-multibutton {
|
||||||
|
@extend .maputnik-input;
|
||||||
|
margin-right: $margin-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maputnik-button-selected {
|
||||||
|
background-color: $color-midgray;
|
||||||
|
}
|
||||||
|
|
||||||
// CHECKBOX
|
// CHECKBOX
|
||||||
.maputnik-checkbox {
|
.maputnik-checkbox {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -94,5 +104,34 @@
|
||||||
|
|
||||||
// AUTOCOMPLETE
|
// AUTOCOMPLETE
|
||||||
.maputnik-autocomplete {
|
.maputnik-autocomplete {
|
||||||
|
&-menu {
|
||||||
|
border: none;
|
||||||
|
padding: 2px 0;
|
||||||
|
position: fixed;
|
||||||
|
overflow: auto;
|
||||||
|
max-height: 50%;
|
||||||
|
background: $color-gray;
|
||||||
|
z-index: 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
&-menu-item {
|
||||||
|
user-select: none;
|
||||||
|
color: $color-lowgray;
|
||||||
|
cursor: default;
|
||||||
|
padding: $margin-1;
|
||||||
|
font-size: $font-size-6;
|
||||||
|
z-index: 3;
|
||||||
|
background: $color-gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-menu-item-selected {
|
||||||
|
background: $color-midgray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FONT
|
||||||
|
.maputnik-font {
|
||||||
|
.maputnik-autocomplete:not(:last-child) {
|
||||||
|
margin-bottom: $margin-3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -45,3 +45,12 @@
|
||||||
.maputnik-toolbar-action {
|
.maputnik-toolbar-action {
|
||||||
@extend .maputnik-toolbar-link;
|
@extend .maputnik-toolbar-link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maputnik-icon-text {
|
||||||
|
padding-left: $margin-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maputnik-icon-action {
|
||||||
|
display: inline;
|
||||||
|
margin-left: $margin-1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue