Pen Settings

HTML

CSS

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

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

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.

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 class="js-app">
	<filters class="filters" ref="filters" inline-template>
		<div>
			<div class="form__control">
				<label for="filter-from">Van</label>
				<i class="icon fa fa-map-marker" aria-hidden="true"></i>

				<input type="text" id="filter-from" v-model="from">
			</div>

			<div class="form__control">
				<label for="filter-to">Naar</label>
					<i class="icon fa fa-flag-o" aria-hidden="true"></i>

				<input type="text" id="filter-to"  v-model="to">
			</div>

			<button class="button primary visually-hidden" type="submit">
				<i class="icon fa fa-search" aria-hidden="true"></i>
				Zoek naar rit
			</button>
		</div>
	</filters>
	
	<ul class="results" aria-live="polite">
		<li v-for="result in results" class="result">
			<search-result :data="result"></search-result>
		</li>
	</ul>
</main>
              
            
!

CSS

              
                @import 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css';

h1, h2, h3, h4, h5, h6 {
	font-size: 1.2em;
}

body{
	background: papayawhip;
}

.filters {
	background: white;
	box-shadow: 0 1px 2px rgba(0,0,0,.3);
	display: block;
	padding: 15px;
	display: flex;
	justify-content: center;
	align-items: flex-end;
}

.form__control {
	display: inline-block;
	margin-right: 1em;
	position: relative;
	
	label{
		display: block;
	}
	
	input{
		padding: .3em .3em .3em 1.6em;
		font-size: 1.6em;
		&:focus{ 
			outline: 2px solid black;
		}
	}
	
	.icon{
			position: absolute;
			bottom: 10px;
			font-size: 1.6em;
			color: #999;
			left: 10px;
	}
}

.button{
		padding: .94em 1.2em;
		border-radius: 3px;
		border: 0;
		box-shadow: 0 1px 5px rgba(0,0,0,.4);
		cursor: pointer;
	
		.fa{
			padding-right: 5px;
		}
	
		&:focus{
			outline: 2px solid black;
		}
	
		&:hover, &focus{
			background: #444;
		}
	
		&.primary{
			background: dodgerBlue;
			color: white;
			text-shadow: 1px 1px rgba(0,0,0,.5);
		}
}

.results{
	list-style: none;
}

.result > div{
	position: relative;
	padding: .5em 3em .5em 1em;
	background: white;
	box-shadow: 0 0 6px rgba( 0,0,0,.3 );
	margin: 50px auto 0 auto;
	max-width: 50%;
	display: flex;
	flex-flow: row wrap;
	
	h2{
		flex: 1 0 100%;
	}
	
	dl{
		flex: 1;
		padding-right: .8em;
	}
	
	dt{
		display: block;
		width: 100%;
		padding: 0 0 .4em 0;
		font-size: .7em;
		text-transform: uppercase;
		color: dodgerblue;
	}
	
	dd{
		text-align: left;
		letter-spacing: .04em;
		line-height: 135%;
		margin: 0;
	}
	
	a{
		position: absolute;
		right: 0;
		top: 0;
		bottom: 0;
		background: dodgerBlue;
		color: white;
		text-shadow: 1px 1px rgba(0,0,0,.3);
		padding: 0 1.2em;
		display: flex;
		justify-content: center;
		flex-flow: column nowrap;
		text-align: center;
		text-decoration: none;
		i{
			font-size: 2.5em;
			padding-bottom: 10px;
		}
		
		&:hover, &:focus{
			background: #444;
		}
		
		&:focus{
			border: 2px solid black;
		}
	}
}

.visually-hidden {
	height: 1px;
	width: 1px; 
	padding: 0;
	border: 0;
	margin: -1px;
	position: absolute; 
	overflow: hidden; 
	clip: rect(0 0 0 0); 
}

@media only screen and ( max-width: 1200px ){
	.filters .form__control{
		display: block;
		flex: 0 1;
		min-width: 20%;
		
		input{
			max-width: 100%;
		}
	}
	
	.result > div{
		max-width: 90%;
		padding-right: 1em;
	
		a{
			box-sizing: border-box;
			position: static;
			flex: 1 0 100%;
			flex-flow: row wrap;
			align-items: center;
			justify-content: center;
			border-radius: 3px;
			padding: .5em;
			right: auto;
			i{
				font-size: 2em;
				padding-right: 10px;
			}
		}
		
		dl:nth-of-type( 3 ), dl:nth-of-type( 4 ){
			display: none;
		}
	}
	
	@media screen and (max-width:540px){
		.result > div dl{
			flex: 1 0 100%;
			display: block;
		}
	}
}
              
            
!

JS

              
                const data = [{"name":"Esther de Goor","car":"Opel Astra","from":"Gewandenweg, Terneuze","to":"Laan van Nieuw Oostindie, Den Haag","seats_available":3,"days":["thu","wed","thu","fri","sat"],"time":{"start":"10:00","end":"12:00"}},{"name":"Jan Hansen","car":"Ford Ka","from":"Ventweg, Den Bosch","to":"Generaal Matcheklaan, Eindhoven ","seats_available":1,"days":["thu","wed","thu"],"time":{"start":"9:00","end":"9:45"}},{"name":"Bep Gaanstra","car":"BMW X5","from":"Oude gracht, Utrecht","to":"Lunette, Utrecht","seats_available":3,"days":["mon","thu","wed"],"time":{"start":"15:00","end":"15:30"}},{"name":"Richard Meeuws","car":"Fiat Mexicano","from":"Arendlaan, Bladel","to":"Meerkoet, Hilversum","seats_available":2,"days":["mon","thu","wed"],"time":{"start":"11:00","end":"12:20"}},{"name":"Bernadette Weerlo","car":"Citroen Picasso","from":"Dorpenweg, Assen","to":"Van Lawick van Pabststraat, Arnhem","seats_available":1,"days":["mon","thu","wed","thu","fri"],"time":{"start":"07:00","end":"08:40"}}];

Vue.component('filters', {
	data() {
		return {
			from: '',
			to: '',
		};
	},
	
	computed: {
		filterData() {
			if (!this.from && !this.to) {
				return null;
			}
			
			return {
				from: this.from,
				to: this.to,
			};
		}
	},
	
	methods: {
		update() {
			this.$emit('filter', this.filterData);
		},
	},
	
	watch: {
		from() {
			this.update();
		},
		
		to() {
			this.update();
		},
	},
});

Vue.component('search-result', {
	props: ['data'],
	
	template: `<div>
		<h2><span class="sr-only">Rij mee </span>Naar {{data.to}} om {{data.time.start}}</h2>
		<dl>
			<dt>Van</dt>
			<dd>{{data.from}}</dd>
		</dl>
		<dl>
			<dt>Naar</dt>
			<dd>{{data.to}}</dd>
		</dl>
		<dl>
			<dt>Chaffeur</dt>
			<dd>{{data.name}}</dd>
		</dl>
		<dl>
			<dt>Auto</dt>
			<dd>{{data.car}}</dd>
		</dl>
		
		<a title="Rij mee naar {{data.to}} om {{data.time.start()}}" href="#">
			<i class="fa fa-car" aria-hidden="true"></i>
			<span>Rij mee</span>
		</a>
	</div>`,
});

new Vue({
  el: '.js-app',
	
	data: {
		data,
		results: data,
	},
	
	methods: {
		filter(query) {
			if (!query) {
				this.results = this.data;
				return;
			}
			
			this.results = this.data.filter((d) => {
				return (
					query.from && d.from.toLowerCase()
						.includes(query.from.toLowerCase()) ||
					query.to && d.to.toLowerCase()
						.includes(query.to.toLowerCase())
				);
			});
		}
	},
	
	mounted() {
		this.$refs.filters
			.$on('filter', query => this.filter(query));
	},
});
              
            
!
999px

Console