mirror of
https://github.com/maputnik/editor.git
synced 2025-12-24 15:10:01 +00:00
## Launch Checklist This removes the `@mdi` (material design icons) package and uses the icons from `react-icons`. The icons are not exactly the same, but have the same idea behind them. - [x] Briefly describe the changes in this PR. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Add an entry to `CHANGELOG.md` under the `## main` section. Main changes can be found below. Before: <img width="580" height="780" alt="image" src="https://github.com/user-attachments/assets/e3d5fc8a-bd59-48fe-bdae-31bb290749c8" /> After: <img width="580" height="780" alt="image" src="https://github.com/user-attachments/assets/bacdbdba-9e73-4bef-bd30-26fe946269c1" /> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import React from "react";
|
|
|
|
import InputButton from "./InputButton";
|
|
import {MdFunctions, MdInsertChart} from "react-icons/md";
|
|
import { TbMathFunction } from "react-icons/tb";
|
|
import { type WithTranslation, withTranslation } from "react-i18next";
|
|
|
|
type FunctionInputButtonsInternalProps = {
|
|
fieldSpec?: any
|
|
onZoomClick?(): void
|
|
onDataClick?(): void
|
|
onExpressionClick?(): void
|
|
onElevationClick?(): void
|
|
} & WithTranslation;
|
|
|
|
class FunctionInputButtonsInternal extends React.Component<FunctionInputButtonsInternalProps> {
|
|
render() {
|
|
const t = this.props.t;
|
|
|
|
if (this.props.fieldSpec.expression?.parameters.includes("zoom")) {
|
|
const expressionInputButton = (
|
|
<InputButton
|
|
className="maputnik-make-zoom-function"
|
|
onClick={this.props.onExpressionClick}
|
|
title={t("Convert to expression")}
|
|
>
|
|
<TbMathFunction />
|
|
</InputButton>
|
|
);
|
|
|
|
const makeZoomInputButton = <InputButton
|
|
className="maputnik-make-zoom-function"
|
|
onClick={this.props.onZoomClick}
|
|
title={t("Convert property into a zoom function")}
|
|
>
|
|
<MdFunctions />
|
|
</InputButton>;
|
|
|
|
let makeDataInputButton;
|
|
if (this.props.fieldSpec["property-type"] === "data-driven") {
|
|
makeDataInputButton = <InputButton
|
|
className="maputnik-make-data-function"
|
|
onClick={this.props.onDataClick}
|
|
title={t("Convert property to data function")}
|
|
>
|
|
<MdInsertChart />
|
|
</InputButton>;
|
|
}
|
|
return <div>
|
|
{expressionInputButton}
|
|
{makeDataInputButton}
|
|
{makeZoomInputButton}
|
|
</div>;
|
|
} else if (this.props.fieldSpec.expression?.parameters.includes("elevation")) {
|
|
const inputElevationButton = <InputButton
|
|
className="maputnik-make-elevation-function"
|
|
onClick={this.props.onElevationClick}
|
|
title={t("Convert property into a elevation function")}
|
|
data-wd-key='make-elevation-function'
|
|
>
|
|
<MdFunctions />
|
|
</InputButton>;
|
|
return <div>{inputElevationButton}</div>;
|
|
} else {
|
|
return <div></div>;
|
|
}
|
|
}
|
|
}
|
|
|
|
const FunctionInputButtons = withTranslation()(FunctionInputButtonsInternal);
|
|
export default FunctionInputButtons;
|