-
Notifications
You must be signed in to change notification settings - Fork 3.2k
refactor: echo-420: remove bem from dm lib #8757
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
Conversation
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
✅ Deploy Preview for label-studio-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for label-studio-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for heartex-docs canceled.
|
2e47d45 to
39e836e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## develop #8757 +/- ##
============================================
- Coverage 66.72% 50.69% -16.03%
============================================
Files 792 553 -239
Lines 61014 39319 -21695
Branches 10400 10400
============================================
- Hits 40709 19932 -20777
+ Misses 20302 19384 -918
Partials 3 3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
892f44f to
84a39a1
Compare
Migrated Badge component from Block/Elem to cn() helper.
- Replaced Block import with cn import
- Replaced <Block name="badge-dm"> with <div className={cn("badge-dm")...}>
- Replaced className prop with .mix(className) method
- Preserved all mods, style, and props
- No behavior change, equivalent class strings
Migrated Tag component from Block/Elem to cn() helper.
- Replaced Block import with cn import
- Replaced <Block tag="span" name="tag-dm"> with <span className={cn("tag-dm")...}>
- Preserved mod={{ size }}, mix, style, and all props
- No behavior change, equivalent class strings
Migrated SkeletonGap component from Block/Elem to cn() helper.
- Replaced Elem import with cn import
- Replaced <Elem name="gap"> with <div className={cn("skeletonLoader").elem("gap")...}>
- Used parent Block name "skeletonLoader" from SkeletonLoader component
- Preserved style prop with CSS custom properties
- No behavior change, equivalent class strings
Migrated SkeletonLine component from Block/Elem to cn() helper.
- Replaced Elem import with cn import
- Replaced <Elem name="line"> with <div className={cn("skeletonLoader").elem("line")...}>
- Used parent Block name "skeletonLoader" from SkeletonLoader component
- Preserved style prop with CSS custom properties and key prop
- No behavior change, equivalent class strings
Migrated Counter component from Block/Elem to cn() helper.
- Replaced Block/Elem imports with cn import
- Replaced <Block name="counter"> with <div className={cn("counter")...}>
- Replaced <Elem tag="input" name="input"> with <input className={cn("counter").elem("input")...}>
- Replaced <Elem name="input"> with <div className={cn("counter").elem("input")...}> (for postfix display)
- Replaced <Elem tag="a" name="btn"> with <a className={cn("counter").elem("btn")...}> in CounterButton
- Preserved all mods (focused, disabled, withPostfix, under, type), refs, handlers, and props
- No behavior change, equivalent class strings
Migrated Form Label component from Block/Elem to cn() helper.
- Replaced Block/Elem imports with cn and createElement imports
- Replaced <Block tag={tagName} name="label-dm"> with createElement(tagName, {className: cn("label-dm")...})
- Replaced all nested <Elem> components with <div className={cn("label-dm").elem(...)...}>
- Used createElement for dynamic tag handling (div or label based on simple prop)
- Preserved all mods (size, large, flat, placement, withDescription, empty), ref, style, and data-required
- No behavior change, equivalent class strings
Migrated RadioGroup component from Block/Elem to cn() helper.
- Replaced Block/Elem imports with cn import
- Replaced <Block name="radio-group-dm"> with <div className={cn("radio-group-dm")...}>
- Replaced <Elem name="buttons"> with <div className={cn("radio-group-dm").elem("buttons")...}>
- Replaced <Elem tag="label" name="button"> with <label className={cn("radio-group-dm").elem("button")...}>
- Replaced <Elem tag="input" name="input"> with <input className={cn("radio-group-dm").elem("input")...}>
- Preserved all mods (size, checked, disabled), spread props, and handlers
- No behavior change, equivalent class strings
Completed migration of Form component from Block/Elem to cn() helper.
- Removed Block and Elem imports (cn was already imported)
- Replaced <Block name="form-indicator-dm"> with <div className={cn("form-indicator-dm")...}>
- Replaced <Elem tag="span" name="item"> with <span className={cn("form-indicator-dm").elem("item")...}>
- Most of Form component was already using cn() - only Form.Indicator needed migration
- Preserved mod={{ type: state }} and case prop for Oneof
- No behavior change, equivalent class strings
Migrated Range component from Block/Elem to cn() helper.
- Replaced Block/Elem imports with cn import
- Replaced <Block name="range"> with <div className={cn("range")...}>
- Replaced all nested <Elem> components with <div className={cn("range").elem(...)...}>
- Updated RangeHandle component to use cn("range").elem("range-handle")
- Updated RangeIndicator component to use cn("range").elem("indicator")
- Preserved all mods (align, with-icon), style props, and event handlers
- No behavior change, equivalent class strings
Migrated Pagination component from Block/Elem to cn() helper.
- Replaced Block/Elem imports with cn import
- Replaced <Block name="pagination-dm"> with <div className={cn("pagination-dm")...}>
- Replaced all nested <Elem> components with <div className={cn("pagination-dm").elem(...)...}>
- Updated NavigationButton component to use cn("pagination-dm").elem("btn")
- Preserved all mods (disabled, size, waiting, arrow variants), event handlers, and props
- No behavior change, equivalent class strings
Migrated Resizer component from Block/Elem to cn() helper.
- Converted Block name="resizer" to cn("resizer")
- Converted Elem name="content" to cn("resizer").elem("content")
- Converted Elem name="handle" to cn("resizer").elem("handle")
- Preserved all mods (resizing, quickview), refs, handlers, and styles
- No behavior change, equivalent class strings
Migrated FieldsButton component from Elem to cn() helper.
- Converted Elem name="field-button" to cn("field-button")
- Preserved rawClassName by concatenating with toClassName()
- Maintained all styles and tooltip functionality
- No behavior change, equivalent class strings
Migrated MediaPlayer component from Block/Elem to cn() helper.
- Converted Block name="player" to cn("player")
- Converted all Elem components to cn("player").elem()
- Replaced tag props with createElement for dynamic media elements
- Preserved all mods (video), refs, handlers, and click events
- Maintained Space component integration with className prop
- No behavior change, equivalent class strings
Migrated MediaSeeker component from Block/Elem to cn() helper.
- Converted Block name="audio-seeker" to cn("audio-seeker")
- Converted Elem name="wrapper" to cn("audio-seeker").elem("wrapper")
- Converted Elem name="progress" to cn("audio-seeker").elem("progress")
- Converted Elem name="buffer" to cn("audio-seeker").elem("buffer")
- Preserved all mods (video), refs, handlers, and styles
- No behavior change, equivalent class strings
Migrated SkeletonLoader component from Block to cn() helper.
- Converted Block name="skeletonLoader" to cn("skeletonLoader")
- Preserved all styles and CSS variable assignments
- No behavior change, equivalent class strings
Migrated Table DataView component from Block/Elem to cn() helper.
- Converted Block name="fill-container" to cn("fill-container")
- Converted Block name="syncInProgress" to cn("syncInProgress")
- Converted Elem name="title" to cn("syncInProgress").elem("title")
- Converted Elem name="text" to cn("syncInProgress").elem("text")
- Converted Block name="no-results" to cn("no-results")
- Converted Block name="data-view-dm" to cn("data-view-dm")
- Preserved all styles, className mixes, and handlers
- No behavior change, equivalent class strings
Migrated GridView component from Block/Elem to cn() helper.
- Converted Block name="grid-view" to cn("grid-view")
- Converted Elem name="cell-header" to cn("grid-view").elem("cell-header")
- Converted Elem name="cell" to cn("grid-view").elem("cell")
- Converted Elem name="cell-content" to cn("grid-view").elem("cell-content")
- Converted Elem name="cell-body" to cn("grid-view").elem("cell-body")
- Converted Elem name="resize" to cn("grid-view").elem("resize")
- Converted Elem name="list" to cn("grid-view").elem("list")
- Replaced tag props with direct className on AutoSizer and FixedSizeGrid
- Preserved all mods, rawClassName concatenation, refs, and handlers
- No behavior change, equivalent class strings
Migrated Toolbar component from Block to cn() helper.
- Converted Block name="tab-panel" to cn("tab-panel")
- Preserved all Space components and mapped instrument rendering
- No behavior change, equivalent class strings
Migrated ActionsButton component from Block/Elem to cn() helper.
- Converted Block name="dialog-content" to cn("dialog-content")
- Converted Elem name="text" to cn("dialog-content").elem("text")
- Converted Elem name="loading" to cn("dialog-content").elem("loading")
- Converted Elem name="form" to cn("dialog-content").elem("form")
- Converted Block name="actionButton" to Menu.Item with cn("actionButton") className
- Converted Elem name="titleContainer" to cn("actionButton").elem("titleContainer")
- Converted Elem name="title" to cn("actionButton").elem("title")
- Converted Elem name="icon" to IconChevronRight with cn("actionButton").elem("icon") className
- Converted Block name="actionButton-submenu" to cn("actionButton-submenu")
- Preserved all mods, refs, handlers, aria labels, and tooltips
- No behavior change, equivalent class strings
Migrated instruments file from Block to cn() helper.
- Converted Block name="button-wrapper" to cn("button-wrapper")
- Preserved all tooltip configuration and ImportButton wrapper
- No behavior change, equivalent class strings
Migrated Filters component from Block/Elem to cn() helper.
- Converted Block name="filters" to cn("filters")
- Converted Elem name="list" to cn("filters").elem("list")
- Converted Elem name="empty" to cn("filters").elem("empty")
- Converted Elem name="actions" to cn("filters").elem("actions")
- Converted dropdownClassName to use cn("filters").elem("selector").toClassName()
- Preserved all mods (sidebar, withFilters), handlers, and button components
- No behavior change, equivalent class strings
Migrated FiltersSidebar component from Block/Elem to cn() helper.
- Converted Block name="filters-sidebar" to cn("filters-sidebar")
- Converted Elem name="header" to cn("filters-sidebar").elem("header")
- Converted Elem name="extra" to cn("filters-sidebar").elem("extra")
- Converted Elem name="title" to cn("filters-sidebar").elem("title")
- Preserved all button handlers, aria labels, and tooltips
- No behavior change, equivalent class strings
Migrated ImageDataGroup component from Block to cn() helper.
- Converted Block name="grid-image-wrapper" to cn("grid-image-wrapper")
- Preserved all image styles, alt attributes, and AnnotationPreview integration
- No behavior change, equivalent class strings
Migrated Label component from Block/Elem to cn() helper.
- Replaced Block/Elem imports with cn import
- Replaced <Block name="label-view"> with <div className={cn("label-view")...}>
- Replaced all nested <Elem> components with appropriate elements using cn("label-view").elem(...)
- Replaced <Elem tag={Resizer}> with <Resizer className={...}> (component tag pattern)
- Preserved all mods (loading, labelStream, mode, animated), refs, ids, keys, and handlers
- No behavior change, equivalent class strings
Updated GridView test file to use cn() helper instead of Block.
- Converted Block import to cn import
- Updated renderWithBEM wrapper to use cn("grid-view")
- Ensures test mocks match the migrated production code
- No behavior change in tests, equivalent class strings
Removed unused Block/Elem exports from bem.tsx. - Removed Block, Elem, BemWithSpecificContext, BlockContext, useBEM, and BemComponent exports - Kept cn, CN, and CNTagName exports (only what's needed) - All 25 files now use cn() instead of Block/Elem - Completes DataManager BEM migration
84a39a1 to
41ea23f
Compare
Refactor: Migrate DataManager from Block/Elem to cn() Helper
Summary
This PR completes the migration of the DataManager library from the legacy
Block/ElemBEM wrappers to the moderncn()helper function. This brings DataManager in line with the Editor library's architecture and modernizes the codebase.What Changed
Block/Elemtocn()helperMotivation
Technical Details
Transformation Patterns
Block Components
Elem Components
Dynamic Tags
Component Tags
Files Migrated
Phase 1: Simple Components (5 files)
Badge.jsxTag.jsxSkeletonGap.tsxSkeletonLine.tsxLabel/Label.jsxPhase 2: Form Components (4 files)
Form/Elements/Counter/Counter.jsxForm/Elements/Label/Label.jsxRadioGroup/RadioGroup.jsxForm/Form.jsxPhase 3: UI Components (3 files)
Range/Range.jsxPagination/Pagination.tsxResizer/Resizer.jsxPhase 4: Complex Components (11 files)
FieldsButton.jsxMediaPlayer/MediaPlayer.jsxMediaPlayer/MediaSeeker.jsxSkeletonLoader/SkeletonLoader.tsxMainView/DataView/Table.jsxMainView/GridView/GridView.jsxDataManager/Toolbar/Toolbar.jsxDataManager/Toolbar/ActionsButton.jsxDataManager/Toolbar/instruments.jsxFilters/Filters.jsxFilters/FiltersSidebar/FilterSidebar.jsxPhase 5: Final Components (1 file)
DataGroups/ImageDataGroup.jsxPhase 6: Tests & Cleanup (2 tasks)
GridView.test.tsx- Updated mocksbem.tsx- Removed unused exportsCommit Structure
Each component was migrated in an individual commit for easy review and potential rollback. All commits follow the format:
Verification
✅ Zero Block/Elem imports remaining
✅ Biome linting passes
✅ All transformations preserve class strings
cn(block).elem(elem).mod(mod).mix(mix).toClassName()Breaking Changes
None. This is a pure refactoring with no functional changes:
Testing Recommendations
Migration Statistics
Follow-up
This completes the BEM migration for DataManager. The codebase now uses modern
cn()helpers consistently across both Editor and DataManager libraries.Related Work