Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add share component #5727

Merged
merged 70 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
698dd23
✨ Add share component
damianpumar Dec 3, 2024
7ebc3d6
✨ Rainbow
damianpumar Dec 3, 2024
c8b8515
✨ Add image and preview
damianpumar Dec 3, 2024
8029f1b
🐛 Translations
damianpumar Dec 3, 2024
1526195
✨ Share progress
damianpumar Dec 3, 2024
799a59d
🔥 Fix texts
damianpumar Dec 4, 2024
886fa48
create share page
frascuchon Dec 4, 2024
991b520
🚀 Share backend route
damianpumar Dec 4, 2024
80dc7b5
Merge branch 'feat/share-annotation-progress' of https://github.com/a…
damianpumar Dec 4, 2024
40b4ee1
fix dataset_name param
frascuchon Dec 4, 2024
1a1825c
fix: remove extra $
frascuchon Dec 4, 2024
ab7aa9a
fix: remove wrong alias and define argas as expected params
frascuchon Dec 4, 2024
0784ba1
🔥 Improve share html
damianpumar Dec 4, 2024
061e90d
Merge branch 'feat/share-annotation-progress' of https://github.com/a…
damianpumar Dec 4, 2024
7e1faa9
🚑 Improve html meta tag
damianpumar Dec 4, 2024
9cb2dde
🚑 Fix
damianpumar Dec 4, 2024
b0dcb76
🚑 Encode to base64
damianpumar Dec 4, 2024
80c936d
🐛 Fix build
damianpumar Dec 4, 2024
1893833
🐛 Fix build
damianpumar Dec 4, 2024
6b929b7
Merge branch 'feat/share-annotation-progress' of https://github.com/a…
damianpumar Dec 4, 2024
5972534
🐛 Restore package
damianpumar Dec 4, 2024
9ac9e82
🚑 Try
damianpumar Dec 4, 2024
8a6ca67
🚑 Try
damianpumar Dec 4, 2024
218c22e
Merge branch 'feat/share-annotation-progress' of https://github.com/a…
damianpumar Dec 4, 2024
eb3bf99
🚑 Rollback
damianpumar Dec 4, 2024
8bd15b2
Merge branch 'develop' into feat/share-annotation-progress
frascuchon Dec 4, 2024
a879191
Merge branch 'feat/share-annotation-progress' of https://github.com/a…
damianpumar Dec 4, 2024
ecb3b74
✨ Try
damianpumar Dec 4, 2024
314e1c5
✨ Fix package lock
damianpumar Dec 4, 2024
e432321
Merge branch 'develop' into feat/share-annotation-progress
frascuchon Dec 4, 2024
5ef4913
decode base64 to utf8
frascuchon Dec 4, 2024
f9d44ec
✨ Show share button at least 1 submitted and show rainbow every 20 su…
damianpumar Dec 5, 2024
ad54b9d
✨ Remove toast
damianpumar Dec 5, 2024
99fc231
🚑 Remove @
damianpumar Dec 5, 2024
6c15667
🚑 Improve copy
damianpumar Dec 5, 2024
8072f04
🚑 Fix copy
damianpumar Dec 5, 2024
1c2a859
✨ New endpoint
damianpumar Dec 5, 2024
7fa3bc4
final share-your-progress server page
frascuchon Dec 5, 2024
4b1c82d
✨ Improve UI
damianpumar Dec 5, 2024
725f7ce
Merge branch 'feat/share-annotation-progress' of https://github.com/a…
damianpumar Dec 5, 2024
a44ab98
review text template
frascuchon Dec 5, 2024
0c7aa71
Merge branch 'feat/share-annotation-progress' of github.com:argilla-i…
frascuchon Dec 5, 2024
775601a
✨ Add new params
damianpumar Dec 5, 2024
3b706af
Merge branch 'feat/share-annotation-progress' of https://github.com/a…
damianpumar Dec 5, 2024
c3c58e0
🚑 Add environment flag to enable share button
damianpumar Dec 5, 2024
be653f2
🚑 Show the rainbow every 10 records and show the share from 2 records…
damianpumar Dec 6, 2024
ae7854b
🚀 Improve some detail
damianpumar Dec 9, 2024
246081b
[FEATURE] Add `ARGILLA_ENABLE_SHARE_YOUR_PROGRESS` environment variab…
frascuchon Dec 9, 2024
88da15b
fix failing tests
frascuchon Dec 9, 2024
6340ecf
fix: Add default order to users progress
frascuchon Dec 9, 2024
801c941
Review og description
frascuchon Dec 9, 2024
82d2203
Revert "🚑 Add environment flag to enable share button"
frascuchon Dec 9, 2024
e9348f0
🐛 Fix pre-fetching image
damianpumar Dec 9, 2024
bf05292
Revert "Revert "🚑 Add environment flag to enable share button""
damianpumar Dec 9, 2024
ab1aef4
🐛 Add spinner
damianpumar Dec 9, 2024
2d72efe
🚀 Fix axios interceptors
damianpumar Dec 10, 2024
e038abc
🐛 Fix translation
damianpumar Dec 10, 2024
c867e96
chore: Add CHANGELOG.md
frascuchon Dec 10, 2024
624104c
docs: Add new environment variable in docs
frascuchon Dec 10, 2024
a8d2960
📝 Changelog
damianpumar Dec 10, 2024
c4632d9
fix: UI - use `last_activity_at` in the dataset list (#5741)
leiyre Dec 10, 2024
9ace1a3
Merge branch 'develop' into feat/share-annotation-progress
frascuchon Dec 10, 2024
3156040
📝 Improve image generation
damianpumar Dec 13, 2024
4b46a93
chore: increase dev version to 2.7.0
jfcalvo Dec 17, 2024
6d9e691
🐛 Fix issue on HF sign in
damianpumar Dec 17, 2024
8eabd96
Merge branch 'develop' into feat/share-annotation-progress
frascuchon Dec 18, 2024
21e7a05
chore: Update changelog
frascuchon Dec 18, 2024
6414b1a
remove extra span
frascuchon Dec 18, 2024
dbd908a
💄 Fix share preview
damianpumar Dec 18, 2024
7637707
Merge branch 'releases/2.6.0' into feat/share-annotation-progress
damianpumar Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions argilla-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ These are the section headers that we use:

### Added

- Add share progress feature ([#5727](https://github.com/argilla-io/argilla/pull/5727))
- Added feature to export datasets from Argilla to Hugging Face hub from the UI ([#5730](https://github.com/argilla-io/argilla/pull/5730))

### Fixed
Expand Down
6 changes: 6 additions & 0 deletions argilla-frontend/components/base/base-button/BaseButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
:target="target"
:rel="newRel"
@click="onClick"
@mouseover="$emit('mouseover')"
@mouseleave="$emit('mouseleave')"
>
<slot />
</a>
Expand All @@ -36,6 +38,8 @@
:loading="loading"
:disabled="disabled"
@click="onClick"
@mouseover="$emit('mouseover')"
@mouseleave="$emit('mouseleave')"
>
<slot />
</nuxt-link>
Expand All @@ -48,6 +52,8 @@
:type="type"
:disabled="disabled"
@click="onClick"
@mouseover="$emit('mouseover')"
@mouseleave="$emit('mouseleave')"
>
<BaseSpinner
class="spinner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@
v-if="!metrics.hasMetrics"
class="my-progress__status--skeleton"
/>
<StatusCounter
v-else
class="my-progress__status"
:color="RecordStatus.submitted.color"
:name="RecordStatus.submitted.name"
:value="metrics.submitted"
/>
<div v-else class="my-progress__share">
<Share v-if="canSeeShare" />
<StatusCounter
:ghost="true"
:rainbow="shouldShowSubmittedAnimation"
class="my-progress__status"
:color="RecordStatus.submitted.color"
:name="RecordStatus.submitted.name"
:value="metrics.submitted"
/>
</div>
</div>
</template>

<script>
import { RecordStatus } from "~/v1/domain/entities/record/RecordStatus";
import { useAnnotationProgressViewModel } from "./useAnnotationProgressViewModel";
Expand Down Expand Up @@ -71,5 +74,12 @@ $statusCounterMinHeight: 30px;
min-height: $statusCounterMinHeight;
}
}
&__share {
width: 100%;
display: flex;
align-items: center;
justify-content: end;
gap: $base-space;
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<template>
<div class="share" @click.stop="copyOnClipboard">
<BaseActionTooltip :tooltip="$t('copiedToClipboard')">
<BaseButton
class="share__button"
:title="$t('button.tooltip.copyToClipboard')"
@mouseover="openDialog"
@mouseleave="closeDialog"
>
<svgicon class="share__icon" name="link" width="14" height="14" />
{{ $t("share") }}
</BaseButton>
</BaseActionTooltip>
<transition name="fade" appear>
<dialog
v-if="isDialogOpen"
class="share__dialog"
v-click-outside="closeDialog"
>
<div class="share__dialog--container">
<BaseSpinner v-if="!sharingImage.loaded" :size="20" />
<img v-else :src="sharingImage.src" />
</div>
</dialog>
</transition>
</div>
</template>
<script>
import { useShareViewModel } from "./useShareViewModel";

export default {
setup() {
return useShareViewModel();
},
};
</script>

<style lang="scss" scoped>
$bullet-size: 8px;
.share {
z-index: 2;
margin-left: auto;
margin-right: 0;

&__dialog {
position: absolute;
right: 1em;
left: auto;
width: auto;
height: 204px;
min-width: 360px;
max-width: 360px;
bottom: calc(100% + $base-space + 2px);
display: block;
padding: $base-space * 2;
border: 1px solid var(--bg-opacity-10);
border-radius: $border-radius-m;
box-shadow: $shadow;
z-index: 2;

&--container {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
}

&__button {
@include font-size(12px);
height: 24px;
padding: $base-space;
background: var(--bg-opacity-3);
border-radius: $border-radius;
}

&__icon {
padding: 0;
flex-shrink: 0;
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { onBeforeMount, ref } from "vue";
import { useUser } from "~/v1/infrastructure/services";
import { useClipboard } from "~/v1/infrastructure/services/useClipboard";
import { useDataset } from "~/v1/infrastructure/storage/DatasetStorage";
import { useMetrics } from "~/v1/infrastructure/storage/MetricsStorage";
import { useTeamProgress } from "~/v1/infrastructure/storage/TeamProgressStorage";

export const useShareViewModel = () => {
const { copy } = useClipboard();
const { user } = useUser();
const { state: metrics } = useMetrics();
const { state: dataset } = useDataset();
const { state: progress } = useTeamProgress();

const isDialogOpen = ref(false);
const sharingImage = ref<{
src: string;
loaded: boolean;
}>({
src: "",
loaded: false,
});

const copyOnClipboard = () => {
closeDialog();

const url = new URL(`${window.location.origin}/share-your-progress`);
const params = new URLSearchParams("");
params.set("user_name", user.value.userName);
params.set("records_submitted", metrics.submitted.toString());
params.set("team_progress", progress.percentage.completed.toString());
params.set("dataset_name", dataset.name);
params.set("dataset_id", dataset.id);

url.search = params.toString();

const textToCopy = `I've just contributed ${
metrics.submitted
} examples to this dataset:

${url.toString()}`;

copy(textToCopy);
};

const createImageLink = () => {
const url = new URL("https://argilla.imglab-cdn.net/dibt/dibt_v2.png");
const params = new URLSearchParams(url.search);
params.set("width", "1200");
params.set("text-width", "700");
params.set("text-height", "590");
params.set("text-padding", "60");
params.set("text-color", "39,71,111");
params.set("text-x", "460");
params.set("text-y", "40");

params.set(
"text",
`<span size="9pt" weight="bold">@${user.value.userName}</span>
I've just contributed <span weight="bold">${metrics.submitted}</span> examples to this dataset:
<span size="9pt" weight="bold">${dataset.name}</span>

<span size="8pt">Team progress</span>
<span weight="bold">${progress.percentage.completed}%</span>`
);

return `${url.origin}${url.pathname}?${params.toString()}`;
};

const openDialog = () => {
setPreloadedImage();

isDialogOpen.value = true;
};

const closeDialog = () => {
isDialogOpen.value = false;
};

const setPreloadedImage = () => {
sharingImage.value.loaded = false;

const image = createImageLink();

const preFetchImage = new Image();
preFetchImage.src = image;
preFetchImage.onload = () => {
sharingImage.value = {
src: image,
loaded: true,
};
};
};

onBeforeMount(() => {
setPreloadedImage();
});

return {
sharingImage,
isDialogOpen,
openDialog,
closeDialog,
copyOnClipboard,
};
};
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<template>
<li class="status-counter">
<li class="status-counter" :class="{ rainbow, ghost }">
<span>
<span class="color-bullet" :style="{ backgroundColor: color }"></span>
<label class="status-counter__name" v-text="statusLabel" />
</span>
<span class="status-counter__counter" v-text="value" />
</li>
</template>

<script>
export default {
props: {
Expand All @@ -23,6 +22,14 @@ export default {
type: Number,
required: true,
},
rainbow: {
type: Boolean,
default: false,
},
ghost: {
type: Boolean,
default: false,
},
},
computed: {
statusLabel() {
Expand Down Expand Up @@ -60,4 +67,51 @@ $bullet-size: 8px;
@include font-size(14px);
}
}

.ghost {
background: none;
}

.rainbow {
position: relative;
padding: $base-space;
}

.rainbow::before {
content: "";
position: absolute;
top: -2px;
right: -2px;
bottom: -2px;
left: -2px;
border-radius: $border-radius;
border: solid 2px transparent;
border-image: conic-gradient(
from var(--angle),
#e70000,
#ff8c00,
#ffef00,
#00811f,
#3064a9,
#87189d
)
1;
animation: 2s rotate linear infinite;
filter: blur(1px);
z-index: -1;
mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
mask-composite: exclude;
}

@keyframes rotate {
to {
--angle: 360deg;
}
}

@property --angle {
syntax: "<angle>";
initial-value: 0deg;
inherits: false;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import { onBeforeMount } from "vue-demi";
import { computed, onBeforeMount, ref } from "vue-demi";
import {
useEvents,
UpdateMetricsEventHandler,
} from "~/v1/infrastructure/events";
import { useRunningEnvironment } from "~/v1/infrastructure/services";
import { useMetrics } from "~/v1/infrastructure/storage/MetricsStorage";

export const useAnnotationProgressViewModel = () => {
const isShareYourProgressEnabled = ref<boolean>(false);

const { state: metrics } = useMetrics();
const { getShareYourProgressEnabled } = useRunningEnvironment();

onBeforeMount(async () => {
isShareYourProgressEnabled.value = await getShareYourProgressEnabled();
});

const canSeeShare = computed(
() => isShareYourProgressEnabled.value && metrics.submitted >= 2
);
const shouldShowSubmittedAnimation = computed(
() => canSeeShare.value && metrics.submitted % 10 === 0
);

onBeforeMount(() => {
useEvents(UpdateMetricsEventHandler);
});

return {
metrics,
canSeeShare,
shouldShowSubmittedAnimation,
};
};
3 changes: 3 additions & 0 deletions argilla-frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ const config: NuxtConfig = {
"/api/": {
target: BASE_URL,
},
"/share-your-progress": {
target: BASE_URL,
},
},
// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
Expand Down
Loading
Loading