Skip to content

Commit fbb24d9

Browse files
committed
Add shadow for slice of chart on hover
1 parent 1cd3667 commit fbb24d9

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

src/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
<div id="resultTable" class="list-of-site"></div>
2929
<div id="total" class="inline-flex"></div>
3030
<div id="byDays" class="calendar-block"></div>
31+
32+
<svg class="height-0">
33+
<filter id="dropShadow">
34+
<feGaussianBlur in="SourceAlpha" stdDeviation="3"/>
35+
<feOffset dx="0" dy="1" />
36+
<feMerge>
37+
<feMergeNode />
38+
<feMergeNode in="SourceGraphic" />
39+
</feMerge>
40+
</filter>
41+
</svg>
3142
</body>
3243

3344
</html>

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"name": "Web Activity Time Tracker",
55
"short_name": "Web Time Tracker",
6-
"version": "1.0.3",
6+
"version": "1.1.0",
77
"minimum_chrome_version": "26",
88

99
"description": "Track and limit time your activity in the browser.",

src/scripts/ui.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,23 @@ class UI {
124124
div.addEventListener('mouseenter', function () {
125125
if (document.getElementById('chart').innerHTML !== '') {
126126
var item = document.getElementById(tab.url);
127-
if (item !== null)
127+
if (item !== null) {
128128
item.dispatchEvent(new Event('mouseenter'));
129-
else document.getElementById('Others').dispatchEvent(new Event('mouseenter'));
129+
item.classList.add('mouse-over');
130+
}
131+
else {
132+
document.getElementById('Others').dispatchEvent(new Event('mouseenter'));
133+
document.getElementById('Others').classList.add('mouse-over');
134+
}
135+
}
136+
});
137+
div.addEventListener('mouseout', function () {
138+
if (document.getElementById('chart').innerHTML !== '') {
139+
var item = document.getElementById(tab.url);
140+
if (item !== null) {
141+
item.classList.remove('mouse-over');
142+
}
143+
else document.getElementById('Others').classList.remove('mouse-over');
130144
}
131145
});
132146
div.classList.add('inline-flex');
@@ -332,7 +346,7 @@ class UI {
332346
var resultList = [];
333347
allDays.forEach(element => {
334348
var day = days.find(x => x.date == element);
335-
if (day !== undefined){
349+
if (day !== undefined) {
336350
resultList.push({
337351
'date': day.date,
338352
'total': day.total
@@ -343,7 +357,7 @@ class UI {
343357
'total': 0
344358
});
345359
});
346-
360+
347361
return resultList;
348362
}
349363
}

src/style/chart.css

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/* Add shadow effect to chart. If you don't like it, get rid of it. */
2-
svg {
3-
-webkit-filter: drop-shadow( 0px 2px 2px rgba(0,0,0,.3) );
4-
filter: drop-shadow( 0px 2px 2px rgba(0,0,0,.25) );
5-
}
6-
71
/*Styling for the lines connecting the labels to the slices*/
82
polyline{
93
opacity: .3;
@@ -38,6 +32,18 @@ tspan{
3832
font-weight: 600 !important;
3933
}
4034

35+
g.slices > path:hover{
36+
transform: translate(0,-1px);
37+
filter: url(#dropShadow);
38+
transition: transform .1s;
39+
}
40+
41+
g.slices > path.mouse-over{
42+
transform: translate(0,-1px);
43+
filter: url(#dropShadow);
44+
transition: transform .1s;
45+
}
46+
4147
/*styles for chart of days*/
4248
.axis path,
4349
.axis line {
@@ -91,3 +97,7 @@ tspan{
9197
.red-label{
9298
color:red;
9399
}
100+
101+
.height-0{
102+
height: 0 !important;
103+
}

0 commit comments

Comments
 (0)