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 3 months ago

NilsJacobsen commented 3 months 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 3 months 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 3 months ago

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

NilsJacobsen commented 3 months ago
image.png

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