Skip to content

Commit

Permalink
chore: prettier formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbrayo committed Aug 1, 2024
1 parent 4f10931 commit 05a7a41
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 233 deletions.
17 changes: 13 additions & 4 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
{
"source": "functions",
"codebase": "default",
"ignore": ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
],
"firestore": {
"rules": "src/firebase/firestore.rules",
"indexes": "src/firebase/firestore.indexes.json"
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
Expand Down
19 changes: 3 additions & 16 deletions src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,10 @@ body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
transition: color 0.5s, background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
Expand Down
5 changes: 2 additions & 3 deletions src/components/Apikey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<AWLHeader />
<div>
<h1>API Key</h1>
<p>Your API key is: {{ apiKey }} <ContentCopyIcon @click ="copyApikey"/></p>
<SnackBarVue :message="snackbarMessage" ref="snackbar"/>
<p>Your API key is: {{ apiKey }} <ContentCopyIcon @click="copyApikey" /></p>
<SnackBarVue :message="snackbarMessage" ref="snackbar" />
<button @click="rotateKey">Rotate Key</button>
</div>
</template>
Expand Down Expand Up @@ -31,7 +31,6 @@ const rotateKey = () => {
store.rotateKey()
snackbarMessage.value = 'ApiKey rotated'
}
</script>

<style scoped></style>
3 changes: 1 addition & 2 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<script lang="ts" setup>
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import LogOutIcon from "vue-material-design-icons/Logout.vue"
import LogOutIcon from 'vue-material-design-icons/Logout.vue'

const router = useRouter()
const { user, logout } = useAuthStore()
Expand All @@ -42,7 +42,6 @@ const handleLogout = async () => {
console.error('Logout failed:', error)
}
}

</script>

<style scoped>
Expand Down
3 changes: 1 addition & 2 deletions src/components/Leaderboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ onMounted(async () => {
// Helper method to format time in minutes and hours
const formatTime = (seconds: number) => {
const hours = Math.floor(seconds / 3600)
const minutes = Math.ceil(seconds % 3600 / 60)
const minutes = Math.ceil((seconds % 3600) / 60)
return `${hours}h ${minutes}m`
}
</script>

<style scoped>
Expand Down
67 changes: 35 additions & 32 deletions src/components/PieChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
</template>

<script setup lang="ts">
import { ref, watch, onMounted } from 'vue';
import type { ScreenTimeSummary } from '@/types';
import autocolors from 'chartjs-plugin-autocolors';
import { Chart as ChartJS, ArcElement,PieController} from 'chart.js';
import { ref, watch, onMounted } from 'vue'
import type { ScreenTimeSummary } from '@/types'
import autocolors from 'chartjs-plugin-autocolors'
import { Chart as ChartJS, ArcElement, PieController } from 'chart.js'
ChartJS.register(autocolors, ArcElement, PieController);
ChartJS.register(autocolors, ArcElement, PieController)
interface Props {
summaries: ScreenTimeSummary[] | null;
summaries: ScreenTimeSummary[] | null
}
const props = defineProps<Props>();
const canvasRef = ref<HTMLCanvasElement>();
const props = defineProps<Props>()
const canvasRef = ref<HTMLCanvasElement>()
const getChartData = () => {
const uniqueCategoriesSet: Set<string> = new Set();
const uniqueCategoriesSet: Set<string> = new Set()
props.summaries?.forEach((summary) => {
for (const category in summary.categoryTotals) {
uniqueCategoriesSet.add(category);
uniqueCategoriesSet.add(category)
}
});
const uniqueCategories = Array.from(uniqueCategoriesSet);
const categoryTotals: number[] = [];
})
const uniqueCategories = Array.from(uniqueCategoriesSet)
const categoryTotals: number[] = []
for (const category of uniqueCategories) {
const categoryTotal = props.summaries?.reduce((acc, summary) => {
return acc + (summary.categoryTotals[category] || 0);
}, 0);
categoryTotals.push(categoryTotal || 0);
return acc + (summary.categoryTotals[category] || 0)
}, 0)
categoryTotals.push(categoryTotal || 0)
}
return {
labels: uniqueCategories,
Expand All @@ -40,16 +40,16 @@ const getChartData = () => {
data: categoryTotals
}
]
};
};
}
}
const renderChart = () => {
const canvas = canvasRef.value;
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (!ctx) return;
const canvas = canvasRef.value
if (!canvas) return
const ctx = canvas.getContext('2d')
if (!ctx) return
ChartJS.getChart(canvas)?.destroy();
ChartJS.getChart(canvas)?.destroy()
new ChartJS(ctx, {
type: 'pie',
Expand All @@ -63,17 +63,20 @@ const renderChart = () => {
}
}
}
});
};
})
}
watch( () => props.summaries, (newValue, oldValue) => {
if (newValue !== oldValue) {
renderChart();
}
}, { deep: true });
watch(
() => props.summaries,
(newValue, oldValue) => {
if (newValue !== oldValue) {
renderChart()
}
},
{ deep: true }
)
onMounted(()=>{
onMounted(() => {
renderChart()
})
</script>

128 changes: 64 additions & 64 deletions src/components/SnackBar.vue
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
<template>
<div v-if="show" class="snackbar" :class="{ show: show }">
{{ message }}
</div>
<div v-if="show" class="snackbar" :class="{ show: show }">
{{ message }}
</div>
</template>

<script lang="ts">
export default {
props: {
props: {
message: {
type: String,
required: true,
type: String,
required: true
},
duration: {
type: Number,
default: 3000,
},
},
data() {
type: Number,
default: 3000
}
},
data() {
return {
show: false,
};
},
methods: {
show: false
}
},
methods: {
display() {
this.show = true;
setTimeout(() => {
this.show = false;
}, this.duration);
},
},
watch: {
this.show = true
setTimeout(() => {
this.show = false
}, this.duration)
}
},
watch: {
message() {
this.display();
},
},
};
this.display()
}
}
}
</script>

<style scoped>
.snackbar {
visibility: hidden;
min-width: 250px;
margin-left: -125px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 2px;
padding: 16px;
position: fixed;
z-index: 1;
left: 50%;
.snackbar {
visibility: hidden;
min-width: 250px;
margin-left: -125px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 2px;
padding: 16px;
position: fixed;
z-index: 1;
left: 50%;
bottom: 30px;
font-size: 17px;
}
.snackbar.show {
visibility: visible;
animation: fadein 0.5s, fadeout 0.5s 2.5s;
}
@keyframes fadein {
from {
bottom: 0;
opacity: 0;
}
to {
bottom: 30px;
font-size: 17px;
}
.snackbar.show {
visibility: visible;
animation: fadein 0.5s, fadeout 0.5s 2.5s;
}
@keyframes fadein {
from {
bottom: 0;
opacity: 0;
}
to {
bottom: 30px;
opacity: 1;
}
}
@keyframes fadeout {
from {
bottom: 30px;
opacity: 1;
}
to {
bottom: 0;
opacity: 0;
}
}
opacity: 1;
}
}
@keyframes fadeout {
from {
bottom: 30px;
opacity: 1;
}
to {
bottom: 0;
opacity: 0;
}
}
</style>
Loading

0 comments on commit 05a7a41

Please sign in to comment.