Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
99993ac
Update layouting in Night sky panel markings tab
WeirdRubberDuck Mar 19, 2026
ac625bb
Tighten up a bit
WeirdRubberDuck Mar 19, 2026
cf03255
Redesign cardinal directions part to look different than the others
WeirdRubberDuck Mar 19, 2026
fc58b88
Redesign layout for markings tab and introduce a new toggle component
WeirdRubberDuck Mar 19, 2026
1ef5591
Refactor cardinal direction and make it listen to the currently shown…
WeirdRubberDuck Mar 19, 2026
cf16098
Add animation to ToggleCard and move to general components
WeirdRubberDuck Mar 20, 2026
39f0b53
Rename components to better reflect the new toggle component
WeirdRubberDuck Mar 20, 2026
6d193db
Fix aria label for scene graph node toggle
WeirdRubberDuck Mar 20, 2026
47b5b30
Add placeholder buttons for hide all per group
WeirdRubberDuck Mar 20, 2026
da83af6
Small cleanup of Sun tab and make text labels better match format in …
WeirdRubberDuck Mar 20, 2026
4e9eabd
Small updates
WeirdRubberDuck Mar 20, 2026
68bdb17
Only pad in y direction to better fit text
WeirdRubberDuck Mar 20, 2026
f9f94b8
Apply suggestions from code review
WeirdRubberDuck Mar 27, 2026
fab388d
Small refactor
WeirdRubberDuck Mar 27, 2026
233ae07
Merge branch 'master' into issue/3753-nightsky-markings-layout
WeirdRubberDuck Mar 31, 2026
713b70b
added functions calls now available in corresponding openspace branch
micahnyc Apr 15, 2026
d643bb4
Merge branch 'issue/3753-nightsky-markings-layout' of https://github.…
WeirdRubberDuck Apr 15, 2026
ab53467
Merge branch 'master' into issue/3753-nightsky-markings-layout
WeirdRubberDuck Apr 15, 2026
601ddb8
Fix the cardinal directions by redesigning it, again
WeirdRubberDuck Apr 15, 2026
b33137d
ci: auto-fix prettier & eslint issues
WeirdRubberDuck Apr 15, 2026
06a1975
Add translation and small refactor of function names
WeirdRubberDuck Apr 15, 2026
eff704e
Move icons to icons file
WeirdRubberDuck Apr 15, 2026
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
46 changes: 25 additions & 21 deletions public/locales/en/panel-nightsky.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"markings": {
"common-button-labels": {
"hide-all": "Hide All",
"hide-all": "Hide all",
"grid": "Grid",
"labels": "Labels",
"line_one": "Line",
Expand Down Expand Up @@ -45,15 +45,18 @@
"cardinal-directions": {
"title": "Cardinal Directions",
"buttons": {
"directions": "Directions",
"small": "Small",
"large": "Large",
"marks": "Marks"
},
"aria-labels": {
"small": "Show cardinal directions (small)",
"large": "Show cardianl directions (large)",
"toggle": "Toggle cardinal directions' size",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"toggle": "Toggle cardinal directions' size",
"toggle": "Toggle cardinal directions' sizes",

"marks": "Show marks on cardinal directions"
}
},
"scene-graph-node-toggle": {
"aria-label": "Toggle {{name}} visibility"
}
},
"location": {
Expand Down Expand Up @@ -93,28 +96,28 @@
"trails": {
"title": "Trails",
"buttons": {
"hide-trails": "Hide all Trails",
"show-planet-trails": "Show Planet Trails"
"hide-trails": "Hide all trails",
"show-planet-trails": "Show planet trails"
}
},
"labels": {
"title": "Labels",
"buttons": {
"show-labels": "Show Labels",
"hide-labels": "Hide Labels"
"show-labels": "Show labels",
"hide-labels": "Hide labels"
}
},
"planets": {
"title": "Planets",
"buttons": {
"show-planets": "Show Night Sky Planets",
"hide-planets": "Hide Night Sky Planets"
"show-planets": "Show night sky planets",
"hide-planets": "Hide night sky planets"
}
},
"moon": {
"title": "Moon",
"buttons": {
"default-scale": "Default Moon Scale (1x)",
"default-scale": "Default Moon scale (1x)",
"2x-scale": "Enlarge Moon (2x)",
"4x-scale": "Enlarge Moon (4x)"
},
Expand All @@ -127,7 +130,7 @@
"moon-shading-settings": "Could not find Moon Perform Shading settings"
},
"show-phase-input": {
"title": "Show Phase",
"title": "Show phase",
"tooltip": "Uncheck this to always show the full moon. This is equivalent to 'Perform Shading' property on the Moon."
}
}
Expand All @@ -136,7 +139,7 @@
"visibility": {
"title": "Visibility",
"input": {
"show-stars": "Show Stars",
"show-stars": "Show stars",
"show-during-day": {
"label": "Show during Day",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"label": "Show during Day",
"label": "Show during day",

"tooltip": "Check this box to show the stars during daytime"
Expand All @@ -146,8 +149,8 @@
"labels": {
"title": "Labels",
"input": {
"show-labels": "Show Labels",
"show-alternate-labels": "Show Alternate Labels"
"show-labels": "Show labels",
"show-alternate-labels": "Show alternate labels"
}
},
"appearance": {
Expand All @@ -172,10 +175,11 @@
},
"size": {
"title": "Size",
"description": "Adjust the Sun's angular size on the sky.",
"buttons": {
"default-size": "Default Angular Size",
"large-size": "Large Angular Size",
"extra-large-size": "Extra Large Angular Size"
"default-size": "Default",
"large-size": "Large",
"extra-large-size": "Extra large"
},
"aria-labels": {
"increase-size": "Increase angular size",
Expand All @@ -186,10 +190,10 @@
"trails": {
"title": "Trails",
"buttons": {
"add-trail": "Add Trail",
"add-trail-simulation-date": "Add Trail for Simulation Date",
"add-trail-today": "Add Trail for Today",
"hide-trails": "Hide All"
"add-trail": "Add trail",
"add-trail-simulation-date": "Add trail for Simulation Date",
"add-trail-today": "Add trail for Today",
Comment on lines +194 to +195
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"add-trail-simulation-date": "Add trail for Simulation Date",
"add-trail-today": "Add trail for Today",
"add-trail-simulation-date": "Add trail for simulation date",
"add-trail-today": "Add trail for today",

?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"add-trail-simulation-date": "Add trail for Simulation Date",
"add-trail-today": "Add trail for Today",
"add-trail-simulation-date": "Add trail for 'Simulation Date'",
"add-trail-today": "Add trail for 'Today'",

Alternative suggestion to make it more clear that that is the important part of the sentence

"hide-trails": "Hide all"
},
"choose-date": "Choose Date",
"added-trails": {
Expand Down
3 changes: 3 additions & 0 deletions src/components/ToggleCard/ToggleCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.card:active {
transform: translateY(2px);
}
37 changes: 37 additions & 0 deletions src/components/ToggleCard/ToggleCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { PropsWithChildren, useEffect, useState } from 'react';
import { Checkbox, CheckboxCardProps } from '@mantine/core';

import styles from './ToggleCard.module.css';

interface Props extends CheckboxCardProps, PropsWithChildren {
onClick: () => void;
checked: boolean;
}

export function ToggleCard({ onClick, checked, children, ...other }: Props) {
const [checkedState, setCheckedState] = useState(checked);

function handleClick() {
setCheckedState(!checkedState);
onClick();
}

useEffect(() => {
setCheckedState(checked);
}, [checked]);

return (
<Checkbox.Card
classNames={styles}
checked={checkedState}
onClick={handleClick}
bg={checkedState ? 'blue' : 'dark.8'}
role={'switch'}
aria-checked={checkedState}
style={{ fontWeight: checkedState ? '500' : undefined }}
{...other}
>
{children}
</Checkbox.Card>
);
}
2 changes: 2 additions & 0 deletions src/icons/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export {
TbClock as ClockIcon,
TbClockX as ClockOffIcon,
TbCompass as CompassMarksIcon,
TbLetterA as LetterAIcon,
TbLetterASmall as LetterASmallIcon,
TbSphere as LineIcon,
TbRepeat as RepeatIcon,
TbRepeatOff as RepeatOffIcon,
Expand Down
164 changes: 164 additions & 0 deletions src/panels/NightSkyPanel/tabs/MarkingsTab/CardinalDirections.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
Box,
Group,
SegmentedControl,
Skeleton,
Stack,
Switch,
Text
} from '@mantine/core';

import { useOpenSpaceApi } from '@/api/hooks';
import { useProperty } from '@/hooks/properties';
import { CompassSmallIcon, LetterAIcon, LetterASmallIcon } from '@/icons/icons';
import { IconSize } from '@/types/enums';

import { SceneGraphNodeToggle } from './SceneGraphNodeToggle';

// @TODO (2025-05-19, emmbr) These checks, especially against the parts of the texture
// file names, are fragile agains file name changes. Consider more robust solution
const Data = {
small: {
showAction: 'os.nightsky.ShowNeswLettersSmall',
hideAction: 'os.nightsky.HideNesw',
textureCheck: 'red_small.png'
},
large: {
showAction: 'os.nightsky.ShowNeswLetters',
hideAction: 'os.nightsky.HideNesw',
textureCheck: 'red.png'
},
marks: {
showAction: 'os.nightsky.AddNeswBandMarks',
hideAction: 'os.nightsky.RemoveNeswBandMarks',
textureCheck: '_lines_'
}
};

// @TODO (2025-05-19, emmbr) This component needs logic for checking if the used actions
// exist. However, for this we need to be able to access the actions state using the
// identifier of the action, so leaving for now

export function CardinalDirections() {
const { t } = useTranslation('panel-nightsky', {
keyPrefix: 'markings.cardinal-directions'
});

const [sizeToggleValue, setSizeToggle] = useState<'small' | 'large' | undefined>(
undefined
);

const luaApi = useOpenSpaceApi();

const [texture] = useProperty(
'StringProperty',
'Scene.CardinalDirectionSphere.Renderable.Texture'
);

const isTextureOn = useCallback(
(variant: keyof typeof Data): boolean => {
if (!texture) {
return false;
}
return texture.includes(Data[variant].textureCheck);
},
[texture]
);

const currentToggle = useCallback((): 'small' | 'large' | undefined => {
if (isTextureOn('small')) {
return 'small';
}
if (isTextureOn('large')) {
return 'large';
}
return undefined;
}, [isTextureOn]);

useEffect(() => {
if (texture) {
setSizeToggle(currentToggle());
}
}, [texture, setSizeToggle, currentToggle]);

function sizeToggleLabel(text: string, icon: React.JSX.Element) {
return (
<Stack gap={0} py={2} align={'center'}>
{icon}
<Text>{text}</Text>
</Stack>
);
}

return (
<Skeleton visible={!texture}>
<Group>
<Box w={100}>
<SceneGraphNodeToggle
title={t('buttons.directions')}
icon={<CompassSmallIcon size={IconSize.sm} />}
identifier={'CardinalDirectionSphere'}
/>
</Box>

<SegmentedControl
onChange={(value: string) => {
switch (value) {
case 'small':
luaApi?.action.triggerAction(Data['small'].showAction);
if (isTextureOn('marks')) {
// The action for showing the small letters also hides the marks, so we
// need to show them again if they were enabled before
luaApi?.action.triggerAction(Data['marks'].showAction);
}
setSizeToggle('small');
break;
case 'large':
luaApi?.action.triggerAction(Data['large'].showAction);
if (isTextureOn('marks')) {
// The action for showing the large letters also hides the marks, so we
// need to show them again if they were enabled before
luaApi?.action.triggerAction(Data['marks'].showAction);
}
setSizeToggle('large');
break;
default:
setSizeToggle(undefined);
break;
}
}}
Comment on lines +107 to +131
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be its own function instead?

value={sizeToggleValue}
data={[
{
value: 'small',
label: sizeToggleLabel(
t('buttons.small'),
<LetterASmallIcon size={IconSize.sm} />
)
},
{
value: 'large',
label: sizeToggleLabel(
t('buttons.large'),
<LetterAIcon size={IconSize.sm} />
)
}
]}
aria-label={t('aria-labels.toggle')}
/>
<Switch
checked={isTextureOn('marks')}
onChange={(event) =>
luaApi?.action.triggerAction(
event.target.checked ? Data['marks'].showAction : Data['marks'].hideAction
)
Comment on lines +153 to +156
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be wrapped with in a function body right?

}
label={t('buttons.marks')}
aria-label={t('aria-labels.marks')}
/>
</Group>
</Skeleton>
);
}
Loading