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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <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>
            
          
!
            
              @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;
		}
	}
}
            
          
!
            
              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
Loading ..................

Console