-
Notifications
You must be signed in to change notification settings - Fork 0
/
collapse.html
80 lines (69 loc) · 2.91 KB
/
collapse.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
80
<!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>Document</title>
</head>
<body>
<!-- To prevent flickering when the document is loaded but them component isn't hide the webcomponent until it is loaded -->
<collapse-component open-text="Read more" close-text="Read less" style="display: none; width: 600px">
<span slot="collapse-content">
<h2>Lorem ipsum dolor</h2>
<p> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. </p>
<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. </p>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
</span>
</collapse-component>
<template id="collapse">
<style>
:host {
display: block !important;
font-family: arial;
background-color: #b05656;
color: white;
padding: 20px;
}
#trigger {
display: none;
}
label {
cursor: pointer;
font-weight: bold;
font-size: 20px;
display: flex;
align-items: center;
user-select: none;
}
.label-icon {
font-size: 28px;
margin-left: 10px;
}
.container {
height: 0;
overflow: hidden;
transition: height 0.5s ease;
}
.content {
padding: 5px;
}
</style>
<input type="checkbox" name="" id="trigger">
<label for="trigger">
<span class="label-text">Read more!</span>
<span class="label-icon">+</span>
</label>
<div class="container">
<div class="content">
<slot name="collapse-content">This is the collapse content</slot>
</div>
</div>
</template>
</body>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="collapse.js"></script>
</html>