Displaying waypoints (and installing a plugin to import SVG files as components)
This commit is contained in:
1 parent
6b0b394d33
commit
62b2b5552a
8 files changed
+255
-14
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { Component } from 'solid-js';
|
||||
import { Component, For } from 'solid-js';
|
||||
import { peekCachedSignal } from '../../workers/cached-signals';
|
||||
import Tree from '../tree';
|
||||
import { WptViewer } from '../wpt';
|
||||
import GpxIcon from './GpxIcon';
|
||||
|
||||
interface Props {
|
||||
@@ -18,13 +19,25 @@ const GpxViewer: Component<Props> = ({ gpxId, restrictToHierarchy }) => {
|
||||
<Tree
|
||||
title={
|
||||
<>
|
||||
<GpxIcon />
|
||||
{' '}
|
||||
{title()}
|
||||
<GpxIcon /> {title()}
|
||||
</>
|
||||
}
|
||||
content={undefined}
|
||||
subTree={undefined}
|
||||
subTree={
|
||||
<For
|
||||
each={Object.keys(restrictToHierarchy).filter((key: string) =>
|
||||
key.startsWith('gpx/')
|
||||
)}
|
||||
>
|
||||
{(key: string) => {
|
||||
const child = restrictToHierarchy[key];
|
||||
if (child.type === 'wpt') {
|
||||
return <WptViewer wptId={key} />;
|
||||
}
|
||||
return <></>;
|
||||
}}
|
||||
</For>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Component } from 'solid-js';
|
||||
import WptIcon from '../../icons/location-pin-svgrepo-com.svg?component-solid';
|
||||
import { peekCachedSignal } from '../../workers/cached-signals';
|
||||
import Tree from '../tree';
|
||||
|
||||
interface Props {
|
||||
wptId: string;
|
||||
}
|
||||
|
||||
const WptViewer: Component<Props> = ({ wptId }) => {
|
||||
const wpt = peekCachedSignal({ id: wptId, method: 'getWpt' });
|
||||
console.log({ caller: 'WptViewer', wptId, wpt: wpt() });
|
||||
const title = () => {
|
||||
return wpt().name;
|
||||
};
|
||||
|
||||
return (
|
||||
<Tree
|
||||
title={
|
||||
<>
|
||||
<WptIcon /> {title()}
|
||||
</>
|
||||
}
|
||||
content={undefined}
|
||||
subTree={undefined}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default WptViewer;
|
||||
@@ -1 +1,3 @@
|
||||
export { default } from './Wpt';
|
||||
|
||||
export { default as WptViewer } from './WptViewer';
|
||||
Reference in new issue
Block a user