Skip to content

Commit

Permalink
✨ Add github star hint, disabled by default (#2377)
Browse files Browse the repository at this point in the history
Co-authored-by: Maurice Oegerli <[email protected]>
  • Loading branch information
moisout and Maurice Oegerli authored Nov 5, 2023
1 parent f2b5578 commit 67dfacc
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release

[unreleased]: https://github.com/viewtube/viewtube/compare/v0.13.0...development
[unreleased]: https://github.com/viewtube/viewtube/compare/v0.13.1...development
[0.13.1]: https://github.com/viewtube/viewtube/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/viewtube/viewtube/compare/v0.12.2...v0.13.0
[0.12.2]: https://github.com/viewtube/viewtube/compare/v0.12.1...v0.12.2
[0.12.1]: https://github.com/viewtube/viewtube/compare/v0.12.0...v0.12.1
Expand Down
180 changes: 180 additions & 0 deletions client/components/GithubHint.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<script setup lang="ts">
const runtimeConfig = useRuntimeConfig();
const hideGithubHint = useCookie('hideGithubHint');
const onDismiss = () => {
hideGithubHint.value = 'true';
};
</script>

<template>
<a
v-if="runtimeConfig.public.githubHint && !hideGithubHint"
class="github-hint"
href="https://github.com/viewtube/viewtube"
target="_blank"
rel="noreferrer noopener"
>
<div class="github-hint-inner">
<VTIcon
v-tippy="'Never show again'"
class="dismiss-icon"
name="mdi:close"
@click.stop.prevent="onDismiss"
/>
<p class="hint-text">Star ViewTube on GitHub!</p>
<VTIcon class="hint-icon hint-icon-1" name="mdi:github" />
<VTIcon class="hint-icon hint-icon-2" name="mdi:github" />
<VTIcon class="hint-icon hint-icon-3" name="mdi:github" />
<VTIcon class="star-icon star-icon-1" name="mdi:star" />
<VTIcon class="star-icon star-icon-2" name="mdi:star" />
<VTIcon class="star-icon star-icon-3" name="mdi:star" />
</div>
</a>
</template>

<style lang="scss" scoped>
.github-hint {
max-width: $main-width;
margin: 0 auto;
width: 100%;
display: grid;
padding: 15px 10px 10px 10px;
box-sizing: border-box;
position: relative;
overflow: hidden;
&::after {
display: none;
}
&:hover {
.github-hint-inner {
border-color: var(--theme-color);
}
}
.github-hint-inner {
padding: 12px 18px;
border-radius: 10px;
overflow: hidden;
border: 2px solid #30363d;
transition: border-color 200ms $intro-easing;
cursor: pointer;
.hint-text {
position: relative;
font-size: 1rem;
font-weight: bold;
}
.dismiss-icon {
position: absolute;
right: 20px;
top: 50%;
transform: translateY(calc(-50% + 2.5px));
height: 20px;
width: 20px;
cursor: pointer;
z-index: 10;
}
.star-icon {
position: absolute;
color: var(--theme-color);
&-1 {
left: 150px;
top: 50px;
width: 15px;
height: 15px;
transform: rotate(20deg);
}
&-2 {
left: 250px;
top: 15px;
width: 25px;
height: 25px;
transform: rotate(-20deg);
opacity: 0.4;
}
&-3 {
left: 350px;
top: 40px;
width: 15px;
height: 15px;
transform: rotate(40deg);
opacity: 0.8;
}
@media screen and (max-width: $mobile-width) {
&-1 {
left: 50px;
}
&-2 {
left: 100px;
top: 13px;
}
&-3 {
display: none;
}
}
}
.hint-icon {
position: absolute;
&-1 {
right: 54px;
top: 17px;
width: 40px;
height: 40px;
transform: rotate(-24deg);
}
&-2 {
right: 115px;
top: 45px;
width: 20px;
height: 20px;
transform: rotate(28deg);
opacity: 0.8;
}
&-3 {
right: 170px;
top: 35px;
width: 10px;
height: 10px;
transform: rotate(200deg);
}
@media screen and (max-width: $mobile-width) {
&-2 {
right: 105px;
}
&-3 {
right: 140px;
}
}
}
&::before {
content: '';
position: absolute;
top: 15px;
left: 10px;
right: 10px;
bottom: 10px;
width: calc(100% - 20px);
background: $theme-color-primary-gradient;
opacity: 0.1;
border-radius: 10px;
}
}
}
</style>
5 changes: 3 additions & 2 deletions client/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default defineNuxtConfig({
runtimeConfig: {
public: {
vapidKey: process.env.VIEWTUBE_PUBLIC_VAPID,
videoplaybackProxy: ''
videoplaybackProxy: '',
githubHint: false
}
},

Expand Down Expand Up @@ -40,7 +41,7 @@ export default defineNuxtConfig({
}
},

modules: ['@pinia/nuxt', '@pinia-plugin-persistedstate/nuxt', '@unocss/nuxt'],
modules: ['@pinia/nuxt', '@pinia-plugin-persistedstate/nuxt', '@unocss/nuxt', '@vueuse/nuxt'],

unocss: {
uno: false,
Expand Down
2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"@typescript-eslint/parser": "6.9.1",
"@unocss/nuxt": "0.57.1",
"@unocss/preset-icons": "0.57.1",
"@vueuse/core": "^10.5.0",
"@vueuse/nuxt": "^10.5.0",
"consola": "3.2.3",
"cross-env": "7.0.3",
"dashjs": "4.7.2",
Expand Down
8 changes: 5 additions & 3 deletions client/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { data: homeFeedData, error: homeFeedError, pending: homeFeedLoading } = u
description="An alternative YouTube frontend"
/>
<Spinner v-if="homeFeedLoading" class="centered" />
<GithubHint />
<ErrorPage v-if="homeFeedError" text="Error loading homepage. The API may not be reachable." />
<HomeSubscriptions v-if="userStore.isLoggedIn && settingsStore.showHomeSubscriptions" />
<HomeVideosContainer
Expand All @@ -38,22 +39,23 @@ const { data: homeFeedData, error: homeFeedError, pending: homeFeedLoading } = u
display: flex;
flex-direction: column;
&.loading, &.error {
&.loading,
&.error {
height: calc(100vh - $header-height);
}
.section-title {
max-width: $main-width;
margin: 0 auto;
.title {
margin: 0 0 0 15px !important;
margin: 0 0 0 10px !important;
}
}
.home-videos-container {
width: 100%;
max-width: $main-width;
margin: 0 auto;
padding: 0 15px;
padding: 0 10px;
box-sizing: border-box;
z-index: 10;
background-color: var(--bgcolor-main);
Expand Down
13 changes: 7 additions & 6 deletions client/utils/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ export const iconSafelist = [
'mdi-arrow-left',
'mdi-arrow-right',
'mdi-at',
'mdi-auto-fix',
'mdi-book-open-variant',
'mdi-brightness-4',
'mdi-calendar-clock',
'mdi-cellphone',
'mdi-check-decagram',
'mdi-check',
'mdi-check-decagram',
'mdi-chevron-left',
'mdi-chevron-right',
'mdi-chevron-up',
Expand Down Expand Up @@ -51,6 +52,8 @@ export const iconSafelist = [
'mdi-pause',
'mdi-pencil',
'mdi-pencil-box-multiple-outline',
'mdi-pipe',
'mdi-pipe-valve',
'mdi-play',
'mdi-playlist-play',
'mdi-plus',
Expand All @@ -66,6 +69,8 @@ export const iconSafelist = [
'mdi-shuffle',
'mdi-skip-next',
'mdi-skip-previous',
'mdi-star',
'mdi-swap-vertical',
'mdi-television',
'mdi-thumb-down',
'mdi-thumb-up',
Expand All @@ -78,9 +83,5 @@ export const iconSafelist = [
'mdi-window-restore',
'mdi-xml',
'mdi-youtube',
'mdi-youtube-subscription',
'mdi-swap-vertical',
'mdi-pipe',
'mdi-pipe-valve',
'mdi-auto-fix'
'mdi-youtube-subscription'
].map(icon => `i-${icon}`);
57 changes: 55 additions & 2 deletions pnpm-lock.yaml

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

0 comments on commit 67dfacc

Please sign in to comment.