-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathSignatureBox.vue
More file actions
73 lines (70 loc) · 1.62 KB
/
SignatureBox.vue
File metadata and controls
73 lines (70 loc) · 1.62 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
<!--
- SPDX-FileCopyrightText: 2024 LibreCode coop and LibreCode contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div class="signature-box"
:style="boxStyle"
role="img"
:aria-label="signatureBoxAriaLabel">
<span class="label" aria-hidden="true">{{ label }}</span>
</div>
</template>
<script>
import { t } from '@nextcloud/l10n'
import { usernameToColor } from '@nextcloud/vue/functions/usernameToColor'
export default {
name: 'SignatureBox',
props: {
label: {
type: String,
default: '',
},
signer: {
type: Object,
default: null,
},
},
computed: {
signatureBoxAriaLabel() {
// TRANSLATORS Accessible label for a placed signature box on the PDF. {name} is the signer's display name.
return t('libresign', 'Signature position for {name}', { name: this.label })
},
boxStyle() {
const signer = this.signer || {}
const seed = signer.displayName || signer.name || signer.email || signer.id || this.label
if (!seed) {
return {}
}
const { r, g, b } = usernameToColor(String(seed))
return {
borderColor: `rgb(${r}, ${g}, ${b})`,
backgroundColor: `rgba(${r}, ${g}, ${b}, 0.12)`,
}
},
},
}
</script>
<style lang="scss" scoped>
.signature-box {
box-sizing: border-box;
border: 2px dashed #2563eb;
background: rgba(37, 99, 235, 0.08);
color: var(--color-text-maxcontrast);
display: flex;
align-items: center;
justify-content: center;
padding: 6px 8px;
border-radius: 6px;
width: 100%;
height: 100%;
line-height: 1.2;
overflow: hidden;
}
.label {
font-weight: 600;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
</style>