-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path07-unsplash.html
37 lines (33 loc) · 1.19 KB
/
07-unsplash.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!doctype html>
<html lang="en">
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- Easy Installation: https://alpinejs.dev/essentials/installation -->
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
<title>Alpine.js : Declare & React</title>
</head>
<body>
<!--
Little Unsplash search bar
https://source.unsplash.com/1600x900/?rocket
-->
<div x-data="{
img : '',
query : '',
search(){
this.img = `https://source.unsplash.com/1600x900/?${this.query}`
},
clear(){
this.img = '';
this.query = '';
}
}">
<form @submit.prevent="search">
<input type="text" x-model="query">
<button type="submit" :disabled="query.length == 0">Search</button>
<button @click="clear" :disabled="query.length == 0">Clear</button>
</form>
<img x-show="img" :src="img" class="img-thumbnail" alt="img">
</div>
</body>
</html>