Sidebar polish round. Menus. `dropdown-menu` and `context-menu` were two copies of one engine that differed only in how the trigger fires — identical from `computePosition` down — and neither could nest. Both are now thin wrappers over `components/ui/menu/`, which owns anchoring, a pure page-stack navigation model, and one presentation fork: flyout on pointer, pushed pages in a sheet on compact. All 31 call sites are unchanged. Items got a rounded inset fill, a visible separator, and `selected` (a check) split from `active` (a fill). Sidebar display preferences. The flat wall of four sections becomes one row per decision with its value, and per-feature toggles over what a workspace row shows: host, pull request, checks, scripts. Each is independent — a ticked toggle that draws nothing is a lie. `display-preferences/` hides that grouping lives in zustand while title source and row items are app settings. Timestamps. "Last activity" now ticks itself. The label rounds to the minute and never shows seconds; past a week it becomes a date. The timer lives in the leaf `<Text>`, at most one per resolution tier shared by every row, and a tick only re-renders when the string actually changed — so a memoized row that legitimately never re-renders still stays current. Colour. Full status tier regenerated at 90% of gamut max (was 85), same rule as the muted tier, lightness and hue untouched. File icons are pulled toward neutral in OKLab behind `getFileIconSvg` — material-icon-theme picks its palette for a tree where the icon is the only colour on the row, and ours is not. New/deleted files use the forge square-plus/square-minus glyphs at muted weight instead of tinted pills. Project icons round a little more; uploaded icons never do. The project status badge is a knockout again: it fills with the colour of the row behind it, so the ring reads as a gap in the icon rather than a white halo. File rows. The always-visible kebab is gone from the file explorer and diff tree in favour of right-click, which also reclaims the reserved action slot.
164 lines
4.3 KiB
TypeScript
164 lines
4.3 KiB
TypeScript
import { useEffect, useMemo, useRef } from "react";
|
|
import { Animated, View, type StyleProp, type ViewStyle } from "react-native";
|
|
import { StyleSheet } from "react-native-unistyles";
|
|
import { projectIconRadius } from "@/components/project-icon-view";
|
|
|
|
const PROJECT_ICON_SIZE = 16;
|
|
|
|
const SECTION_OPACITIES: readonly number[] = [1, 0.7, 0.4];
|
|
const SECTION_KEYS = SECTION_OPACITIES.map((_, i) => `skeleton-section-${i}`);
|
|
const ROW_KEYS_BY_SECTION: readonly (readonly string[])[] = SECTION_OPACITIES.map((_, sIdx) =>
|
|
[0, 1, 2].map((r) => `skeleton-row-${sIdx}-${r}`),
|
|
);
|
|
|
|
function SkeletonPulse({ pulse, style }: { pulse: Animated.Value; style: StyleProp<ViewStyle> }) {
|
|
const opacity = pulse.interpolate({
|
|
inputRange: [0, 1],
|
|
outputRange: [0.4, 0.8],
|
|
});
|
|
|
|
const pulseStyle = useMemo(() => [style, { opacity }], [style, opacity]);
|
|
|
|
return <Animated.View style={pulseStyle} />;
|
|
}
|
|
|
|
function SkeletonSection({
|
|
pulse,
|
|
sectionOpacity,
|
|
sectionIdx,
|
|
}: {
|
|
pulse: Animated.Value;
|
|
sectionOpacity: number;
|
|
sectionIdx: number;
|
|
}) {
|
|
const sectionStyle = useMemo(
|
|
() => [styles.section, { opacity: sectionOpacity }],
|
|
[sectionOpacity],
|
|
);
|
|
return (
|
|
<View style={sectionStyle}>
|
|
<View style={styles.sectionHeader}>
|
|
<SkeletonPulse pulse={pulse} style={styles.chevron} />
|
|
<SkeletonPulse pulse={pulse} style={styles.projectIcon} />
|
|
<SkeletonPulse pulse={pulse} style={styles.sectionTitle} />
|
|
</View>
|
|
|
|
<View style={styles.rows}>
|
|
{ROW_KEYS_BY_SECTION[sectionIdx]?.map((key) => (
|
|
<View key={key} style={styles.row}>
|
|
<SkeletonPulse pulse={pulse} style={styles.rowDot} />
|
|
<SkeletonPulse pulse={pulse} style={styles.rowTitle} />
|
|
<SkeletonPulse pulse={pulse} style={styles.rowBadge} />
|
|
</View>
|
|
))}
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
export function SidebarAgentListSkeleton() {
|
|
const pulse = useRef(new Animated.Value(0)).current;
|
|
|
|
useEffect(() => {
|
|
const animation = Animated.loop(
|
|
Animated.sequence([
|
|
Animated.timing(pulse, {
|
|
toValue: 1,
|
|
duration: 1000,
|
|
useNativeDriver: true,
|
|
}),
|
|
Animated.timing(pulse, {
|
|
toValue: 0,
|
|
duration: 1000,
|
|
useNativeDriver: true,
|
|
}),
|
|
]),
|
|
);
|
|
|
|
animation.start();
|
|
return () => animation.stop();
|
|
}, [pulse]);
|
|
|
|
return (
|
|
<View style={styles.container}>
|
|
{SECTION_OPACITIES.map((sectionOpacity, sectionIdx) => (
|
|
<SkeletonSection
|
|
key={SECTION_KEYS[sectionIdx]}
|
|
pulse={pulse}
|
|
sectionOpacity={sectionOpacity}
|
|
sectionIdx={sectionIdx}
|
|
/>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create((theme) => ({
|
|
container: {
|
|
flex: 1,
|
|
paddingTop: theme.spacing[2],
|
|
paddingBottom: theme.spacing[4],
|
|
},
|
|
section: {
|
|
marginHorizontal: theme.spacing[2],
|
|
marginBottom: theme.spacing[2],
|
|
},
|
|
sectionHeader: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: theme.spacing[2],
|
|
paddingVertical: theme.spacing[2],
|
|
paddingHorizontal: theme.spacing[3],
|
|
marginTop: theme.spacing[2],
|
|
marginBottom: theme.spacing[2],
|
|
},
|
|
chevron: {
|
|
width: 14,
|
|
height: 14,
|
|
borderRadius: theme.borderRadius.sm,
|
|
backgroundColor: theme.colors.surface2,
|
|
},
|
|
projectIcon: {
|
|
width: PROJECT_ICON_SIZE,
|
|
height: PROJECT_ICON_SIZE,
|
|
// Matches the real icon it stands in for, so the skeleton doesn't change shape on load.
|
|
borderRadius: projectIconRadius(PROJECT_ICON_SIZE),
|
|
backgroundColor: theme.colors.surface2,
|
|
},
|
|
sectionTitle: {
|
|
width: "45%",
|
|
height: 12,
|
|
borderRadius: theme.borderRadius.sm,
|
|
backgroundColor: theme.colors.surface2,
|
|
},
|
|
rows: {
|
|
gap: theme.spacing[1],
|
|
},
|
|
row: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: theme.spacing[2],
|
|
paddingVertical: theme.spacing[2],
|
|
paddingHorizontal: theme.spacing[3],
|
|
marginLeft: theme.spacing[1],
|
|
},
|
|
rowDot: {
|
|
width: 8,
|
|
height: 8,
|
|
borderRadius: theme.borderRadius.full,
|
|
backgroundColor: theme.colors.surface2,
|
|
},
|
|
rowTitle: {
|
|
flex: 1,
|
|
height: 12,
|
|
borderRadius: theme.borderRadius.sm,
|
|
backgroundColor: theme.colors.surface2,
|
|
},
|
|
rowBadge: {
|
|
width: 40,
|
|
height: 20,
|
|
borderRadius: theme.borderRadius.md,
|
|
backgroundColor: theme.colors.surface2,
|
|
},
|
|
}));
|