Skip to content

Ошибка в приложенном коде #878

Open
@pawwvw

Description

@pawwvw

https://ru.bem.info/methodology/css/#dry

В разделе описывается принцип DRY в БЭМ.

Как неправильный представлен код:

HTML

<button class="button">...</button>
<button class="btn">...</button>

CSS

.button {
    font-family: Arial, sans-serif;
    text-align: center;
    color: #000;
    background: #fff;
}

.btn {
    font-family: Arial, sans-serif;
    text-align: center;
    color: #000;
    background: rgba(255, 0, 0, 0.4);
}

image

А как правильный:

HTML

<button class="button button_theme_islands">...</button>
<button class="button button_theme_simple">...</button>

CSS

.button {
    font-family: Arial, sans-serif;
    text-align: center;
}

.button_theme_islands {
    color: #000;
    background: #fff;
}

.button_theme_simple {
    color: #000;
    background: rgba(255, 0, 0, 0.4);
}

image

Что, кажется, не совсем соответствует принципам DRY

Возможно вы имели ввиду:

CSS

.button {
    font-family: Arial, sans-serif;
    text-align: center;
    color: #000;
}

.button_theme_islands {
    background: #fff;
}

.button_theme_simple {
    background: rgba(255, 0, 0, 0.4);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions