summaryrefslogtreecommitdiffstats
path: root/css/Properties/Properties.scss
blob: e22cb5b88ca6ce6a73e19fe00334cafda0b78f08 (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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/**
 * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
 *
 * @author John Molakvoæ <skjnldsv@protonmail.com>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
$property-label-min-width: 60px;
$property-label-max-width: 2 * $property-label-min-width;
$property-value-max-width: 250px;

.property {
	@include generate-grid-span(1);
	position: relative;
	padding-right: 44px; // delete button
	// we need this to keep the alignment of the ext and delete button
	// The flex grow will never go over those values. Therefore we can set
	// the max width and keep the right alignment
	max-width: $property-label-max-width + $property-value-max-width + 44px;
	justify-self: center;
	width: 100%;

	&--last {
		margin-bottom: $grid-height-unit;
	}
	// no delete icon on addressbook selector
	&--addressbooks &__delete {
		display: none !important;
	}
		
	// property row
	&__row {
		display: flex;
		align-items: center;
		position: relative;
	}
	
	// property label or multiselect within row
	&__label,
	&__label.multiselect {
		margin: $grid-input-margin 5px $grid-input-margin 0;
		padding: $grid-input-padding 0;
		flex: 1 0; // min width is 60px, let's grow until 120px
		height: $grid-input-height-with-margin;
		width: $property-label-min-width !important; // override multiselect
		min-width: $property-label-min-width;
		max-width: $property-label-max-width;

		opacity: .7;
		user-select: none;
		background-size: 16px;

		&,
		.multiselect__input::placeholder {
			text-align: right;
		}

		&:not(.multiselect) {
			text-overflow: ellipsis;
			white-space: nowrap;
			overflow: hidden;
			overflow-x: hidden;
		}

		// mouse feedback
		&:hover,
		&:focus,
		&:active {
			opacity: 1;
			.multiselect__tags {
				border-color: var(--color-border-dark);
			}
		}

		// read-only mode
		&.multiselect--disabled {
			&, .multiselect__single {
				&, &:hover, &:focus &:active {
					background-color: var(--color-main-background) !important;
					border-color: transparent !important;
				}
			}
		}
	}

	&__label.multiselect {
		.multiselect__tags {
			border: none !important; // override multiselect
			.multiselect__single {
				background-repeat: no-repeat;
				background-position: center right 4px;
				padding-right: 24px;
			}
			.multiselect__content-wrapper {
				min-width: $property-label-max-width; // improve readability on narrow screens
			}
		}
	}

	// Property value within row, after label
	&__value {
		flex: 1 1 $property-value-max-width;
		max-width: $property-value-max-width;

		textarea& {
			align-self: flex-start;
			min-height: 2 * $grid-height-unit - 2*$grid-input-margin;
			max-height: 5 * $grid-height-unit - 2*$grid-input-margin;
		}

		// read-only mode
		&:read-only {
			border-color: var(--color-border-dark);
		}
		input&--with-ext {
			// ext icon width + 8px padding
			padding-right: 24px;
			&:hover,
			&:focus,
			&:active {
				~ .property__ext, 
				~ .property__delete {
					opacity: .5;
				}
			}
		}
	}

	// show ext & delete button on full row hover
	&:hover &__ext,
	&:hover &__delete {
		opacity: .5;
	}

	// External link (tel, mailto, http, ftp...)
	&__ext {
		position: absolute;
		// 8px padding
		right: 8px;
		opacity: 0;
		&:hover,
		&:focus,
		&:active {
			opacity: .7;
			// still show the delete button for keyboard accessibility
			~ .property__delete {
				opacity: .5;
			}
		}
	}
	
	// Delete property button
	&__delete {
		position: absolute;
		top: 0;
		left: 100%;
		width: $grid-height-unit;
		height: $grid-height-unit;
		margin: 0;
		border: 0;
		background-color: transparent;
		opacity: 0;
		&:hover,
		&:active,
		&:focus {
			opacity: .7;
		}
	}
}