Simplification of <Infos>
This commit is contained in:
parent
3daa2d11f9
commit
8e519dd862
|
@ -1,7 +1,7 @@
|
|||
import { Button, IconButton } from '@suid/material';
|
||||
import { Feature } from 'ol';
|
||||
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 TravelExploreIcon from '@suid/icons-material/TravelExplore';
|
||||
import AddLocationAltIcon from '@suid/icons-material/AddLocationAlt';
|
||||
|
@ -192,9 +192,7 @@ const Infos: Component<{}> = (props) => {
|
|||
<Tree
|
||||
title={
|
||||
<>
|
||||
<div>
|
||||
${feature.get('name') || ''}`}
|
||||
</div>
|
||||
<div>{feature.get('name') || ''}</div>
|
||||
<div>
|
||||
<IconButton>
|
||||
<AddLocationAltIcon />
|
||||
|
@ -229,28 +227,12 @@ const Infos: Component<{}> = (props) => {
|
|||
<For each={Object.keys(feature.getProperties())}>
|
||||
{(key: string) => (
|
||||
<div>
|
||||
<Show
|
||||
when={key === 'website'}
|
||||
fallback={
|
||||
<Show
|
||||
when={key === 'phone'}
|
||||
<Switch
|
||||
fallback={`${key}: ${
|
||||
feature.getProperties()[key]
|
||||
}`}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
startIcon={<CallIcon />}
|
||||
href={
|
||||
'tel:' +
|
||||
feature.getProperties()[key]
|
||||
}
|
||||
>
|
||||
{feature.getProperties()[key]}
|
||||
</Button>
|
||||
</Show>
|
||||
}
|
||||
>
|
||||
<Match when={key === 'website'}>
|
||||
<Button
|
||||
size='small'
|
||||
startIcon={<OpenInNewIcon />}
|
||||
|
@ -262,7 +244,20 @@ const Infos: Component<{}> = (props) => {
|
|||
>
|
||||
{feature.getProperties()[key]}
|
||||
</Button>
|
||||
</Show>
|
||||
</Match>
|
||||
<Match when={key === 'phone'}>
|
||||
<Button
|
||||
size='small'
|
||||
startIcon={<CallIcon />}
|
||||
href={
|
||||
'tel:' +
|
||||
feature.getProperties()[key]
|
||||
}
|
||||
>
|
||||
{feature.getProperties()[key]}
|
||||
</Button>
|
||||
</Match>
|
||||
</Switch>
|
||||
</div>
|
||||
)}
|
||||
</For>
|
||||
|
|
Loading…
Reference in New Issue