Color relief support and hillshading improvements. (#1371)

## Launch Checklist

This adds support for `relief-color` property so that it will create an
elevation expression when the button is pressed.
It also adds support for `colorArray` and `numberArray` types so that
the user would be able to add the relevant information.

Before:
<img width="403" height="324" alt="image"
src="https://github.com/user-attachments/assets/250abd81-6176-4711-a1ee-d33d443932d7"
/>

<img width="403" height="324" alt="image"
src="https://github.com/user-attachments/assets/6a1bb268-66db-42a1-97fc-33e5a40863b6"
/>


After:
<img width="403" height="324" alt="image"
src="https://github.com/user-attachments/assets/8ebaa1ea-4ef9-4aed-abcd-3c8b0057ea76"
/>

<img width="403" height="324" alt="image"
src="https://github.com/user-attachments/assets/e0728c92-85f9-4b86-8635-8877cf257b2f"
/>


 - [x] Briefly describe the changes in this PR.
- [x] Include before/after visuals or gifs if this PR includes visual
changes.
 - [x] Write tests for all new functionality.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Harel M
2025-09-11 20:43:20 +03:00
committed by GitHub
parent d81316435b
commit 42e1273241
20 changed files with 258 additions and 53 deletions
+33 -25
View File
@@ -1,37 +1,45 @@
import Block from './Block'
import InputSpec, { InputSpecProps } from './InputSpec'
import InputSpec, { FieldSpecType, InputSpecProps } from './InputSpec'
import Fieldset from './Fieldset'
const typeMap = {
color: () => Block,
enum: ({fieldSpec}: any) => (Object.keys(fieldSpec.values).length <= 3 ? Fieldset : Block),
boolean: () => Block,
array: () => Fieldset,
resolvedImage: () => Block,
number: () => Block,
string: () => Block,
formatted: () => Block,
padding: () => Block,
};
function getElementFromType(fieldSpec: { type?: FieldSpecType, values?: unknown[] }): typeof Fieldset | typeof Block {
switch(fieldSpec.type) {
case 'color':
return Block;
case 'enum':
return (Object.keys(fieldSpec.values!).length <= 3 ? Fieldset : Block)
case 'boolean':
return Block;
case 'array':
return Fieldset;
case 'resolvedImage':
return Block;
case 'number':
return Block;
case 'string':
return Block;
case 'formatted':
return Block;
case 'padding':
return Block;
case 'numberArray':
return Fieldset;
case 'colorArray':
return Fieldset;
case 'variableAnchorOffsetCollection':
return Fieldset;
default:
console.warn("No such type for: " + fieldSpec.type);
return Block;
}
}
export type FieldSpecProps = InputSpecProps & {
name?: string
};
const FieldSpec: React.FC<FieldSpecProps> = (props) => {
const fieldType = props.fieldSpec?.type;
const typeBlockFn = typeMap[fieldType!];
let TypeBlock;
if (typeBlockFn) {
TypeBlock = typeBlockFn(props);
}
else {
console.warn("No such type for '%s'", fieldType);
TypeBlock = Block;
}
const TypeBlock = getElementFromType(props.fieldSpec!);
return (
<TypeBlock label={props.label} action={props.action} fieldSpec={props.fieldSpec}>