♻️ (flux note) move in a component flux …
flux note will be used for fleeting notes and drafts too
This commit is contained in:
116
src/components/FluxNote.vue
Normal file
116
src/components/FluxNote.vue
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flux-note content note-container">
|
||||||
|
<div class="note readme">
|
||||||
|
<header-note class="header" />
|
||||||
|
<slot>
|
||||||
|
<div class="repo-title">
|
||||||
|
<h1 class="title is-1">
|
||||||
|
[<router-link
|
||||||
|
:to="{ name: 'Home', params: { user, repo } }"
|
||||||
|
@click="resetStackedNotes"
|
||||||
|
>{{ repo }}</router-link
|
||||||
|
>]
|
||||||
|
</h1>
|
||||||
|
<h4 class="subtitle is-4">
|
||||||
|
<em>{{ user }}</em>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<p class="note-display" v-html="readme"></p>
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
<stacked-note
|
||||||
|
class="note"
|
||||||
|
v-for="(stackedNote, index) in stackedNotes"
|
||||||
|
:key="stackedNote"
|
||||||
|
:index="index"
|
||||||
|
:user="user"
|
||||||
|
:repo="repo"
|
||||||
|
:sha="stackedNote"
|
||||||
|
:title="titles[stackedNote ?? '']"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
|
||||||
|
import { defineComponent, defineAsyncComponent, toRefs } from 'vue'
|
||||||
|
import HeaderNote from '@/components/HeaderNote.vue'
|
||||||
|
import { useNote } from '@/hooks/useNote.hook'
|
||||||
|
|
||||||
|
const StackedNote = defineAsyncComponent(() =>
|
||||||
|
import('@/components/StackedNote.vue')
|
||||||
|
)
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'FluxNote',
|
||||||
|
components: {
|
||||||
|
HeaderNote,
|
||||||
|
StackedNote
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
user: { type: String, required: false, default: '' },
|
||||||
|
repo: { type: String, required: false, default: '' }
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const refProps = toRefs(props)
|
||||||
|
const { stackedNotes, resetStackedNotes } = useQueryStackedNotes()
|
||||||
|
|
||||||
|
return {
|
||||||
|
stackedNotes,
|
||||||
|
resetStackedNotes,
|
||||||
|
...useNote('note-container', refProps.user, refProps.repo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
$header-height: 40px;
|
||||||
|
|
||||||
|
.flux-note {
|
||||||
|
.header {
|
||||||
|
height: $header-height;
|
||||||
|
}
|
||||||
|
|
||||||
|
.readme {
|
||||||
|
position: sticky;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
padding: 0 2rem 1rem;
|
||||||
|
|
||||||
|
.repo-title {
|
||||||
|
margin-top: 1rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.note {
|
||||||
|
text-align: left;
|
||||||
|
overflow-y: auto;
|
||||||
|
height: 100vh;
|
||||||
|
position: sticky;
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
|
border-top: 1px solid rgba(18, 19, 58, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 769px) {
|
||||||
|
.note {
|
||||||
|
min-width: 620px;
|
||||||
|
max-width: 620px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 768px) {
|
||||||
|
.flux-note {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.note {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -28,6 +28,7 @@ export const useLinks = (className: string, sha?: string) => {
|
|||||||
|
|
||||||
const removeListeners = () => {
|
const removeListeners = () => {
|
||||||
const elements = document.querySelectorAll(selector)
|
const elements = document.querySelectorAll(selector)
|
||||||
|
|
||||||
elements.forEach((element) => {
|
elements.forEach((element) => {
|
||||||
element.removeEventListener('click', linkNote)
|
element.removeEventListener('click', linkNote)
|
||||||
})
|
})
|
||||||
@@ -36,6 +37,7 @@ export const useLinks = (className: string, sha?: string) => {
|
|||||||
const listenToClick = () => {
|
const listenToClick = () => {
|
||||||
removeListeners()
|
removeListeners()
|
||||||
const elements = document.querySelectorAll(selector)
|
const elements = document.querySelectorAll(selector)
|
||||||
|
|
||||||
elements.forEach((element) => {
|
elements.forEach((element) => {
|
||||||
element.addEventListener('click', linkNote)
|
element.addEventListener('click', linkNote)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ let initial = true
|
|||||||
|
|
||||||
export const useQueryStackedNotes = () => {
|
export const useQueryStackedNotes = () => {
|
||||||
const { query } = useRoute()
|
const { query } = useRoute()
|
||||||
if (initial) {
|
|
||||||
initial = false
|
const setStackedNotes = () => {
|
||||||
stackedNotes.value = (Array.isArray(query.stackedNotes)
|
stackedNotes.value = (Array.isArray(query.stackedNotes)
|
||||||
? query.stackedNotes
|
? query.stackedNotes
|
||||||
: [query.stackedNotes]
|
: [query.stackedNotes]
|
||||||
@@ -18,6 +18,11 @@ export const useQueryStackedNotes = () => {
|
|||||||
.filter((n) => !!n) as string[]
|
.filter((n) => !!n) as string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (initial) {
|
||||||
|
initial = false
|
||||||
|
setStackedNotes()
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stackedNotes: readonly(stackedNotes),
|
stackedNotes: readonly(stackedNotes),
|
||||||
updateQueryStackedNotes: (newStackedNotes: string[]) =>
|
updateQueryStackedNotes: (newStackedNotes: string[]) =>
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ interface Tree {
|
|||||||
url?: string
|
url?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
|
export const useRepo = (
|
||||||
|
owner: Ref<string>,
|
||||||
|
repo: Ref<string>,
|
||||||
|
fetchRepo = true
|
||||||
|
) => {
|
||||||
const { getCachedNote, saveCacheNote } = useNoteCache('README')
|
const { getCachedNote, saveCacheNote } = useNoteCache('README')
|
||||||
const { accessToken } = useGitHubLogin()
|
const { accessToken } = useGitHubLogin()
|
||||||
|
|
||||||
@@ -83,7 +87,11 @@ export const useRepo = (owner: Ref<string>, repo: Ref<string>) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => retrieveRepo())
|
onMounted(() => {
|
||||||
|
if (fetchRepo) {
|
||||||
|
retrieveRepo()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
watch([owner, repo], () => retrieveRepo())
|
watch([owner, repo], () => retrieveRepo())
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
props: true,
|
props: true,
|
||||||
component: Home
|
component: Home
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/:user/:repo/fleeting-notes',
|
||||||
|
name: 'FleetingNotes',
|
||||||
|
props: true,
|
||||||
|
component: () =>
|
||||||
|
import(
|
||||||
|
/* webpackChunkName: "fleeting-notes" */ '@/views/FleetingNotes.vue'
|
||||||
|
)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/about',
|
path: '/about',
|
||||||
name: 'About',
|
name: 'About',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap');
|
||||||
|
|
||||||
$primary: #2c3a47;
|
$primary: #2c3a47;
|
||||||
$link: #58b19f;
|
$link: #3b7e70;
|
||||||
|
|
||||||
@import '~bulma/bulma.sass';
|
@import '~bulma/bulma.sass';
|
||||||
|
|
||||||
|
|||||||
20
src/views/FleetingNotes.vue
Normal file
20
src/views/FleetingNotes.vue
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<div class="fleeting-notes"></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent } from 'vue'
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'FleetingNotes',
|
||||||
|
props: {
|
||||||
|
user: { type: String, required: true },
|
||||||
|
repo: { type: String, required: true }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.fleeting-notes {
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,51 +2,20 @@
|
|||||||
<div class="home content" v-if="!user || !repo">
|
<div class="home content" v-if="!user || !repo">
|
||||||
<welcome-world />
|
<welcome-world />
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="notFound">
|
<flux-note class="home" :user="user" :repo="repo" :key="routeKey" v-else />
|
||||||
<div class="notification is-warning">
|
|
||||||
Not found.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="home content note-container" v-else>
|
|
||||||
<div class="note readme">
|
|
||||||
<header-note class="header" />
|
|
||||||
<div class="repo-title">
|
|
||||||
<h1 class="title is-1">
|
|
||||||
[<router-link
|
|
||||||
:to="{ name: 'Home', params: { user, repo } }"
|
|
||||||
:key="routeKey"
|
|
||||||
@click="resetStackedNotes"
|
|
||||||
>{{ repo }}</router-link
|
|
||||||
>]
|
|
||||||
</h1>
|
|
||||||
<h4 class="subtitle is-4">
|
|
||||||
<em>{{ user }}</em>
|
|
||||||
</h4>
|
|
||||||
</div>
|
|
||||||
<p class="note-display" v-html="readme"></p>
|
|
||||||
</div>
|
|
||||||
<stacked-note
|
|
||||||
class="note"
|
|
||||||
v-for="(stackedNote, index) in stackedNotes"
|
|
||||||
:key="stackedNote"
|
|
||||||
:index="index"
|
|
||||||
:user="user"
|
|
||||||
:repo="repo"
|
|
||||||
:sha="stackedNote"
|
|
||||||
:title="titles[stackedNote ?? '']"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, defineAsyncComponent, computed, toRefs } from 'vue'
|
import {
|
||||||
import { useNote } from '@/hooks/useNote.hook'
|
defineComponent,
|
||||||
|
defineAsyncComponent,
|
||||||
|
computed,
|
||||||
|
toRefs,
|
||||||
|
watch
|
||||||
|
} from 'vue'
|
||||||
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
|
import { useQueryStackedNotes } from '@/hooks/useQueryStackedNotes.hook'
|
||||||
import HeaderNote from '@/components/HeaderNote.vue'
|
|
||||||
|
|
||||||
const StackedNote = defineAsyncComponent(() =>
|
const FluxNote = defineAsyncComponent(() => import('@/components/FluxNote.vue'))
|
||||||
import('@/components/StackedNote.vue')
|
|
||||||
)
|
|
||||||
|
|
||||||
const WelcomeWorld = defineAsyncComponent(() =>
|
const WelcomeWorld = defineAsyncComponent(() =>
|
||||||
import('@/components/WelcomeWorld.vue')
|
import('@/components/WelcomeWorld.vue')
|
||||||
@@ -55,9 +24,8 @@ const WelcomeWorld = defineAsyncComponent(() =>
|
|||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
components: {
|
components: {
|
||||||
StackedNote,
|
|
||||||
WelcomeWorld,
|
WelcomeWorld,
|
||||||
HeaderNote
|
FluxNote
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
user: { type: String, required: false, default: '' },
|
user: { type: String, required: false, default: '' },
|
||||||
@@ -65,10 +33,14 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const refProps = toRefs(props)
|
const refProps = toRefs(props)
|
||||||
|
const { resetStackedNotes } = useQueryStackedNotes()
|
||||||
|
|
||||||
|
watch([refProps.user, refProps.repo], () => {
|
||||||
|
resetStackedNotes()
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...useNote('note-container', refProps.user, refProps.repo),
|
resetStackedNotes,
|
||||||
...useQueryStackedNotes(),
|
|
||||||
routeKey: computed(() => `${props.user}-${props.repo}`)
|
routeKey: computed(() => `${props.user}-${props.repo}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,55 +48,8 @@ export default defineComponent({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$header-height: 40px;
|
|
||||||
|
|
||||||
.home {
|
.home {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
.header {
|
|
||||||
height: $header-height;
|
|
||||||
}
|
|
||||||
|
|
||||||
.readme {
|
|
||||||
position: sticky;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
padding: 0 2rem 1rem;
|
|
||||||
|
|
||||||
.repo-title {
|
|
||||||
margin-top: 1rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.note {
|
|
||||||
text-align: left;
|
|
||||||
overflow-y: auto;
|
|
||||||
height: 100vh;
|
|
||||||
position: sticky;
|
|
||||||
background-color: #fff;
|
|
||||||
|
|
||||||
&:not(:first-child) {
|
|
||||||
border-top: 1px solid rgba(18, 19, 58, 0.2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (min-width: 769px) {
|
|
||||||
.note {
|
|
||||||
min-width: 620px;
|
|
||||||
max-width: 620px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 768px) {
|
|
||||||
.home {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
|
|
||||||
.note {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user