Skip to content

Commit

Permalink
Merge pull request #161 from vu3th/new-website
Browse files Browse the repository at this point in the history
New website
  • Loading branch information
johnson86tw committed Apr 17, 2024
2 parents e0937a7 + 1e661bd commit 50fe716
Show file tree
Hide file tree
Showing 29 changed files with 18,259 additions and 24,222 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pnpm -F core watch

0x9D75F4EbcB8e7669E59dcc27CBadC698E0F77187

## MIT license
## Credits

Copyright (c) 2021-present, Johnson Chen ([@johnson86tw](https://twitter.com/johnson86tw))
- Vue Dapp Logo by @ramuta https://github.com/vu3th/vue-dapp/issues/24
- Favicon.io - Emoji Favicons > Sheaf Of Rice https://favicon.io/emoji-favicons/sheaf-of-rice
8 changes: 8 additions & 0 deletions app/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ declare module 'vue' {
export interface GlobalComponents {
NButton: (typeof import('naive-ui'))['NButton']
NConfigProvider: (typeof import('naive-ui'))['NConfigProvider']
NDrawer: (typeof import('naive-ui'))['NDrawer']
NDrawerContent: (typeof import('naive-ui'))['NDrawerContent']
NLayout: (typeof import('naive-ui'))['NLayout']
NLayoutFooter: (typeof import('naive-ui'))['NLayoutFooter']
NLayoutHeader: (typeof import('naive-ui'))['NLayoutHeader']
NLayoutSider: (typeof import('naive-ui'))['NLayoutSider']
NMenu: (typeof import('naive-ui'))['NMenu']
NSpace: (typeof import('naive-ui'))['NSpace']
RouterLink: (typeof import('vue-router'))['RouterLink']
RouterView: (typeof import('vue-router'))['RouterView']
}
Expand Down
5 changes: 5 additions & 0 deletions app/components/content/Card.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="p-2 border bg-white dark:bg-black dark:border-gray-700 rounded">
<slot />
</div>
</template>
20 changes: 20 additions & 0 deletions app/composables/useRWD.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'

export default function useRWD() {
const breakpoints = useBreakpoints(breakpointsTailwind)

const isMobileScreen = breakpoints.smallerOrEqual('sm')

const isLargerThanMd = breakpoints.greater('md')

const isSmallerThanMd = breakpoints.smaller('md')

const isBelowMdBreakpoint = breakpoints.smallerOrEqual('md')

return {
isMobileScreen,
isLargerThanMd,
isSmallerThanMd,
isBelowMdBreakpoint,
}
}
21 changes: 21 additions & 0 deletions app/content/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Overview

## header 2

### header 3

code block

```
code block
```

Hello world

::card
The content of the card
::

image

160 changes: 155 additions & 5 deletions app/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,157 @@
<script lang="ts" setup>
import { NuxtLink } from '#components'
import packageJsonCore from '../../packages/core/package.json'
const headerLeftMenu = [
{
label: () =>
h(
NuxtLink,
{
to: '/',
},
{ default: () => 'Vue Dapp' },
),
key: 'vue-dapp',
icon: () => h('img', { src: '/sheaf-of-rice/favicon-32x32.png' }),
},
]
const headerRightMenu = [
{
label: () =>
h(
NuxtLink,
{
to: packageJsonCore.repository,
external: true,
target: '_blank',
},
{ default: () => 'Github' },
),
key: 'github',
},
{
label: () =>
h(
NuxtLink,
{
to: 'https://github.com/vu3th/vue-dapp/releases',
external: true,
target: '_blank',
},
{ default: () => 'v' + packageJsonCore.version },
),
key: 'version',
},
]
const sidebarMenu = [
{
label: () =>
h(
NuxtLink,
{
to: '/overview',
},
{ default: () => 'Overview' },
),
key: 'Overview',
},
{
label: () =>
h(
NuxtLink,
{
to: '/wallet',
},
{ default: () => 'Wallet' },
),
key: 'Wallet',
},
{
label: () =>
h(
NuxtLink,
{
to: '/vue-dapp-provider',
},
{ default: () => 'VueDappProvider' },
),
key: 'VueDappProvider',
},
{
label: 'Examples',
key: 'Examples',
children: [
{
label: 'Contract',
key: 'Contract',
},
{
label: 'Multicall',
key: 'Multicall',
},
{
label: 'Switch chain',
key: 'Switch chain',
},
],
},
]
const showDrawer = ref(false)
</script>

<template>
<div>
<TheHeader />
<slot />
<TheFooter />
</div>
<n-layout content-class="flex flex-col" position="absolute">
<n-layout-header bordered class="grid grid-cols-2">
<div class="flex items-center">
<!-- drawer button -->
<div class="pl-5 md:hidden flex justify-center items-center" @click="() => (showDrawer = true)">
<Icon size="20" name="ic:baseline-sort" class="hover:cursor-pointer hover:text-primary-dark" />
</div>
<!-- logo -->
<n-menu mode="horizontal" :options="headerLeftMenu" />
</div>
<!-- right side menu -->
<div class="place-self-end">
<n-menu mode="horizontal" :options="headerRightMenu" />
</div>
</n-layout-header>

<n-layout has-sider class="flex-1">
<!-- sidebar -->
<n-layout-sider
class="hidden md:block"
bordered
collapse-mode="width"
:collapsed-width="0"
:width="240"
:native-scrollbar="false"
>
<n-menu :collapsed-width="64" :collapsed-icon-size="20" :options="sidebarMenu" default-expand-all />
</n-layout-sider>

<!-- pages -->
<n-layout>
<slot />
</n-layout>

<!-- top-down drawer -->
<n-drawer v-model:show="showDrawer" height="100vh" placement="top" :trap-focus="false">
<n-drawer-content closable>
<template #header>
<NuxtLink to="/" class="h-5 flex justify-center items-center gap-1" @click="showDrawer = false">
<img class="w-5" src="/sheaf-of-rice/favicon-32x32.png" alt="" />
<p class="text-gray-500 text-sm">Vue Dapp</p>
</NuxtLink>
</template>
<n-menu :options="sidebarMenu" default-expand-all />
</n-drawer-content>
</n-drawer>
</n-layout>

<n-layout-footer bordered> </n-layout-footer>
</n-layout>
</template>
19 changes: 10 additions & 9 deletions app/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ export default defineNuxtConfig({
build: {
transpile:
process.env.NODE_ENV === 'production'
? ['naive-ui', '@css-render/vue3-ssr', '@juggle/resize-observer']
? ['naive-ui', 'vueuc', '@css-render/vue3-ssr', '@juggle/resize-observer']
: ['@juggle/resize-observer'],
},
vite: {
plugins: [
// @ts-ignore
nodePolyfills(), // only for @vue-dapp/coinbase
Components({
dts: true,
resolvers: [NaiveUiResolver()], // Automatically register all components in the `components` directory
}),
],
optimizeDeps: {
include: process.env.NODE_ENV === 'development' ? ['naive-ui'] : [],
include:
process.env.NODE_ENV === 'development' ? ['naive-ui', 'vueuc', 'date-fns-tz/formatInTimeZone'] : [],
},
},
components: [
Expand All @@ -33,7 +35,6 @@ export default defineNuxtConfig({
],
modules: [
'@vue-dapp/nuxt',
'@nuxtjs/tailwindcss',
[
'@pinia/nuxt',
{
Expand All @@ -43,13 +44,13 @@ export default defineNuxtConfig({
'@pinia-plugin-persistedstate/nuxt',
'@vueuse/nuxt',
'nuxt-icon',
'@nuxt/content',
],
imports: {
dirs: ['store'],
},
tailwindcss: {
cssPath: '~/styles/tailwind.css',
configPath: 'tailwind.config',
postcss: {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
},
css: ['~/styles/main.scss'],
runtimeConfig: {
Expand Down
13 changes: 9 additions & 4 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
"preview": "nuxt preview",
"typecheck": "nuxi typecheck"
},
"dependencies": {
"@nuxt/content": "^2.12.1",
"@pinia-plugin-persistedstate/nuxt": "^1.2.0",
"@pinia/nuxt": "^0.5.1",
"@tailwindcss/typography": "^0.5.12",
"@vicons/ionicons5": "^0.12.0",
"@vue-dapp/coinbase": "workspace:^",
"@vue-dapp/core": "workspace:^",
"@vue-dapp/modal": "workspace:^",
Expand All @@ -32,13 +36,14 @@
"vs-vue3-select": "^1.3.5"
},
"devDependencies": {
"@nuxt/devtools": "^1.0.8",
"@nuxtjs/tailwindcss": "^6.11.1",
"@css-render/vue3-ssr": "^0.15.12",
"@nuxt/devtools": "^1.1.5",
"autoprefixer": "^10.4.17",
"nuxt": "^3.9.3",
"nuxt": "^3.10.3",
"postcss": "^8.4.33",
"postcss-custom-properties": "^13.3.4",
"sass": "^1.70.0",
"tailwindcss": "^3.4.3",
"unplugin-vue-components": "^0.26.0",
"vite-plugin-node-polyfills": "^0.19.0",
"vue": "^3.4.21",
Expand Down
15 changes: 15 additions & 0 deletions app/pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script setup lang="ts">
/**
- https://github.com/tailwindlabs/tailwindcss-typography
*/
</script>

<template>
<main class="py-5 px-10">
<ContentDoc class="prose prose-zinc">
<template #not-found>
<p>Stay tuned; it will be added later 😉</p>
</template>
</ContentDoc>
</main>
</template>
22 changes: 4 additions & 18 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script setup lang="ts">
import pkg from '~/package.json'
import { shortenAddress, useVueDapp } from '@vue-dapp/core'
import type { ConnWallet } from '../../packages/core/dist'
const { address, chainId, wallet, status, error, disconnect, onConnected, onDisconnected } = useVueDapp()
const { address, chainId, status, error, disconnect, onConnected, onDisconnected } = useVueDapp()
const dappStore = useDappStore()
const ensName = ref('')
onConnected(async ({ address }) => {
console.log('onConnected')
const ens = await dappStore.provider.lookupAddress(address)
onConnected(async (wallet: ConnWallet) => {
const ens = await dappStore.provider.lookupAddress(wallet.address)
if (ens) {
ensName.value = ens
}
Expand All @@ -25,20 +25,6 @@ function onClickConnectButton() {
}
dappStore.connectModalOpen = !dappStore.connectModalOpen
}
// bug: when connected, get the wallet twice
if (process.client) {
watch(
wallet,
() => {
console.log('app -> index.vue -> wallet', wallet.value)
},
{
immediate: true,
deep: true,
},
)
}
</script>

<template>
Expand Down
Loading

0 comments on commit 50fe716

Please sign in to comment.