Skip to content

Commit

Permalink
Merge branch 'master' into fix/torus
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaaash committed Oct 26, 2021
2 parents a0da7e9 + 3addc1a commit 69f0039
Show file tree
Hide file tree
Showing 9 changed files with 933 additions and 699 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ To add it to your dApp, you only need the core packages and UI components for yo
### Core
These packages are what most projects can use to support wallets on Solana.

| package | description | npm |
| --------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| package | description | npm |
| --------------------------------------------------------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| [wallets](https://github.com/solana-labs/wallet-adapter/tree/master/packages/core/wallets) | All wallets with icons | [`@solana/wallet-adapter-wallets`](https://npmjs.com/package/@solana/wallet-adapter-wallets) |
| [base](https://github.com/solana-labs/wallet-adapter/tree/master/packages/core/base) | Adapter interfaces, error types, and common utilities | [`@solana/wallet-adapter-base`](https://npmjs.com/package/@solana/wallet-adapter-base) |
| [react](https://github.com/solana-labs/wallet-adapter/tree/master/packages/core/react) | Contexts and hooks for React dApps | [`@solana/wallet-adapter-react`](https://npmjs.com/package/@solana/wallet-adapter-react) |
Expand All @@ -175,21 +175,19 @@ These packages are what most projects can use to support wallets on Solana.
### UI Components
These packages provide components for common UI frameworks.

| package | description | npm |
| ------------------------------------------------------------------------------------------------ | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| package | description | npm |
| ------------------------------------------------------------------------------------------------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [material-ui](https://github.com/solana-labs/wallet-adapter/tree/master/packages/ui/material-ui) | Components for [Material UI](https://material-ui.com) | [`@solana/wallet-adapter-material-ui`](https://npmjs.com/package/@solana/wallet-adapter-material-ui) |
| [ant-design](https://github.com/solana-labs/wallet-adapter/tree/master/packages/ui/ant-design) | Components for [Ant Design](https://ant.design) | [`@solana/wallet-adapter-ant-design`](https://npmjs.com/package/@solana/wallet-adapter-ant-design) |
| [react-ui](https://github.com/solana-labs/wallet-adapter/tree/master/packages/ui/react-ui) | Components for React (no UI framework, just CSS) | [`@solana/wallet-adapter-react-ui`](https://npmjs.com/package/@solana/wallet-adapter-react-ui) |
| [vue-ui](https://github.com/solana-labs/wallet-adapter/tree/master/packages/ui/vue-ui) \* | Components for Vue (no UI framework, just CSS) | [`@solana/wallet-adapter-vue-ui`](https://npmjs.com/package/@solana/wallet-adapter-vue-ui) |

\* Package has not been published to NPM yet.
| [vue-ui](https://github.com/solana-labs/wallet-adapter/tree/master/packages/ui/vue-ui) | Components for Vue (no UI framework, just CSS) | [`@solana/wallet-adapter-vue-ui`](https://npmjs.com/package/@solana/wallet-adapter-vue-ui) |

### Starter Projects
These packages provide projects that you can use to start building a dApp with built-in wallet support.
Alternatively, check out [dapp-scaffold](https://github.com/solana-labs/dapp-scaffold) for a more complete framework.

| package | description | npm |
| --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| package | description | npm |
| --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [example](https://github.com/solana-labs/wallet-adapter/tree/master/packages/starter/example) | Demo of UI components | [`@solana/wallet-adapter-example`](https://npmjs.com/package/@solana/wallet-adapter-example) |
| [material-ui-starter](https://github.com/solana-labs/wallet-adapter/tree/master/packages/starter/material-ui-starter) | [Create React App](https://create-react-app.dev) project using Material UI | [`@solana/wallet-adapter-material-ui-starter`](https://npmjs.com/package/@solana/wallet-adapter-material-ui-starter) |
| [react-ui-starter](https://github.com/solana-labs/wallet-adapter/tree/master/packages/starter/react-ui-starter) | [Create React App](https://create-react-app.dev) project using React UI | [`@solana/wallet-adapter-react-ui-starter`](https://npmjs.com/package/@solana/wallet-adapter-react-ui-starter) |
Expand Down
2 changes: 1 addition & 1 deletion packages/core/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solana/wallet-adapter-vue",
"version": "0.3.0",
"version": "0.3.1",
"author": "Solana Maintainers <[email protected]>",
"repository": "https://github.com/solana-labs/wallet-adapter",
"license": "Apache-2.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/core/vue/src/useWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ export interface WalletStoreProps {

const walletStoreKey: InjectionKey<WalletStore> = Symbol();

export const useWallet = (): WalletStore | undefined => {
return inject(walletStoreKey);
export const useWallet = (): WalletStore => {
const walletStore = inject(walletStoreKey);
if (!walletStore)
throw new Error('Wallet not initialized. Please use the `WalletProvider` component to initialize the wallet.');
return walletStore;
};

export const initWallet = ({
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/vue-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"private": true,
"name": "@solana/wallet-adapter-vue-ui",
"version": "0.1.0",
"author": "Solana Maintainers <[email protected]>",
"repository": "https://github.com/solana-labs/wallet-adapter",
"license": "Apache-2.0",
"main": "lib/index.js",
"esnext": "lib/index.js",
"types": "lib/src/index.d.ts",
"files": [
"lib",
"src",
Expand Down
25 changes: 17 additions & 8 deletions packages/ui/vue-ui/src/WalletModal.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { useWallet } from "@solana/wallet-adapter-vue";
import { WalletName } from "@solana/wallet-adapter-wallets";
import { computed, defineComponent, ref, watchPostEffect } from "vue";
import { computed, defineComponent, ref, watch } from "vue";
import { useWalletModal } from "./useWalletModal";
import WalletButton from "./WalletButton.vue";
import WalletListItem from "./WalletListItem.vue";
Expand Down Expand Up @@ -54,7 +54,7 @@ export default defineComponent({
}
};
watchPostEffect(onInvalidate => {
watch(visible, (newVisible, oldVisible, onInvalidate) => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
hideModal();
Expand All @@ -64,18 +64,27 @@ export default defineComponent({
};
// Get original overflow
const { overflow } = window.getComputedStyle(document.body);
// Prevent scrolling on mount
document.body.style.overflow = 'hidden';
// Listen for keydown events
window.addEventListener('keydown', handleKeyDown, false);
let overflow = window.getComputedStyle(document.body).overflow;
if (newVisible) {
// Refetch original overflow
overflow = window.getComputedStyle(document.body).overflow;
// Prevent scrolling on mount
document.body.style.overflow = 'hidden';
// Listen for keydown events
window.addEventListener('keydown', handleKeyDown, false);
} else {
// Re-enable scrolling when component unmounts
document.body.style.overflow = overflow;
window.removeEventListener('keydown', handleKeyDown, false);
}
onInvalidate(() => {
// Re-enable scrolling when component unmounts
document.body.style.overflow = overflow;
window.removeEventListener('keydown', handleKeyDown, false);
});
});
}, { immediate: true });
return {
container,
Expand Down
9 changes: 7 additions & 2 deletions packages/ui/vue-ui/src/useWalletModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ export interface WalletModalStore {

const walletModalStoreKey: InjectionKey<WalletModalStore> = Symbol();

export const useWalletModal = (): WalletModalStore | undefined => {
return inject(walletModalStoreKey);
export const useWalletModal = (): WalletModalStore => {
const walletModalStore = inject(walletModalStoreKey);
if (!walletModalStore)
throw new Error(
'Wallet modal not initialized. Please use the `WalletModalProvider` component to initialize the wallet modal.'
);
return walletModalStore;
};

export const initWalletModal = (initiallyVisible = false): void => {
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/vue-ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default defineConfig({
},
},
},
sourcemap: true,
},
plugins: [vue(), dts({ insertTypesEntry: true })],
plugins: [vue(), dts()],
});
26 changes: 25 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,31 @@
"include": ["packages/*/*/src"],
"exclude": ["node_modules", "packages/*/*/node_modules"],
"typedocOptions": {
"entryPoints": ".",
"entryPoints": [
"packages/core/angular",
"packages/core/vue",
"packages/core/wallets",
"packages/core/base",
"packages/core/react",
"packages/ui/ant-design",
"packages/ui/material-ui",
"packages/ui/react-ui",
"packages/wallets/bitkeep",
"packages/wallets/bitpie",
"packages/wallets/blocto",
"packages/wallets/clover",
"packages/wallets/coin98",
"packages/wallets/ledger",
"packages/wallets/mathwallet",
"packages/wallets/phantom",
"packages/wallets/safepal",
"packages/wallets/slope",
"packages/wallets/solflare",
"packages/wallets/sollet",
"packages/wallets/solong",
"packages/wallets/tokenpocket",
"packages/wallets/torus"
],
"entryPointStrategy": "packages",
"out": "docs",
"readme": "README.md"
Expand Down
Loading

0 comments on commit 69f0039

Please sign in to comment.