diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11ba20ca..dace598c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,20 +27,20 @@ jobs: - name: Typecheck run: npm run typecheck -tests: - name: Tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup Node - uses: actions/setup-node@v2 - with: - node-version: '14.x' - cache: 'npm' - - name: Install Packages - run: npm ci - - name: Unit Tests - run: npm run test + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '14.x' + cache: 'npm' + - name: Install Packages + run: npm ci + - name: Unit Tests + run: npm run test diff --git a/src/components/ChartKit.tsx b/src/components/ChartKit.tsx index 5cc21d82..bd6b5ba7 100644 --- a/src/components/ChartKit.tsx +++ b/src/components/ChartKit.tsx @@ -1,6 +1,7 @@ import React from 'react'; +import block from 'bem-cn-lite'; import {settings} from '../libs'; -import {block, getRandomCKId} from '../utils'; +import {getRandomCKId} from '../utils'; import type {ChartkitType, ChartKitProps} from '../types'; import {ErrorBoundary} from './ErrorBoundary/ErrorBoundary'; import {Loader} from './Loader/Loader'; @@ -9,7 +10,7 @@ import '@yandex-cloud/uikit/styles/styles.scss'; import '../styles/theme.scss'; import './ChartKit.scss'; -const b = block(); +const b = block('chartkit'); export const ChartKit = (props: ChartKitProps) => { const {id = getRandomCKId(), type, data, onLoad, ...restProps} = props; diff --git a/src/components/ErrorView/ErrorView.scss b/src/components/ErrorView/ErrorView.scss index 44b304ce..d4496b8a 100644 --- a/src/components/ErrorView/ErrorView.scss +++ b/src/components/ErrorView/ErrorView.scss @@ -1,8 +1,4 @@ -@import '../../styles/variables'; - -$block: '.#{$ns}-error'; - -#{$block} { +.chartkit-error { display: flex; flex-direction: column; width: 100%; diff --git a/src/components/ErrorView/ErrorView.tsx b/src/components/ErrorView/ErrorView.tsx index 44024ebf..ddca6a98 100644 --- a/src/components/ErrorView/ErrorView.tsx +++ b/src/components/ErrorView/ErrorView.tsx @@ -1,11 +1,11 @@ import React from 'react'; +import block from 'bem-cn-lite'; import {dict} from '../../dict/dict'; import {settings} from '../../libs'; -import {block} from '../../utils'; import './ErrorView.scss'; -const b = block('error'); +const b = block('chartkit-error'); export const ErrorView = () => { const lang = settings.get('lang'); diff --git a/src/components/Loader/Loader.scss b/src/components/Loader/Loader.scss index cd79adad..f77ebcf4 100644 --- a/src/components/Loader/Loader.scss +++ b/src/components/Loader/Loader.scss @@ -1,8 +1,4 @@ -@import '../../styles/variables'; - -$block: '.#{$ns}-loader'; - -#{$block} { +.chartkit-loader { display: flex; align-items: center; justify-content: center; diff --git a/src/components/Loader/Loader.tsx b/src/components/Loader/Loader.tsx index 72c55555..09440c5b 100644 --- a/src/components/Loader/Loader.tsx +++ b/src/components/Loader/Loader.tsx @@ -1,10 +1,10 @@ import React from 'react'; +import block from 'bem-cn-lite'; import {Loader as BaseLoader, LoaderProps as BaseLoaderProps} from '@yandex-cloud/uikit'; -import {block} from '../../utils'; import './Loader.scss'; -const b = block('loader'); +const b = block('chartkit-loader'); type LoaderProps = BaseLoaderProps; diff --git a/src/utils/__tests__/cn.test.ts b/src/utils/__tests__/cn.test.ts deleted file mode 100644 index 0aa752dd..00000000 --- a/src/utils/__tests__/cn.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {NAMESPACE, block} from '../cn'; - -describe('utils/block', () => { - it('Should return namespace only', () => { - const result = block()(); - expect(result).toBe(NAMESPACE); - }); - - it('Should return class name like "-value"', () => { - const result = block('loader')(); - expect(result).toBe(`${NAMESPACE}-loader`); - }); -}); diff --git a/src/utils/__tests__/common.test.ts b/src/utils/__tests__/common.test.ts new file mode 100644 index 00000000..362a22b8 --- /dev/null +++ b/src/utils/__tests__/common.test.ts @@ -0,0 +1,11 @@ +import {getRandomCKId} from '../common'; + +// length of "ck." + 10 random symbols +const ID_LENGTH = 13; + +describe('utils/getRandomCKId', () => { + it('Id should have 13 symbols', () => { + const result = getRandomCKId(); + expect(result.length).toBe(ID_LENGTH); + }); +}); diff --git a/src/utils/cn.ts b/src/utils/cn.ts deleted file mode 100644 index e599d886..00000000 --- a/src/utils/cn.ts +++ /dev/null @@ -1,13 +0,0 @@ -import bemBlock from 'bem-cn-lite'; - -export type CnBlock = ReturnType; - -export const NAMESPACE = 'chartkit'; - -export const block = (name?: string): CnBlock => { - if (!name) { - return bemBlock(NAMESPACE); - } - - return bemBlock(`${NAMESPACE}-${name}`); -}; diff --git a/src/utils/index.ts b/src/utils/index.ts index 4d3bcec0..23a2408e 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,3 +1 @@ export {getRandomCKId} from './common'; -export {block} from './cn'; -export type {CnBlock} from './cn';