vrimar / construct-ui

A Mithril.js UI library
https://vrimar.github.io/construct-ui
MIT License
287 stars 23 forks source link

Vertical alignment inconsistencies inside and outside ControlGroup #13

Closed angrytongan closed 4 years ago

angrytongan commented 4 years ago

There appears to be some slight vertical alignment inconsistencies between elements, both inside and outside of a ControlGroup, with and without icons.

It looks like a Button with / without an iconLeft / label changes the vertical size of the button and it's vertical position. Additionally, the first element in a ControlGroup looks like it "aligns" following elements.

const {
    Button,
    ControlGroup,
    FocusManager,
    Icon,
    Input,
    Select,

} = CUI;

const ControlGroupAlignment = () => {
    return {
        view: () => {
            return [
                /*
                 * Buttons: labels only.
                 */
                m('', {
                    style: 'margin: 1em; background: #000;',
                }, [
                    m(Button, { label: 'a' }),
                    m(Input, { placeholder: 'no controlgroup' }),
                    m(Select, { options: [ 'b', 'c' ] }),

                    m(ControlGroup, [
                        m(Button, { label: 'a' }),
                        m(Input, { placeholder: 'in controlgroup' }),
                        m(Select, { options: [ 'b', 'c' ] }),
                    ]),

                    m(ControlGroup, [
                        m(Input, { placeholder: 'first in controlgroup' }),
                        m(Button, { label: 'a' }),
                        m(Select, { options: [ 'b', 'c' ] }),
                    ]),
                ]),

                /*
                 * Buttons: icons only.
                 */
                m('', {
                    style: 'margin: 1em; background: #000;',
                }, [
                    m(Button, { iconLeft: 'settings' }),
                    m(Input, { placeholder: 'no controlgroup' }),
                    m(Select, { options: [ 'b', 'c' ] }),

                    m(ControlGroup, [
                        m(Button, { iconLeft: 'settings' }),
                        m(Input, { placeholder: 'in controlgroup' }),
                        m(Select, { options: [ 'b', 'c' ] }),
                    ]),

                    m(ControlGroup, [
                        m(Input, { placeholder: 'first in controlgroup' }),
                        m(Button, { iconLeft: 'settings' }),
                        m(Select, { options: [ 'b', 'c' ] }),
                    ]),
                ]),

                /*
                 * Buttons: icons and labels only.
                 */
                m('', {
                    style: 'margin: 1em; background: #000;',
                }, [
                    m(Button, { label: 'a', iconLeft: 'settings' }),
                    m(Input, { placeholder: 'no controlgroup' }),
                    m(Select, { options: [ 'b', 'c' ] }),

                    m(ControlGroup, [
                        m(Button, { label: 'a', iconLeft: 'settings' }),
                        m(Input, { placeholder: 'in controlgroup' }),
                        m(Select, { options: [ 'b', 'c' ] }),
                    ]),

                    m(ControlGroup, [
                        m(Input, { placeholder: 'first in controlgroup' }),
                        m(Button, { label: 'a', iconLeft: 'settings' }),
                        m(Select, { options: [ 'b', 'c' ] }),
                    ]),
                ]),

                /*
                 * Buttons with / without labels and icons.
                 */
                m('', {
                    style: 'margin: 1em; background: #000;',
                }, [
                    m(Button, { label: 'a' }),
                    m(Button, { iconLeft: 'settings' }),

                    m(ControlGroup, [
                        m(Button, { label: 'a' }),
                        m(Button, { iconLeft: 'settings' }),
                    ]),

                    m(ControlGroup, [
                        m(Button, { iconLeft: 'settings' }),
                        m(Button, { label: 'a' }),
                    ]),
                ]),
            ];
        },
    };
};

document.addEventListener('DOMContentLoaded', () => {
    m.route(document.body, '/', {
        '/': ControlGroupAlignment
    });
});
vrimar commented 4 years ago

Thanks for the detailed report, I really appreciate it.

I've committed a fix but I'll have to test other browsers before I can publish a new version.

Here's an updated flems.

angrytongan commented 4 years ago

Thanks for the fast fix. Looking forward to 1.0.0!

vrimar commented 4 years ago

Added to v0.2.3.