<div class="m-continue-video-guide js-guide-continue ">
    <button type="button" class="a-button a-button--peacock-light background-peacock-light a-button--icon a-button--standalone-icon m-continue-video-guide__close js-guide-close">
        <span class="a-button__text u-visuallyhidden">Stäng</span>
        <svg class="icon a-button__icon u-icon--smallest">
            <use xlink:href="#icon-close"></use>
        </svg>
    </button>
    <div class="m-continue-video-guide__inner">
        <a href="/components/detail/video-guide.html" class="m-continue-video-guide__continue js-guide-continue-link" data-alt-text="Fortsätt den guidade turen">
            <span class="u-visuallyhidden">Guidad tur</span>
            <div class="m-continue-video-guide__arrow"></div>
        </a>
        <progress-ring class="m-continue-video-guide__progressbar" stroke="4" radius="50" progress="70"></progress-ring>
        <img class="m-continue-video-guide__image js-guide-continue-image" src="/assets/images/sticky-guide.png" alt="Fortsätt den guidade turen">
    </div>
</div>
<div class="m-continue-video-guide js-guide-continue {{#if additional_classes}}{{additional_classes}}{{/if}}">
<button type="button" class="a-button a-button--peacock-light background-peacock-light a-button--icon a-button--standalone-icon m-continue-video-guide__close js-guide-close">
	<span class="a-button__text u-visuallyhidden">Stäng</span>
	<svg class="icon a-button__icon u-icon--smallest">
        <use xlink:href="#icon-close"></use>
	</svg>
</button>
	<div class="m-continue-video-guide__inner">
		<a href="/components/detail/video-guide.html" class="m-continue-video-guide__continue js-guide-continue-link" data-alt-text="Fortsätt den guidade turen">
			<span class="u-visuallyhidden">Guidad tur</span>
			<div class="m-continue-video-guide__arrow"></div>
		</a>
		<progress-ring class="m-continue-video-guide__progressbar" stroke="4" radius="50" progress="70"></progress-ring>
		<img class="m-continue-video-guide__image js-guide-continue-image" src="/assets/images/sticky-guide.png" alt="Fortsätt den guidade turen">
	</div>
</div>
{
  "additional_classes": false
}
  • Content:
    import className from '../../assets/js/className';
    
    class ProgressRing extends HTMLElement {
    	constructor() {
    		super();
    		const stroke = this.getAttribute('stroke');
    		const radius = this.getAttribute('radius');
    		const normalizedRadius = radius - stroke * 2;
    		this.circumference = normalizedRadius * 2 * Math.PI;
    
    		this.root = this.attachShadow({ mode: 'open' });
    		this.root.innerHTML = `
    		<svg
    		height="${radius * 2}"
    		width="${radius * 2}"
    		>
    		<circle
    		stroke="white"
    		stroke-dasharray="${this.circumference} ${this.circumference}"
    		style="stroke-dashoffset:${this.circumference}"
    		stroke-width="${stroke}"
    		fill="transparent"
    		r="${normalizedRadius}"
    		cx="${radius}"
    		cy="${radius}"
    		/>
    		</svg>
    
    		<style>
    		circle {
    			transition: stroke-dashoffset 0.35s;
    			transform: rotate(-90deg);
    			transform-origin: 50% 50%;
    		}
    		</style>
    		`;
    	}
    
    	setProgress(percent) {
    		const offset = this.circumference - ((percent / 100) * this.circumference);
    		const circle = this.root.querySelector('circle');
    		circle.style.strokeDashoffset = offset;
    	}
    
    	static get observedAttributes() {
    		return ['progress'];
    	}
    
    	attributeChangedCallback(name, oldValue, newValue) {
    		if (name === 'progress') {
    			this.setProgress(newValue);
    		}
    	}
    }
    
    window.customElements.define('progress-ring', ProgressRing);
    const continueElement = document.querySelector('.js-guide-continue');
    
    // Get value from sessionStorage if present
    if (sessionStorage.getItem('InmsCurrentTime')) {
    	const videoCurrentTime = sessionStorage.getItem('InmsCurrentTime');
    	const videoDuration = sessionStorage.getItem('InmsDuration');
    	const progressRing = document.querySelector('progress-ring');
    	const continueLink = document.querySelector('.js-guide-continue-link');
    	const guideURL = sessionStorage.getItem('InmsCurrentGuideURL');
    	const guideImage = sessionStorage.getItem('InmsCurrentGuideImage');
    
    	if ((videoCurrentTime > 0)
    		&& progressRing
    		&& continueElement
    		&& guideImage
    		&& continueLink) {
    		const alternativeText = continueLink.dataset.altText;
    		const currentProgress = videoCurrentTime / videoDuration;
    		const currentGuideImage = document.querySelector('.js-guide-continue-image');
    
    		continueElement.classList.add(className('m-continue-video-guide--has-progress'));
    		continueLink.setAttribute('href', guideURL);
    		currentGuideImage.src = guideImage;
    		continueLink.querySelector('span').innerText = alternativeText;
    		// Calculate percentage played
    		progressRing.setAttribute('progress', Math.floor(currentProgress * 100));
    	}
    }
    
    // Close Continue Component
    const closeButton = document.querySelector('.js-guide-close');
    
    if (closeButton) {
    	closeButton.addEventListener('click', () => {
    		sessionStorage.setItem('InmsGuideClosed', true);
    		continueElement.classList.remove('is-visible');
    	});
    
    	if (!sessionStorage.getItem('InmsGuideClosed')) {
    		continueElement.classList.add('is-visible');
    	}
    
    	if (document.querySelector('.js-video-guide')) {
    		continueElement.classList.remove('is-visible');
    	}
    }
    
  • URL: /components/raw/continue-video-guide/continue-video-guide.js
  • Filesystem Path: src/molecules/continue-video-guide/continue-video-guide.js
  • Size: 3 KB
  • Content:
    @charset "UTF-8";
    @use '../../configurations/mixins' as mixin;
    @use '../../configurations/bem' as bem;
    @use '../../configurations/config' as config;
    @use '../../configurations/variables' as var;
    @use '../../configurations/functions' as func;
    @use '../../configurations/colors/colors' as colors;
    @use '../../configurations/colors/colors-functions' as colorFunc;
    @use '../../vendor/grid/breakpoints' as breakpoint;
    @use '../../vendor/grid/grid' as grid;
    
    @include mixin.molecule(continue-video-guide) {
    	position: fixed;
    	bottom: 0;
    	right: 0;
    	z-index: func.z_index(middlegroundImportant);
    	width: 100px;
    	height: calc(100px + 23px + func.rhythm(1));
    	transform: scale(0.7);
    	display: none;
    
    	&.is-visible {
    		display: block;
    	}
    
    	@include breakpoint.bp-up(md) {
    		transform: scale(1);
    		bottom: func.rhythm(2);
    		right: func.rhythm(2);
    	}
    
    	@include bem.e(inner) {
    		position: relative;
    	}
    
    	@include bem.e(progressbar) {
    		display: none;
    	}
    
    	@include bem.e(continue) {
    		position: absolute;
    		z-index: 3;
    		display: flex;
    		align-items: center;
    		justify-content: center;
    		width: 100px;
    		height: 100px;
    		border-color: colors.$color-snow;
    
    		&::after {
    			content: 'Guidad tur';
    			display: block;
    			position: absolute;
    			left: auto;
    			right: auto;
    			bottom: 0;
    			transform: translateY(calc(100% + func.rhythm(1)));
    			text-align: center;
    			background-color: colors.$color-peacock-light;
    			font-size: var.$size-medium;
    			font-family: var.$font-family-headings;
    			border-radius: var.$border-radius;
    			color: colors.$color-cyberspace;
    			padding: func.rhythm(0.5) func.rhythm(1);
    			line-height: 1;
    		}
    
    		&:hover,
    		&:focus {
    			&::after {
    				font-size: calc(var.$size-medium + 1px);
    			}
    		}
    	}
    
    	@include bem.m(has-progress) {
    		@include bem.e(continue) {
    			&::after {
    				content: 'Fortsätt';
    			}
    
    			@include bem.e(arrow) {
    				width: 0;
    				height: 0;
    				border-style: solid;
    				border-width: 15px 0 15px 20px;
    				transition: border-width 0.25s ease-out;
    				border-bottom: 15px solid transparent;
    				border-left-color: inherit;
    				border-left-style: solid;
    				border-left-width: 20px;
    				border-right: 0 solid transparent;
        border-top: 15px solid transparent;
    			}
    
    			&:hover,
    			&:focus {
    				> div {
    					border-width: 20px 0 20px 30px;
    				}
    			}
    		}
    
    		@include bem.e(progressbar) {
    			display: block;
    			position: absolute;
    			z-index: 2;
    			border-radius: 50%;
    
    			&::after {
    				position: absolute;
    				top: 6px;
    				left: 6px;
    				width: 88px;
    				height: 88px;
    				border-radius: 50%;
    				content: '';
    				display: block;
    				border: 4px solid rgba(colors.$color-snow, 0.5);
    			}
    		}
    	}
    
    	@include bem.e(image) {
    		position: absolute;
    		z-index: 1;
    		width: 100px;
    		height: 100px;
    		border-radius: 50%;
    	}
    
    	@include bem.e(close) {
    		border-radius: 50%;
    		position: absolute;
    		top: 0;
    		right: 0;
    		z-index: 4;
    
    		&:hover,
    		&:focus {
    			background-color: colors.$color-peacock !important;
    		}
    	}
    }
    
  • URL: /components/raw/continue-video-guide/continue-video-guide.scss
  • Filesystem Path: src/molecules/continue-video-guide/continue-video-guide.scss
  • Size: 2.9 KB

Continue Video Guide

This component is dependent on the Video Guide Component. Continuing a guided tour is only possible if the video player has a saved timestamp in sessionStorage