mirror of
https://github.com/codex-team/editor.js
synced 2024-05-19 06:47:16 +02:00
e1c70b4fb8
* Support delimiter * Rename types, move types to popover-item folder * Fix ts errors * Add tests * Review fixes * Review fixes 2 * Fix delimiter while search * Fix flipper issue * Fix block tunes types * Fix types * Fixes * Make search input emit event * Fix types * Rename delimiter to separator * Update chengelog
26 lines
879 B
TypeScript
26 lines
879 B
TypeScript
const ELEMENT_DELIMITER = '__';
|
|
const MODIFIER_DELIMITER = '--';
|
|
|
|
/**
|
|
* Utility function that allows to construct class names from block and element names
|
|
*
|
|
* @example bem('ce-popover)() -> 'ce-popover'
|
|
* @example bem('ce-popover)('container') -> 'ce-popover__container'
|
|
* @example bem('ce-popover)('container', 'hidden') -> 'ce-popover__container--hidden'
|
|
* @example bem('ce-popover)(null, 'hidden') -> 'ce-popover--hidden'
|
|
* @param blockName - string with block name
|
|
* @param elementName - string with element name
|
|
* @param modifier - modifier to be appended
|
|
*/
|
|
export function bem(blockName: string) {
|
|
return (elementName?: string | null, modifier?: string) => {
|
|
const className = [blockName, elementName]
|
|
.filter(x => !!x)
|
|
.join(ELEMENT_DELIMITER);
|
|
|
|
return [className, modifier]
|
|
.filter(x => !!x)
|
|
.join(MODIFIER_DELIMITER);
|
|
};
|
|
}
|