Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update README to include rounded corners example #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BaderSerhan
Copy link

Credits to @arifqys for providing the custom SVG path.

Copy link

@rexfordessilfie rexfordessilfie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you so much for this @BaderSerhan and @@arifqys! I was starting to itch for it. I left a small comment about parameterizing the border radius. What do you think?

Regarding masks, I wonder if this package could also export some standard SVG masks out of the box. It would also be nice to be able to specify SVG masks per step/tour if/when multi-tours are provided. If you are interested, would you mind creating an issue/PR for it, for when @mohebifar and others to take a look at?

Comment on lines +256 to +265
const roundedRectangleSvgPath = ({ position, canvasSize, size }) => {
const br = 10; // border radius
const sizeX = size.x._value - 2 * br;
const sizeY = size.y._value - 2 * br;
return `M 0 0 H ${canvasSize.x} V ${canvasSize.y} H 0 V 0 Z M ${position.x._value+br} ${position.y._value} Z h ${sizeX} a ${br} ${br} 0 0 1 ${br} ${br} v ${sizeY} a ${br} ${br} 0 0 1 -${br} ${br} h -${sizeX} a ${br} ${br} 0 0 1 -${br} -${br} v -${sizeY} a ${br} ${br} 0 0 1 ${br} -${br} z`;
}

copilot({
svgMaskPath: circleSvgPath
})(RootComponent);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this! Do you think we could make a slight tweak to the example to parameterize the border radius? It could make it more usable for folks

Suggested change
const roundedRectangleSvgPath = ({ position, canvasSize, size }) => {
const br = 10; // border radius
const sizeX = size.x._value - 2 * br;
const sizeY = size.y._value - 2 * br;
return `M 0 0 H ${canvasSize.x} V ${canvasSize.y} H 0 V 0 Z M ${position.x._value+br} ${position.y._value} Z h ${sizeX} a ${br} ${br} 0 0 1 ${br} ${br} v ${sizeY} a ${br} ${br} 0 0 1 -${br} ${br} h -${sizeX} a ${br} ${br} 0 0 1 -${br} -${br} v -${sizeY} a ${br} ${br} 0 0 1 ${br} -${br} z`;
}
copilot({
svgMaskPath: circleSvgPath
})(RootComponent);
function rectangleSvgPath({ borderRadius: br = 2 } = {}) {
function path({ position, canvasSize, size }) {
const sizeX = size.x._value - 2 * br;
const sizeY = size.y._value - 2 * br;
return `M 0 0 H ${canvasSize.x} V ${canvasSize.y} H 0 V 0 Z M ${
position.x._value + br
} ${
position.y._value
} Z h ${sizeX} a ${br} ${br} 0 0 1 ${br} ${br} v ${sizeY} a ${br} ${br} 0 0 1 -${br} ${br} h -${sizeX} a ${br} ${br} 0 0 1 -${br} -${br} v -${sizeY} a ${br} ${br} 0 0 1 ${br} -${br} z`;
}
return path;
}
copilot({
svgMaskPath: rectangleSvgPath({ borderRadius: 10 })
})(RootComponent);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants