-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ThetaSinner
authored and
ThetaSinner
committed
Feb 17, 2024
1 parent
01fa2da
commit a78481e
Showing
9 changed files
with
189 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,93 @@ | ||
<script setup lang="ts"> | ||
import { defineComponent, computed, inject, ComputedRef, ref, watch, provide, onMounted } from 'vue'; | ||
import { AppAgentClient, AppAgentWebsocket } from '@holochain/client'; | ||
import '@material/mwc-circular-progress'; | ||
import '@material/mwc-button'; | ||
import DistributeGpgKey from './trusted/trusted/DistributeGpgKey.vue'; | ||
import MyKeys from './trusted/trusted/MyKeys.vue'; | ||
import SearchKeys from './trusted/trusted/SearchKeys.vue'; | ||
import Notify from './component/Notify.vue'; | ||
import { useThemeStore } from './store/theme-store'; | ||
import Settings from './component/Settings.vue'; | ||
const themeStore = useThemeStore(); | ||
const client = ref<AppAgentClient | null>(null); | ||
provide('client', client); | ||
const loading = ref(true); | ||
const showScreen = ref<'home' | 'search' | 'settings' | 'about'>('home'); | ||
const applyTheme = (theme: string) => { | ||
document.documentElement.setAttribute('data-theme', theme); | ||
}; | ||
onMounted(async () => { | ||
// Set the current theme on load | ||
applyTheme(themeStore.theme); | ||
// then listen for changes to the theme and apply them | ||
themeStore.$subscribe((_, state) => { | ||
applyTheme(state.theme); | ||
}); | ||
// We pass an unused string as the url because it will dynamically be replaced in launcher environments | ||
client.value = await AppAgentWebsocket.connect(new URL('https://UNUSED'), 'hWOT'); | ||
loading.value = false; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div v-if="loading"> | ||
<p class="text-lg p-12">Connecting to Holochain</p> | ||
<span class="loading loading-infinity loading-lg"></span> | ||
</div> | ||
<div v-else> | ||
<div id="content"> | ||
<DistributeGpgKey @gpg-key-dist-created="() => {}"></DistributeGpgKey> | ||
<div class="navbar bg-base-100"> | ||
<div class="navbar-start"> | ||
<div class="dropdown"> | ||
<div tabindex="0" role="button" class="btn btn-ghost btn-circle"> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" | ||
stroke="currentColor"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h7" /> | ||
</svg> | ||
</div> | ||
<ul tabindex="0" class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"> | ||
<li><a @click="showScreen = 'home'">Home</a></li> | ||
<li><a @click="showScreen = 'settings'">Settings</a></li> | ||
<li><a @click="showScreen = 'about'">About</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
<div class="navbar-center"> | ||
<button class="btn btn-ghost text-xl" @click="showScreen = 'home'">Web of Trust</button> | ||
</div> | ||
<div class="navbar-end"> | ||
<button class="btn btn-ghost btn-circle" @click="showScreen = 'search'"> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" | ||
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div v-if="showScreen === 'home'"> | ||
<MyKeys></MyKeys> | ||
|
||
<SearchKeys></SearchKeys> | ||
|
||
<Notify></Notify> | ||
<DistributeGpgKey @gpg-key-dist-created="() => { }"></DistributeGpgKey> | ||
</div> | ||
<div v-else-if="showScreen === 'settings'"> | ||
<div class="container mx-auto w-1/2"> | ||
<Settings></Settings> | ||
</div> | ||
</div> | ||
<div v-else-if="showScreen === 'search'"> | ||
<div class="container mx-auto"> | ||
<SearchKeys></SearchKeys> | ||
</div> | ||
</div> | ||
|
||
<Notify></Notify> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts"> | ||
import { defineComponent, computed } from 'vue'; | ||
import { AppAgentClient, AppAgentWebsocket } from '@holochain/client'; | ||
import '@material/mwc-circular-progress'; | ||
import '@material/mwc-button'; | ||
import DistributeGpgKey from './trusted/trusted/DistributeGpgKey.vue'; | ||
import MyKeys from './trusted/trusted/MyKeys.vue'; | ||
import SearchKeys from './trusted/trusted/SearchKeys.vue'; | ||
import Notify from './component/Notify.vue'; | ||
export default defineComponent({ | ||
components: { | ||
DistributeGpgKey, | ||
MyKeys, | ||
SearchKeys, | ||
Notify, | ||
}, | ||
data(): { | ||
client: AppAgentClient | undefined; | ||
loading: boolean; | ||
} { | ||
return { | ||
client: undefined, | ||
loading: true, | ||
}; | ||
}, | ||
async mounted() { | ||
// We pass an unused string as the url because it will dynamically be replaced in launcher environments | ||
this.client = await AppAgentWebsocket.connect(new URL('https://UNUSED'), 'hWOT'); | ||
this.loading = false; | ||
}, | ||
provide() { | ||
return { | ||
client: computed(() => this.client), | ||
}; | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script setup lang="ts"> | ||
import { ref, watch } from 'vue'; | ||
import { useThemeStore, Theme } from '../store/theme-store'; | ||
const themeStore = useThemeStore(); | ||
const themeToggle = ref(!themeStore.isDefault); | ||
watch(themeToggle, (newVal) => { | ||
console.log('set theme', newVal) | ||
if (newVal) { | ||
console.log('call set theme'); | ||
themeStore.setTheme(Theme.Luxury); | ||
} else { | ||
themeStore.setTheme(Theme.Bumblebee); | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
|
||
<div class="form-control"> | ||
<label class="label cursor-pointer"> | ||
<span class="label-text">Theme</span> | ||
<input type="checkbox" class="toggle" v-model="themeToggle" /> | ||
</label> | ||
</div> | ||
|
||
</template> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { defineStore } from "pinia"; | ||
import { computed, ref } from "vue"; | ||
|
||
export enum Theme { | ||
Bumblebee = 'bumblebee', | ||
Luxury = 'luxury' | ||
} | ||
|
||
export const useThemeStore = defineStore('theme', () => { | ||
const theme = ref<string>(Theme.Bumblebee) | ||
|
||
const stored = localStorage.getItem('theme') | ||
if (stored) { | ||
console.log('recover from stored', stored) | ||
theme.value = stored as Theme | ||
} | ||
|
||
const setTheme = (newTheme: Theme) => { | ||
console.log('do set theme', newTheme) | ||
theme.value = newTheme | ||
localStorage.setItem('theme', newTheme) | ||
} | ||
|
||
const isDefault = computed(() => { | ||
return theme.value === Theme.Bumblebee | ||
}) | ||
|
||
return { | ||
theme, | ||
setTheme, | ||
isDefault, | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
:root { | ||
--mdc-theme-primary: #7B1FA2; | ||
--mdc-theme-secondary: #FF5722; | ||
} | ||
|
||
:root { | ||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif; | ||
font-size: 16px; | ||
line-height: 24px; | ||
font-weight: 400; | ||
|
||
font-synthesis: none; | ||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-text-size-adjust: 100%; | ||
} | ||
|
||
a { | ||
font-weight: 500; | ||
color: #646cff; | ||
text-decoration: inherit; | ||
} | ||
a:hover { | ||
color: #535bf2; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
display: flex; | ||
place-items: center; | ||
min-width: 320px; | ||
min-height: 100vh; | ||
} | ||
|
||
h1 { | ||
font-size: 3.2em; | ||
line-height: 1.1; | ||
} | ||
|
||
button { | ||
border-radius: 8px; | ||
border: 1px solid transparent; | ||
padding: 0.6em 1.2em; | ||
font-size: 1em; | ||
font-weight: 500; | ||
font-family: inherit; | ||
background-color: #1a1a1a; | ||
cursor: pointer; | ||
transition: border-color 0.25s; | ||
} | ||
button:hover { | ||
border-color: #646cff; | ||
} | ||
button:focus, | ||
button:focus-visible { | ||
outline: 4px auto -webkit-focus-ring-color; | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
#app { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
:root { | ||
color: #213547; | ||
background-color: #ffffff; | ||
} | ||
a:hover { | ||
color: #747bff; | ||
} | ||
button { | ||
background-color: #f9f9f9; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters