Skip to content

Commit 67aa84d

Browse files
committed
Fix tracker styling issues when left aligned or scrolling
1 parent 7e1cff7 commit 67aa84d

File tree

3 files changed

+192
-188
lines changed

3 files changed

+192
-188
lines changed

module/clock-panel.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
118118
// Update the last rendered list (to get ready for next cycle)
119119
this.lastRendered = rendered;
120120

121-
for (const clock of html.querySelectorAll(".clock-entry.editable :where(.clock, .points, .tracker)")) {
121+
const elements = [".clock-element", ".points-element", ".tracker-element"].join(", ");
122+
for (const clock of html.querySelectorAll(`.clock-entry.editable :where(${elements})`)) {
122123
clock.addEventListener("click", (event) => {
123124
const clockId = event.target.closest("[data-id]").dataset.id;
124125
const clock = this.db.get(clockId);

styles/style.css

Lines changed: 154 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ body:has(#effects-panel .effect-item) #clock-panel {
7373

7474
/** Flip everything when left aligned */
7575
&.left {
76-
.clock-entry {
76+
.clock-entry:not(.tracker) {
7777
flex-direction: row-reverse;
7878
&::before {
7979
border-radius: calc(var(--entry-height) / 2) 4px 4px calc(var(--entry-height) / 2);
@@ -150,21 +150,23 @@ body:has(#effects-panel .effect-item) #clock-panel {
150150
min-width: var(--entry-width);
151151
max-width: var(--max-entry-width);
152152

153-
&::before {
154-
content: " ";
155-
position: absolute;
156-
width: 100%;
157-
height: 100%;
153+
&:not(.tracker) {
154+
&::before {
155+
content: " ";
156+
position: absolute;
157+
width: 100%;
158+
height: 100%;
158159

159-
border-radius: 4px calc(var(--entry-height) / 2) calc(var(--entry-height) / 2) 4px;
160-
background: var(--control-bg-color);
161-
border: 1px solid var(--control-border-color);
162-
z-index: 0;
163-
}
160+
border-radius: 4px calc(var(--entry-height) / 2) calc(var(--entry-height) / 2) 4px;
161+
background: var(--control-bg-color);
162+
border: 1px solid var(--control-border-color);
163+
z-index: 0;
164+
}
164165

165-
&.private::before {
166-
border-color: var(--private-highlight-color);
167-
box-shadow: 0 0 3px inset var(--private-highlight-color);
166+
&.private::before {
167+
border-color: var(--private-highlight-color);
168+
box-shadow: 0 0 3px inset var(--private-highlight-color);
169+
}
168170
}
169171

170172
&.hidden {
@@ -223,7 +225,106 @@ body:has(#effects-panel .effect-item) #clock-panel {
223225
}
224226
}
225227

226-
.points {
228+
/* Show controls, hide real name, when hovering */
229+
&:has(.controls):hover {
230+
.controls {
231+
display: flex;
232+
}
233+
234+
.name > .value {
235+
visibility: hidden;
236+
}
237+
}
238+
239+
&.editable .graphic {
240+
cursor: pointer;
241+
}
242+
243+
/* Tracker Styles */
244+
&:has(.tracker-container) {
245+
height: auto;
246+
min-height: var(--entry-height);
247+
background: transparent;
248+
border: none;
249+
justify-content: flex-end;
250+
}
251+
252+
&:has(.tracker-container)::before {
253+
display: none;
254+
}
255+
256+
&:has(.tracker-container) > .name {
257+
display: none;
258+
}
259+
260+
&.tracker {
261+
display: flex;
262+
flex-direction: column;
263+
align-items: center;
264+
gap: 0;
265+
width: 100%;
266+
justify-content: flex-end;
267+
height: unset;
268+
269+
.name {
270+
align-items: center;
271+
align-self: center;
272+
background: var(--control-bg-color);
273+
border-radius: 4px 4px 0 0;
274+
border: 1px solid var(--control-border-color);
275+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
276+
color: var(--control-icon-color);
277+
display: flex;
278+
font-size: 14px;
279+
gap: 8px;
280+
justify-content: space-between;
281+
max-width: none;
282+
padding: 0 8px;
283+
position: relative;
284+
white-space: nowrap;
285+
width: 100%;
286+
flex: 1 0 1.5rem;
287+
288+
.value {
289+
order: 2;
290+
overflow: hidden;
291+
text-overflow: ellipsis;
292+
text-align: right;
293+
flex: 1;
294+
}
295+
296+
.tracker-controls {
297+
display: none;
298+
order: 1;
299+
flex-direction: row;
300+
align-items: center;
301+
justify-content: center;
302+
gap: 1px;
303+
border-radius: inherit;
304+
flex-shrink: 0;
305+
font-size: 0.85em;
306+
307+
a {
308+
color: white;
309+
cursor: pointer;
310+
}
311+
}
312+
313+
&:hover .tracker-controls {
314+
display: flex;
315+
}
316+
}
317+
318+
&:hover .value {
319+
opacity: 1;
320+
transition: opacity 0s;
321+
}
322+
}
323+
}
324+
325+
/** Styling for the actual element, separated for reusability */
326+
#clock-panel {
327+
.points-element {
227328
background: white;
228329
border-radius: 25%;
229330
border: black 2px solid;
@@ -244,7 +345,7 @@ body:has(#effects-panel .effect-item) #clock-panel {
244345
z-index: 1;
245346
}
246347

247-
.clock {
348+
.clock-element {
248349
width: var(--entry-height);
249350
height: var(--entry-height);
250351

@@ -277,103 +378,10 @@ body:has(#effects-panel .effect-item) #clock-panel {
277378
}
278379
}
279380

280-
/* Show controls, hide real name, when hovering */
281-
&:has(.controls):hover {
282-
.controls {
283-
display: flex;
284-
}
285-
286-
.name > .value {
287-
visibility: hidden;
288-
}
289-
}
290-
291-
&.editable {
292-
.points,
293-
.clock,
294-
.tracker {
295-
cursor: pointer;
296-
}
297-
}
298-
299-
/* Tracker Styles */
300-
&:has(.tracker-container) {
301-
height: auto;
302-
min-height: var(--entry-height);
303-
background: transparent;
304-
border: none;
305-
justify-content: flex-end;
306-
}
307-
308-
&:has(.tracker-container)::before {
309-
display: none;
310-
}
311-
312-
&:has(.tracker-container) > .name {
313-
display: none;
314-
}
315-
316-
.tracker-container {
317-
display: flex;
318-
flex-direction: column;
319-
align-items: center;
320-
gap: 0;
321-
width: 100%;
322-
justify-content: flex-end;
323-
}
324-
325-
.tracker-name {
326-
background: var(--control-bg-color);
327-
color: var(--control-icon-color);
328-
border: 1px solid var(--control-border-color);
329-
padding: 4px 8px;
330-
border-radius: 4px 4px 0 0;
331-
font-size: 14px;
332-
width: 100%;
333-
max-width: none;
334-
align-self: center;
335-
white-space: nowrap;
336-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
337-
position: relative;
338-
display: flex;
339-
gap: 8px;
340-
align-items: center;
341-
justify-content: space-between;
342-
343-
.value {
344-
order: 2;
345-
overflow: hidden;
346-
text-overflow: ellipsis;
347-
text-align: right;
348-
flex: 1;
349-
}
350-
351-
.tracker-controls {
352-
display: none;
353-
order: 1;
354-
flex-direction: row;
355-
align-items: center;
356-
justify-content: center;
357-
gap: 1px;
358-
border-radius: inherit;
359-
flex-shrink: 0;
360-
font-size: 0.85em;
361-
362-
a {
363-
color: white;
364-
cursor: pointer;
365-
}
366-
}
367-
368-
&:hover .tracker-controls {
369-
display: flex;
370-
}
371-
}
372-
373-
.tracker {
381+
.tracker-element {
374382
background: var(--entry-background);
375383
overflow: hidden;
376-
height: 32px;
384+
flex: 1 0 1.75rem;
377385
width: 100%;
378386
position: relative;
379387
display: flex;
@@ -383,48 +391,43 @@ body:has(#effects-panel .effect-item) #clock-panel {
383391
padding-right: 8px;
384392
border: 2px solid var(--control-border-color);
385393
border-radius: 0 0 4px 4px;
386-
border-top: none;
387-
}
388-
389-
.tracker-value {
390-
font-size: 20px;
391-
font-weight: 600;
392-
color: white;
393-
z-index: 2;
394-
padding: 0px 3px;
395-
background: rgba(0, 0, 0, 0.4);
396-
border-radius: 3px;
397-
opacity: 0;
398-
transition: opacity 0.2s;
399-
}
394+
border-top: none;
400395

401-
.tracker-container:hover .tracker-value {
402-
opacity: 1;
403-
transition: opacity 0s;
404-
}
405-
406-
.tracker-slashes {
407-
position: absolute;
408-
height: 100%;
409-
width: 100%;
410-
left: -4px;
411-
gap: 4px;
412-
display: flex;
413-
flex-direction: row;
414-
align-items: center;
415-
pointer-events: none;
416-
}
396+
.value {
397+
font-size: 20px;
398+
font-weight: 600;
399+
color: white;
400+
z-index: 2;
401+
padding: 0px 3px;
402+
background: rgba(0, 0, 0, 0.4);
403+
border-radius: 3px;
404+
opacity: 0;
405+
transition: opacity 0.2s;
406+
}
417407

418-
.tracker-slash {
419-
height: 100%;
420-
width: calc((100% - (var(--max) - 1) * 4px) / (var(--max) - 0.2));
421-
background: var(--entry-color);
422-
transform: skewX(-15deg);
423-
flex-shrink: 0;
424-
opacity: 0.2;
425-
}
408+
.tracker-slashes {
409+
position: absolute;
410+
height: 100%;
411+
width: 100%;
412+
left: -4px;
413+
gap: 4px;
414+
display: flex;
415+
flex-direction: row;
416+
align-items: center;
417+
pointer-events: none;
418+
419+
.slash {
420+
height: 100%;
421+
width: calc((100% - (var(--max) - 1) * 4px) / (var(--max) - 0.2));
422+
background: var(--entry-color);
423+
transform: skewX(-15deg);
424+
flex-shrink: 0;
425+
opacity: 0.2;
426+
}
426427

427-
.tracker-slash.filled {
428-
opacity: 1;
428+
.slash.filled {
429+
opacity: 1;
430+
}
431+
}
429432
}
430433
}

0 commit comments

Comments
 (0)