Skip to content

Commit 5874ef9

Browse files
committed
Change popup UI and add settings page
1 parent cf07e61 commit 5874ef9

File tree

12 files changed

+91
-28
lines changed

12 files changed

+91
-28
lines changed

src/assets/css/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
:root {
22
--main-color: #6ebf5d;
3+
--popup-header: #d7d7d7;
34
}
45
::-webkit-scrollbar-track {
56
border-radius: 10px;
@@ -25,6 +26,9 @@
2526
.ml-10{
2627
margin-left: 10px;
2728
}
29+
.mr-10{
30+
margin-right: 10px;
31+
}
2832
.text-right{
2933
text-align: right;
3034
}

src/background.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import Browser from 'webextension-polyfill';
22
import { initTracker } from './tracker';
33
import { logger } from './compositions/logger';
4-
import { useFavicon } from './compositions/update-favicon';
54

65
logger.log('Start background script');
76

87
Browser.runtime.onInstalled.addListener(details => {
98
logger.log('Extension installed:', details);
109
});
1110

12-
Browser.webNavigation.onCompleted.addListener(async function (details) {
13-
await useFavicon(details.tabId);
14-
});
15-
1611
initTracker();

src/components/Favicon.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<img
33
v-if="favicon == undefined || favicon == ''"
4-
class="favicon"
4+
class="favicon no-favicon"
55
height="22"
66
:src="NO_FAVICON_URL"
77
/>
@@ -31,4 +31,7 @@ const props = defineProps<{
3131
.favicon {
3232
padding: 5px;
3333
}
34+
.no-favicon {
35+
margin: 0 5px;
36+
}
3437
</style>

src/components/TabItem.vue

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<template>
22
<div class="tab-item">
33
<Favicon :favicon="tab.favicon" />
4-
<div class="ml-10 display-inline-block">
5-
<p class="url">{{ tab.url }}</p>
6-
<p>{{ sessions }}</p>
7-
</div>
8-
<div class="display-inline-block float-right">
9-
<p class="text-right time">{{ summaryTimeForTab }}</p>
10-
<p class="text-right">{{ percent }} %</p>
11-
</div>
12-
<div class="progress-bar">
13-
<div :style="styleForProgressBar"></div>
4+
<div class="ml-10 flex-grow-2">
5+
<div class="display-inline-block">
6+
<p class="url">{{ tab.url }}</p>
7+
<p>{{ sessions }}</p>
8+
</div>
9+
<div class="display-inline-block float-right">
10+
<p class="text-right time">{{ summaryTimeForTab }}</p>
11+
<p class="text-right">{{ percent }} %</p>
12+
</div>
13+
<div class="progress-bar">
14+
<div :style="styleForProgressBar"></div>
15+
</div>
1416
</div>
1517
</div>
1618
</template>
@@ -54,6 +56,9 @@ const styleForProgressBar = computed(() => `width: ${percent}%`);
5456
border: 1px transparent solid;
5557
border-radius: 10px;
5658
margin: 10px;
59+
display: flex;
60+
justify-content: flex-start;
61+
align-items: center;
5762
}
5863
.tab-item:hover {
5964
border: 1px rgb(202, 202, 202) solid;
@@ -74,12 +79,15 @@ const styleForProgressBar = computed(() => `width: ${percent}%`);
7479
font-weight: 600;
7580
}
7681
.tab-item .progress-bar {
77-
margin: 5px 0 0 45px;
82+
margin: 5px 0 0 5px;
7883
border-radius: 10px;
7984
border: 1px rgb(225 224 224) solid;
8085
}
8186
.tab-item .progress-bar div {
8287
height: 6px;
8388
background-color: var(--main-color);
8489
}
90+
.flex-grow-2 {
91+
flex-grow: 2;
92+
}
8593
</style>

src/components/TabList.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ onMounted(async () => {
3737
let unSortedTabs = repo.getTodayTabs();
3838
tabs.value = unSortedTabs?.sort(function (a: Tab, b: Tab) {
3939
return (
40-
b.days.find(s => s.date === todayLocalDate())!.summary - a.days.find(s => s.date === todayLocalDate())!.summary
40+
b.days.find(s => s.date === todayLocalDate())!.summary -
41+
a.days.find(s => s.date === todayLocalDate())!.summary
4142
);
4243
});
4344
});

src/pages/Blocked.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template></template>
2+
3+
<script lang="ts" setup></script>

src/pages/Popup.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
<template>
22
<div class="headerBlock">
33
<p class="header">Web Activity Time Tracker</p>
4-
<div class="float-right">
4+
<div class="float-right mr-10">
55
<img
66
height="20"
77
src="../assets/icons/dark-mode.svg"
88
/>
99
<img
1010
height="20"
1111
src="../assets/icons/settings.svg"
12+
@click="openSettings()"
1213
/>
1314
</div>
1415
</div>
1516
<TabList />
1617
</template>
1718

1819
<script lang="ts" setup>
20+
import Browser from 'webextension-polyfill';
1921
import TabList from '../components/TabList.vue';
22+
23+
async function openSettings() {
24+
await Browser.tabs.create({
25+
url: Browser.runtime.getURL('settings.html'),
26+
active: true,
27+
});
28+
}
2029
</script>
2130

2231
<style>
@@ -30,15 +39,15 @@ body {
3039
3140
.headerBlock {
3241
height: 50px;
33-
background-color: var(--main-color);
42+
background-color: var(--popup-header);
3443
}
3544
3645
.headerBlock .header {
3746
font-size: 16px;
3847
padding: 0 20px;
3948
display: inline-block;
4049
font-weight: 600;
41-
color: white;
50+
color: rgb(0, 0, 0);
4251
}
4352
4453
.headerBlock img {

src/pages/Settings.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>settings</template>
2+
3+
<script lang="ts" setup></script>
4+
5+
<style></style>

src/popup.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
<title>Popup</title>
1414
</head>
1515

16-
<body></body>
16+
<body>
17+
<script
18+
type="module"
19+
src="./popup.ts"
20+
></script>
21+
</body>
1722

1823
<link
1924
rel="stylesheet"
2025
href="assets/css/main.css"
2126
/>
22-
<script type="module">
23-
import Popup from './pages/Popup.vue';
24-
import { createApp } from 'vue';
25-
26-
createApp(Popup).mount('body');
27-
</script>
2827
</html>

src/popup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Popup from './pages/Popup.vue';
2+
import { router } from './router';
3+
import { createApp } from 'vue';
4+
5+
createApp(Popup).use(router).mount('body');

0 commit comments

Comments
 (0)