Skip to content

Commit

Permalink
StaticSquircle (#11)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bring-shrubbery authored Nov 10, 2023
1 parent 7e8608f commit 84a5477
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"commit": true,
"fixed": [],
"linked": [],
"access": "public",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/eight-jobs-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@squircle-js/react": patch
---

Static squircle test
5 changes: 5 additions & 0 deletions .changeset/little-carpets-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@squircle-js/react": minor
---

Test StaticSquircle component
13 changes: 13 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"mode": "exit",
"tag": "dev",
"initialVersions": {
"web": "1.0.0",
"eslint-config-custom": "0.0.0",
"@squircle-js/react": "1.1.0",
"tsconfig": "1.0.0"
},
"changesets": [
"little-carpets-watch"
]
}
6 changes: 6 additions & 0 deletions packages/squircle-element-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @squircle-js/react

## 1.2.0-dev.0

### Minor Changes

- ba8c348: Test StaticSquircle component

## 1.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/squircle-element-react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@squircle-js/react",
"license": "MIT",
"version": "1.1.0",
"version": "1.2.0-dev.0",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
39 changes: 39 additions & 0 deletions packages/squircle-element-react/src/StaticSquircle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Slot } from "@radix-ui/react-slot";
import { getSvgPath } from "figma-squircle";
import { ComponentPropsWithoutRef, PropsWithChildren, useMemo } from "react";

type StaticSquircleProps = {
asChild?: boolean;

width: number;
height: number;
cornerRadius: number;
cornerSmoothing: number;
};

export const StaticSquircle = ({
asChild,
width,
height,
cornerRadius,
cornerSmoothing,
style,
...props
}: PropsWithChildren<
StaticSquircleProps & ComponentPropsWithoutRef<"div">
>) => {
const Component = asChild ? Slot : "div";

const path = useMemo(() => {
return getSvgPath({
width,
height,
cornerRadius,
cornerSmoothing,
});
}, [width, height, cornerRadius, cornerSmoothing]);

return (
<Component style={{ clipPath: `path('${path}')`, ...style }} {...props} />
);
};
1 change: 1 addition & 0 deletions packages/squircle-element-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ function Squircle<E extends React.ElementType = "div">({
}

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

1 comment on commit 84a5477

@vercel
Copy link

@vercel vercel bot commented on 84a5477 Nov 10, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.