Skip to content

Commit

Permalink
chore(utils): added status classNames (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
N1MBER committed Oct 10, 2023
1 parent b499f22 commit 7b9f33d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/NavbarCanary/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { getGroups } from '@consta/uikit/__internal__/src/utils/getGroups';
import { renderHeader } from '@consta/uikit/ListCanary';
import React, { forwardRef, useMemo } from 'react';

import { cnCanary } from '##/utils/bem';

import { withDefaultGetters } from './helpers';
import { NavbarItem } from './NavbarItem';
import {
Expand All @@ -11,6 +13,8 @@ import {
NavbarProps,
} from './types';

const cnNavbar = cnCanary('Navbar');

const NavbarRender = (props: NavbarProps, ref: React.Ref<HTMLDivElement>) => {
const {
items,
Expand Down Expand Up @@ -44,7 +48,7 @@ const NavbarRender = (props: NavbarProps, ref: React.Ref<HTMLDivElement>) => {
);

return (
<div {...otherProps} ref={ref} className={className}>
<div {...otherProps} ref={ref} className={cnNavbar(null, [className])}>
{groups.map((group, groupIndex) => {
return (
<React.Fragment key={group.key}>
Expand Down
11 changes: 10 additions & 1 deletion src/utils/bem.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import { withNaming } from '@bem-react/classname';

export const cn = withNaming({ n: 'che--', e: '-', m: '_' });
const reactBemNaming = { n: 'che--', e: '-', m: '_', v: '_' };

export const cn = withNaming(reactBemNaming);

export const withPrefix = (prefix: string) =>
withNaming({ ...reactBemNaming, n: prefix + reactBemNaming.n });

export const cnCanary = withPrefix('canary');

export const cnDeprecated = withPrefix('deprecated');

0 comments on commit 7b9f33d

Please sign in to comment.