Skip to content

Commit

Permalink
add icons in contextmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelk authored and Chocobozzz committed Apr 12, 2021
1 parent de77903 commit 83ff548
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/src/assets/player/images/code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/player/images/link-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/player/images/repeat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions client/src/assets/player/peertube-player-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ export class PeertubePlayerManager {
const isLoopEnabled = player.options_['loop']
const items = [
{
label: isLoopEnabled ? player.localize('Stop playing in loop') : player.localize('Play in loop'),
icon: 'repeat',
label: player.localize('Play in loop') + (isLoopEnabled ? '<span class="vjs-icon-tick-white"></span>' : ''),
listener: function () {
player.options_['loop'] = !isLoopEnabled
}
Expand All @@ -518,6 +519,7 @@ export class PeertubePlayerManager {
}
},
{
icon: 'code',
label: player.localize('Copy embed code'),
listener: () => {
copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle))
Expand All @@ -534,7 +536,10 @@ export class PeertubePlayerManager {
})
}

return items
return items.map(i => ({
...i,
label: `<span class="vjs-icon-${i.icon || 'link-2'}"></span>` + i.label
}))
}

// adding the menu
Expand Down
28 changes: 27 additions & 1 deletion client/src/sass/player/context-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ $context-menu-width: 350px;
.video-js .vjs-contextmenu-ui-menu {
position: absolute;
background-color: rgba(0, 0, 0, 0.5);
padding: 5px 0;
padding: 8px 0;
border-radius: 4px;
width: $context-menu-width;

.vjs-menu-content {
Expand All @@ -29,5 +30,30 @@ $context-menu-width: 350px;
&:hover {
background-color: rgba(255, 255, 255, 0.2);
}

[class^="vjs-icon-"] {
display: inline-flex;
position: relative;
top: 2px;
cursor: pointer;
width: 14px;
height: 14px;
background-color: white;
mask-size: cover;
margin-right: 0.8rem !important;

$icons: 'link-2', 'repeat', 'code', 'tick-white';

@each $icon in $icons {
&[class$="-#{$icon}"] {
mask-image: url('#{$assets-path}/player/images/#{$icon}.svg');
}
}

&[class$="-tick-white"] {
float: right;
margin: 0 !important;
}
}
}
}

0 comments on commit 83ff548

Please sign in to comment.