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
150 changes: 0 additions & 150 deletions ios/JsonCanvasGlass.m

This file was deleted.

1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export {createCanvasState, type CanvasState} from './core/canvas-state';
export {CanvasView, type CanvasCamera, type FindResult} from './renderer/CanvasView';
export {nodesMatching} from './renderer/findNodes';
export {CanvasMinimap, type Insets, type MinimapPosition} from './renderer/CanvasMinimap';
export {CanvasGlass, CanvasGlassButton, type CanvasGlassProps, type CanvasGlassButtonProps} from './renderer/CanvasGlass';
export {getNodeColors, resolveScheme, type ColorScheme} from './renderer/theme';
export {useCanvasContext, CanvasProvider} from './renderer/CanvasContext';
export {activateScrollWheel, deactivateScrollWheel} from './renderer/NativeScrollWheelView';
Expand Down
49 changes: 0 additions & 49 deletions src/renderer/CanvasGlass.tsx

This file was deleted.

26 changes: 9 additions & 17 deletions src/renderer/CanvasMinimap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {CanvasNode, CanvasEdge} from '../core';
import {getCanvasBackground, getMinimapColors, type ColorScheme} from './theme';
import {hasCssClasses, enrichNodes, type EnrichedNode} from './extensions/cssclasses';
import {recordShapesPicture} from './useCanvasPicture';
import {CanvasGlass} from './CanvasGlass';

export type MinimapPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';

Expand All @@ -27,18 +26,14 @@ interface Props {
/** The screen's safe area: the minimap keeps inside it, on every side. */
safeArea?: Insets;
/**
* The host's material to sit on, in place of the default: Liquid Glass on
* the Mac (CanvasGlass), a drawn background and border elsewhere.
* The host's material to sit on (its glass, say), in place of the drawn
* background and border: how the minimap looks is the host's.
*/
background?: (size: {width: number; height: number}) => React.ReactNode;
/** Its corners' radius, in points: the drawn background's, and what clips the host's. */
cornerRadius?: number;
}

/** The Mac's default minimap background: Liquid Glass, as the window's other floating controls. */
const macGlass = ({width, height}: {width: number; height: number}) => (
<CanvasGlass cornerRadius={BORDER_RADIUS_GLASS} style={{width, height}} />
);
const BORDER_RADIUS_GLASS = 12;

const EDGE_PADDING = 12;
const INNER_PADDING = 8;
const BORDER_RADIUS = 6;
Expand Down Expand Up @@ -113,9 +108,9 @@ export function CanvasMinimap({
leftOverlayWidth,
bottomInset = 0,
safeArea = NO_INSETS,
background: hostBackground,
background,
cornerRadius = BORDER_RADIUS,
}: Props) {
const background = hostBackground ?? (Platform.OS === 'macos' ? macGlass : undefined);
const bounds = useMemo(() => (nodes.length > 0 ? contentBounds(nodes) : null), [nodes]);
const size = useMemo(() => getMinimapSize(bounds ? bounds.width / bounds.height : 1), [bounds]);
// Typed rather than inline so a mistyped key fails the build instead of
Expand Down Expand Up @@ -205,15 +200,15 @@ export function CanvasMinimap({
pointerEvents="none"
style={[styles.container, getPositionStyle(position, bottomInset, safeArea), {width: size.width, height: size.height}]}
>
{background ? <View style={[StyleSheet.absoluteFill, styles.background, Platform.OS === 'macos' && styles.backgroundMac]}>{background(size)}</View> : null}
{background ? <View style={[StyleSheet.absoluteFill, styles.background, {borderRadius: cornerRadius}]}>{background(size)}</View> : null}
<Canvas style={canvasStyle}>
{background ? null : (
<>
<RoundedRect x={0} y={0} width={size.width} height={size.height} r={BORDER_RADIUS} color={bgColor} />
<RoundedRect x={0} y={0} width={size.width} height={size.height} r={cornerRadius} color={bgColor} />
<RoundedRect
x={0.5} y={0.5}
width={size.width - 1} height={size.height - 1}
r={BORDER_RADIUS - 0.5}
r={Math.max(0, cornerRadius - 0.5)}
color={borderColor}
style="stroke" strokeWidth={1}
/>
Expand All @@ -237,9 +232,6 @@ const styles = StyleSheet.create({
container: {
position: 'absolute',
},
backgroundMac: {
borderRadius: BORDER_RADIUS_GLASS,
},
background: {
borderRadius: BORDER_RADIUS,
overflow: 'hidden',
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/CanvasView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
* minimap's size and drawn behind its content, clipped to its corners.
*/
minimapBackground?: (size: {width: number; height: number}) => React.ReactNode;
/** The minimap's corner radius, in points (6 by default): its background's, drawn or the host's. */
minimapCornerRadius?: number;
/**
* A strip along the view's left edge, in points, where a drag doesn't pan
* the canvas but is left to the system: iOS's swipe back, when the canvas
Expand Down Expand Up @@ -189,7 +191,7 @@
* break rendering). Content changes flow through React reconciliation via
* useMemo/useLayoutEffect on the content prop.
*/
export function CanvasView({content, basePath, initialViewState, onViewStateChange, onReady, doubleTapMaxDelayMs, minimap = 'bottom-right', minimapBottomInset = 0, safeAreaInsets, leftOverlayWidth, minimapBackground, systemEdge = 0}: Props) {
export function CanvasView({content, basePath, initialViewState, onViewStateChange, onReady, doubleTapMaxDelayMs, minimap = 'bottom-right', minimapBottomInset = 0, safeAreaInsets, leftOverlayWidth, minimapBackground, minimapCornerRadius, systemEdge = 0}: Props) {
// `useWindowDimensions` returns the whole application window — on desktop
// that includes the sidebar pane that sits to the left of the canvas
// viewport. Computing "centre" against full-window dimensions lands the
Expand Down Expand Up @@ -501,7 +503,7 @@
// (handleDoubleTap, tapGesture) does NOT recompose when the sidebar
// changes. That's load-bearing for #154 — earlier attempts that put
// sidebar state in deps regressed double-tap.
const fitToViewport = useCallback((leftOverlayWidth: number = 0) => {

Check warning on line 506 in src/renderer/CanvasView.tsx

View workflow job for this annotation

GitHub Actions / typecheck · lint · test

'leftOverlayWidth' is already declared in the upper scope on line 194 column 181
lastActionRef.current = 'fit';
const sw = viewportWidth;
const sh = viewportHeight;
Expand Down Expand Up @@ -535,7 +537,7 @@
// from `leftOverlayWidth` and passes it here per call. Kept as a parameter, not
// a closure dep, to preserve callback identity — see the matching
// discussion above `fitToViewport`.
const zoomToNode = useCallback((node: CanvasNode, leftOverlayWidth: number = 0) => {

Check warning on line 540 in src/renderer/CanvasView.tsx

View workflow job for this annotation

GitHub Actions / typecheck · lint · test

'leftOverlayWidth' is already declared in the upper scope on line 194 column 181
const sw = viewportWidth;
const sh = viewportHeight;
const visibleW = Math.max(1, sw - leftOverlayWidth);
Expand Down Expand Up @@ -608,7 +610,7 @@

// Recenter content at current zoom level, against the visible canvas pane.
// See `fitToViewport` for the leftOverlayWidth rationale.
const recenter = useCallback((leftOverlayWidth: number = 0) => {

Check warning on line 613 in src/renderer/CanvasView.tsx

View workflow job for this annotation

GitHub Actions / typecheck · lint · test

'leftOverlayWidth' is already declared in the upper scope on line 194 column 181
lastActionRef.current = 'recenter';
const sw = viewportWidth;
const sh = viewportHeight;
Expand Down Expand Up @@ -678,8 +680,8 @@

useEffect(() => {
onReady?.({
fitToViewport: (leftOverlayWidth?: number) => fitRef.current(leftOverlayWidth),

Check warning on line 683 in src/renderer/CanvasView.tsx

View workflow job for this annotation

GitHub Actions / typecheck · lint · test

'leftOverlayWidth' is already declared in the upper scope on line 194 column 181
recenter: (leftOverlayWidth?: number) => recenterRef.current(leftOverlayWidth),

Check warning on line 684 in src/renderer/CanvasView.tsx

View workflow job for this annotation

GitHub Actions / typecheck · lint · test

'leftOverlayWidth' is already declared in the upper scope on line 194 column 181
getLastAction: () => lastActionRef.current,
camera: {translateX, translateY, scale, isPinching},
find,
Expand Down Expand Up @@ -1138,6 +1140,7 @@
bottomInset={minimapBottomInset}
safeArea={safeAreaInsets}
background={minimapBackground}
cornerRadius={minimapCornerRadius}
/>
)}
</View>
Expand Down
1 change: 0 additions & 1 deletion src/renderer/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export {CanvasView} from './CanvasView';
export {CanvasMinimap, type MinimapPosition} from './CanvasMinimap';
export {CanvasGlass, CanvasGlassButton, type CanvasGlassProps, type CanvasGlassButtonProps} from './CanvasGlass';
export {getNodeColors, resolveScheme, type ColorScheme} from './theme';
export {useCanvasContext, CanvasProvider} from './CanvasContext';
export {activateScrollWheel, deactivateScrollWheel} from './NativeScrollWheelView';
Expand Down
Loading