Skip to content

fix: FIT-137: Multiple labeling templates not yet adapted to dark mode #7584

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

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
2 changes: 1 addition & 1 deletion docs/source/templates/content_moderation.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This template displays text from your source data, and then allows an annotator
<Choice value="Insult" background="orange"/>
<Choice value="Hate" background="grey"/>
</Choices>
<View style="margin-top: 2em; box-shadow: 2px 12px 15px #999; padding: 30px; border-radius: 5px; background-color: #F0FFF0;">
<View style="margin: var(--spacing-tight); box-shadow: 0 4px 8px rgba(var(--color-neutral-shadow-raw) / 10%); padding: var(--spacing-tight) var(--spacing-base); border-radius: var(--corner-radius-small); background-color: var(--color-neutral-background); border: 1px solid var(--color-neutral-border);">
<Header value="Please provide additional comments"/>
<TextArea name="comments" toName="text" required="false"/>
</View>
Expand Down
4 changes: 1 addition & 3 deletions docs/source/templates/text_to_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Based on the natural language prompt, you can generate the set of images from wh
<Style>
.ch-title {
font-size: 2em;
box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
text-align: center;
}
.ch-title .lsf-richtext__line:before {
Expand All @@ -42,15 +41,14 @@ Based on the natural language prompt, you can generate the set of images from wh
padding: 8px;
}
.ant-checkbox-checked+span {
border-color: red;
border-color: var(--color-primary-border-subtle);
}
.ant-checkbox+span sup {
position: absolute;
right: 8px;
top: 8px;
z-index: 2;
display: block;
background: white;
width: 24px;
line-height: 16px;
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ details: Here is a demo that showcases how to construct an interface enabling us
config: |
<View>
<View style="display: flex; align-items: center; font-size: 1em;">
<View style="margin: 0.5em 0.5em 0 0;">
<View style="margin: var(--spacing-tight) var(--spacing-tight) 0 0;">
<Header value="Task: " style="font-size: 1em;"/>
</View>
<Text name="task" value="$task"/>
</View>
<View style="display: flex; align-items: center; box-shadow: 2px 2px 5px #999; padding: 10px; border-radius: 5px; background-color: #E0E0E0; font-size: 1.25em;">
<View style="display: flex; align-items: center; box-shadow: 0px 2px 5px 0px rgba(var(--color-neutral-shadow-raw) / 10%); padding: var(--spacing-tight); border-radius: 5px; background-color: var(--color-neutral-background); font-size: 1.25em; border: 1px solid var(--color-neutral-border); margin-bottom: var(--spacing-tight);">
<View style="margin: 0 1em 0 0">
<Header value="Prompt: " />
</View>
Expand All @@ -22,24 +22,32 @@ config: |
<List name="answers" value="$items" title="All Results" />
<Style>
.htx-ranker-column {
background: #f8f8f8;
background: var(--color-neutral-background);
width: 50%;
padding: 20px;
border-radius: 3px;
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.1);
padding: var(--spacing-tight);
border-radius: var(--corner-radius-smaller);
box-shadow: 0px 2px 5px 0px rgba(var(--color-neutral-shadow-raw) / 10%);
border: 1px solid var(--color-neutral-border);
}

.htx-ranker-item {
background: #e0e0e0;
color: #333;
background: var(--color-neutral-surface);
color: var(--color-neutral-content);
font-size: 16px;
width: 100%;
padding: 10px;
margin-bottom: 10px;
border-radius: 3px;
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.1);
padding: var(--spacing-tight);
margin-bottom: var(--spacing-tight);
border-radius: var(--corner-radius-smaller);
box-shadow: 0px 2px 5px 0px rgba(var(--color-neutral-shadow-raw) / 10%);
border: 1px solid var(--color-neutral-border);
}
.htx-ranker-item p:last-child { display: none }


.htx-ranker-item:hover {
background: var(--color-neutral-surface-hover);
}

.htx-ranker-item p:last-child { display: none };
</Style>
<Ranker name="rank" toName="answers">
<Bucket name="relevant_results" title="Relevant Results" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ config: |
<Choice value="Hate" background="grey"/>
</Choices>

<View style="margin-top: 2em; box-shadow: 2px 12px 15px #999; padding: 30px; border-radius: 5px; background-color: #F0FFF0;">
<View style="margin: var(--spacing-tight); box-shadow: 0 4px 8px rgba(var(--color-neutral-shadow-raw) / 10%); padding: var(--spacing-tight) var(--spacing-base); border-radius: var(--corner-radius-small); background-color: var(--color-neutral-background); border: 1px solid var(--color-neutral-border);">
<Header value="Please provide additional comments"/>
<TextArea name="comments" toName="text" required="false"/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ config: |
<Style>
.ch-title {
font-size: 2em;
box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
text-align: center;
}
.ch-title .lsf-richtext__line:before {
Expand All @@ -30,15 +29,14 @@ config: |
padding: 8px;
}
.ant-checkbox-checked+span {
border-color: red;
border-color: var(--color-primary-border-subtle);
}
.ant-checkbox+span sup {
position: absolute;
right: 8px;
top: 8px;
z-index: 2;
display: block;
background: white;
width: 24px;
line-height: 16px;
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/src/examples/pairwise/annotations/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"from_name": "pw",
"id": "Dx_aB91ISN",
"to_name": "pw",
"to_name": "txt-2",
"type": "pairwise",
"value": {
"selected": "right"
Expand Down
52 changes: 42 additions & 10 deletions web/libs/editor/src/tags/control/Pairwise.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,39 @@ const Model = types

setResult(dir = "none") {
self.selected = dir;
self.left.addProp("style", dir === "left" ? self._selection : {});
self.right.addProp("style", dir === "right" ? self._selection : {});
if (!self.left || !self.right) {
// eslint-disable-next-line no-console
console.warn("Pairwise: left or right object reference is missing. Check toName and config.", {
left: self.left,
right: self.right,
});
return;
}
// Common interactive classes
const interactive = "cursor-pointer hover:bg-primary-emphasis-subtle transition-colors rounded-sm";
if (self._selectionType === "className") {
self.left.addProp(
"className",
dir === "left" ? `${interactive} ${self._selection}` : `${interactive} border border-transparent`,
);
self.right.addProp(
"className",
dir === "right" ? `${interactive} ${self._selection}` : `${interactive} border border-transparent`,
);
self.left.addProp("style", {});
self.right.addProp("style", {});
} else {
self.left.addProp(
"style",
dir === "left" ? self._selection : { border: "1px solid transparent", borderRadius: "0.125rem" },
);
self.right.addProp(
"style",
dir === "right" ? self._selection : { border: "1px solid transparent", borderRadius: "0.125rem" },
);
self.left.addProp("className", interactive);
self.right.addProp("className", interactive);
}
},

selectLeft() {
Expand All @@ -100,21 +131,22 @@ const Model = types
InfoModal.error("Incorrect toName parameter on Pairwise, must be two names separated by a comma: name1,name2");
}

let selection = {};

// If selectionstyle is provided, use inline style for backward compatibility.
// Otherwise, use Tailwind semantic classes for selection via className.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting approach with tailwind and classnames override! I would simplify it a little: we don't need selection var at this level, just assign it directly in both branches to self._selection. But it's good anyway

let selection;
if (self.selectionstyle) {
const s = Tree.cssConverter(self.selectionstyle);

selection = {};
for (const key in s) {
selection[key] = s[key];
}
self._selectionType = "style";
} else {
selection = {
backgroundColor: "#f6ffed",
border: "1px solid #b7eb8f",
};
// Use semantic Tailwind classes for primary/selected state
// See: label-studio/web/libs/ui/src/tokens/tokens.js
selection = "bg-primary-background border border-primary-border-subtle rounded-sm";
self._selectionType = "className";
}

self._selection = selection;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ $border-thin: 1px solid rgb(137 128 152 / 16%);
height: 40px;
padding: 0 12px;
border: none;
border-bottom: 1px solid rgb(0 0 0 / 15%);
border-bottom: 1px solid var(--color-neutral-border);
font-size: 14px;
line-height: 22px;
background: var(--color-neutral-surface);
Expand All @@ -142,7 +142,7 @@ $border-thin: 1px solid rgb(137 128 152 / 16%);
gap: 4px;

&__item {
color: initial;
color: var(--color-neutral-content);
background-color: var(--color-neutral-background);
display: inline-flex;
font-weight: 400;
Expand Down
Loading