mirror of
https://github.com/maputnik/editor.git
synced 2026-09-02 02:17:26 +00:00
974dd7bfd9
This is to continue the work of migrating all the jsx files into tsx files. The MO is basically described here: #848. About 7 files to go...
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import React from 'react'
|
|
|
|
import InputButton from './InputButton'
|
|
import {MdFunctions, MdInsertChart} from 'react-icons/md'
|
|
import {mdiFunctionVariant} from '@mdi/js';
|
|
|
|
type FunctionInputButtonsProps = {
|
|
fieldSpec?: any
|
|
onZoomClick?(...args: unknown[]): unknown
|
|
onDataClick?(...args: unknown[]): unknown
|
|
onExpressionClick?(...args: unknown[]): unknown
|
|
};
|
|
|
|
export default class FunctionInputButtons extends React.Component<FunctionInputButtonsProps> {
|
|
render() {
|
|
let makeZoomInputButton, makeDataInputButton, expressionInputButton;
|
|
|
|
if (this.props.fieldSpec.expression.parameters.includes('zoom')) {
|
|
expressionInputButton = (
|
|
<InputButton
|
|
className="maputnik-make-zoom-function"
|
|
onClick={this.props.onExpressionClick}
|
|
title="Convert to expression"
|
|
>
|
|
<svg style={{width:"14px", height:"14px", verticalAlign: "middle"}} viewBox="0 0 24 24">
|
|
<path fill="currentColor" d={mdiFunctionVariant} />
|
|
</svg>
|
|
</InputButton>
|
|
);
|
|
|
|
makeZoomInputButton = <InputButton
|
|
className="maputnik-make-zoom-function"
|
|
onClick={this.props.onZoomClick}
|
|
title="Convert property into a zoom function"
|
|
>
|
|
<MdFunctions />
|
|
</InputButton>
|
|
|
|
if (this.props.fieldSpec['property-type'] === 'data-driven') {
|
|
makeDataInputButton = <InputButton
|
|
className="maputnik-make-data-function"
|
|
onClick={this.props.onDataClick}
|
|
title="Convert property to data function"
|
|
>
|
|
<MdInsertChart />
|
|
</InputButton>
|
|
}
|
|
return <div>
|
|
{expressionInputButton}
|
|
{makeDataInputButton}
|
|
{makeZoomInputButton}
|
|
</div>
|
|
}
|
|
else {
|
|
return <div>{expressionInputButton}</div>
|
|
}
|
|
}
|
|
}
|