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

134 feat check react component wrapping #135

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions apps/sample-react-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import reactLogo from './assets/react.svg';
import viteLogo from '/vite.svg';
import './App.css';
import { ConnectWalletButtonWithModal } from '@vechainfoundation/dapp-kit-react';
import { VechainDappConnectKit } from '@vechainfoundation/dapp-kit-react';

function App() {
return (
Expand All @@ -20,7 +20,7 @@ function App() {
</div>
<h1>Vite + React</h1>
<div className="card">
<ConnectWalletButtonWithModal />
<VechainDappConnectKit />
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import GlobalFonts from '../../../assets/fonts/fonts';
import { ThemeProvider } from '../../provider/ThemeProvider';
import { VechainDappConnectKitWithTheme } from './Wrapped/VechainDappConnectKitWrapped';

export const VechainDappConnectKit: React.FC = (): React.ReactElement => {
return (
<ThemeProvider>
<GlobalFonts />
<VechainDappConnectKitWithTheme />
</ThemeProvider>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { useMemo } from 'react';
import { createComponent } from '@lit/react';
import { VechainDappConnectKit as VechainDappConnectKitVanilla } from '@vechainfoundation/dapp-kit-ui';
import { useThemeSelector } from '../../../provider/ThemeProvider';

const VechainDappConnectKitWrapped = () =>
createComponent({
tagName: 'vwk-vechain-dapp-connect-kit',
elementClass: VechainDappConnectKitVanilla,
react: React,
});

export const VechainDappConnectKitWithTheme: React.FC = () => {
const { theme } = useThemeSelector();

const VechainDappConnectKit = useMemo(
() => VechainDappConnectKitWrapped(),
[],
);

return <VechainDappConnectKit mode={theme.mode} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './VechainDappConnectKit';
1 change: 1 addition & 0 deletions packages/dapp-kit-react/src/Components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './ConnectWalletButtonWithModal';
export * from './ConnectWalletModal';
export * from './SelectWalletModal';
export * from './VechainDappConnectKit';
4 changes: 3 additions & 1 deletion packages/dapp-kit-react/test/helpers/react-test-helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {
ConnectWalletButtonWithModal,
ConnectWalletModal,
DAppKitProvider,
SelectWalletModal,
VechainDappConnectKit,
ConnectWalletButtonWithModal,
} from '../../src';
import { ThemeProvider } from '../../src/provider/ThemeProvider';

export const wrapper = ({ children }: { children?: React.ReactNode }) => (
<DAppKitProvider nodeUrl="https://testnet.vechain.org">
<ThemeProvider>
{children}
<VechainDappConnectKit />
<ConnectWalletButtonWithModal />
<SelectWalletModal isOpen={false} />
<ConnectWalletModal isOpen={false} />
Expand Down
Loading