-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: OPTIC-2148: Icons in the circles under pre-annotation regions are missing #7506
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
base: develop
Are you sure you want to change the base?
fix: OPTIC-2148: Icons in the circles under pre-annotation regions are missing #7506
Conversation
✅ Deploy Preview for label-studio-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for heartex-docs canceled.
|
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
fill="#CC5E46" | ||
iconColor="#FFFFFF" | ||
icon={IconCross} | ||
/> | ||
<ControlButton | ||
x={32} | ||
onClick={() => item.annotation.acceptSuggestion(item.id)} | ||
fill="#98C84E" | ||
iconColor="#fff" | ||
fill="#287A72" | ||
iconColor="#FFFFFF" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these colors will be the same for light and darkmode, is that intended? if we need separate colors we can look at getCurrentTheme()
from web/libs/ui/src/lib/ThemeToggle/ThemeToggle.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and can we use css vars here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dug into it a little, css var probably wont work because fill gets passed into a Konva Circle
component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried CSS vars, it didn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yyassi-heartex the colors look ok on both Light and Dark Mode even though we aren't using the correct vars.
That said, this will need more work because the icons themselves aren't visible and it seems they had not been visible for some time (issue seems unrelated to recent work). The above fix by Brandon unfortunately didn't address the issue.
@hlomzik is this something you could help us look into?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hlomzik The problem here is simple, though the solution may not be.
The icons never were able to be rendered previously, because it was always requiring an image to be used for canvas, but our icons have always been SVG components through SVGR. So that means this never worked, because the resulting icons for as long as I have been here have been handled through SVGR, and would produce an SVG React component, not a base64 url or url to an svg.
Now, the solution here I would say we can't entertain as is, because it involves using React Server Rendering utilities which I am still surprised it even works on the client like this to be honest. As to what else could we do here, maybe have a special import of the svg which produces a url to the asset instead of a component with the svg inside, that might be a simpler approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the guidance @bmartel . I'll try that approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these icons were definitely working at some point...
I see 2 options:
- to modify imports as you mentioned to get the path to svg and add it via Konva.Image. doesn't SVGR allow to get the path or stringified svg?
- to recreate this panel in a real svg, this might be more complicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this as unresolved for the time being. It's a low priority fix in any case.
In short, I was not successful in applying the recommended approach (removing React Server Rendering and attempting to pull icons as URLs) after many prompt iterations. Happy to jump back to it with some help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's not a styling issue anymore, it requires some subtle but fundamential changes
…into fb-optic-2148/icons-in-the-circles-under-preannotation-regions-are-missing
…the hover effect and increased icon size so that they are easier to see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the missing icons in the preannotation circles and updates the button colors to match the new branding guidelines, while also introducing a smoother hover state transition.
- Update icon source location and colors for Accept/Reject buttons
- Introduce hover animations and update cursor behavior
- Add polyfills for TextEncoder/TextDecoder in Jest
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
web/libs/editor/src/components/ImageView/SuggestionControls.jsx | Updated icon imports, colors, and hover animations in the SuggestionControls component |
web/libs/editor/jest.setup.js | Added polyfills for TextEncoder and TextDecoder for Jest |
@@ -100,10 +102,13 @@ export const SuggestionControls = observer(({ item, useLayer }) => { | |||
|
|||
const ControlButton = ({ x = 0, fill, iconColor, onClick, icon }) => { | |||
const [img, setImg] = useState(new window.Image()); | |||
const imageSize = 16; | |||
const imageSize = 20; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The intrinsic icon dimensions are set to 12 (in useEffect) while the displayed image size is 20. Consider aligning these dimensions to avoid potential scaling artifacts.
Copilot uses AI. Check for mistakes.
|
||
const iconElement = React.createElement(icon, { color: iconColor, width: 12, height: 12 }); | ||
const svgString = ReactDOMServer.renderToStaticMarkup(iconElement); | ||
const base64 = btoa(unescape(encodeURIComponent(svgString))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of 'unescape' is discouraged as it is deprecated. Consider using an alternative method for handling Unicode characters when encoding the SVG to base64.
const base64 = btoa(unescape(encodeURIComponent(svgString))); | |
const base64 = btoa(decodeURIComponent(encodeURIComponent(svgString))); |
Copilot uses AI. Check for mistakes.
…0. Using decodeURIComponent instead of unescape.
fill="#CC5E46" | ||
iconColor="#FFFFFF" | ||
icon={IconCross} | ||
/> | ||
<ControlButton | ||
x={32} | ||
onClick={() => item.annotation.acceptSuggestion(item.id)} | ||
fill="#98C84E" | ||
iconColor="#fff" | ||
fill="#287A72" | ||
iconColor="#FFFFFF" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh holy moly... what is this...
that's not funky, that's scary a little. we should really improve our cursor rules to stick to tools we already have.
…into fb-optic-2148/icons-in-the-circles-under-preannotation-regions-are-missing
Reason for change
The checkmark and cross icons on the preannotation circles were not displaying correctly. Additionally, the colors of the Accept and Reject buttons were not aligned with the new branding guidelines. This PR addresses both of these issues to improve the visual consistency and user experience.
This PR also introduces a smoother transition animation to the hover state of the buttons as well as displaying the pointer cursor when hovering them.
Screenshots
Rollout strategy
No specific rollout strategy is required for this visual fix. The changes will be deployed with the next release.
Testing
Risks
Low. This PR primarily involves visual corrections and should not introduce any functional regressions.
Reviewer notes
General notes