opral / inlang-message-ui-components

Issue tracker for UI components
0 stars 0 forks source link

Refactoring: No easy way to use subcomponents independently #115

Open NilsJacobsen opened 2 weeks ago

NilsJacobsen commented 2 weeks ago

The bundle component was built to work well in editing mode with slotting and nesting other stuff inside it. U basically passed in props and used an event listener to get the new value of the json back.

New Requirements:

NilsJacobsen commented 2 weeks ago

The following can be found here: https://link.excalidraw.com/l/1RmnkzJA3Ph/QEikyCrXjN

Interaction:

image.png


Thought through use cases:

image.png


Component structure:

image.png



In code:

const test = () => {
    return <inlang-bundle
        bundle={bundle}
        messageIds={messageIds}
    >
        <inlang-message
            slot="message"
            message={message}
            settings={settings}
        >
            <inlang-selector-bar
                slot="selector-bar"
                selectors={selectors}
                message={message}
                messageIds={messageIds}
            >
            </inlang-selector-bar>
            <inlang-variant
                variant={variant}
            >
                <inlang-pattern-editor
                    slot="pattern-editor"
                    variant={variant}
                    messageId={messageId}
                >
                </inlang-pattern-editor>
                <inlang-selector-button
                    slot="variant-action"
                    message={message}
                    messageIds={messageIds}
                >
                </inlang-selector-button>
            </inlang-variant>
        </inlang-message>
    </inlang-bundle>
}

Challenges that will still be present in the app (acceptable for now)

NilsJacobsen commented 2 weeks ago

Seams to work quite well. Gonna open a draft PR and after some clean up and testing we can merge.

NilsJacobsen commented 2 weeks ago
image.png

Just as a test we can nest stuff and the component is fully wired up.