Skip to content
Open
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
1 change: 1 addition & 0 deletions package/src/helpers/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface RefNode {
}

export interface ShapeProps {
borderRadius: number;
motion: Motion;
padding: number;
setReference: (node?: RefNode) => void;
Expand Down
9 changes: 8 additions & 1 deletion package/src/lib/SpotlightTour.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ export type Motion = "bounce" | "fade" | "slide";
export type Shape = "circle" | "rectangle";

export interface ShapeOptions {
/**
* The rounding radius of the rectangle shape corners.
* Ignored if `type` is `"circle"`.
*
* @default 4
*/
borderRadius?: number;
/**
* The padding of the spot shape based on the wrapped component. A zero
* padding means the spot shape will fit exactly around the wrapped
* component. The padding value is a number in points.
*
* @default 16;
* @default 16
*/
padding?: number;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ export const TourOverlay = forwardRef<TourOverlayRef, TourOverlayProps>((props,
const shapeOptions = useMemo((): Required<ShapeOptions> => {
const options = tourStep.shape ?? shape;
const padding = 16;
const borderRadius = 4;

return typeof options !== "string"
? { padding, type: "circle", ...options }
: { padding, type: options };
? { borderRadius, padding, type: "circle", ...options }
: { borderRadius, padding, type: options };
}, [tourStep, shape]);

const useNativeDriver = useMemo(() => {
Expand Down Expand Up @@ -206,6 +207,7 @@ export const TourOverlay = forwardRef<TourOverlayRef, TourOverlayProps>((props,
setReference={refs.setReference}
motion={stepMotion}
padding={shapeOptions.padding}
borderRadius={shapeOptions.borderRadius}
useNativeDriver={useNativeDriver}
/>
</Mask>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { type ShapeProps, transitionOf } from "../../../../helpers/shape";
const AnimatedRect = Animated.createAnimatedComponent(Rect);

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

const width = useMemo((): number => {
return spot.width + padding;
Expand Down Expand Up @@ -60,8 +60,8 @@ export const RectShape = memo<ShapeProps>(props => {
height={size.y}
opacity={opacity}
fill="black"
rx={4}
ry={4}
rx={borderRadius}
ry={borderRadius}
/>
);
}, isEqual);