Answer the question
In order to leave comments, you need to log in
How to correctly implement many differences between blocks and dependencies of other elements on these BEM differences?
Hello! Be patient, please, but I really need advice
. There are form components (select, input, textarea). Select is not default, but needs to be styled. It so happened that depending on the page, the elements change their appearance, and I thought that all these blocks are different (in terms of functionality), but the groups of elements have the same appearance, and I did so.
Created a form-element block, the only purpose of which is to be a mixin for styling groups of entities, because I found it strange to create the same styles for each component, DRY our everything After that, I began to look for differences between the elements and came up with something incredible
7 different component heights
7 different component font sizes
5 different bg values, including the absence of bg
2 border-radius values, 1 by 10px, another by 16
Whether
or not there is a border
2 border thickness
values 3 border color values
3 different shadow position values
I needed and created 5 modifiers, namely: form-elementboder(normal || bold) responsible only for the thickness of the frame
form-elementrounded(md || lg) responsible for the values 10 and 16
form-elementshadow(md || lg) responsible for for the shadow
form-elementsize(many values) responsible for the height and size of the font
form-elementtheme(many values) responsible for the background color, font color, border color
Created a separate input block, as a result the code looks something like this
<div class="
input form-element
form-element_theme_first
form-element_size_md
form-element_rounded_md
form-element_border_normal
">
<input type="text" class="input__field">
</div>
.input__field {
padding: 0 16px;
margin: 0;
height: 100%;
width: 100%;
border: none;
outline: none;
background: none;
color: inherit;
}
<div class="
select
select_opened
form-element
form-element_theme_first
form-element_size_md
form-element_rounded_md
form-element_border_normal
">
<select name=""></select>
<div class="select__header">
<p class="select__value">Product</p>
<span class="arrow arrow_bottom select__arrow"></span>
</div>
<ul class="select__body">
<li class="select__option">Product</li>
<li class="select__option">Product</li>
</ul>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question