Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/BaselayerSections.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LayerSelectorProps } from './LayerSelector';
import { CollapsibleSection } from './CollapsibleSection';
import { makeLayerName } from '../utils/layerUtils';
import { EXTERNAL_BASELAYERS } from '../configs/mapSettings';

type BaselayerSectionsProps = {
Expand All @@ -23,6 +22,7 @@ export function BaselayerSections({
key={'section-internal-map-' + map.id}
summary={map.name}
defaultOpen={index === 0}
tooltip={map.description}
>
{map.bands.map((band) => (
<div className="input-container" key={band.map_id + '-' + band.id}>
Expand All @@ -40,7 +40,7 @@ export function BaselayerSections({
)
}
/>
<label htmlFor={String(band.id)}>{makeLayerName(band)}</label>
<label htmlFor={String(band.id)}>{band.band_display_name}</label>
</div>
))}
</CollapsibleSection>
Expand Down
10 changes: 8 additions & 2 deletions src/components/CollapsibleSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ type Props = {
summary: ReactNode;
children: ReactNode;
defaultOpen: boolean;
tooltip?: string;
};

export function CollapsibleSection({ summary, defaultOpen, children }: Props) {
export function CollapsibleSection({
summary,
defaultOpen,
children,
tooltip,
}: Props) {
return (
<details open={defaultOpen}>
<summary>{summary}</summary>
<summary title={tooltip}>{summary}</summary>
{children}
</details>
);
Expand Down
1 change: 1 addition & 0 deletions src/types/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type BandResponseBase = {
id: number;
map_id: number;
map_name: string;
band_display_name: string;
units: string;
tiles_available: boolean;
tile_size: number;
Expand Down
16 changes: 1 addition & 15 deletions src/utils/layerUtils.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
import { Feature } from 'ol';
import { BandWithCmapValues, BoxExtent } from '../types/maps';
import { BoxExtent } from '../types/maps';
import { Source } from '../types/maps';
import { NUMBER_OF_FIXED_COORDINATE_DECIMALS } from '../configs/mapSettings';
import { Point } from 'ol/geom';
import { Fill, Stroke, Style } from 'ol/style';
import { FeatureLike } from 'ol/Feature';

/**
* A utility function to format a layer's name.
* @param band The band object
* @returns A string of map_name + stokes_parameter + quantity, where quantity
* and stokes_parameter are conditionally rendered based on their truthiness
*/
export function makeLayerName(band: BandWithCmapValues) {
return (
band.map_name +
(band.stokes_parameter ? ` ${band.stokes_parameter}` : '') +
(band.quantity ? ` ${band.quantity}` : '')
);
}

export function handleSelectChange(
event: React.ChangeEvent<HTMLInputElement>,
setter: (value: React.SetStateAction<number[]>) => void
Expand Down