Simplification of <Infos>

This commit is contained in:
Eric van der Vlist 2023-02-03 18:07:18 +01:00
parent 3daa2d11f9
commit 8e519dd862
1 changed files with 33 additions and 38 deletions

View File

@ -1,7 +1,7 @@
import { Button, IconButton } from '@suid/material'; import { Button, IconButton } from '@suid/material';
import { Feature } from 'ol'; import { Feature } from 'ol';
import { Geometry } from 'ol/geom'; import { Geometry } from 'ol/geom';
import { Component, createSignal, For, Show } from 'solid-js'; import { Component, createSignal, For, Match, Show, Switch } from 'solid-js';
import { useI18n } from '@solid-primitives/i18n'; import { useI18n } from '@solid-primitives/i18n';
import TravelExploreIcon from '@suid/icons-material/TravelExplore'; import TravelExploreIcon from '@suid/icons-material/TravelExplore';
import AddLocationAltIcon from '@suid/icons-material/AddLocationAlt'; import AddLocationAltIcon from '@suid/icons-material/AddLocationAlt';
@ -192,9 +192,7 @@ const Infos: Component<{}> = (props) => {
<Tree <Tree
title={ title={
<> <>
<div> <div>{feature.get('name') || ''}</div>
${feature.get('name') || ''}`}
</div>
<div> <div>
<IconButton> <IconButton>
<AddLocationAltIcon /> <AddLocationAltIcon />
@ -229,28 +227,12 @@ const Infos: Component<{}> = (props) => {
<For each={Object.keys(feature.getProperties())}> <For each={Object.keys(feature.getProperties())}>
{(key: string) => ( {(key: string) => (
<div> <div>
<Show <Switch
when={key === 'website'}
fallback={
<Show
when={key === 'phone'}
fallback={`${key}: ${ fallback={`${key}: ${
feature.getProperties()[key] feature.getProperties()[key]
}`} }`}
> >
<Button <Match when={key === 'website'}>
size='small'
startIcon={<CallIcon />}
href={
'tel:' +
feature.getProperties()[key]
}
>
{feature.getProperties()[key]}
</Button>
</Show>
}
>
<Button <Button
size='small' size='small'
startIcon={<OpenInNewIcon />} startIcon={<OpenInNewIcon />}
@ -262,7 +244,20 @@ const Infos: Component<{}> = (props) => {
> >
{feature.getProperties()[key]} {feature.getProperties()[key]}
</Button> </Button>
</Show> </Match>
<Match when={key === 'phone'}>
<Button
size='small'
startIcon={<CallIcon />}
href={
'tel:' +
feature.getProperties()[key]
}
>
{feature.getProperties()[key]}
</Button>
</Match>
</Switch>
</div> </div>
)} )}
</For> </For>