-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
79 lines (79 loc) · 1.9 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Web Share</title>
<style>
body {
margin: 0;
background: lightblue;
font-family: system-ui;
color: rebeccapurple;
padding: 20px;
}
img {
width: 100%;
}
main {
max-width: 320px;
margin: 20px auto;
border: 5px dashed lightseagreen;
height: calc(100vh - 80px);
border-radius: 10px;
background: white;
padding: 20px;
box-shadow: 0 0 5px lightslategray;
}
button {
background: lightcoral;
padding: 10px 20px 12px;
color: white;
border-radius: 30px;
width: 100%;
border: none;
font-size: 20px;
text-transform: uppercase;
-webkit-appearance: none;
font-weight: bold;
outline: 0;
cursor: pointer;
box-shadow: inset 0px -2px 0 2px black;
}
button:active {
transform: scale(.9);
}
</style>
</head>
<body>
<main>
<section>
<img src="thumb.jpg" alt="">
</section>
<h4><em>Hoy es un buen día para compartir conocimiento...</em></h4>
<button id="button">Compartir</button>
</main>
<script>
const $button = document.querySelector('#button')
if ('share' in navigator) {
$button.addEventListener('click', share)
function share() {
navigator.share({
title: 'Probando Share API',
text: 'Suscríbete a Youtube.com/LeonidasEsteban',
url: './thumb.jpg',
})
.then(()=>{
alert('hemos logrado compartir')
})
.catch(()=>{
alert('no se pudo compartir, prueba usando https en un navegador móvil')
})
}
} else {
alert('No está disponible el API de web share')
}
</script>
</body>
</html>