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 />
|
||||
|
@ -203,7 +201,7 @@ const Infos: Component<{}> = (props) => {
|
|||
onClick={async () => {
|
||||
await Browser.open({
|
||||
url: `https://www.qwant.com/?q=${encodeURIComponent(
|
||||
feature.get('name') || ''
|
||||
feature.get('name') || ''
|
||||
)}&t=web`,
|
||||
});
|
||||
}}
|
||||
|
@ -229,40 +227,37 @@ const Infos: Component<{}> = (props) => {
|
|||
<For each={Object.keys(feature.getProperties())}>
|
||||
{(key: string) => (
|
||||
<div>
|
||||
<Show
|
||||
when={key === 'website'}
|
||||
fallback={
|
||||
<Show
|
||||
when={key === 'phone'}
|
||||
fallback={`${key}: ${
|
||||
feature.getProperties()[key]
|
||||
}`}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
startIcon={<CallIcon />}
|
||||
href={
|
||||
'tel:' +
|
||||
feature.getProperties()[key]
|
||||
}
|
||||
>
|
||||
{feature.getProperties()[key]}
|
||||
</Button>
|
||||
</Show>
|
||||
}
|
||||
<Switch
|
||||
fallback={`${key}: ${
|
||||
feature.getProperties()[key]
|
||||
}`}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
startIcon={<OpenInNewIcon />}
|
||||
onClick={async () => {
|
||||
await Browser.open({
|
||||
url: feature.getProperties()[key],
|
||||
});
|
||||
}}
|
||||
>
|
||||
{feature.getProperties()[key]}
|
||||
</Button>
|
||||
</Show>
|
||||
<Match when={key === 'website'}>
|
||||
<Button
|
||||
size='small'
|
||||
startIcon={<OpenInNewIcon />}
|
||||
onClick={async () => {
|
||||
await Browser.open({
|
||||
url: feature.getProperties()[key],
|
||||
});
|
||||
}}
|
||||
>
|
||||
{feature.getProperties()[key]}
|
||||
</Button>
|
||||
</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