Skip to content

Commit 27a581f

Browse files
committed
Adding borderRadius prop for RectShape.
1 parent 02029b0 commit 27a581f

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

package/src/helpers/shape.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface RefNode {
77
}
88

99
export interface ShapeProps {
10+
borderRadius: number;
1011
motion: Motion;
1112
padding: number;
1213
setReference: (node?: RefNode) => void;

package/src/lib/SpotlightTour.context.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ShapeOptions {
3232
* padding means the spot shape will fit exactly around the wrapped
3333
* component. The padding value is a number in points.
3434
*
35-
* @default 16;
35+
* @default 16
3636
*/
3737
padding?: number;
3838
/**
@@ -43,6 +43,13 @@ export interface ShapeOptions {
4343
* @default circle
4444
*/
4545
type?: Shape;
46+
/**
47+
* The rounding radius of the rectangle shape corners.
48+
* Ignored if `type` is `"circle"`.
49+
*
50+
* @default 4
51+
*/
52+
borderRadius?: number;
4653
}
4754

4855
export interface RenderProps {

package/src/lib/components/tour-overlay/TourOverlay.component.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ export const TourOverlay = forwardRef<TourOverlayRef, TourOverlayProps>((props,
106106
const shapeOptions = useMemo((): Required<ShapeOptions> => {
107107
const options = tourStep.shape ?? shape;
108108
const padding = 16;
109+
const borderRadius = 4;
109110

110111
return typeof options !== "string"
111-
? { padding, type: "circle", ...options }
112-
: { padding, type: options };
112+
? { padding, type: "circle", borderRadius, ...options }
113+
: { padding, type: options, borderRadius };
113114
}, [tourStep, shape]);
114115

115116
const useNativeDriver = useMemo(() => {
@@ -206,6 +207,7 @@ export const TourOverlay = forwardRef<TourOverlayRef, TourOverlayProps>((props,
206207
setReference={refs.setReference}
207208
motion={stepMotion}
208209
padding={shapeOptions.padding}
210+
borderRadius={shapeOptions.borderRadius}
209211
useNativeDriver={useNativeDriver}
210212
/>
211213
</Mask>

package/src/lib/components/tour-overlay/shapes/RectShape.component.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { type ShapeProps, transitionOf } from "../../../../helpers/shape";
88
const AnimatedRect = Animated.createAnimatedComponent(Rect);
99

1010
export const RectShape = memo<ShapeProps>(props => {
11-
const { motion, padding, setReference, spot, useNativeDriver } = props;
11+
const { borderRadius, motion, padding, setReference, spot, useNativeDriver } = props;
1212

1313
const width = useMemo((): number => {
1414
return spot.width + padding;
@@ -60,8 +60,8 @@ export const RectShape = memo<ShapeProps>(props => {
6060
height={size.y}
6161
opacity={opacity}
6262
fill="black"
63-
rx={4}
64-
ry={4}
63+
rx={borderRadius}
64+
ry={borderRadius}
6565
/>
6666
);
6767
}, isEqual);

0 commit comments

Comments
 (0)