The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 38 lines 1.29 KB
Raw
1 import { useState } from "react";
2 import { StyleSheet, View } from "react-native";
3 import Svg, { Path } from "react-native-svg";
4
5 import type { FrostedCutoutProps } from "./FrostedCutout.types";
6
7 export function FrostedCutout(props: FrostedCutoutProps) {
8 const [width, setWidth] = useState(0);
9 const [height, setHeight] = useState(0);
10 const x = (width - props.cutoutWidth) / 2;
11 const y = props.cutoutTop;
12 const w = props.cutoutWidth;
13 const h = props.cutoutHeight;
14 const r = Math.min(props.cutoutRadius, w / 2, h / 2);
15 const hole = `M${x + r},${y} H${x + w - r} A${r},${r} 0 0 1 ${x + w},${y + r} V${y + h - r} A${r},${r} 0 0 1 ${x + w - r},${y + h} H${x + r} A${r},${r} 0 0 1 ${x},${y + h - r} V${y + r} A${r},${r} 0 0 1 ${x + r},${y} Z`;
16
17 return (
18 <View
19 pointerEvents="none"
20 style={StyleSheet.absoluteFill}
21 onLayout={(event) => {
22 setWidth(event.nativeEvent.layout.width);
23 setHeight(event.nativeEvent.layout.height);
24 }}
25 >
26 {width > 0 ? (
27 <Svg height={height} width={width}>
28 <Path
29 d={`M0,0 H${width} V${height} H0 Z ${hole}`}
30 fill={props.appearance === "light" ? "#ffffff" : "#000000"}
31 fillOpacity={0.55}
32 fillRule="evenodd"
33 />
34 </Svg>
35 ) : null}
36 </View>
37 );
38 }