aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/src/components/PredefinedStatus.vue
blob: 8ce1acd041198415aed188ab4c08a164ca13915e (plain)
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
<!--
  - SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  - SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
	<li class="predefined-status">
		<input :id="id"
			class="hidden-visually predefined-status__input"
			type="radio"
			name="predefined-status"
			:checked="selected"
			@change="select">
		<label class="predefined-status__label" :for="id">
			<span aria-hidden="true" class="predefined-status__label--icon">
				{{ icon }}
			</span>
			<span class="predefined-status__label--message">
				{{ message }}
			</span>
			<span class="predefined-status__label--clear-at">
				{{ clearAt | clearAtFilter }}
			</span>
		</label>
	</li>
</template>

<script>
import { clearAtFilter } from '../filters/clearAtFilter.js'

export default {
	name: 'PredefinedStatus',
	filters: {
		clearAtFilter,
	},
	props: {
		messageId: {
			type: String,
			required: true,
		},
		icon: {
			type: String,
			required: true,
		},
		message: {
			type: String,
			required: true,
		},
		clearAt: {
			type: Object,
			required: false,
			default: null,
		},
		selected: {
			type: Boolean,
			required: false,
			default: false,
		},
	},
	computed: {
		id() {
			return `user-status-predefined-status-${this.messageId}`
		},
	},
	methods: {
		/**
		 * Emits an event when the user clicks the row
		 */
		select() {
			this.$emit('select')
		},
	},
}
</script>

<style lang="scss" scoped>
.predefined-status {
	&__label {
		display: flex;
		flex-wrap: nowrap;
		justify-content: flex-start;
		flex-basis: 100%;
		border-radius: var(--border-radius);
		align-items: center;
		min-height: 44px;

		&--icon {
			flex-basis: 40px;
			text-align: center;
		}

		&--message {
			font-weight: bold;
			padding: 0 6px;
		}

		&--clear-at {
			color: var(--color-text-maxcontrast);

			&::before {
				content: ' – ';
			}
		}
	}

	&__input:checked + &__label,
	&__label:active {
		outline: 2px solid var(--color-main-text);
		box-shadow: 0 0 0 4px var(--color-main-background);
		border-radius: var(--border-radius-large);
	}

	&__input:focus-visible + &__label {
		outline: 2px solid var(--color-primary-element) !important;
		border-radius: var(--border-radius-large);
	}
}
</style>