Skip to content

select: кастомные модификаторы и атрибуты для button #2080

@belozer

Description

@belozer
block('select').elem('button')(
    mods()(function() {
        var mods = this.mods;
        return {
            size : mods.size,
            theme : mods.theme,
            view : mods.view,
            focused : mods.focused,
            disabled : mods.disabled,
            checked : mods.mode !== 'radio' && !!this._checkedOptions.length
        }
    }),
    attrs()(function() {
        var mods = this.mods;
        return {
            role : 'listbox',
            'aria-owns' : this._optionIds.join(' '),
            'aria-multiselectable' : mods.mode === 'check'? 'true' : undefined,
            'aria-labelledby' : this._selectTextId
        },
    }),
    replace()(function() {
        var select = this._select,
            mods = this.mods;

        return {
            block : 'button',
            mix : { block : this.block, elem : this.elem },
            mods : apply('mods'),
            attrs : apply('attrs'),
            id : select.id,
            tabIndex : select.tabIndex,
            content : [
                apply('content'),
                { block : 'icon', mix : { block : 'select', elem : 'tick' } }
            ]
        };
    }),
    def()(function() {
        return applyNext({ _selectTextId : this.generateId() });
    })
);

Полезно для переопределения на проекте как-то так.

block('select').mod('prefixed').elem('button')(
    mods()(function() { return this.extend(applyNext(), { prefixed : true })})
);

@veged @tadatuta

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions