Skip to content

Commit 41c08c0

Browse files
leiyredamianpumar
andauthored
feat: UI Metadata info component (#4851)
This PR allows the visualization of the metadata clicking on the menu at the top of the record closes #4788 --------- Co-authored-by: Damián Pumar <[email protected]>
1 parent b687798 commit 41c08c0

File tree

19 files changed

+1026
-94
lines changed

19 files changed

+1026
-94
lines changed

argilla-frontend/assets/icons/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ require('./filter')
2323
require('./focus-mode')
2424
require('./hand-labeling')
2525
require('./info')
26+
require('./kebab')
2627
require('./link')
2728
require('./log-out')
2829
require('./matching')
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* coding=utf-8
3+
* Copyright 2021-present, the Recognai S.L. team.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/* eslint-disable */
19+
var icon = require('vue-svgicon')
20+
icon.register({
21+
'kebab': {
22+
width: 20,
23+
height: 21,
24+
viewBox: '0 0 20 21',
25+
data: '<path pid="0" d="M11.875 4.875a1.875 1.875 0 11-3.75 0 1.875 1.875 0 013.75 0zM11.875 10.5a1.875 1.875 0 11-3.75 0 1.875 1.875 0 013.75 0zM11.875 16.125a1.875 1.875 0 11-3.75 0 1.875 1.875 0 013.75 0z" _fill="#000"/>'
26+
}
27+
})

argilla-frontend/assets/scss/abstract/variables/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ $primary-font-family: "Inter", "Helvetica", "Arial", sans-serif;
133133
$secondary-font-family: "raptor_v2_premiumbold", "Helvetica", "Arial",
134134
sans-serif;
135135
$tertiary-font-family: "Roboto Condensed", sans-serif;
136+
$quaternary-font-family: "Roboto Mono", monospace;
136137
$base-font-size: 14px;
137138
$base-line-height: 1.4em;
138139

argilla-frontend/components/base/base-action-tooltip/BaseActionTooltip.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>
66
<slot></slot>
77
<span
8-
v-if="showTooltip && tooltip"
8+
v-if="tooltip && showTooltip"
99
class="tooltip"
1010
:class="tooltipClass"
1111
v-text="tooltip"
@@ -48,7 +48,7 @@ export default {
4848
<style scoped lang="scss">
4949
.tooltip {
5050
position: absolute;
51-
top: 100%;
51+
top: 0;
5252
background: palette(grey, 100);
5353
display: inline-block;
5454
border-radius: $border-radius-s;
@@ -59,10 +59,10 @@ export default {
5959
white-space: nowrap;
6060
font-family: $primary-font-family !important;
6161
&.--left {
62-
right: 0;
62+
right: 100%;
6363
}
6464
&.--right {
65-
left: 0;
65+
left: 100%;
6666
}
6767
&__container {
6868
position: relative;

argilla-frontend/components/base/base-dropdown/BaseDropdown.vue

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<slot name="dropdown-content" />
4343
</div>
4444
</transition>
45+
<div
46+
@click="onClose"
47+
v-if="visible && freezingPage"
48+
class="dropdown--frozen-page"
49+
></div>
4550
</div>
4651
</template>
4752
<script>
@@ -60,6 +65,10 @@ export default {
6065
default: "parent",
6166
validator: (value) => ["parent", "viewport"].includes(value),
6267
},
68+
freezingPage: {
69+
type: Boolean,
70+
default: false,
71+
},
6372
gap: {
6473
type: Number,
6574
default: 8,
@@ -70,6 +79,7 @@ export default {
7079
dropdownTop: 0,
7180
dropdownLeft: 0,
7281
inViewport: true,
82+
frozenScrollParent: null,
7383
};
7484
},
7585
computed: {
@@ -83,6 +93,14 @@ export default {
8393
this.setViewportPosition();
8494
});
8595
},
96+
freezingPage(value) {
97+
if (value) {
98+
this.frozenScrollParent = this.getScrollableParent(this.$refs.dropdown);
99+
this.frozenScrollParent.style.overflow = "hidden";
100+
} else {
101+
this.frozenScrollParent.style.overflow = "auto";
102+
}
103+
},
86104
},
87105
methods: {
88106
onClose() {
@@ -108,21 +126,21 @@ export default {
108126
109127
this.dropdownLeft = left;
110128
},
111-
isScrollable(el) {
112-
const hasScrollableContent =
113-
el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth;
114-
const overflowYStyle = window.getComputedStyle(el).overflow;
115-
const isOverflowHidden = overflowYStyle.indexOf("hidden") !== -1;
116-
return hasScrollableContent && !isOverflowHidden;
117-
},
118129
getScrollableParent(element) {
119-
const isBody = !element || element === document.body;
120-
121-
if (isBody) return document.body;
130+
if (!element) {
131+
return undefined;
132+
}
122133
123-
if (this.isScrollable(element)) return element;
134+
let parent = element.parentElement;
135+
while (parent) {
136+
const { overflow } = window.getComputedStyle(parent);
137+
if (overflow.split(" ").every((o) => o === "auto" || o === "scroll")) {
138+
return parent;
139+
}
140+
parent = parent.parentElement;
141+
}
124142
125-
return this.getScrollableParent(element.parentNode);
143+
return document.documentElement;
126144
},
127145
isInViewport(element) {
128146
const rect = element.getBoundingClientRect();
@@ -189,5 +207,18 @@ export default {
189207
border-radius: $border-radius;
190208
background: palette(white);
191209
}
210+
&--frozen-page {
211+
&:before {
212+
content: "";
213+
position: fixed;
214+
height: 100vh;
215+
width: 100vw;
216+
top: 0;
217+
left: 0;
218+
right: 0;
219+
bottom: 0;
220+
z-index: 2;
221+
}
222+
}
192223
}
193224
</style>

argilla-frontend/components/feedback-task/container/fields/Record.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export default {
6161
background: palette(white);
6262
border: 1px solid palette(grey, 600);
6363
border-radius: $border-radius-m;
64-
&--focus {
65-
overflow-y: auto;
66-
overflow-x: hidden;
64+
&:has(.dropdown__content),
65+
&:has(.checkbox.checked) {
66+
border-color: $black-20;
6767
}
6868
&__wrapper {
6969
flex: 1;
@@ -87,6 +87,10 @@ export default {
8787
height: 100%;
8888
overflow: auto;
8989
}
90+
.record--focus & {
91+
overflow-y: auto;
92+
overflow-x: hidden;
93+
}
9094
}
9195
&__fixed-header {
9296
padding: $base-space * 2;

argilla-frontend/components/feedback-task/container/fields/RecordFieldsHeader.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
:recordId="record.id"
2626
/>
2727
<RecordStatus :recordStatus="record.status" />
28+
<RecordMenu :record="record" />
2829
</div>
2930
</div>
3031
</template>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<template>
2+
<div class="record-menu">
3+
<BaseDropdown
4+
:freezing-page="visibleMetadataInfo"
5+
:visible="dropdownIsVisible"
6+
@visibility="onVisibility"
7+
>
8+
<template slot="dropdown-header">
9+
<BaseButton class="record-menu__header">
10+
<svgicon name="kebab" width="20" height="20" />
11+
</BaseButton>
12+
</template>
13+
<template slot="dropdown-content">
14+
<RecordMetadataInfo v-if="visibleMetadataInfo" :record="record" />
15+
<ul v-else class="record-menu__content">
16+
<li>
17+
<BaseButton @on-click="viewMetadata">
18+
{{ $t("viewMetadata") }}
19+
</BaseButton>
20+
</li>
21+
<li>
22+
<BaseButton @on-click="copyRecord">
23+
{{ $t("copyRecord") }}
24+
</BaseButton>
25+
</li>
26+
</ul>
27+
</template>
28+
</BaseDropdown>
29+
</div>
30+
</template>
31+
32+
<script>
33+
import "assets/icons/kebab";
34+
export default {
35+
props: {
36+
record: {
37+
type: Object,
38+
required: true,
39+
},
40+
},
41+
data() {
42+
return {
43+
dropdownIsVisible: false,
44+
visibleMetadataInfo: false,
45+
};
46+
},
47+
methods: {
48+
viewMetadata() {
49+
this.visibleMetadataInfo = true;
50+
},
51+
copyRecord() {
52+
this.dropdownIsVisible = false;
53+
this.$copyToClipboard(
54+
this.record.fields
55+
.map((field) => `${field.title}\n${field.content}`)
56+
.join("\n")
57+
);
58+
},
59+
onVisibility(isVisible) {
60+
this.visibleMetadataInfo = false;
61+
this.dropdownIsVisible = isVisible;
62+
},
63+
},
64+
};
65+
</script>
66+
67+
<style lang="scss" scoped>
68+
.record-menu {
69+
&__header {
70+
padding: 0;
71+
color: $black-54;
72+
margin-right: -$base-space;
73+
&:hover {
74+
color: $black-87;
75+
}
76+
}
77+
&__content {
78+
list-style: none;
79+
padding: $base-space;
80+
margin: 0;
81+
li {
82+
border-radius: $border-radius-s;
83+
transition: background-color 0.3s ease;
84+
&:hover {
85+
background: $black-4;
86+
cursor: pointer;
87+
transition: background-color 0.3s ease;
88+
}
89+
}
90+
.button {
91+
display: block;
92+
max-width: 200px;
93+
text-align: left;
94+
padding: $base-space;
95+
font-weight: normal;
96+
@include truncate;
97+
}
98+
}
99+
:deep(.dropdown__content) {
100+
min-width: 100%;
101+
left: auto;
102+
right: 0;
103+
top: calc(100% + $base-space * 2);
104+
}
105+
}
106+
</style>

0 commit comments

Comments
 (0)