-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathCollapsible.vue
More file actions
149 lines (137 loc) · 3.22 KB
/
Collapsible.vue
File metadata and controls
149 lines (137 loc) · 3.22 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!--
- SPDX-FileCopyrightText: 2018 Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<script setup lang="ts">
import { t } from '@nextcloud/l10n'
import { ref } from 'vue'
const props = defineProps({
initialCollapsed: {
type: Boolean,
default: false,
},
showMoreCaption: {
type: String,
default: t('polls', 'Show more'),
},
closeCaption: {
type: String,
default: t('polls', 'Collapse'),
},
noCollapse: {
type: Boolean,
default: false,
},
})
const showMore = ref(!props.initialCollapsed || props.noCollapse)
</script>
<template>
<div class="collapsible">
<div
id="collapsible_container"
:class="['collapsible_container', { open: showMore || noCollapse }]">
<slot />
</div>
<div
v-show="!noCollapse"
:class="['collapsible-toggle', { open: showMore }]"
@click="showMore = !showMore">
{{ showMore ? props.closeCaption : props.showMoreCaption }}
</div>
</div>
</template>
<style lang="scss">
.collapsible {
overflow: hidden;
.collapsible-toggle {
cursor: pointer;
position: relative;
line-height: 2rem;
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
background-color: var(--color-background-plain);
color: var(--color-primary-element-text);
border-radius: var(--border-radius-element);
&::before {
content: '\25B8';
margin: 0 0.3em;
display: inline-block;
transform: rotate(90deg);
transition: transform 0.3s ease-in-out;
}
&.open {
&::before {
transform: rotate(-90deg);
}
}
}
.collapsible_container {
transition: max-height 0.3s ease-in-out;
overflow: auto;
max-height: 0;
background:
/* Shadow covers */
linear-gradient(
var(--color-main-background) 30%,
rgba(from var(--color-main-text) r g b / 0)
),
linear-gradient(
rgba(from var(--color-main-text) r g b / 0),
var(--color-main-background) 70%
)
0 100%,
/* Shadows */
radial-gradient(
50% 0,
farthest-side,
rgba(from var(--color-main-text) r g b / 0.2),
rgba(from var(--color-main-background) r g b / 0.2)
),
radial-gradient(
50% 100%,
farthest-side,
rgba(from var(--color-main-text) r g b / 0.2),
rgba(from var(--color-main-background) r g b / 0.2)
)
0 100%;
background:
/* Shadow covers */
linear-gradient(
var(--color-main-background) 30%,
rgba(from var(--color-main-text) r g b / 0)
),
linear-gradient(
rgba(from var(--color-main-text) r g b / 0),
var(--color-main-background) 70%
)
0 100%,
/* Shadows */
radial-gradient(
farthest-side at 50% 0,
rgba(from var(--color-main-text) r g b / 0.2),
rgba(from var(--color-main-background) r g b / 0.2)
),
radial-gradient(
farthest-side at 50% 100%,
rgba(from var(--color-main-text) r g b / 0.2),
rgba(from var(--color-main-background) r g b / 0.2)
)
0 100%;
background-repeat: no-repeat;
background-color: var(--color-main-background);
background-size:
100% 40px,
100% 40px,
100% 14px,
100% 14px;
/* Opera doesn't support this in the shorthand */
background-attachment: local, local, scroll, scroll;
&.open {
max-height: max(51vh, 6rem);
}
}
}
</style>