Skip to content

Commit 27737a7

Browse files
committed
Merge pull request #84 from bem/refact
Refactoring
2 parents a2e34cd + 7d5cb11 commit 27737a7

File tree

5 files changed

+303
-251
lines changed

5 files changed

+303
-251
lines changed

.jscs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module.exports = {
2424
disallowQuotedKeysInObjects: 'allButReserved',
2525
disallowSpaceAfterObjectKeys: true,
2626
requireCommaBeforeLineBreak: true,
27-
requireOperatorBeforeLineBreak: true,
2827
disallowSpaceAfterPrefixUnaryOperators: true,
2928
disallowSpaceBeforePostfixUnaryOperators: true,
3029
requireSpaceBeforeBinaryOperators: true,

README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bem-naming
1717
About
1818
-----
1919

20-
This tool allows getting information about BEM entity using [string](#string-representation) as well as forming string representation based on [BEM-naming](#bem-naming).
20+
This tool allows getting information about BEM entity using [string](#string-representation) as well as forming string representation based on [naming object](#object-representation-of-bem-entity).
2121

2222
Install
2323
-------
@@ -41,9 +41,9 @@ Table of Contents
4141
-----------------
4242

4343
* [String representation](#string-representation)
44-
* [Common misconceptions](#common-misconceptions)
45-
* [BEM-naming](#bem-naming-1)
44+
* [Object representation of BEM entity](#object-representation-of-bem-entity)
4645
* [API](#api)
46+
* [Common misconceptions](#common-misconceptions)
4747
* [Custom naming convention](#custom-naming-convention)
4848
* [Convention by Harry Roberts](#convention-by-harry-roberts)
4949

@@ -66,25 +66,10 @@ According to original BEM-naming convention it looks like the following:
6666
* Element's modifier in key-value format — `block-name__elem-name_mod-name_mod-val`.
6767
* Element's boolean modifier — `block-name__elem_mod`.
6868

69-
Common misconceptions
70-
---------------------
71-
72-
BEM methodology involves the use of flat structure inside a block. It means that BEM entity can not be represented as an element of the other element and the following string representation will be invalid:
73-
74-
```js
75-
'block__some-elem__sub-elem'
76-
```
77-
78-
Also there is no such BEM entity as a modifier and an element modifier simultaneously so the following string representation will be invalid:
79-
80-
```js
81-
'block_block-mod-name_block-mod-val__elem-name_elem-mod-name_elem-mod-val'
82-
```
83-
84-
BEM-naming
85-
----------
69+
Object representation of BEM entity
70+
-----------------------------------
8671

87-
BEM entities can be defined with a help of js-object with the following fields:
72+
BEM entities can be defined with a help of JS object with the following fields:
8873

8974
* `block` — a block name. The field is required because only a block exists as an independent BEM entity
9075
* `elem` — an element name.
@@ -169,7 +154,7 @@ bemNaming.validate('^*^'); // false
169154

170155
### parse(str)
171156

172-
It parses string `str` into BEM-naming.
157+
It parses string into naming object.
173158

174159
Example:
175160

@@ -180,7 +165,7 @@ bemNaming.parse('block__elem_mod_val'); // { block: 'block', elem: 'elem',
180165

181166
### stringify(obj)
182167

183-
It forms a string according to BEM-naming `obj`.
168+
It forms a string according to naming object.
184169

185170
Example:
186171

@@ -219,7 +204,7 @@ bemNaming.typeOf({ block: 'block', elem: 'elem', modName: 'mod' }); // elemMod
219204

220205
### isBlock(str)
221206

222-
Checks whether string `str` is a block.
207+
Checks whether string is a block.
223208

224209
Example:
225210

@@ -230,7 +215,7 @@ bemNaming.isBlock('block__elem'); // false
230215

231216
### isBlock(obj)
232217

233-
Checks whether BEM-naming `obj` is a block.
218+
Checks whether naming object is a block.
234219

235220
Example:
236221

@@ -241,7 +226,7 @@ bemNaming.isBlock({ block: 'block', elem: 'elem' }); // false
241226

242227
### isBlockMod(str)
243228

244-
Checks whether string `str` is modifier of a block.
229+
Checks whether string is modifier of a block.
245230

246231
Example:
247232

@@ -252,7 +237,7 @@ bemNaming.isBlockMod('block__elem_mod'); // false
252237

253238
### isBlockMod(obj)
254239

255-
Checks whether BEM-naming `obj` is modifier of a block.
240+
Checks whether naming object is modifier of a block.
256241

257242
Example:
258243

@@ -266,7 +251,7 @@ bemNaming.isBlockMod({ block: 'block', elem: 'elem',
266251

267252
### isElem(str)
268253

269-
Checks whether string `str` is element of a block.
254+
Checks whether string is element of a block.
270255

271256
Example:
272257

@@ -277,7 +262,7 @@ bemNaming.isElem('block-name'); // false
277262

278263
### isElem(obj)
279264

280-
Checks whether BEM-naming `obj` is element of a block.
265+
Checks whether naming object is element of a block.
281266

282267
Example:
283268

@@ -288,7 +273,7 @@ bemNaming.isElem({ block: 'block-name' }); // false
288273

289274
### isElemMod(str)
290275

291-
Checks whether string `str` is modifier of an element.
276+
Checks whether string is modifier of an element.
292277

293278
Example:
294279

@@ -299,7 +284,7 @@ bemNaming.isElemMod('block__elem'); // false
299284

300285
### isElemMod(obj)
301286

302-
Checks whether BEM-naming `obj` is modifier of an element.
287+
Checks whether naming object is modifier of an element.
303288

304289
Example:
305290

@@ -323,6 +308,21 @@ String to separate modifiers from blocks and elements.
323308

324309
String to separate value of modifier from name of modifier.
325310

311+
Common misconceptions
312+
---------------------
313+
314+
BEM methodology involves the use of flat structure inside a block. It means that BEM entity can not be represented as an element of the other element and the following string representation will be invalid:
315+
316+
```js
317+
'block__some-elem__sub-elem'
318+
```
319+
320+
Also there is no such BEM entity as a modifier and an element modifier simultaneously so the following string representation will be invalid:
321+
322+
```js
323+
'block_block-mod-name_block-mod-val__elem-name_elem-mod-name_elem-mod-val'
324+
```
325+
326326
Custom naming convention
327327
------------------------
328328

README.ru.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ bemNaming.stringify({ block: 'button', modName: 'checked' }); // button_checked
4141
----------
4242

4343
* [Строковое представление](#Строковое-представление)
44-
* [Частые заблуждения](#Частые-заблуждения)
4544
* [БЭМ-нотация](#БЭМ-нотация)
4645
* [API](#api)
46+
* [Частые заблуждения](#Частые-заблуждения)
4747
* [Собственный стиль](#Собственный-стиль)
4848
* [В стиле Гарри Робертса](#В-стиле-Гарри-Робертса)
4949

@@ -66,21 +66,6 @@ bemNaming.stringify({ block: 'button', modName: 'checked' }); // button_checked
6666
* Модификатор элемента в формате ключ-значение — `block-name__elem-name_mod-name_mod-val`.
6767
* Булевый модификатор элемента — `block-name__elem_mod`.
6868

69-
Частые заблуждения
70-
------------------
71-
72-
БЭМ-методология предполагает использование плоской структуры внутри блока, это означает, что БЭМ-сущность не может быть представлена как элемент элемента, и следующее строковое представление будет невалидным:
73-
74-
```js
75-
'block__some-elem__sub-elem'
76-
```
77-
78-
Также не бывает такой БЭМ-сущности, как модификатор блока и модификатор элемента одновременно, поэтому следующее строковое представление будет невалидным:
79-
80-
```js
81-
'block_block-mod-name_block-mod-val__elem-name_elem-mod-name_elem-mod-val'
82-
```
83-
8469
БЭМ-нотация
8570
-----------
8671

@@ -323,6 +308,21 @@ bemNaming.isElemMod({ block: 'block',
323308

324309
Строка для разделения значения модификатора от названия модификатора.
325310

311+
Частые заблуждения
312+
------------------
313+
314+
БЭМ-методология предполагает использование плоской структуры внутри блока, это означает, что БЭМ-сущность не может быть представлена как элемент элемента, и следующее строковое представление будет невалидным:
315+
316+
```js
317+
'block__some-elem__sub-elem'
318+
```
319+
320+
Также не бывает такой БЭМ-сущности, как модификатор блока и модификатор элемента одновременно, поэтому следующее строковое представление будет невалидным:
321+
322+
```js
323+
'block_block-mod-name_block-mod-val__elem-name_elem-mod-name_elem-mod-val'
324+
```
325+
326326
Собственный стиль
327327
-----------------
328328

0 commit comments

Comments
 (0)