Skip to content

feat: FIT-14: LabelStudio Playground 2.0 #7521

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 62 commits into
base: develop
Choose a base branch
from
Open

feat: FIT-14: LabelStudio Playground 2.0 #7521

wants to merge 62 commits into from

Conversation

bmartel
Copy link
Contributor

@bmartel bmartel commented May 13, 2025

This pull request introduces the foundational setup and implementation of the LabelStudio Playground, a standalone React application for editing and previewing LabelStudio XML labeling configurations. This implementation will serve as the replacement of the defunct playground used on labelstud.io.

Project Setup and Configuration

  • Added a .babelrc file to configure Babel with the @nx/react/babel preset for automatic runtime.
  • Introduced a jest.config.ts file for unit testing, with support for Babel transformations and module name mapping.
  • Added a project.json file to define build, serve, and test targets using Nx executors for Webpack and Jest.

Documentation and Overview

  • Created a comprehensive README.mdc file detailing the purpose of the Playground app, its features, architecture, state management, and extensibility.

State Management

  • Defined Jotai atoms in configAtoms.ts to manage application state, including configuration, loading, error, and annotation data.

UI Components

  • Added a BottomPanel component to display sample data input and annotation output, with collapsible and resizable functionality. [1] [2]
  • Implemented an EditorPanel component for XML editing with a resizable bottom panel for input/output display. [1] [2]

Styling

  • Added SCSS styles in PlaygroundApp.module.scss to lightly customize the appearance of CodeMirror and LabelStudio components.

Copy link

netlify bot commented May 13, 2025

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit a74361b
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/6824dac1f338aa00085f836c

Copy link

netlify bot commented May 13, 2025

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit a74361b
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-storybook/deploys/6824dac117f5bf0008e2cb69
😎 Deploy Preview https://deploy-preview-7521--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 13, 2025

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit a74361b
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/6824dac12a5b380008439f45

@github-actions github-actions bot added the feat label May 13, 2025
Comment on lines 31 to 32
className="relative h-[33px] flex flex-row items-center bg-neutral-surface select-none"
style={{ minHeight: HEADER_HEIGHT, maxHeight: HEADER_HEIGHT }}
Copy link
Contributor

Choose a reason for hiding this comment

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

this should do the same thing with out inline styles but if we have the height set - why do we need min and max set too?

Suggested change
className="relative h-[33px] flex flex-row items-center bg-neutral-surface select-none"
style={{ minHeight: HEADER_HEIGHT, maxHeight: HEADER_HEIGHT }}
className={`relative h-[${HEADER_HEIGHT}px] flex flex-row items-center bg-neutral-surface select-none min-h-[${HEADER_HEIGHT}px] max-h-[${HEADER_HEIGHT}px]`}

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, if we need to have this height fixed:

  • h-[${HEADER_HEIGHT}px]
  • no min/max
  • flex-shrink: 0

Comment on lines 44 to 45
className="lsf-button lsf-button_look_ lsf-collapsible-bottom-panel-toggle absolute right-[5px] top-1/2 -translate-y-1/2 !h-6 !w-6 !p-0 flex items-center justify-center !bg-transparent !border-none"
style={{ zIndex: 10 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

this should do the same - but maybe there is a cleaner z-index class that does this?

Suggested change
className="lsf-button lsf-button_look_ lsf-collapsible-bottom-panel-toggle absolute right-[5px] top-1/2 -translate-y-1/2 !h-6 !w-6 !p-0 flex items-center justify-center !bg-transparent !border-none"
style={{ zIndex: 10 }}
className="lsf-button lsf-button_look_ lsf-collapsible-bottom-panel-toggle absolute right-[5px] top-1/2 -translate-y-1/2 !h-6 !w-6 !p-0 flex items-center justify-center !bg-transparent !border-none z-[10]"

const setLoading = useSetAtom(loadingAtom);
const setError = useSetAtom(errorAtom);
const setInterfaces = useSetAtom(interfacesAtom);
const [editorWidth, setEditorWidth] = useState(50); // percent
Copy link
Contributor

Choose a reason for hiding this comment

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

lets use a constant as the default value instead of a magic 50


const renderApp = () => {
if (isRendered) {
clearRenderedApp();
}
render(<App store={this.store} />, rootElement);
renderTimeout = setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to render it like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were errors when unmounting/remounting in quick succession. I am still adjusting for what I have been seeing in different usages, so this could be made redundant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, good! in any case the final version better to have the reasoning described in a comment

document.body.style.cursor = "col-resize";
document.body.style.userSelect = "none";
const percent = (e.clientX / window.innerWidth) * 100;
setEditorWidth(Math.max(20, Math.min(80, percent)));
Copy link
Contributor

Choose a reason for hiding this comment

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

can we set the default min and max (20 and 80) as constants so we're not using magic numbers

e.preventDefault();
document.body.style.cursor = "";
document.body.style.userSelect = "";
setEditorWidth(50); // Reset to 50/50 split
Copy link
Contributor

Choose a reason for hiding this comment

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

this should use the constant from earlier for 50

Copy link
Contributor

@yyassi-heartex yyassi-heartex left a comment

Choose a reason for hiding this comment

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

i have a number of relatively minor suggestions but overall looks good - would love to see this get to production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants