Skip to content

Commit 4bdb64c

Browse files
committed
docs(topbar): adding clarity to changes made
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
1 parent e421288 commit 4bdb64c

10 files changed

Lines changed: 20 additions & 16 deletions

File tree

fission/src/systems/match_mode/DefaultMatchModeConfigs.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class DefaultMatchModeConfigs {
1212
private static readonly MANIFEST_LOCATION = `${API_URL}/match_configs/manifest.json`
1313
private static _configs: MatchModeConfig[] = []
1414

15+
/** deferring loading so when you import this module, it doesn't fire a request */
1516
private static _loading: Promise<void> = new Promise<void>(resolve => {
1617
setTimeout(() => resolve(this.load()))
1718
})
@@ -50,10 +51,6 @@ class DefaultMatchModeConfigs {
5051
return this._configs
5152
}
5253

53-
public static get configs(): MatchModeConfig[] {
54-
return this._configs
55-
}
56-
5754
static fallbackValues = (): MatchModeConfig => {
5855
return {
5956
id: "default",

fission/src/systems/scene/DragModeSystem.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class DragModeSystem extends WorldSystem {
9595
return this._enabled
9696
}
9797

98+
/** toggle using SetDragModeEvent. Not this */
9899
public set enabled(enabled: boolean) {
99100
if (this._enabled === enabled) return
100101

fission/src/test/ui/TopBarFit.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { describe, expect, test } from "vitest"
2-
import { computeVisibleCount } from "@/ui/components/topbar/TopBarFit"
2+
import { computeVisibleCount, FIT_TOLERANCE_PX } from "@/ui/components/topbar/TopBarFit"
33

44
const GAP = 12
55
const BUTTON = 40
6-
const SUBPIXEL_SLACK_PX = 8
76

87
const BUTTONS = Array<number>(6).fill(BUTTON)
98

10-
const leastBudgetFitting = (n: number) => n * (BUTTON + GAP) + SUBPIXEL_SLACK_PX
9+
const leastBudgetFitting = (n: number) => n * (BUTTON + GAP) + FIT_TOLERANCE_PX
1110

1211
describe("computeVisibleCount", () => {
1312
test("drops exactly one item per item-width of budget, holding back slack", () => {

fission/src/ui/components/PortraitOverlay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type React from "react"
44
import { useCallback, useState } from "react"
55
import { useIsMobile } from "@/ui/helpers/useIsMobile"
66

7-
/** Rotate your device to landscape screen */
7+
/** "Rotate your device to landscape" screen; dismissible */
88
const PortraitOverlay: React.FC = () => {
99
const isMobile = useIsMobile()
1010
const isPortrait = useMediaQuery("(orientation: portrait)")

fission/src/ui/components/SplitButtonDropdown.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ const SplitButtonDropdown: React.FC<SplitButtonDropdownProps> = ({
8989
[closeMenu]
9090
)
9191

92-
const hasIconSlot = items.some(item => item.icon !== undefined || item.selected !== undefined)
92+
// !== undefined because row needs room for checkmark
93+
const reservesIconColumn = items.some(item => item.icon !== undefined || item.selected !== undefined)
9394

9495
return (
9596
<>
@@ -128,7 +129,7 @@ const SplitButtonDropdown: React.FC<SplitButtonDropdownProps> = ({
128129
onClick={() => selectItem(item)}
129130
sx={{ gap: 1 }}
130131
>
131-
{hasIconSlot && (
132+
{reservesIconColumn && (
132133
<Box sx={ICON_SLOT_SX}>
133134
{item.icon ?? (item.selected ? <SynthesisIcons.CHECK /> : null)}
134135
</Box>

fission/src/ui/components/topbar/CollapsibleGroup.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface CollapsibleGroupProps {
1616

1717
const GROUP_SX = { flexShrink: 0, "& > *": { flexShrink: 0 } } as const
1818

19-
const KEY_SEPARATOR = "\u0000"
19+
const KEY_SEPARATOR = "\u0000" // joins item keys into comparable string
2020

2121
export const CollapsibleGroup: React.FC<CollapsibleGroupProps> = ({ items, always }) => {
2222
const fit = useTopBarFit()
@@ -26,6 +26,7 @@ export const CollapsibleGroup: React.FC<CollapsibleGroupProps> = ({ items, alway
2626
const itemCount = items.length
2727
const itemsKey = items.map(item => item.key).join(KEY_SEPARATOR)
2828

29+
// adding guard to ensure 'fitted' isn't stale during renders
2930
const [fitted, setFitted] = useState({ itemsKey, visibleCount: itemCount })
3031
if (fitted.itemsKey !== itemsKey) {
3132
widthsRef.current = []
@@ -49,6 +50,7 @@ export const CollapsibleGroup: React.FC<CollapsibleGroupProps> = ({ items, alway
4950
const spacer = fit?.spacerRef.current
5051
if (!row || !spacer) return
5152

53+
// width the items occupy; free space the flex spacer is taking rn; subtracting anything overflowing out of the row already
5254
const widths = widthsRef.current
5355
const usedByItems = widths.slice(0, visibleCount).reduce((total, width) => total + width + TOP_BAR_GAP_PX, 0)
5456
const overflow = Math.max(0, row.scrollWidth - row.clientWidth)

fission/src/ui/components/topbar/ConfigureIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { TopBarIcon, type TopBarIconName } from "@/ui/components/topbar/TopBarIc
55

66
export type ConfigureIconSource = { sprite: TopBarIconName } | { glyph: IconType }
77

8+
// GLYPHS have a different scale than the SVGs so they match
89
const GLYPH_SCALE = 0.87
910
const glyphFontSize = (size: number | string) =>
1011
typeof size === "number" ? size * GLYPH_SCALE : `calc(${size} * ${GLYPH_SCALE})`

fission/src/ui/components/topbar/TopBarConfig.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ export const TOP_BAR_ICON_BUTTON_SX = {
1212
"&:focus, &:focus-visible": { outline: "none" },
1313
} as const
1414

15-
const tintedWithButtonColor = (percent: number) => `color-mix(in srgb, currentColor ${percent}%, transparent)`
15+
const tintedCurrentColor = (percent: number) => `color-mix(in srgb, currentColor ${percent}%, transparent)`
1616

17+
/** The tints resolve against the `color` below - keep the two together. */
1718
export const TOP_BAR_ICON_BUTTON_ACTIVE_SX = {
1819
borderRadius: 1,
1920
color: "primary.main",
20-
backgroundColor: tintedWithButtonColor(16),
21-
"&:hover": { backgroundColor: tintedWithButtonColor(24) },
21+
backgroundColor: tintedCurrentColor(16),
22+
"&:hover": { backgroundColor: tintedCurrentColor(24) },
2223
} as const
2324

2425
// making react-icon glyph consistent with buttons

fission/src/ui/components/topbar/TopBarFit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type React from "react"
22
import { createContext, useContext } from "react"
33

4-
const SUBPIXEL_SLACK_PX = 8
4+
export const FIT_TOLERANCE_PX = 8
55

66
export function computeVisibleCount(budget: number, widths: readonly number[], gap: number): number {
7-
const spendable = budget - SUBPIXEL_SLACK_PX
7+
const spendable = budget - FIT_TOLERANCE_PX
88

99
let used = 0
1010
for (let i = 0; i < widths.length; i++) {
@@ -17,6 +17,7 @@ export function computeVisibleCount(budget: number, widths: readonly number[], g
1717
export interface TopBarFitValue {
1818
rowRef: React.RefObject<HTMLElement | null>
1919
spacerRef: React.RefObject<HTMLElement | null>
20+
// not read. increased on resize to give context value new identity & re-run
2021
resizeTick: number
2122
}
2223

fission/src/ui/panels/configuring/MatchModeConfigPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const MatchModeConfigPanel: React.FC<PanelImplProps<void, void>> = ({ panel }) =
204204
window.localStorage.getItem("match-mode-configs") || "[]"
205205
)
206206

207+
// `prev` last so configs added while the manifest was loading survive.
207208
setMatchModeConfigs(prev =>
208209
Array.from(
209210
new Map([...defaultConfigs, ...localConfigs, ...prev].map(item => [item.id, item])).values()

0 commit comments

Comments
 (0)