Skip to content

Commit

Permalink
feat(cassettator-markers): css customization
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amtins committed Dec 3, 2023
1 parent 992c505 commit 5c40056
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 33 deletions.
3 changes: 2 additions & 1 deletion docs/cassettator-markers.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ You can customize the look and feel of these markers using CSS variables.

| **Variable Name** | **Description** |
|------------------|-----------------|
| `--cst-default-background-color` | Sets default background color to be applied to `.cst-markers:empty` and `.cst-marker` |
| `--cst-markers-background-color` | Sets the background color of the markers in the seek bar. |
| `--cst-marker-background-color` | Sets the background color of the marker in the seek bar. |
| `--cst-marker-played-background-color` | Sets the background color of the played portion of the marker. |
| `--cst-marker-buffered-background-color` | Sets the background color of the buffered portion of the marker. |
| `--cst-marker-background-color` | Sets the background color of the markers in the seek bar. |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cassettator.js",
"version": "0.69.42035",
"version": "0.420.0",
"description": "A collection of video.js components and plugins",
"author": "amtins <[email protected]>",
"license": "MIT",
Expand Down
46 changes: 18 additions & 28 deletions src/markers/css/cassettator-markers.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
.cassettator-markers .vjs-progress-holder,
.cassettator-markers .vjs-load-progress,
.cassettator-markers .vjs-load-progress div,
.cassettator-markers .vjs-play-progress {
background-color: transparent;
.cassettator-markers {
--cst-default-background-color: rgba(115, 133, 159, 0.5);
/* private variables */
--_cst-marker-played: 0%;
/* TODO implement buffered */
--cst-marker-buffered: 0%;
}


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

.cassettator-markers .vjs-mouse-display .vjs-time-tooltip {
white-space: nowrap;
transform: translateX(-50%);


/* max-width: 10em;
background: blueviolet;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis; */
}

/* remove mouse display flickering when hovering with the mouse */
Expand All @@ -28,7 +21,6 @@
}

.cst-markers {
--cst-markers-background-color : rgba(115, 133, 159, 0.5);
width: 100%;
height: 100%;
display: flex;
Expand All @@ -37,23 +29,21 @@
}

.cst-markers:empty {
background: var(--cst-markers-background-color);
background: var(--cst-markers-background-color, var(--cst-default-background-color));
}

.cst-marker {
--cst-marker-played-background-color: #fff;
--cst-marker-buffered-background-color: transparent;
--cst-marker-background-color : var(--cst-markers-background-color);
--cst-marker-played: 0%;
/* TODO implement buffered */
--cst-marker-buffered: 0%;

height: 100%;
background: linear-gradient(
to right,
var(--cst-marker-played-background-color) var(--cst-marker-played),
var(--cst-marker-buffered-background-color) 0 var(--cst-marker-buffered),
var(--cst-marker-background-color) 0%
);
background: linear-gradient(to right,
var(--cst-marker-played-background-color, #fff) var(--_cst-marker-played),
var(--cst-marker-buffered-background-color, transparent) 0 var(--cst-marker-buffered),
var(--cst-marker-background-color, var(--cst-default-background-color)) 0%);
border-radius: var(--cst-marker-border-radius, 0.05em);
}

.cassettator-markers .vjs-progress-holder,
.cassettator-markers .vjs-load-progress,
.cassettator-markers .vjs-load-progress div,
.cassettator-markers .vjs-play-progress {
background-color: transparent;
}
6 changes: 3 additions & 3 deletions src/markers/src/marker-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ class MarkerDisplay extends videojs.getComponent('component') {

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

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

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

Expand Down

0 comments on commit 5c40056

Please sign in to comment.