Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main mv-app="carousel"
		mv-storage="https://github.com/DmitrySharabin/mavo-carousel-widget"
		mv-plugins="cropper"
		mv-bar="no-login">

	<h2>Carousel Widget with Thumbnails</h2>
	
	<!-- 	Carousel -->
	<meta property="timer" content="[seconds($now) mod (image_count * delay) + 1]" />

	<section class="carousel"
				style="background-image: url([get(source, ind_bg)]);">
		<!-- 	We have a shift in timing: the background image (which is the next in the gallery) changes 2 seconds earlier so we can implement the cross-dissolve transition. -->
		<meta property="ind_bg"
				content="[ceil(((seconds($now) + 2) mod (image_count * delay) + 1) / delay) - 1]" />
		
		<meta property="ind" content="[ceil(timer / delay) - 1]" />
		<img src="https://cdn.jsdelivr.net/gh/DmitrySharabin/mavo-carousel-widget@639d1d15251b0f232905a066d8ea2508a8864cc1/images/redcharlie-k2zWqv_yfNM-unsplash.jpg"
			  mv-attr-src="get(source, ind)"
			  alt="Beautiful image from Unsplash"
			  class="[if(timer mod delay = 0, 'fade')]" />
		
		<aside mv-list mv-value="1 .. image_count">
			<span mv-list-item="thumbnail"
					class="[if($index = ind, 'active')]"
					style="background-image: url([get(source, $index)]);"></span>
		</aside>
	</section>
	
	<!-- Settings	 -->
	<section class="settings">
		<fieldset>
			<legend>Settings</legend>
			<p>
				The widget can display
				<span property="max_count"
						mv-editor-type="number"
						mv-editor-min="[max(2, image_count)]"
						mv-editor-max="10"
						mv-editor-value="5"
						title="Change number of images">5</span> images
				with
				<span property="delay"
						mv-editor-type="number"
						mv-editor-min="3"
						mv-editor-max="10"
						mv-editor-value="5"
						title="Change delay">5</span>s delay.
			</p>
			
			<section mv-list>
				<article mv-list-item="image">
					<img src="" alt="" property="source" />
				</article>
			</section>
			
			<meta property="image_count" content="[count(image)]" />
			
			<aside hidden="[image_count >= max_count]">
				<button class="mv-add-image">
					+ Add image
				</button>
			</aside>
		</fieldset>
	</section>
	
	<p>Follow these steps to play with the widget:</p>
	<ol>
		<li><a href="?login">Log in</a> with your <b>GitHub</b> account</li>
		<li>Switch to <b>Edit</b> mode</li>
		<li>Change the widget settings: number of images, images themselves and their order, and delay.</li>
	</ol>
	
	<p class="credits">
		Credits: the images are taken from
		<a href="https://unsplash.com/">Unsplash</a>. Made with ❤️ and <a href="https://mavo.io/">Mavo</a>.
	</p>
</main>
              
            
!

CSS

              
                * {
	box-sizing: border-box;
}

body {
	max-width: 70em;
	margin: auto;
	
	color: #2a4365;
	background-color: #edf2f7;
	
	font-family: Roboto, 'Helvetica Neue', sans-serif;
}

[mv-app] {
	--aspect-ratio: 1.77;
	--image-width: 16em;
	
	--main-color: #2b6cb0;
	--secondary-color: rgba(255, 255, 255, 0.5);
	
	font-size: 120%;
}

.settings {
	fieldset {
		max-width: max-content;
		margin: 1em;
		
		border-radius: 0.3em;
		
		border: 2px solid var(--main-color);
		
		* {
			font-size: inherit;
			color: inherit;
		}
		
		legend {
			font-weight: bold;
		}
		
		p {
			margin: 0.5em 0.25em;

			cursor: default;
			
			span {
				font-style: normal;
				font-size: 150%;
				font-weight: bold;
				
				&:hover {
					text-decoration: underline;
					
					cursor: pointer !important;
				}
			}
		}
	}
}

article[property="image"] {
	display: inline-block;
	width: var(--image-width);
	height: calc(var(--image-width) / var(--aspect-ratio));

	margin: 0.3em;
	
	&.mv-highlight {
		box-shadow: 0 0 0 3px var(--main-color) !important;
	}
}

[property="source"] {
	width: 100%;
	height: 100%;
	object-fit: cover;
	
	box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
	
	&.mv-empty {
		min-width: var(--image-width);
		min-height: calc(var(--image-width) / var(--aspect-ratio));
		
		border: 3px dashed var(--main-color);
		
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cg fill='%232b6cb0' fill-opacity='0.4'%3E%3Cpolygon fill-rule='evenodd' points='8 4 12 6 8 8 6 12 4 8 0 6 4 4 6 0 8 4'/%3E%3C/g%3E%3C/svg%3E");
	}
	
	&:hover {
		box-shadow: 0 0 0 3px var(--main-color) !important;
	}
}

button.mv-add-image {
	margin: 0.2em;
	padding: 0.3em 0.5em;
	
	border: none;
	border-radius: 0.3em;
	
	color: #fff5f7;
	
	background-color: var(--main-color);
	
	box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
	
	&:hover {
		filter: brightness(120%);
	}
}

.carousel {
	margin: auto;
	
	width: calc(var(--image-width) * 2.5);
	height: calc(var(--image-width) * 2.5 / var(--aspect-ratio));
	
	text-align: center;
	
	background-size: cover;
	background-repeat: no-repeat;
	background-position: center;

	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
	
	img {
		width: 100%;
		height: 100%;
		object-fit: cover;
		
		transition: opacity 1s ease-in-out;
		
		&.fade {
			opacity: 0;
		}
	}
	
	aside {
		display: flex;
		justify-content: center;
		
		margin-top: -3.5em;
		
		cursor: default;
	}
	
	span[property="thumbnail"] {
		display: block;

		width: 1.7em;
		height: 1.7em;
		
		margin: 0 0.2em;
		
		color: transparent;
		
		border-radius: 100%;
		
		border: 2px solid var(--secondary-color);
		
		background-color: var(--secondary-color);
		
		background-blend-mode: screen;
		
		background-size: cover;
		background-repeat: no-repeat;
		background-position: center;
		
		&.active {
			border: 2px solid var(--main-color);
			background-color: var(--main-color);
		}
	}
}

[mv-app]:not([mv-mode="edit"]) {
	.settings {
		display: none;
	}
}

.credits {
	font-style: italic;
}

a {
	color: inherit;
	font-weight: bold;
	
	&:not(:hover) {
		text-decoration: none;
	}
}
              
            
!

JS

              
                
              
            
!
999px

Console