Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Properties Panel displays file properties (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
deenhaque authored Jun 28, 2021
1 parent 9cd8cbd commit 799b947
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 16 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"electron-is-dev": "^1.2.0",
"electron-reload": "^1.5.0",
"eslint": "^7.28.0",
"mapbox-gl": "^2.3.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-map-gl": "^6.1.8",
Expand Down
19 changes: 15 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled, {
createGlobalStyle // TODO: Establish a theme and hook this up to everything
} from 'styled-components';
import Left from './Left';
import Right from './Right';
import Properties from './Properties';

const { ipcRenderer } = window.require('electron');

Expand All @@ -21,6 +21,11 @@ const GlobalStyle = createGlobalStyle`
}
`;

const carleton = {
latitude: 45.3854,
longitude: -75.69608
};

const App: React.FC = () => {
const [data, setData] = useState<FeatureCollection | null>(null);
const onFileOpen = useCallback((event, contents: FeatureCollection) => {
Expand All @@ -31,16 +36,22 @@ const App: React.FC = () => {
useEffect(() => {
ipcRenderer.on(fileChannel, onFileOpen);

return () => ipcRenderer.removeListener(fileChannel, onFileOpen);
return () => {
ipcRenderer.removeListener(fileChannel, onFileOpen);
};
}, []);

return (
<>
<GlobalStyle />
<StyledDiv className='App'>
<Left />
<Map latitude={45.3854} longitude={-75.69608} data={data} />
<Right />
<Map
latitude={carleton.latitude}
longitude={carleton.longitude}
data={data}
/>
<Properties info={data} />
</StyledDiv>
</>
);
Expand Down
61 changes: 61 additions & 0 deletions src/Properties.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import { FeatureCollection } from 'geojson';

import { Text } from './common';

interface PropertyProps {
info: FeatureCollection | null;
// children?: ReactNode;
}

const Properties: React.FC<PropertyProps> = (props: PropertyProps) => {
console.log('props', props);
const { info } = props;
return (
<div>
{info ? (
<>
<p>Type: {info.type}</p>
<ul>
Properties:{' '}
{info.features.map((feature) => {
const { properties } = feature;
console.log('properties', properties);
return properties ? (
<>
<br />
<li key={`${properties.fid}-map-properties`}>
{properties.building}
{properties.roomId}
</li>
<li> Floor: {properties.floor}</li>
<li>
{' '}
Room: {properties.roomName} ({properties.roomType})
</li>
<li>
Search Tags:
<ul>
{properties.searchTagProps.map(
(searchTag: string, i: number) => (
<li key={`${i}-search=tag`}>{searchTag}</li>
)
)}
</ul>
</li>
<br />
</>
) : (
'N/A'
);
})}
</ul>
</>
) : (
'Open a file qt'
)}
</div>
);
};

export default Properties;
7 changes: 0 additions & 7 deletions src/Right.tsx

This file was deleted.

11 changes: 11 additions & 0 deletions src/common/Text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

// interface TextProps {
// children: ReactN
// }

const Text: React.FC = () => {
return <p></p>;
};

export default Text;
3 changes: 3 additions & 0 deletions src/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Text from './Text';

export { Text };
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
44 changes: 40 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1502,9 +1502,9 @@
resolved "https://registry.yarnpkg.com/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz"
integrity sha1-ioP5M1x4YO/6Lu7KJUMyqgru2PI=

"@mapbox/tiny-sdf@^1.2.3":
"@mapbox/tiny-sdf@^1.2.3", "@mapbox/tiny-sdf@^1.2.5":
version "1.2.5"
resolved "https://registry.yarnpkg.com/@mapbox/tiny-sdf/-/tiny-sdf-1.2.5.tgz"
resolved "https://registry.yarnpkg.com/@mapbox/tiny-sdf/-/tiny-sdf-1.2.5.tgz#424c620a96442b20402552be70a7f62a8407cc59"
integrity sha512-cD8A/zJlm6fdJOk6DqPUV8mcpyJkRz2x2R+/fYcWDYG3oWbG7/L7Yl/WqQ1VZCjnL9OTIMAn6c+BC5Eru4sQEw==

"@mapbox/unitbezier@^0.0.0":
Expand Down Expand Up @@ -6011,9 +6011,9 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"

gl-matrix@^3.0.0, gl-matrix@^3.2.1:
gl-matrix@^3.0.0, gl-matrix@^3.2.1, gl-matrix@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/gl-matrix/-/gl-matrix-3.3.0.tgz"
resolved "https://registry.yarnpkg.com/gl-matrix/-/gl-matrix-3.3.0.tgz#232eef60b1c8b30a28cbbe75b2caf6c48fd6358b"
integrity sha512-COb7LDz+SXaHtl/h4LeaFcNdJdAQSDeVqjiIihSXNrkWObZLhDI4hIkZC11Aeqp7bcE72clzB0BnDXr2SmslRA==

glob-parent@^3.1.0:
Expand Down Expand Up @@ -8170,6 +8170,35 @@ mapbox-gl@^2.0.1:
tinyqueue "^2.0.3"
vt-pbf "^3.1.1"

mapbox-gl@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/mapbox-gl/-/mapbox-gl-2.3.1.tgz#970fbb91b7c21e81c726d547b3153b6f90a09c29"
integrity sha512-xGohzbxxdN3UhHMHy0aweaueYwSoOspSg90gi1T7DIl8Ev0YLjl+ApV6VYtNnR1B9lmwDn8jITfG6Y2JiSEuwg==
dependencies:
"@mapbox/geojson-rewind" "^0.5.0"
"@mapbox/geojson-types" "^1.0.2"
"@mapbox/jsonlint-lines-primitives" "^2.0.2"
"@mapbox/mapbox-gl-supported" "^2.0.0"
"@mapbox/point-geometry" "^0.1.0"
"@mapbox/tiny-sdf" "^1.2.5"
"@mapbox/unitbezier" "^0.0.0"
"@mapbox/vector-tile" "^1.3.1"
"@mapbox/whoots-js" "^3.1.0"
csscolorparser "~1.0.3"
earcut "^2.2.2"
geojson-vt "^3.2.1"
gl-matrix "^3.3.0"
grid-index "^1.1.0"
minimist "^1.2.5"
murmurhash-js "^1.0.0"
pbf "^3.2.1"
potpack "^1.0.1"
quickselect "^2.0.0"
rw "^1.3.3"
supercluster "^7.1.3"
tinyqueue "^2.0.3"
vt-pbf "^3.1.1"

matcher@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/matcher/-/matcher-3.0.0.tgz"
Expand Down Expand Up @@ -11754,6 +11783,13 @@ supercluster@^7.1.2:
dependencies:
kdbush "^3.0.0"

supercluster@^7.1.3:
version "7.1.3"
resolved "https://registry.yarnpkg.com/supercluster/-/supercluster-7.1.3.tgz#8c5412c7d7e53b010f7514e87f279544babc3425"
integrity sha512-7+bR4FbF5SYsmkHfDp61QiwCKtwNDyPsddk9TzfsDA5DQr5Goii5CVD2SXjglweFCxjrzVZf945ahqYfUIk8UA==
dependencies:
kdbush "^3.0.0"

supports-color@^5.3.0, supports-color@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz"
Expand Down

0 comments on commit 799b947

Please sign in to comment.