refactor logo, bottom bar and perks.js

- add new logo
- add tsconfig.json
- move logo to new component
- update bottombar
- remove props from hotkeys and progress bar
- convert perks.js -> perks.ts
This commit is contained in:
geoffrey45
2022-05-24 15:55:26 +03:00
parent 599ba060b2
commit b497344521
24 changed files with 129 additions and 246 deletions
+9 -28
View File
@@ -3,12 +3,8 @@
<Modal /> <Modal />
<Notification /> <Notification />
<div class="l-container"> <div class="l-container">
<div class="l-sidebar"> <div class="l-sidebar rounded">
<div id="logo-container"> <Logo />
<router-link :to="{ name: 'Home' }">
<div class="logo"></div
></router-link>
</div>
<Navigation /> <Navigation />
<div class="l-album-art"> <div class="l-album-art">
<nowPlaying /> <nowPlaying />
@@ -24,7 +20,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import Navigation from "./components/LeftSidebar/Navigation.vue"; import Navigation from "./components/LeftSidebar/Navigation.vue";
import Main from "./components/RightSideBar/Main.vue"; import Main from "./components/RightSideBar/Main.vue";
@@ -38,6 +34,7 @@ import Modal from "./components/modal.vue";
import Notification from "./components/Notification.vue"; import Notification from "./components/Notification.vue";
import useQStore from "./stores/queue"; import useQStore from "./stores/queue";
import listenForKeyboardEvents from "./composables/keyboard"; import listenForKeyboardEvents from "./composables/keyboard";
import Logo from "./components/Logo.vue";
const RightSideBar = Main; const RightSideBar = Main;
const context_store = useContextStore(); const context_store = useContextStore();
@@ -55,38 +52,22 @@ app_dom.addEventListener("click", (e) => {
</script> </script>
<style lang="scss"> <style lang="scss">
@import "./assets/css/mixins.scss";
.l-sidebar { .l-sidebar {
position: relative; position: relative;
.l-album-art { .l-album-art {
width: calc(100% - 2rem);
position: absolute; position: absolute;
bottom: 0; bottom: 0;
margin-bottom: 1rem;
} }
} }
#logo-container {
position: relative;
height: 3.6rem;
display: flex;
align-items: center;
margin-bottom: 0.5rem;
#toggle {
position: absolute;
width: 3rem;
height: 100%;
background: url(./assets/icons/menu.svg) no-repeat center;
background-size: 2rem;
cursor: pointer;
}
}
.logo {
height: 4.5rem;
width: 15rem;
background: url(./assets/icons/logo.svg) no-repeat 1rem;
background-size: 9rem;
}
.r-sidebar { .r-sidebar {
&::-webkit-scrollbar { &::-webkit-scrollbar {
+2 -36
View File
@@ -7,46 +7,16 @@
display: grid; display: grid;
height: 100%; height: 100%;
padding-right: $small; padding-right: $small;
@include phone-only { @include phone-only {
grid-template-columns: 1fr 9.2rem; grid-template-columns: 1fr 9.2rem;
} }
.info {
display: flex;
padding-top: $small;
margin-left: $small;
.art {
width: 3rem;
height: 3rem;
background-image: url("../../images/null.webp");
}
.separator {
margin: 2px;
}
.desc {
width: calc(100% - 5rem);
margin-left: $small;
display: flex;
align-items: center;
margin-top: -$small;
.artists {
font-size: 0.8rem;
color: $white;
}
}
}
.controlsx { .controlsx {
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
display: flex; display: grid;
grid-template-columns: 12rem 1fr 12rem;
align-items: center; align-items: center;
padding: $small; padding: $small;
@@ -55,10 +25,6 @@
align-items: center; align-items: center;
} }
.controls-bottom {
width: min-content;
}
.progress-bottom { .progress-bottom {
width: 100%; width: 100%;
+6 -4
View File
@@ -1,4 +1,5 @@
@import "../css/ProgressBar.scss"; @import "../css/ProgressBar.scss";
@import "mixins.scss";
:root { :root {
--separator: #ffffff46; --separator: #ffffff46;
@@ -20,6 +21,8 @@ body {
image-rendering: -webkit-optimize-contrast; image-rendering: -webkit-optimize-contrast;
} }
.heading { .heading {
font-size: 2rem; font-size: 2rem;
font-weight: bold; font-weight: bold;
@@ -39,7 +42,6 @@ a {
} }
.border { .border {
// border: solid 1px $gray5;
background-color: $black; background-color: $black;
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1); box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1);
} }
@@ -95,11 +97,11 @@ a {
} }
.l-sidebar { .l-sidebar {
width: 15rem; width: 17rem;
grid-area: l-sidebar; grid-area: l-sidebar;
padding-top: 0.5rem;
// border-right: solid 1px $gray3;
background-color: $black; background-color: $black;
margin: $small;
padding: 1rem;
} }
.bottom-bar { .bottom-bar {
+5
View File
@@ -0,0 +1,5 @@
@mixin ximage {
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+4 -4
View File
@@ -23,8 +23,8 @@
<div class="bottom"> <div class="bottom">
<div class="stats"> <div class="stats">
{{ props.album.count }} Tracks {{ props.album.count }} Tracks
{{ perks.formatSeconds(props.album.duration, "long") }} {{ formatSeconds(props.album.duration) }} {{ props.album.date }}
{{ props.album.date }} {{ props.album.artist }} {{ props.album.artist }}
</div> </div>
<PlayBtnRect :source="playSources.album" /> <PlayBtnRect :source="playSources.album" />
</div> </div>
@@ -34,8 +34,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import perks from "../../composables/perks.js"; import { formatSeconds } from "../../composables/perks";
import { AlbumInfo } from "../../interfaces.js"; import { AlbumInfo } from "../../interfaces";
import PlayBtnRect from "../shared/PlayBtnRect.vue"; import PlayBtnRect from "../shared/PlayBtnRect.vue";
import { playSources } from "../../composables/enums"; import { playSources } from "../../composables/enums";
import { paths } from "../../config"; import { paths } from "../../config";
+13 -17
View File
@@ -1,37 +1,33 @@
<!-- <template> <template>
<div class="b-bar"> <div class="b-bar">
<div class="grid rounded"> <div class="grid rounded">
<div class="controlsx rounded"> <div class="controlsx rounded">
<div class="controls controls-bottom"> <div class="controls-bottom">
<HotKeys /> <HotKeys />
</div> </div>
<div class="progress progress-bottom"> <div class="progress progress-bottom">
<span class="durationx">{{ formatSeconds(current_pos) }}</span> <span class="durationx">{{ formatSeconds(q.track.current_time) }}</span>
<Progress /> <Progress />
<span class="durationx">{{ <span class="durationx">{{ formatSeconds(q.length) }}</span>
formatSeconds(state.current.value.length)
}}</span>
</div> </div>
<div class="r-group"> <div class="r-group">
<div id="heart" class="image ctrl-btn"></div> <div id="heart" class="image ctrl-btn"></div>
<div id="add-to" class="image ctrl-btn"></div> <div id="add-to" class="image ctrl-btn"></div>
<div id="repeat" class="image ctrl-btn"></div> <div id="repeat" class="image ctrl-btn"></div>
</div> </div>
<div class="controls controls-bottom"></div>
</div> </div>
<div class="volume-group"></div> <div class="volume-group"></div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import "../../assets/css/BottomBar/BottomBar.scss"; import "@/assets/css/BottomBar/BottomBar.scss";
import Progress from "../shared/Progress.vue"; import Progress from "../LeftSidebar/NP/Progress.vue";
import HotKeys from "../shared/HotKeys.vue"; import HotKeys from "../LeftSidebar/NP/HotKeys.vue";
import state from "../../composables/state"; import { formatSeconds } from "@/composables/perks";
import perks from "../../composables/perks";
import playAudio from "../../composables/playAudio";
const current_pos = playAudio.current_time; import useQStore from "@/stores/queue";
const formatSeconds = perks.formatSeconds;
</script> --> const q = useQStore();
</script>
+11 -13
View File
@@ -1,33 +1,31 @@
<template> <template>
<div class="hotkeys"> <div class="hotkeys">
<div class="image ctrl-btn" id="previous" @click="props.prev"></div> <div class="image ctrl-btn" id="previous" @click="q.playPrev"></div>
<div <div
class="image ctrl-btn play-pause" class="image ctrl-btn play-pause"
@click="playPause" @click="q.playPause"
:class="{ isPlaying: props.playing }" :class="{ isPlaying: q.playing }"
></div> ></div>
<div class="image ctrl-btn" id="next" @click="props.next"></div> <div class="image ctrl-btn" id="next" @click="q.playNext"></div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const props = defineProps<{ import useQStore from "@/stores/queue";
playing: boolean;
playPause: () => void; const q = useQStore();
next: () => void;
prev: () => void;
}>();
</script> </script>
<style lang="scss"> <style lang="scss">
.hotkeys { .hotkeys {
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
width: 100%;
gap: $small; gap: $small;
height: 3rem; height: 2.5rem;
align-items: center; align-items: center;
justify-content: center;
place-content: flex-end; place-content: flex-end;
width: 100%;
.ctrl-btn { .ctrl-btn {
height: 2.5rem; height: 2.5rem;
@@ -37,7 +35,7 @@ const props = defineProps<{
border-radius: 0.5rem; border-radius: 0.5rem;
&:hover { &:hover {
background-color: $red; background-color: $accent;
} }
} }
+10 -10
View File
@@ -2,22 +2,22 @@
<input <input
id="progress" id="progress"
type="range" type="range"
:value="props.pos" :value="q.track.current_time"
min="0" min="0"
max="100" :max="q.track.duration"
step="0.1" step="0.1"
@change="seek()" @change="seek()"
/> />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
const seek = () => { import useQStore from "../../../stores/queue";
const value = Number(document.getElementById("progress").value);
props.seek(value);
};
const props = defineProps<{ const q = useQStore();
pos: number; const seek = () => {
seek: (time: number) => void; const elem = <HTMLFormElement>document.getElementById("progress");
}>(); const value = elem.value;
q.seek(value);
};
</script> </script>
+4 -7
View File
@@ -15,7 +15,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
const menus = [ const menus = [
{ {
name: "home", name: "home",
@@ -53,9 +53,7 @@ const menus = [
.side-nav-container { .side-nav-container {
color: #fff; color: #fff;
margin-bottom: 1rem; margin: 1rem 0;
padding: 10px $small $small;
margin-top: 1rem;
text-transform: capitalize; text-transform: capitalize;
.nav-button { .nav-button {
@@ -63,11 +61,10 @@ const menus = [
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
justify-content: flex-start; justify-content: flex-start;
height: 100%; padding: 0.6rem 0;
padding: 0.6rem 0 0.6rem 0;
&:hover { &:hover {
background-color: $gray; background-color: $gray3;
} }
.nav-icon { .nav-icon {
+2 -4
View File
@@ -34,12 +34,10 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import perks from "../../composables/perks"; import { putCommas } from "../../composables/perks";
import { Track } from "../../interfaces"; import { Track } from "../../interfaces";
import { paths } from "../../config"; import { paths } from "../../config";
const imguri = paths.images.thumb const imguri = paths.images.thumb;
const putCommas = perks.putCommas;
const props = defineProps<{ const props = defineProps<{
track: Track; track: Track;
+4 -10
View File
@@ -5,18 +5,13 @@
<div class="separator no-border"></div> <div class="separator no-border"></div>
<div> <div>
<SongCard :track="queue.current" /> <SongCard :track="queue.current" />
<Progress :seek="queue.seek" :pos="queue.current_time" /> <Progress />
<HotKeys <HotKeys />
:playing="queue.playing"
:playPause="queue.playPause"
:next="queue.playNext"
:prev="queue.playPrev"
/>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import SongCard from "./SongCard.vue"; import SongCard from "./SongCard.vue";
import HotKeys from "./NP/HotKeys.vue"; import HotKeys from "./NP/HotKeys.vue";
import Progress from "./NP/Progress.vue"; import Progress from "./NP/Progress.vue";
@@ -28,9 +23,8 @@ const queue = useQStore();
.l_ { .l_ {
padding: 1rem; padding: 1rem;
background-color: $primary; background-color: $primary;
margin: $small;
text-align: center; text-align: center;
width: 14rem; width: 100%;
display: grid; display: grid;
position: relative; position: relative;
text-transform: capitalize; text-transform: capitalize;
+23
View File
@@ -0,0 +1,23 @@
<template>
<div id="logo-container">
<router-link :to="{ name: 'Home' }">
<div id="logo" class="rounded"></div
></router-link>
</div>
</template>
<style lang="scss">
@import "../assets/css/mixins.scss";
#logo-container {
overflow: hidden;
}
#logo {
height: 4.5rem !important;
width: 15rem;
background-image: url(./../assets/images/logo.webp);
background-size: contain;
@include ximage;
}
</style>
+1 -1
View File
@@ -51,7 +51,7 @@
<script> <script>
import playAudio from "@/composables/playAudio.js"; import playAudio from "@/composables/playAudio.js";
import {ref} from "@vue/reactivity"; import {ref} from "@vue/reactivity";
import perks from "../../composables/perks.js"; import {putCommas, formatSeconds} from "../../composables/perks.js";
import HotKeys from "../shared/HotKeys.vue"; import HotKeys from "../shared/HotKeys.vue";
import Progress from "../shared/Progress.vue"; import Progress from "../shared/Progress.vue";
-14
View File
@@ -15,26 +15,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from "@vue/reactivity";
import useSearchStore from "../../stores/gsearch";
import useTabStore from "../../stores/tabs";
import TabsWrapper from "./TabsWrapper.vue"; import TabsWrapper from "./TabsWrapper.vue";
import Tab from "./Tab.vue"; import Tab from "./Tab.vue";
import TracksGrid from "./Search/TracksGrid.vue"; import TracksGrid from "./Search/TracksGrid.vue";
import AlbumGrid from "./Search/AlbumGrid.vue"; import AlbumGrid from "./Search/AlbumGrid.vue";
import "@/assets/css/Search/Search.scss"; import "@/assets/css/Search/Search.scss";
import ArtistGrid from "./Search/ArtistGrid.vue"; import ArtistGrid from "./Search/ArtistGrid.vue";
const search = useSearchStore();
const tabs = useTabStore();
const search_thing = ref(null);
const artists = reactive({
artists: [],
more: false,
});
</script> </script>
<style lang="scss"> <style lang="scss">
+2 -2
View File
@@ -12,7 +12,7 @@
<p class="title ellip">{{ next.title }}</p> <p class="title ellip">{{ next.title }}</p>
<hr /> <hr />
<p class="artist ellip"> <p class="artist ellip">
<span v-for="artist in perks.putCommas(next.artists)" :key="artist">{{ <span v-for="artist in putCommas(next.artists)" :key="artist">{{
artist artist
}}</span> }}</span>
</p> </p>
@@ -23,7 +23,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Track } from "../../../interfaces"; import { Track } from "../../../interfaces";
import perks from "../../../composables/perks"; import {putCommas} from "../../../composables/perks";
import { paths } from "../../../config"; import { paths } from "../../../config";
const imguri = paths.images.thumb; const imguri = paths.images.thumb;
+4 -4
View File
@@ -29,7 +29,7 @@
<div class="ellip" v-if="props.song.artists[0] !== ''"> <div class="ellip" v-if="props.song.artists[0] !== ''">
<span <span
class="artist" class="artist"
v-for="artist in perks.putCommas(props.song.artists)" v-for="artist in putCommas(props.song.artists)"
:key="artist" :key="artist"
>{{ artist }}</span >{{ artist }}</span
> >
@@ -53,13 +53,13 @@
</div> </div>
</router-link> </router-link>
<div class="song-duration"> <div class="song-duration">
{{ perks.formatSeconds(props.song.length) }} {{ formatSeconds(props.song.length) }}
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import perks from "../../composables/perks.js"; import { putCommas, formatSeconds } from "../../composables/perks";
import useContextStore from "../../stores/context"; import useContextStore from "../../stores/context";
import useModalStore from "../../stores/modal"; import useModalStore from "../../stores/modal";
import useQueueStore from "../../stores/queue"; import useQueueStore from "../../stores/queue";
@@ -67,7 +67,7 @@ import { ContextSrc } from "../../composables/enums";
import { ref } from "vue"; import { ref } from "vue";
import trackContext from "../../contexts/track_context"; import trackContext from "../../contexts/track_context";
import { Track } from "../../interfaces.js"; import { Track } from "../../interfaces";
import { paths } from "../../config"; import { paths } from "../../config";
const contextStore = useContextStore(); const contextStore = useContextStore();
+2 -6
View File
@@ -36,7 +36,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import perks from "../../composables/perks"; import { putCommas } from "../../composables/perks";
import trackContext from "../../contexts/track_context"; import trackContext from "../../contexts/track_context";
import { Track } from "../../interfaces"; import { Track } from "../../interfaces";
import { ContextSrc } from "../../composables/enums"; import { ContextSrc } from "../../composables/enums";
@@ -46,9 +46,8 @@ import useModalStore from "../../stores/modal";
import useQueueStore from "../../stores/queue"; import useQueueStore from "../../stores/queue";
import { paths } from "../../config"; import { paths } from "../../config";
const contextStore = useContextStore(); const contextStore = useContextStore();
const imguri = paths.images.thumb const imguri = paths.images.thumb;
const props = defineProps<{ const props = defineProps<{
track: Track; track: Track;
@@ -78,9 +77,6 @@ const emit = defineEmits<{
(e: "PlayThis", track: Track): void; (e: "PlayThis", track: Track): void;
}>(); }>();
const current = ref(perks.current);
const putCommas = perks.putCommas;
const playThis = (track: Track) => { const playThis = (track: Track) => {
emit("PlayThis", track); emit("PlayThis", track);
}; };
+3 -3
View File
@@ -1,8 +1,8 @@
import perks from "./perks"; import { getElem } from "./perks";
export default (mouseX, mouseY) => { export default (mouseX, mouseY) => {
const scope = perks.getElem("app", "id"); const scope = getElem("app", "id");
const contextMenu = perks.getElem("context-menu", "class"); const contextMenu = getElem("context-menu", "class");
// ? compute what is the mouse position relative to the container element (scope) // ? compute what is the mouse position relative to the container element (scope)
let { left: scopeOffsetX, top: scopeOffsetY } = scope.getBoundingClientRect(); let { left: scopeOffsetX, top: scopeOffsetY } = scope.getBoundingClientRect();
@@ -1,4 +1,4 @@
const putCommas = (artists) => { const putCommas = (artists: string[]) => {
let result = []; let result = [];
artists.forEach((i, index, artists) => { artists.forEach((i, index, artists) => {
@@ -24,18 +24,18 @@ function focusCurrent() {
} }
} }
function getElem(identifier, type) { function getElem(id: string, type: string) {
switch (type) { switch (type) {
case "class": { case "class": {
return document.getElementsByClassName(identifier)[0]; return document.getElementsByClassName(id)[0];
} }
case "id": { case "id": {
return document.getElementById(identifier); return document.getElementById(id);
} }
} }
} }
function formatSeconds(seconds) { function formatSeconds(seconds: number) {
// check if there are arguments // check if there are arguments
const date = new Date(seconds * 1000); const date = new Date(seconds * 1000);
@@ -75,10 +75,4 @@ function formatSeconds(seconds) {
} }
} }
export { putCommas, focusCurrent, formatSeconds, getElem };
export default {
putCommas,
focusCurrent,
formatSeconds,
getElem,
};
-67
View File
@@ -1,67 +0,0 @@
import { defineStore } from "pinia";
import useDebouncedRef from "../composables/useDebouncedRef";
export default defineStore("gsearch", {
state: () => ({
filters: [],
query: useDebouncedRef("", 600),
results: {
tracks: {
items: [],
more: false,
},
albums: {
items: [],
more: false,
},
artists: {
items: [],
more: false,
},
},
}),
actions: {
addFilter(filter) {
if (this.filters.includes(filter)) {
return;
}
this.filters.push(filter);
},
removeFilter(filter) {
this.filters = this.filters.filter((f) => f !== filter);
},
removeLastFilter() {
this.filters.pop();
},
updateQuery(query) {
this.query = query;
},
updateTrackResults(results) {
this.results.tracks = results;
},
addMoreTrackResults(results) {
this.results.tracks.items = [
...this.results.tracks.items,
...results.items,
];
},
updateAlbumResults(results) {
this.results.albums = results;
},
addMoreAlbumResults(results) {
this.results.albums.items = [
...this.results.albums.items,
...results.items,
];
},
updateArtistResults(results) {
this.results.artists = results;
},
addMoreArtistResults(results) {
this.results.artists.items = [
...this.results.artists.items,
...results.items,
];
},
},
});
-1
View File
@@ -12,7 +12,6 @@ export default defineStore("Loader", {
}, },
stopLoading() { stopLoading() {
const diff = new Date().getTime() - this.duration; const diff = new Date().getTime() - this.duration;
console.log(diff);
if (diff <= 250) { if (diff <= 250) {
setTimeout(() => { setTimeout(() => {
+9 -3
View File
@@ -12,7 +12,6 @@ import {
import notif from "../composables/mediaNotification"; import notif from "../composables/mediaNotification";
import { FromOptions } from "../composables/enums"; import { FromOptions } from "../composables/enums";
function writeQueue( function writeQueue(
from: fromFolder | fromAlbum | fromPlaylist, from: fromFolder | fromAlbum | fromPlaylist,
tracks: Track[] tracks: Track[]
@@ -49,11 +48,15 @@ export default defineStore("Queue", {
state: () => ({ state: () => ({
progressElem: HTMLElement, progressElem: HTMLElement,
audio: new Audio(), audio: new Audio(),
track: {
current_time: 0,
duration: 0,
},
current: <Track>{}, current: <Track>{},
length: 0,
next: <Track>{}, next: <Track>{},
prev: <Track>{}, prev: <Track>{},
playing: false, playing: false,
current_time: 0,
from: <fromFolder>{} || <fromAlbum>{} || <fromPlaylist>{}, from: <fromFolder>{} || <fromAlbum>{} || <fromPlaylist>{},
tracks: <Track[]>[defaultTrack], tracks: <Track[]>[defaultTrack],
}), }),
@@ -69,12 +72,15 @@ export default defineStore("Queue", {
this.audio.onerror = reject; this.audio.onerror = reject;
}) })
.then(() => { .then(() => {
this.length = this.audio.duration;
this.audio.play().then(() => { this.audio.play().then(() => {
this.playing = true; this.playing = true;
notif(track, this.playPause, this.playNext, this.playPrev); notif(track, this.playPause, this.playNext, this.playPrev);
this.audio.ontimeupdate = () => { this.audio.ontimeupdate = () => {
this.current_time = this.track.current_time = this.audio.currentTime;
const current_time =
(this.audio.currentTime / this.audio.duration) * 100; (this.audio.currentTime / this.audio.duration) * 100;
elem.style.backgroundSize = `${this.current_time}% 100%`; elem.style.backgroundSize = `${this.current_time}% 100%`;
}; };
+9
View File
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"jsx": "preserve",
"paths": {
"baseUrl": ["./"],
"@/*": ["./src/*"]
}
}
}