-
-
Notifications
You must be signed in to change notification settings - Fork 228
✨ feat: migrate FlexBasic to web component implementation #441
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: master
Are you sure you want to change the base?
Conversation
- Refactor FlexBasic component into a web component, FlexBasicElement, with shadow DOM support. - Introduce CSS variables for flexible styling and layout management. - Update index to export new web component and its definition function. - Remove legacy FlexBasic implementation from FlexBasic.tsx. Signed-off-by: Innei <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's GuideReplaces the React-based FlexBasic component with a custom element implementation (FlexBasicElement) backed by a shadow-DOM-based web component, wiring all previous layout props through attributes and CSS custom properties, and updates exports and global typing to support the new element and Vite raw CSS imports. Sequence diagram for defining and using FlexBasicElementsequenceDiagram
actor Developer
participant ReactApp
participant Browser
participant CustomElementsRegistry as customElements
participant FlexBasicElement
Developer->>ReactApp: Import FlexBasic (NativeFlexBasicElement)
ReactApp->>Browser: Render <lobe-flex ...> in DOM
Note over Browser,CustomElementsRegistry: defineFlexBasicElement() has registered lobe-flex
Browser->>CustomElementsRegistry: Lookup constructor for tag lobe-flex
CustomElementsRegistry-->>Browser: FlexBasicElement
Browser->>FlexBasicElement: new FlexBasicElement() and connectedCallback()
FlexBasicElement->>FlexBasicElement: attachShadow({mode:open})
FlexBasicElement->>FlexBasicElement: create style, hostStyle, container, slot
FlexBasicElement->>FlexBasicElement: #sync() apply CSS vars and classes
Developer->>ReactApp: Update props on FlexBasic
ReactApp->>Browser: Update attributes on <lobe-flex>
Browser->>FlexBasicElement: attributeChangedCallback()
FlexBasicElement->>FlexBasicElement: #sync() recompute layout CSS variables
Class diagram for FlexBasicElement web component implementationclassDiagram
class HTMLElement
class FlexBasicProps
class FlexBasicElement {
+static AttrName[] observedAttributes
-ShadowRoot #shadow
-HTMLDivElement #container
+connectedCallback() void
+attributeChangedCallback() void
-#sync() void
}
class Utils {
+getCssValue(value)
+getFlexDirection(direction, horizontal)
+isHorizontal(direction, horizontal)
+isSpaceDistribution(justifyContent)
}
class AttributeParsers {
+parseBooleanAttr(value) boolean
+parseMaybeNumber(value) number|string
+readStringAttr(value) string
}
class FlexBasicExports {
+defineFlexBasicElement(tagName) void
+NativeFlexBasicElement FC_FlexBasicProps
}
FlexBasicElement --|> HTMLElement
FlexBasicElement ..> FlexBasicProps
FlexBasicElement ..> Utils
FlexBasicElement ..> AttributeParsers
FlexBasicExports ..> FlexBasicElement
FlexBasicExports ..> FlexBasicProps
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
👍 @Innei |
commit: |
- Refactor the FlexBasicElement class definition to be encapsulated within a `defineFlexBasicElement` function for better modularity. - Maintain existing functionality while improving the structure for future enhancements. - Ensure compatibility with custom elements and shadow DOM. Signed-off-by: Innei <[email protected]>
…n logic - Introduce global styles for lobe-flex elements to improve styling consistency. - Refactor initialization logic to eliminate the use of shadow DOM, simplifying the component structure. - Update class management to directly manipulate the element's class list, enhancing performance and readability. Signed-off-by: Innei <[email protected]>
- Eliminate the global CSS styles for lobe-flex elements to streamline the component. - Update the FlexBasicElement definition to focus on core functionality without injecting styles into the document. - Prepare for future enhancements by simplifying the component structure. Signed-off-by: Innei <[email protected]>
- Introduce tests for handling React-style camelCase and kebab-case attributes in the FlexBasic web component. - Validate that attributes are correctly parsed and applied to the element's styles and class list. - Ensure compatibility with custom elements in various environments. Signed-off-by: Innei <[email protected]>
- Introduce ReactFlexBasic as a functional component to handle props and styles dynamically. - Update FlexBasic to conditionally render either the native web component or the React implementation based on the 'as' prop. - Enhance class management in FlexBasicElement to prevent clobbering existing class names, improving compatibility with frameworks like React. - Add unit tests to ensure className integrity when connecting the custom element. Signed-off-by: Innei <[email protected]>
…in Flexbox - Refactor Center component to utilize AutoFlex for improved layout handling. - Update Flexbox exports to default to AutoFlex, streamlining component usage. Signed-off-by: Innei <[email protected]>
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
📝 补充信息 | Additional Information
Summary by Sourcery
Migrate the FlexBasic layout component to a custom web component backed by a shadow-DOM-based HTMLElement implementation and update exports accordingly.
New Features:
Enhancements: