Skip to content

Commit 199123a

Browse files
committed
Adding borderRadius prop for RectShape.
1 parent 02029b0 commit 199123a

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
@@ -27,12 +27,19 @@ export type Motion = "bounce" | "fade" | "slide";
2727
export type Shape = "circle" | "rectangle";
2828

2929
export interface ShapeOptions {
30+
/**
31+
* The rounding radius of the rectangle shape corners.
32+
* Ignored if `type` is `"circle"`.
33+
*
34+
* @default 4
35+
*/
36+
borderRadius?: number;
3037
/**
3138
* The padding of the spot shape based on the wrapped component. A zero
3239
* padding means the spot shape will fit exactly around the wrapped
3340
* component. The padding value is a number in points.
3441
*
35-
* @default 16;
42+
* @default 16
3643
*/
3744
padding?: number;
3845
/**

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+
? { borderRadius, padding, type: "circle", ...options }
113+
: { borderRadius, padding, type: options };
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)