Skip to content

Commit

Permalink
feat: add simple footer
Browse files Browse the repository at this point in the history
  • Loading branch information
idlist committed Nov 15, 2024
1 parent 9325a15 commit 30e1326
Show file tree
Hide file tree
Showing 26 changed files with 248 additions and 83 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run generate
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"preview": "vite preview --host",
"build-only": "vite build",
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"prepare": "husky",
"generate": "tsx scripts/generate.ts && git add src/generated.ts"
},
"dependencies": {
"@rewl/kit": "^0.1.3",
Expand All @@ -31,6 +33,7 @@
"eslint": "^9.13.0",
"eslint-plugin-vue": "^9.29.1",
"globals": "^15.11.0",
"husky": "^9.1.6",
"npm-run-all2": "^6.2.6",
"radash": "^12.1.0",
"sass": "^1.80.4",
Expand Down
28 changes: 28 additions & 0 deletions scripts/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import fs from 'fs/promises'

interface YearMonthDay {
year: number
month: number
day: number
}

export const ymd = (date: Date): YearMonthDay => {
return {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate(),
}
}

const date = ymd(new Date())
const update = `${date.year} / ${date.month} / ${date.day}`

const yearStart = 2024
const yearPeriod = yearStart == date.year ? `${date.year}` : `${yearStart} - ${date.year}`

const content = `// Auto-generated file, don't modify.
export const LastUpdate = '${update}'
export const CopyrightYears = '${yearPeriod}'
`

await fs.writeFile('src/generated.ts', content, { encoding: 'utf8' })
7 changes: 0 additions & 7 deletions src/assets/bg/bg_piece.svg

This file was deleted.

3 changes: 3 additions & 0 deletions src/assets/byme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
THe SVG files in this folder are made by me.

No, it's not MIT.
1 change: 1 addition & 0 deletions src/assets/byme/bg_piece.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/byme/chinese.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/byme/english.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/byme/japanese.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/svgrepo/heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/assets/svgrepo/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ krita: https://www.svgrepo.com/svg/341976/krita
affinity_designer: https://www.svgrepo.com/svg/305670/affinity-designer
star: https://www.svgrepo.com/svg/525539/star
electron: https://www.svgrepo.com/svg/327355/logo-electron

heart: https://www.svgrepo.com/svg/525363/heart-angle
28 changes: 14 additions & 14 deletions src/components/OnAppear.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref, useTemplateRef, watch, type WatchHandle } from 'vue'
import { debounce } from 'radash'
import { throttle } from 'radash'
import { useWindowScroll, useWindowSize } from '@vueuse/core'
import { createDelay, createFrames } from '@rewl/kit'
const { height: wh } = useWindowSize()
const { y } = useWindowScroll()
const props = defineProps<{
const props = withDefaults(defineProps<{
name?: string
delay?: number
}>()
once?: boolean
}>(), {
name: 'v',
delay: 0,
})
const el = useTemplateRef('el')
const name = computed(() => props.name ?? 'v')
const classEnterFrom = computed(() => `${name.value}-enter-from`)
const classEnterActive = computed(() => `${name.value}-enter-active`)
const classEnterFrom = computed(() => `${props.name}-enter-from`)
const classEnterActive = computed(() => `${props.name}-enter-active`)
const delay = computed(() => createDelay(props.delay ?? 0))
const show = ref(false)
let unwatchShowCondition: WatchHandle
onMounted(() => {
unwatchShowCondition = watch([wh, y], debounce({ delay: 100 }, ([wh, _]) => {
if (!el.value) {
return
}
unwatchShowCondition = watch([wh, y], throttle({ interval: 100 }, ([wh, _]) => {
if (!el.value) return
const { top, bottom } = el.value.getBoundingClientRect()
Expand All @@ -37,13 +38,12 @@ onMounted(() => {
if (!show.value && inWindow) {
next = true
if (props.once) unwatchShowCondition()
}
if (show.value && outOfWindow) {
next = false
}
if (show.value && outOfWindow) next = false
show.value = next
}), { immediate: true })
}))
})
onUnmounted(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/background/BgPiece.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import PieceSvg from '@/assets/bg/bg_piece.svg'
import PieceSvg from '@/assets/byme/bg_piece.svg'
const props = defineProps<{
opacity?: number
Expand Down
1 change: 1 addition & 0 deletions src/components/background/FullPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const cssMinHeight = props.minHeight ?? '100vh'
.full-page {
min-width: 100%;
min-height: v-bind('cssMinHeight');
position: relative;
.background {
min-width: 100%;
Expand Down
34 changes: 19 additions & 15 deletions src/components/page/PageList.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { computed, defineComponent, h, ref, type Ref, watch } from 'vue'
import { computed, defineComponent, h, onMounted, ref, type Ref, watch } from 'vue'
import { useWindowSize, useWindowScroll } from '@vueuse/core'
import PageNavigator from './PageNavigator.vue'
import { debounce } from 'radash'
import { throttle } from 'radash'
import { animate, easeInOut } from 'popmotion'
import type { PageNavigatorItem } from './types'
Expand Down Expand Up @@ -51,17 +51,19 @@ const setupNavigatorStatus = (): PageNavigatorItem[] => {
const navigatorStatus = ref(setupNavigatorStatus())
watch(() => slots.default(), () => {
navigatorStatus.value = setupNavigatorStatus()
onMounted(() => {
watch(() => slots.default(), () => {
navigatorStatus.value = setupNavigatorStatus()
}, { immediate: true })
})
let magnetScrollTimeout: ReturnType<typeof setTimeout> | undefined
let snapScrollTimeout: ReturnType<typeof setTimeout> | undefined
let scrollAnimation: ReturnType<typeof animate> | undefined
const cancelMagnetScroll = () => {
if (magnetScrollTimeout) {
clearTimeout(magnetScrollTimeout)
magnetScrollTimeout = undefined
const cancelSnapScroll = () => {
if (snapScrollTimeout) {
clearTimeout(snapScrollTimeout)
snapScrollTimeout = undefined
}
}
Expand Down Expand Up @@ -120,22 +122,24 @@ const updateNavigatorStatus = (windowHeight: number) => {
navigatorStatus.value[i].progress = percent
}
cancelMagnetScroll()
cancelSnapScroll()
if (insidePage || !props.snapScroll) {
return
}
magnetScrollTimeout = setTimeout(() => {
snapScrollTimeout = setTimeout(() => {
jumpTo(mostIndex, scrollAlign)
magnetScrollTimeout = undefined
snapScrollTimeout = undefined
}, delay.value)
}
watch([height, y], debounce({ delay: 100 }, ([wh, _]) => updateNavigatorStatus(wh)), { immediate: true })
onMounted(() => {
watch([height, y], throttle({ interval: 100 }, ([wh, _]) => updateNavigatorStatus(wh)), { immediate: true })
})
const jumpTo = (index: number, align: ScrollAlign = 'top') => {
cancelMagnetScroll()
cancelSnapScroll()
if (scrollAnimation) {
scrollAnimation.stop()
Expand All @@ -151,7 +155,7 @@ const jumpTo = (index: number, align: ScrollAlign = 'top') => {
to = toMax
}
const from = window.scrollY
const duration = Math.max(Math.abs(from - to) / height.value * 1000, 500)
const duration = Math.max(Math.abs(from - to) / height.value * 500, 250)
scrollAnimation = animate({
from,
Expand Down
3 changes: 3 additions & 0 deletions src/generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Auto-generated file, don't modify.
export const LastUpdate = '2024 / 11 / 15'
export const CopyrightYears = '2024'
3 changes: 3 additions & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const en = {
'japanese': 'Japanese',
},
},
'footer': {
'last-update': 'Last Update: ',
},
}

export default en
Expand Down
7 changes: 5 additions & 2 deletions src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const zh: LocaleSchema = {
'pl': '编程语言',
'web': '网页技术',
'desktop': '桌面应用',
'gamedev': '游戏开发',
'art': '绘画 & 设计',
'gamedev': '游戏设计',
'art': '绘画 & 平面',
'compose': '编曲',
},
'skills': {
Expand All @@ -37,6 +37,9 @@ const zh: LocaleSchema = {
'japanese': '日文',
},
},
'footer': {
'last-update': '最近更新:',
},
}

export default zh
10 changes: 10 additions & 0 deletions src/utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
}
}

.icon-md {
width: 1rem;
height: 1rem;
}

.icon-sm {
width: 0.75rem;
height: 0.75rem;
}

.card {
padding: 0.25rem;

Expand Down
7 changes: 7 additions & 0 deletions src/views/ViewMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PageContent from '@/components/page/PageContent.vue'
import PageDivider from '@/components/page/PageDivider.vue'
import PageHome from './view-main/PageHome.vue'
import PageAbility from './view-main/PageAbility.vue'
import PageFooter from './view-main/PageFooter.vue'
// import FullPage from '@/components/background/FullPage.vue'
</script>

Expand All @@ -18,5 +19,11 @@ import PageAbility from './view-main/PageAbility.vue'
<PageContent>
<PageAbility />
</PageContent>

<PageDivider />

<PageContent>
<PageFooter />
</PageContent>
</PageList>
</template>
7 changes: 1 addition & 6 deletions src/views/view-main/LinkItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defineProps<LinkItemProps>()
<a class="card link-item" :href="link" target="_blank" noopener noreferer>
<div class="hover-fx fx-quick-hover">
<div class="type">
<img :src="icon" :alt="iconAlt" />
<img class="icon-md" :src="icon" :alt="iconAlt" />
<div>{{ type }}</div>
</div>
<slot></slot>
Expand Down Expand Up @@ -53,11 +53,6 @@ defineProps<LinkItemProps>()
font-size: 0.875rem;
color: #fff;
background-color: hsl(0, 0%, 10%);
img {
width: 1rem;
height: 1rem;
}
}
}
</style>
Loading

0 comments on commit 30e1326

Please sign in to comment.