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: connectkit docs demo #339

Merged
merged 4 commits into from
Feb 2, 2024
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
9 changes: 9 additions & 0 deletions examples/testbench/src/pages/demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { NextPage } from 'next';

import { ConnectKitModalDemo } from 'connectkit';

const Demo: NextPage = () => {
return <ConnectKitModalDemo open />;
};

export default Demo;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"dev:connectkit-next-siwe": "yarn workspace connectkit-next-siwe run dev",
"dev:cra": "yarn workspace cra run dev",
"dev:nextjs": "yarn workspace nextjs run dev",
"dev:nextjs-app": "yarn workspace nextjs-app run dev",
"dev:nextjs-siwe": "yarn workspace nextjs-siwe run dev",
"dev:vite": "yarn workspace vite run dev",
"dev:testbench": "yarn workspace testbench run dev",
"build": "node build.js && yarn workspace connectkit run build && cp README.md packages/connectkit/README.md",
"build:connectkit-next-siwe": "yarn workspace connectkit-next-siwe run build",
"build:cra": "yarn build && yarn workspace cra build",
"build:nextjs": "yarn build && yarn workspace nextjs build",
"build:nextjs-app": "yarn build && yarn workspace nextjs-app build",
"build:nextjs-siwe": "yarn build && yarn workspace nextjs-siwe build",
"build:vite": "yarn build && yarn workspace vite build",
"build:testbench": "yarn build && yarn build:connectkit-next-siwe && yarn workspace testbench build",
Expand Down
2 changes: 1 addition & 1 deletion packages/connectkit/src/components/ConnectKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const ConnectKitProvider = ({
Context.Provider,
{ value },
<>
<Web3ContextProvider>
<Web3ContextProvider enabled={open}>
<ThemeProvider theme={defaultTheme}>
{children}
<ConnectKitModal
Expand Down
67 changes: 35 additions & 32 deletions packages/connectkit/src/components/ConnectModal/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ConnectKitThemeProvider } from '../ConnectKitThemeProvider/ConnectKitTh
import styled from './../../styles/styled';
import { keyframes } from 'styled-components';
import { useChains } from '../../hooks/useChains';
import { Web3ContextProvider } from '../contexts/web3';

const dist = 8;
const shake = keyframes`
Expand Down Expand Up @@ -223,38 +224,40 @@ const ConnectModal: React.FC<{
}, [open, inline]);

return (
<ConnectKitThemeProvider
theme={theme}
customTheme={customTheme}
mode={mode}
>
<Container ref={ref}>
{inline && onClose && (
<>
<Cursor ref={cursorRef} />
<ButtonContainer>
<ConnectKitButton
customTheme={customTheme}
theme={theme}
mode={mode}
/>
</ButtonContainer>
</>
)}
<Modal
demo={{ theme: theme, customTheme: customTheme, mode: mode }}
onClose={closeable ? onModalClose : undefined}
positionInside={inline}
open={isOpen}
pages={pages}
pageId={context.route}
onInfo={
showInfoButton ? () => context.setRoute(routes.ABOUT) : undefined
}
onBack={showBackButton ? onBack : undefined}
/>
</Container>
</ConnectKitThemeProvider>
<Web3ContextProvider enabled={open}>
<ConnectKitThemeProvider
theme={theme}
customTheme={customTheme}
mode={mode}
>
<Container ref={ref}>
{inline && onClose && (
<>
<Cursor ref={cursorRef} />
<ButtonContainer>
<ConnectKitButton
customTheme={customTheme}
theme={theme}
mode={mode}
/>
</ButtonContainer>
</>
)}
<Modal
demo={{ theme: theme, customTheme: customTheme, mode: mode }}
onClose={closeable ? onModalClose : undefined}
positionInside={inline}
open={isOpen}
pages={pages}
pageId={context.route}
onInfo={
showInfoButton ? () => context.setRoute(routes.ABOUT) : undefined
}
onBack={showBackButton ? onBack : undefined}
/>
</Container>
</ConnectKitThemeProvider>
</Web3ContextProvider>
);
};

Expand Down
7 changes: 4 additions & 3 deletions packages/connectkit/src/components/contexts/web3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ const Web3Context = React.createContext({
} as Web3Context);

export const Web3ContextProvider = ({
enabled,
children,
}: {
enabled?: boolean;
children: React.ReactNode;
}) => {
const context = useContext();
const isMobile = useIsMobile();

const { uri: walletConnectUri } = useWalletConnectUri({
enabled: context.open,
enabled,
});
const { uri: coinbaseWalletUri } = useCoinbaseWalletUri({
enabled: context.open && !isMobile,
enabled: enabled && !isMobile,
});

const { address: currentAddress, chain } = useAccount();
Expand Down
Loading
Loading