cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

            
              <div class="container-fluid">
			<div id="container-hero-search">
				<div id="logo">
					<img src="http://vincent-humeau.com/content/wiki/logo.png" alt="logo wikipedia viewer"/>
				</div>
				<div id="search-box">
					<form>
						<input type ="text" id="search-box--wiki-search" autofocus/>
						<br />
						<button class="btn" type="submit">Search</button>
						<a class="btn" href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">Random</a>
					</form>
				</div>

			</div>

			<div class="row wiki-article--container">
			</div>
		</div>
		<footer>
			<p><a href="http://vincent-humeau.com/" target="_blank">Design and Code by Vincent Humeau</a></p>
			<p><a href="https://github.com/vinceumo/fcc_wikipedia_viewer" target="_blank">See this project on GitHub</a></p>
			<p><a href="https://www.mediawiki.org/wiki/API:Main_page/fr" target="_blank">API from Wikipedia</a></p>
		</footer>
            
          
!
            
              //Mixin
@mixin transform {
	-webkit-transition: all 0.5s; /* Safari */
	transition: all 0.5s;
	transition-timing-function: ease-in-out;
}
@mixin aspect-ratio($width, $height) {
	position: relative;
	display: block;
	height: 0;
	padding-bottom: ($height / $width) * 100%;
	overflow: hidden;
}


$blue-dark: #2F3440;
$blue-light: #3F5666;
$yellow-light: #F5E5C0;
$yellow-dark: #F8CA4D;
$red: #EA6045;
$white: #FFF;

$font-title: 'EB Garamond', serif;

.clear-float{
	clear: both;
}
.bold-text{
	font-weight: bold;
}
.vcenter {
	display: inline-block;
	vertical-align: middle;
	float: none;
}
.capitalize{
	text-transform: capitalize;
}
input:focus,select:focus,textarea:focus,button:focus {
	outline: none;
}
.btn{
	border-radius: 0;
	color: $white;
	background-color: $red;
	opacity: 1;
	@include transform;
	&:hover, &:focus{
		opacity: 0.8;
		color: $white;
	}
}
#container-hero-search{
	text-align: center;
	margin-bottom: 140px;
	#logo{
		margin:140px auto;
		max-width: 464px;
		width:70%;
		img{
			width:100%;
		}
	}
	#search-box{
		input{
			width:100%;
			max-width: 820px;
			border: none;
			border-bottom: 3px solid $yellow-dark;
			color: $yellow-dark;
			font-size: 1.3em;
			margin-bottom: 20px;
			@include transform;
			&:focus{
				border-bottom: 3px solid $blue-light;
			}
		}
		.btn{
			background-color: $blue-light;
			color: $white;
			@include transform;
			&:hover, &:focus{
				opacity: 0.8;
				color: $white;
			}
		}
	}
}
.wiki-article--container{
	max-width: 1400px;
	margin: 0 auto;
}
.wiki-article{
	margin-bottom: 50px;
	position: relative;
	width: 100%; /* for IE 6 */
	z-index: 1;
	h2{
		font-family: $font-title;
		color: $blue-light;
	}
	p{
		margin-top: 1rem;
		color: $blue-dark;
	}
	/*Responsive thumbnaile keeping ratio whatever the size of the image,*/
	.wiki-articles--img-container{
		overflow: hidden;
		@include aspect-ratio(470, 220);
		.lighten-filter{
			background-color: $blue-light;
			mix-blend-mode: lighten;
			width: 100%;
			height: 100%;
			transform: translate(-50%, -50%);
			left: 50%;
			top: 50%;
			position: absolute;
			z-index: 1;
		}
		.multiply-filter{
			background-color: $yellow-dark;
			mix-blend-mode: multiply;
			width: 100%;
			height: 100%;
			transform: translate(-50%, -50%);
			left: 50%;
			top: 50%;
			position: absolute;
			z-index: 1;
		}
		img{
			width: 100%;
			transform: translate(-50%, -50%);
			left: 50%;
			top: 50%;
			position: absolute;
			filter: grayscale(100%);
		}
	}
}
footer{
	background-color: $blue-light;
	text-align: center;
	padding: 50px 0;
	margin-top: 50px;
	a{
		color: $white;
		opacity: 1;
		text-decoration: underline;
		@include transform;
		&:hover,&:focus{
			color: $white;
			opacity: 0.8;
		}
	}
	p{
		margin-bottom: 5px;
	}
}

            
          
!
            
              $(document).ready(function() {
	$('#search-box').submit(function(e) {
		var search = $('#search-box--wiki-search').val();
		var wikiApiUrl = 'https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=' + search;
		var wikiApiImageUrl = 'https://en.wikipedia.org/w/api.php?action=query&format=json&prop=pageimages%7Cpageterms&generator=prefixsearch&redirects=1&formatversion=2&piprop=thumbnail&pithumbsize=500&pilimit=20&wbptterms=description&gpssearch=' + search;
		e.preventDefault();
		//alert(wikiApiUrl);
		$.ajax({
			method: 'GET',
			url: wikiApiUrl,
			dataType: 'jsonp',
			success: function(data){
				$('.wiki-article--container').html('');
				if (data[1].length === 0) {
					$('.wiki-article--container').append('<div class="col-xl-12 col-lg-12 col-md-12 col-xs-12 wiki-article text-center"><h2>No Data Found</h2><p>Please try again :)</p></div>');
				} else{
				for (var i = 0; i < data[1].length; i++){
					var title = data[1][i];
					if(title.length > 29){
						title = title.substring(0,29) + "...";
					} else{
						title = data[1][i];
					}
					var text = data[2][i];
					var link = data[3][i];
					$('.wiki-article--container').append('<div class="col-xl-4 col-lg-6 col-md-6 col-xs-12 wiki-article">'+'<h2>'+ title +'</h2><div class="wiki-articles--img-container"><div class="lighten-filter"></div><div class="multiply-filter"></div><div id="imagewiki'+i+'"></div></div><p>'+ text +'</p><a href="'+ link +'" class="btn" target="_blank">Read More</a></div>');
					}
				}
				$.ajax({
					url: wikiApiImageUrl,
					method: 'GET',
					dataType: 'jsonp',
					success: function(newData) {
						for (var i = 0; i < 30; i++) {
							if (newData.query.pages[i].hasOwnProperty('thumbnail') === true) {
								$('#imagewiki' + (newData.query.pages[i].index - 1)).html('<img class="wiki-articles--img-container--img" src="' + newData.query.pages[i].thumbnail.source + '" >');
							} else {
								$('#imagewiki' + (newData.query.pages[i].index - 1)).html('<img src="http://vincent-humeau.com/content/wiki/img-placeholder.png" class="wiki-articles--img-container--img">');
							}
						}
					}
				});
			},
			error: function() {
				console.log('Api error');
			}
		});

	});
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console