Skip to content

Commit 9578411

Browse files
committed
Replace visibility toggle with slide number indicator
1 parent f1dba1a commit 9578411

File tree

2 files changed

+53
-12
lines changed

2 files changed

+53
-12
lines changed

packages/base/src/panelview/components/layers.tsx

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const LAYER_CLASS = 'jp-gis-layer';
4040
const LAYER_TITLE_CLASS = 'jp-gis-layerTitle';
4141
const LAYER_ICON_CLASS = 'jp-gis-layerIcon';
4242
const LAYER_TEXT_CLASS = 'jp-gis-layerText data-jgis-keybinding';
43+
const LAYER_SLIDE_NUMBER_CLASS = 'jp-gis-layerSlideNumber';
4344

4445
interface IBodyProps {
4546
model: IJupyterGISModel;
@@ -416,6 +417,7 @@ const LayerGroupComponent: React.FC<ILayerGroupProps> = props => {
416417
* Properties of the layer component.
417418
*/
418419
interface ILayerProps {
420+
// ! todo this should never be undefined, like it's not possible in the parent, it will never be undef here
419421
gisModel: IJupyterGISModel | undefined;
420422
layerId: string;
421423
onClick: ({ type, item }: ILeftPanelClickHandlerParams) => void;
@@ -556,6 +558,22 @@ const LayerComponent: React.FC<ILayerProps> = props => {
556558
gisModel?.centerOnPosition(layerId);
557559
};
558560

561+
const getSlideNumber = () => {
562+
if (!gisModel) {
563+
return;
564+
}
565+
566+
const { story } = gisModel.getSelectedStory();
567+
568+
if (!story?.landmarks) {
569+
return;
570+
}
571+
572+
const slideNum = story.landmarks.indexOf(layerId) + 1;
573+
574+
return slideNum;
575+
};
576+
559577
return (
560578
<div
561579
className={`${LAYER_ITEM_CLASS} ${LAYER_CLASS}${selected ? ' jp-mod-selected' : ''}`}
@@ -589,18 +607,24 @@ const LayerComponent: React.FC<ILayerProps> = props => {
589607
</Button>
590608
)}
591609

592-
{/* Visibility toggle */}
593-
<Button
594-
title={layer.visible ? 'Hide layer' : 'Show layer'}
595-
onClick={toggleVisibility}
596-
minimal
597-
>
598-
<LabIcon.resolveReact
599-
icon={layer.visible ? visibilityIcon : nonVisibilityIcon}
600-
className={`${LAYER_ICON_CLASS}${layer.visible ? '' : ' jp-gis-mod-hidden'}`}
601-
tag="span"
602-
/>
603-
</Button>
610+
{/* Visibility toggle for normal layers, Slide number for landmarks */}
611+
{layer.type === 'LandmarkLayer' ? (
612+
<span className={LAYER_SLIDE_NUMBER_CLASS} title="Slide number">
613+
{getSlideNumber()}
614+
</span>
615+
) : (
616+
<Button
617+
title={layer.visible ? 'Hide layer' : 'Show layer'}
618+
onClick={toggleVisibility}
619+
minimal
620+
>
621+
<LabIcon.resolveReact
622+
icon={layer.visible ? visibilityIcon : nonVisibilityIcon}
623+
className={`${LAYER_ICON_CLASS}${layer.visible ? '' : ' jp-gis-mod-hidden'}`}
624+
tag="span"
625+
/>
626+
</Button>
627+
)}
604628

605629
{icons.has(layer.type) && (
606630
<LabIcon.resolveReact

packages/base/style/leftPanel.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,23 @@
141141
flex-grow: 1;
142142
}
143143

144+
.jp-gis-layerSlideNumber {
145+
box-sizing: border-box;
146+
display: inline-flex;
147+
align-items: center;
148+
justify-content: center;
149+
min-width: 18px;
150+
height: 18px;
151+
padding: 0 6px;
152+
margin-right: 4px;
153+
background-color: var(--jp-brand-color1);
154+
color: var(--jp-ui-inverse-font-color1);
155+
border-radius: 9999px;
156+
font-size: var(--jp-ui-font-size0);
157+
font-weight: 600;
158+
line-height: 1;
159+
}
160+
144161
li .lm-Menu-itemLabel {
145162
text-transform: capitalize;
146163
}

0 commit comments

Comments
 (0)