Skip to content

Commit 5c40056

Browse files
committed
feat(cassettator-markers): css customization
Facilitates customization via CSS. It is no longer necessary to target the component class in order to redefine the CSS variable, thus improving the developer experience. In concrete terms, this means the following changes: - Before modification: ```css .cst-marker { --cst-marker-played-background-color: blue; } ``` - After modification: ```css .video-js { --cst-marker-played-background-color: blue; } ``` - remove the assignment of a default value to variables - add a new variable for the default background color - add documentation for the new variable
1 parent 992c505 commit 5c40056

File tree

4 files changed

+24
-33
lines changed

4 files changed

+24
-33
lines changed

docs/cassettator-markers.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ You can customize the look and feel of these markers using CSS variables.
3131

3232
| **Variable Name** | **Description** |
3333
|------------------|-----------------|
34+
| `--cst-default-background-color` | Sets default background color to be applied to `.cst-markers:empty` and `.cst-marker` |
3435
| `--cst-markers-background-color` | Sets the background color of the markers in the seek bar. |
36+
| `--cst-marker-background-color` | Sets the background color of the marker in the seek bar. |
3537
| `--cst-marker-played-background-color` | Sets the background color of the played portion of the marker. |
3638
| `--cst-marker-buffered-background-color` | Sets the background color of the buffered portion of the marker. |
37-
| `--cst-marker-background-color` | Sets the background color of the markers in the seek bar. |

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cassettator.js",
3-
"version": "0.69.42035",
3+
"version": "0.420.0",
44
"description": "A collection of video.js components and plugins",
55
"author": "amtins <[email protected]>",
66
"license": "MIT",
+18-28
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
.cassettator-markers .vjs-progress-holder,
2-
.cassettator-markers .vjs-load-progress,
3-
.cassettator-markers .vjs-load-progress div,
4-
.cassettator-markers .vjs-play-progress {
5-
background-color: transparent;
1+
.cassettator-markers {
2+
--cst-default-background-color: rgba(115, 133, 159, 0.5);
3+
/* private variables */
4+
--_cst-marker-played: 0%;
5+
/* TODO implement buffered */
6+
--cst-marker-buffered: 0%;
67
}
78

8-
99
.cassettator-markers .vjs-time-tooltip {
1010
padding: var(--cst-time-tooltip, .15em .25em);
1111
}
1212

1313
.cassettator-markers .vjs-mouse-display .vjs-time-tooltip {
1414
white-space: nowrap;
1515
transform: translateX(-50%);
16-
17-
18-
/* max-width: 10em;
19-
background: blueviolet;
20-
white-space: nowrap;
21-
overflow: hidden;
22-
text-overflow: ellipsis; */
2316
}
2417

2518
/* remove mouse display flickering when hovering with the mouse */
@@ -28,7 +21,6 @@
2821
}
2922

3023
.cst-markers {
31-
--cst-markers-background-color : rgba(115, 133, 159, 0.5);
3224
width: 100%;
3325
height: 100%;
3426
display: flex;
@@ -37,23 +29,21 @@
3729
}
3830

3931
.cst-markers:empty {
40-
background: var(--cst-markers-background-color);
32+
background: var(--cst-markers-background-color, var(--cst-default-background-color));
4133
}
4234

4335
.cst-marker {
44-
--cst-marker-played-background-color: #fff;
45-
--cst-marker-buffered-background-color: transparent;
46-
--cst-marker-background-color : var(--cst-markers-background-color);
47-
--cst-marker-played: 0%;
48-
/* TODO implement buffered */
49-
--cst-marker-buffered: 0%;
50-
5136
height: 100%;
52-
background: linear-gradient(
53-
to right,
54-
var(--cst-marker-played-background-color) var(--cst-marker-played),
55-
var(--cst-marker-buffered-background-color) 0 var(--cst-marker-buffered),
56-
var(--cst-marker-background-color) 0%
57-
);
37+
background: linear-gradient(to right,
38+
var(--cst-marker-played-background-color, #fff) var(--_cst-marker-played),
39+
var(--cst-marker-buffered-background-color, transparent) 0 var(--cst-marker-buffered),
40+
var(--cst-marker-background-color, var(--cst-default-background-color)) 0%);
5841
border-radius: var(--cst-marker-border-radius, 0.05em);
42+
}
43+
44+
.cassettator-markers .vjs-progress-holder,
45+
.cassettator-markers .vjs-load-progress,
46+
.cassettator-markers .vjs-load-progress div,
47+
.cassettator-markers .vjs-play-progress {
48+
background-color: transparent;
5949
}

src/markers/src/marker-display.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ class MarkerDisplay extends videojs.getComponent('component') {
7676

7777
if (currentTime > markerEnd) {
7878
// Setting the value to 200% avoids losing pixel when resizing the player.
79-
this.el().style.setProperty('--cst-marker-played', `200%`);
79+
this.el().style.setProperty('--_cst-marker-played', `200%`);
8080
}
8181

8282
if (currentTime < markerStart) {
83-
this.el().style.setProperty('--cst-marker-played', `0%`);
83+
this.el().style.setProperty('--_cst-marker-played', `0%`);
8484
}
8585

8686
if (currentTime >= markerStart && currentTime <= markerEnd) {
87-
this.el().style.setProperty('--cst-marker-played', `${Math.abs(percent) * 100}%`);
87+
this.el().style.setProperty('--_cst-marker-played', `${Math.abs(percent) * 100}%`);
8888
}
8989
}
9090

0 commit comments

Comments
 (0)