This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: integrate frontend sdk to have flexible frontend sdk
- Loading branch information
1 parent
30fcf4e
commit 36a4d91
Showing
7 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
packages/revert-next/app/dashboard/onboarding/FrontendSDKContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { CopyToClipboard } from '@revertdotdev/components'; | ||
import { inter } from '@revertdotdev/fonts'; | ||
import { sdkContent } from '@revertdotdev/lib/constants'; | ||
|
||
function FrontendSDKContent({ value }: { value: string }) { | ||
return ( | ||
<div> | ||
<div className="mb-4"> | ||
<div className="mb-4 flex justify-between items-center"> | ||
<div> | ||
<h1 className={`${inter.className} mb-1 text-lg font-medium`}>Getting Started</h1> | ||
<p className="text-gray-50 text-sm">In your frontend, install the npm package</p> | ||
</div> | ||
</div> | ||
<CopyToClipboard value={sdkContent[value].command} /> | ||
</div> | ||
<div className="mb-4"> | ||
<div className="mb-4 flex justify-between items-center"> | ||
<div> | ||
<h1 className={`${inter.className} mb-1 text-lg font-medium`}>Usage</h1> | ||
<p className="text-gray-50 text-sm"> | ||
1. Adding the {'<'} | ||
<span>RevertConnect</span> | ||
{'>'} component will instantly give your app a way for your users to connect their tools by | ||
opening our Modal on clicking where they will be a able to choose & connect their 3rd party | ||
tool. | ||
</p> | ||
</div> | ||
</div> | ||
<CopyToClipboard value={sdkContent[value].step1} height={value === 'react' ? '25vh' : '52vh'} /> | ||
</div> | ||
<div className="mb-4"> | ||
<p className="text-gray-50 text-sm mb-1"> | ||
2. If you wish to use your own UI for it you can use the useRevertConnnect hook and call | ||
the open() method when appropriate. For example: | ||
</p> | ||
<CopyToClipboard value={sdkContent[value].step2} height={value === 'react' ? '43vh' : '53vh'} /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default FrontendSDKContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/revert-next/components/ui/common/CopyToClipboard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use client'; | ||
|
||
import { Icons } from '@revertdotdev/icons'; | ||
import { useClipboard } from 'use-clipboard-copy'; | ||
import React from 'react'; | ||
|
||
type CopyToClipboardProps = { | ||
value: string; | ||
height?: string | number; // Optional height prop to control height | ||
}; | ||
export function CopyToClipboard({ value, height = 'auto' }: CopyToClipboardProps) { | ||
const clipboard = useClipboard({ | ||
copiedTimeout: 600, | ||
}); | ||
|
||
return ( | ||
<div className="w-full max-w-[64rem]"> | ||
<div className="relative"> | ||
<pre | ||
ref={clipboard.target} | ||
className="col-span-6 bg-gray-50/5 border border-gray-25/5 text-gray-50/80 text-sm rounded-lg p-2.5 overflow-auto" | ||
style={{ height }} | ||
> | ||
<code>{value}</code> | ||
</pre> | ||
<button | ||
className="absolute end-2 top-2 rounded-lg p-2 inline-flex hover:bg-gray-25 items-center justify-center revert-focus-outline" | ||
onClick={() => clipboard.copy(value)} | ||
> | ||
{clipboard.copied ? <Icons.success /> : <Icons.copy />} | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters