Skip to content

Commit

Permalink
interactive docs started
Browse files Browse the repository at this point in the history
  • Loading branch information
davay42 committed Jan 20, 2023
1 parent 62dc93c commit 5bd4f6a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
7 changes: 0 additions & 7 deletions docs/.vitepress/components/avatar-view.vue

This file was deleted.

21 changes: 21 additions & 0 deletions docs/.vitepress/components/gun-avatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup>
import { gunAvatar } from '../../../src/main'
import { useCssVar } from '@vueuse/core'
import { computed } from 'vue';
const props = defineProps({
pub: { type: String, default: '' },
size: { type: Number, default: 100 },
dark: { type: Boolean, default: false },
draw: { type: String, default: 'circles' },
reflect: { type: Boolean, default: true },
round: { type: Boolean, default: true }
})
const avatar = computed(() => gunAvatar({ ...props }))
</script>

<template>
<img :src="avatar" />
</template>
9 changes: 6 additions & 3 deletions docs/.vitepress/composables/state.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import Gun from "gun/gun";
import SEA from "gun/sea.js";
import { reactive } from "vue";

import { reactive, computed, toRef } from "vue";
import { useRefHistory } from '@vueuse/core'

export const state = reactive({
pair: {
Expand All @@ -11,7 +11,10 @@ export const state = reactive({
epub: "GcA7UOQyRPo8GlG1PCTOfcOjwvfxNgvdAjILC7NM9gc.T7yZYjlb7iJWxokcI01oCGTGAK8XDBgks9hXA-FDkeY",
epriv: "Tr9_a9sWJbo7EI0ARB5VeptIBALFuVNkSkrRAuP8vQc",
},
pub: computed(() => state.pair.pub),
async generatePair() {
state.pair = await SEA.pair()
}
})
})

state.history = useRefHistory(toRef(state, 'pair'))
9 changes: 8 additions & 1 deletion docs/.vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<script setup>
import DefaultTheme from 'vitepress/theme'
import { state } from '../composables/state'
const { Layout } = DefaultTheme
</script>

<template lang="pug">
Layout
template(#home-hero-image)
avatar-view
gun-avatar.image-src.rounded-full.cursor-pointer.m-auto(
:pub="state.pub"
:size="300"
@click="state.generatePair()"
)
template(#nav-bar-content-before)
header-links
</template>
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,4 @@ function chunkIt(list, chunkSize = 3) {
return [...Array(Math.ceil(list.length / chunkSize))].map(() =>
list.splice(0, chunkSize)
);
}
}
2 changes: 2 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from "vite";
import Vue from '@vitejs/plugin-vue'
import Unocss from 'unocss/vite'
import { presetUno, presetIcons, transformerDirectives, extractorSplit } from "unocss";
import extractorPug from '@unocss/extractor-pug'
Expand All @@ -9,6 +10,7 @@ export default defineConfig({
outDir: "./demo",
},
plugins: [
Vue(),
Unocss({
presets: [
presetIcons({
Expand Down

0 comments on commit 5bd4f6a

Please sign in to comment.