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

fix(docs): button custom implementation #1641

Merged
merged 1 commit into from
Sep 16, 2023
Merged
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
5 changes: 5 additions & 0 deletions .changeset/honest-yaks-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/react": patch
---

Ripple component added to @nextui-org/react exports
19 changes: 8 additions & 11 deletions apps/docs/content/components/button/custom-impl.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const App = `import {forwardRef} from "react";
import {useButton, Ripple, Spinner} from "@nextui-org/react";

import {useButton, Drip, Spinner} from "@nextui-org/react";

const MyButton = forwardRef((props, ref) => {
const {
domRef,
children,
classNames,
drips,
ripples,
spinnerSize,
spinner = <Spinner color="current" size={spinnerSize} />,
spinnerPlacement,
Expand All @@ -22,13 +21,13 @@ const MyButton = forwardRef((props, ref) => {
});

return (
<button ref={domRef} className={classNames} {...getButtonProps()}>
<button ref={domRef} {...getButtonProps()}>
{startContent}
{isLoading && spinnerPlacement === "start" && spinner}
{children}
{isLoading && spinnerPlacement === "end" && spinner}
{endContent}
{!disableRipple && <Drip drips={drips} />}
{!disableRipple && <Ripple ripples={ripples} />}
</button>
);
});
Expand All @@ -38,17 +37,15 @@ MyButton.displayName = "MyButton";
export default MyButton;`;

const AppTs = `import {forwardRef} from "react";

import {useButton, Drip, Spinner, ButtonProps as BaseButtonProps} from "@nextui-org/react";
import {useButton, Ripple, Spinner, ButtonProps as BaseButtonProps} from "@nextui-org/react";

export interface ButtonProps extends BaseButtonProps {}

const MyButton = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
const {
domRef,
children,
classNames,
drips,
ripples,
spinnerSize,
spinner = <Spinner color="current" size={spinnerSize} />,
spinnerPlacement,
Expand All @@ -63,13 +60,13 @@ const MyButton = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
});

return (
<button ref={domRef} className={classNames} {...getButtonProps()}>
<button ref={domRef} {...getButtonProps()}>
{startContent}
{isLoading && spinnerPlacement === "start" && spinner}
{children}
{isLoading && spinnerPlacement === "end" && spinner}
{endContent}
{!disableRipple && <Drip drips={drips} />}
{!disableRipple && <Ripple ripples={ripples} />}
</button>
);
});
Expand Down
1 change: 1 addition & 0 deletions packages/core/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@nextui-org/select": "workspace:*",
"@nextui-org/listbox": "workspace:*",
"@nextui-org/menu": "workspace:*",
"@nextui-org/ripple": "workspace:*",
"@react-aria/visually-hidden": "^3.8.4"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/core/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export * from "@nextui-org/scroll-shadow";
export * from "@nextui-org/select";
export * from "@nextui-org/listbox";
export * from "@nextui-org/menu";
export * from "@nextui-org/ripple";

/**
* React Aria - Exports
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.