Giter Site home page Giter Site logo

Comments (3)

belozer avatar belozer commented on June 16, 2024

Возможно моды mods и attrs не самые удачные и лучше использовать mode('button-attrs'), mode('button-mods')

from bem-components.

belozer avatar belozer commented on June 16, 2024

Возможно стоит даже и базовый код button вынести в моду.

block('select').elem('button')(
    mode('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
        }
    }),
    mode('button-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
        },
    }),
    mode('button')(function() {
        var select = this._select,
            mods = this.mods;

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

    replace()(function() {
        return apply('button');
    }),

    def()(function() {
        return applyNext({ _selectTextId : this.generateId() });
    })
);

from bem-components.

belozer avatar belozer commented on June 16, 2024

Пример использования:

block('select').mod('prefixed')(
    def()((node, ctx) => {
        return applyNext({
            _textPrefix : ctx.textPrefix
        });
    }),

    elem('button')(
        mode('button-mods')((node) => {
            return node.extend(applyNext(), { prefixed : true });
        }),

        mode('button')((node) => {
            return node.extend(applyNext(), { textPrefix : node._textPrefix });
        })
    )
);

from bem-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.