Skip to content

Commit

Permalink
Alpha (#142)
Browse files Browse the repository at this point in the history
* feat: Support embedding modal into page.  (#135)

* docs: Change `@totejs/uikit` -> `@node-real/uikit`

* fix: Update grid layout condition

* feat: Support embedding modal into page.

* chore: update versions (alpha) (#136)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix: Fixed ssr issue (#137)

* docs: Change `@totejs/uikit` -> `@node-real/uikit`

* fix: Update grid layout condition

* feat: Support embedding modal into page.

* fix: Fixed ssr issue

* chore: update versions (alpha) (#138)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* docs: Update docs (#139)

* docs: Change `@totejs/uikit` -> `@node-real/uikit`

* fix: Update grid layout condition

* feat: Support embedding modal into page.

* fix: Fixed ssr issue

* docs: Update docs

* docs: Update docs (#140)

* docs: Change `@totejs/uikit` -> `@node-real/uikit`

* fix: Update grid layout condition

* feat: Support embedding modal into page.

* fix: Fixed ssr issue

* docs: Update docs

* docs: Update docs

* Update docs (#141)

* docs: Change `@totejs/uikit` -> `@node-real/uikit`

* fix: Update grid layout condition

* feat: Support embedding modal into page.

* fix: Fixed ssr issue

* docs: Update docs

* docs: Update docs

* docs: Update docs

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent ac90453 commit f81777b
Show file tree
Hide file tree
Showing 95 changed files with 962 additions and 595 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-bulldogs-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@node-real/walletkit": patch
---

Support embedding modal into page.
5 changes: 5 additions & 0 deletions .changeset/olive-brooms-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@node-real/walletkit": patch
---

Fixed ssr issue
14 changes: 14 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"mode": "pre",
"tag": "alpha",
"initialVersions": {
"example-nextjs": "0.0.1",
"example-vite": "0.0.1",
"@node-real/walletkit": "1.0.11",
"website": "0.0.1"
},
"changesets": [
"eight-bulldogs-heal",
"olive-brooms-lie"
]
}
12 changes: 12 additions & 0 deletions packages/walletkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @node-real/walletkit

## 1.0.12-alpha.1

### Patch Changes

- 3a9e8f0: Fixed ssr issue

## 1.0.12-alpha.0

### Patch Changes

- 2e73c6b: Support embedding modal into page.

## 1.0.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/walletkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@node-real/walletkit",
"version": "1.0.11",
"version": "1.0.12-alpha.1",
"author": "node-real",
"private": false,
"description": "WalletKit is a React component library for easily connecting a wallet to your dApp.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { cx } from '@/base/utils/css';
import { Box, BoxProps } from '../../Box';
import { clsModalContent } from './style.css';

export type ModalContentProps = BoxProps;

export function ModalContent(props: ModalContentProps) {
const { className, ...restProps } = props;

return <Box className={cx('wk-modal-content', clsModalContent, className)} {...restProps} />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { cssVar } from '@/base/utils/css';
import { mobile } from '@/base/vanilla/index.css';
import { style } from '@vanilla-extract/css';

export const clsModalContent = style({
position: 'absolute',
background: cssVar('modalBackground'),
padding: '48px 24px',
width: 'calc(100% - 32px)',
maxWidth: 484,
borderRadius: cssVar('modal', 'radii'),
'@media': mobile({
width: '100%',
maxWidth: '100vw',
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
paddingBottom: 40,
left: 0,
bottom: 0,
}),
});
7 changes: 3 additions & 4 deletions packages/walletkit/src/base/components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { cx } from '@/base/utils/css';
import { BoxProps, Box } from '../Box';
import { Portal } from '../Portal';
import { Transition } from '../Transition';
import { clsModal, clsModalOverlay, clsModalContent } from './styles.css';
import { clsModal, clsModalOverlay } from './styles.css';
import { useScrollLock } from '@/base/hooks/useScrollLock';
import { useResponsive } from '@/base/hooks/useResponsive';
import { ModalContent } from './ModalContent';

export interface ModalProps extends BoxProps {
isOpen: boolean;
Expand Down Expand Up @@ -49,9 +50,7 @@ export function Modal(props: ModalProps) {
onClick={() => closeOnOverlayClick && onClose()}
/>
<Transition in={isOpen} variant={isMobileLayout ? 'modal-slide' : undefined}>
<Box className={cx('wk-modal-content', clsModalContent, contentClassName)}>
{children}
</Box>
<ModalContent className={contentClassName}>{children}</ModalContent>
</Transition>
</Box>
</Transition>
Expand Down
18 changes: 0 additions & 18 deletions packages/walletkit/src/base/components/Modal/styles.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,3 @@ export const clsModalOverlay = style({
height: '100%',
backgroundColor: cssVar('modalOverlay'),
});

export const clsModalContent = style({
position: 'absolute',
background: cssVar('modalBackground'),
padding: '48px 24px',
width: 'calc(100% - 32px)',
maxWidth: 484,
borderRadius: cssVar('modal', 'radii'),
'@media': mobile({
width: '100%',
maxWidth: '100vw',
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
paddingBottom: 40,
left: 0,
bottom: 0,
}),
});
4 changes: 2 additions & 2 deletions packages/walletkit/src/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BoxProps, Box } from '@/base/components/Box';
import { cx } from '@/index';
import { useEnsAddress, useEnsAvatar, useEnsName } from 'wagmi';
import { Address, useEnsAddress, useEnsAvatar, useEnsName } from 'wagmi';
import { clsAvatar, clsAvatarImg, clsAvatarDefault } from './styles.css';

export interface AvatarProps extends BoxProps {
address?: `0x${string}`;
address?: Address;
name?: string | undefined;
}

Expand Down
22 changes: 19 additions & 3 deletions packages/walletkit/src/components/DisconnectButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { ButtonProps, Button } from '@/base/components/Button';
import { ExitIcon } from '@/base/icons/ExitIcon';
import { cx } from '@/index';
import { useConnect, useDisconnect } from 'wagmi';
import { useModal } from '../ModalProvider/context';
import { clsContainer } from './styles.css';
import { useProfileModal } from '@/components/ProfileModal/ProfileModalProvider/context';
import { useSwitchNetworkModal } from '@/components/SwitchNetworkModal/SwitchNetworkProvider/context';
import { useWalletKitModal } from '@/components/WalletKitModal/WalletKitModalProvider/context';

export type DisconnectButtonProps = ButtonProps;

Expand All @@ -12,10 +14,10 @@ export function DisconnectButton(props: DisconnectButtonProps) {

const { reset } = useConnect();
const { disconnect } = useDisconnect();
const { onClose } = useModal();
const { onCloseAllModals } = useCloseAllModals();

const onDisconnect = () => {
onClose();
onCloseAllModals();
setTimeout(() => {
disconnect();
reset();
Expand All @@ -33,3 +35,17 @@ export function DisconnectButton(props: DisconnectButtonProps) {
</Button>
);
}

function useCloseAllModals() {
const walletkitModal = useWalletKitModal();
const switchNetworkModal = useSwitchNetworkModal();
const profileModal = useProfileModal();

return {
onCloseAllModals() {
walletkitModal.onClose();
switchNetworkModal.onClose();
profileModal.onClose();
},
};
}
28 changes: 0 additions & 28 deletions packages/walletkit/src/components/ModalProvider/context.ts

This file was deleted.

98 changes: 0 additions & 98 deletions packages/walletkit/src/components/ModalProvider/index.tsx

This file was deleted.

20 changes: 7 additions & 13 deletions packages/walletkit/src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,27 @@ import { IconButton } from '@/base/components/IconButton';
import { BackIcon } from '@/base/icons/BackIcon';
import { CloseIcon } from '@/base/icons/CloseIcon';
import { cx } from '@/index';
import { useModal } from '../ModalProvider/context';
import { useRouter } from '../RouteProvider/context';
import { clsNavbar } from './styles.css';
import { useRouter } from '../RouteProvider/context';

export interface NavbarProps extends BoxProps {
showBack?: boolean;
onBack?: () => void;
onClose?: () => void;
}

export function Navbar(props: NavbarProps) {
const { className, showBack = false, onBack, ...restProps } = props;
const { className, onClose, ...restProps } = props;

const { onClose: onCloseModal } = useModal();
const router = useRouter();
const { history, back } = useRouter();

const onBeforeBack = () => {
onBack?.();
router.back();
};
const showBack = history.length > 1;

return (
<Box className={cx('wk-navbar', clsNavbar, className)} {...restProps}>
{showBack && (
<IconButton className="wk-navbar-back-button" icon={<BackIcon />} onClick={onBeforeBack} />
<IconButton className="wk-navbar-back-button" icon={<BackIcon />} onClick={back} />
)}
<Box style={{ flex: 1 }} />
<IconButton className="wk-navbar-close-button" icon={<CloseIcon />} onClick={onCloseModal} />
<IconButton className="wk-navbar-close-button" icon={<CloseIcon />} onClick={onClose} />
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { useContext } from 'react';

export interface ProfileModalContextProps {
isOpen: boolean;
onClose: () => void;
onOpen: () => void;
}

export const ProfileModalContext = React.createContext({} as ProfileModalContextProps);

export function useProfileModal() {
return useContext(ProfileModalContext);
}
Loading

0 comments on commit f81777b

Please sign in to comment.