Skip to content

Commit 84a5477

Browse files
StaticSquircle (#11)
* Added StaticSquircle test component * Added missing `style` prop. * Added changeset for test component * Added test component version * Exited pre mode * commit: true * docs(changeset): Static squircle test
1 parent 7e8608f commit 84a5477

File tree

8 files changed

+71
-2
lines changed

8 files changed

+71
-2
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
33
"changelog": "@changesets/cli/changelog",
4-
"commit": false,
4+
"commit": true,
55
"fixed": [],
66
"linked": [],
77
"access": "public",

.changeset/eight-jobs-laugh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@squircle-js/react": patch
3+
---
4+
5+
Static squircle test

.changeset/little-carpets-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@squircle-js/react": minor
3+
---
4+
5+
Test StaticSquircle component

.changeset/pre.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"mode": "exit",
3+
"tag": "dev",
4+
"initialVersions": {
5+
"web": "1.0.0",
6+
"eslint-config-custom": "0.0.0",
7+
"@squircle-js/react": "1.1.0",
8+
"tsconfig": "1.0.0"
9+
},
10+
"changesets": [
11+
"little-carpets-watch"
12+
]
13+
}

packages/squircle-element-react/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @squircle-js/react
22

3+
## 1.2.0-dev.0
4+
5+
### Minor Changes
6+
7+
- ba8c348: Test StaticSquircle component
8+
39
## 1.1.0
410

511
### Minor Changes

packages/squircle-element-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@squircle-js/react",
33
"license": "MIT",
4-
"version": "1.1.0",
4+
"version": "1.2.0-dev.0",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",
77
"types": "dist/index.d.ts",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Slot } from "@radix-ui/react-slot";
2+
import { getSvgPath } from "figma-squircle";
3+
import { ComponentPropsWithoutRef, PropsWithChildren, useMemo } from "react";
4+
5+
type StaticSquircleProps = {
6+
asChild?: boolean;
7+
8+
width: number;
9+
height: number;
10+
cornerRadius: number;
11+
cornerSmoothing: number;
12+
};
13+
14+
export const StaticSquircle = ({
15+
asChild,
16+
width,
17+
height,
18+
cornerRadius,
19+
cornerSmoothing,
20+
style,
21+
...props
22+
}: PropsWithChildren<
23+
StaticSquircleProps & ComponentPropsWithoutRef<"div">
24+
>) => {
25+
const Component = asChild ? Slot : "div";
26+
27+
const path = useMemo(() => {
28+
return getSvgPath({
29+
width,
30+
height,
31+
cornerRadius,
32+
cornerSmoothing,
33+
});
34+
}, [width, height, cornerRadius, cornerSmoothing]);
35+
36+
return (
37+
<Component style={{ clipPath: `path('${path}')`, ...style }} {...props} />
38+
);
39+
};

packages/squircle-element-react/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ function Squircle<E extends React.ElementType = "div">({
6969
}
7070

7171
export { Squircle, type SquircleProps };
72+
export * from "./StaticSquircle";

0 commit comments

Comments
 (0)