From 6fef4b77122d1d3fa6b494711a69217726e90b13 Mon Sep 17 00:00:00 2001 From: 3y3 <3y3@ya.ru> Date: Tue, 12 Sep 2023 03:41:05 +0300 Subject: [PATCH] wip --- demo/src/.eslintrc | 3 +++ demo/src/Components/DocLeadingPage/index.tsx | 3 ++- demo/src/Components/DocPage/index.stories.tsx | 6 +++--- demo/src/Components/ErrorPage/index.tsx | 3 ++- demo/src/Components/Header/Header.tsx | 3 ++- demo/src/Components/Paginator/index.tsx | 3 ++- demo/src/Components/SearchItem/index.tsx | 3 ++- demo/src/Components/SearchPage/index.tsx | 3 ++- package.json | 2 +- src/components/Controls/Controls.scss | 2 -- src/components/DocPage/DocPage.scss | 2 +- src/components/TocNavPanel/TocNavPanel.tsx | 10 +++++----- src/internal-typings/global.d.ts | 7 +++++++ tsconfig.esm.json | 2 +- 14 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 demo/src/.eslintrc diff --git a/demo/src/.eslintrc b/demo/src/.eslintrc new file mode 100644 index 00000000..9ecc6200 --- /dev/null +++ b/demo/src/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "@gravity-ui/eslint-config/client" +} diff --git a/demo/src/Components/DocLeadingPage/index.tsx b/demo/src/Components/DocLeadingPage/index.tsx index e3ebb5b5..d708a85c 100644 --- a/demo/src/Components/DocLeadingPage/index.tsx +++ b/demo/src/Components/DocLeadingPage/index.tsx @@ -1,6 +1,7 @@ +import React, {useState} from 'react'; + import {DEFAULT_SETTINGS, DocLeadingPage, DocLeadingPageData} from '@doc-tools/components'; import cn from 'bem-cn-lite'; -import React, {useState} from 'react'; import getLangControl from '../../controls/lang'; import {getIsMobile} from '../../controls/settings'; diff --git a/demo/src/Components/DocPage/index.stories.tsx b/demo/src/Components/DocPage/index.stories.tsx index eb1c2fd5..da992d6c 100644 --- a/demo/src/Components/DocPage/index.stories.tsx +++ b/demo/src/Components/DocPage/index.stories.tsx @@ -1,8 +1,6 @@ -import React, {useCallback, useEffect, useState} from 'react'; import {join} from 'path'; -import cn from 'bem-cn-lite'; -import {configure as configureUikit} from '@gravity-ui/uikit'; +import React, {useCallback, useEffect, useState} from 'react'; import { DEFAULT_SETTINGS, @@ -12,6 +10,8 @@ import { Theme, configure as configureDocs, } from '@doc-tools/components'; +import {configure as configureUikit} from '@gravity-ui/uikit'; +import cn from 'bem-cn-lite'; import {getIsMobile} from '../../controls/settings'; import getVcsControl from '../../controls/vcs'; diff --git a/demo/src/Components/ErrorPage/index.tsx b/demo/src/Components/ErrorPage/index.tsx index 19158866..ae544d52 100644 --- a/demo/src/Components/ErrorPage/index.tsx +++ b/demo/src/Components/ErrorPage/index.tsx @@ -1,6 +1,7 @@ +import React from 'react'; + import {ERROR_CODES, ErrorPage} from '@doc-tools/components'; import {radios, text} from '@storybook/addon-knobs'; -import React from 'react'; import getLangControl from '../../controls/lang'; import {getIsMobile} from '../../controls/settings'; diff --git a/demo/src/Components/Header/Header.tsx b/demo/src/Components/Header/Header.tsx index ad4f1afc..f5820a95 100644 --- a/demo/src/Components/Header/Header.tsx +++ b/demo/src/Components/Header/Header.tsx @@ -1,3 +1,5 @@ +import React from 'react'; + import { ControlSizes, DividerControl, @@ -7,7 +9,6 @@ import { } from '@doc-tools/components'; import {TextInput} from '@gravity-ui/uikit'; import cn from 'bem-cn-lite'; -import React from 'react'; import './Header.scss'; diff --git a/demo/src/Components/Paginator/index.tsx b/demo/src/Components/Paginator/index.tsx index ee6b2b01..d9a2f1a8 100644 --- a/demo/src/Components/Paginator/index.tsx +++ b/demo/src/Components/Paginator/index.tsx @@ -1,6 +1,7 @@ -import {Paginator} from '@doc-tools/components'; import React, {useState} from 'react'; +import {Paginator} from '@doc-tools/components'; + const PaginatorDemo = () => { const [page, setPage] = useState(1); diff --git a/demo/src/Components/SearchItem/index.tsx b/demo/src/Components/SearchItem/index.tsx index 2d1ddd9f..5b835f90 100644 --- a/demo/src/Components/SearchItem/index.tsx +++ b/demo/src/Components/SearchItem/index.tsx @@ -1,6 +1,7 @@ -import {SearchItem} from '@doc-tools/components'; import React from 'react'; +import {SearchItem} from '@doc-tools/components'; + import data from './page.json'; const SearchItemDemo = () => { diff --git a/demo/src/Components/SearchPage/index.tsx b/demo/src/Components/SearchPage/index.tsx index 7cffae3e..f03049fd 100644 --- a/demo/src/Components/SearchPage/index.tsx +++ b/demo/src/Components/SearchPage/index.tsx @@ -1,6 +1,7 @@ -import {ISearchItem, SearchPage} from '@doc-tools/components'; import React, {useState} from 'react'; +import {ISearchItem, SearchPage} from '@doc-tools/components'; + import getLangControl from '../../controls/lang'; import {getIsMobile} from '../../controls/settings'; diff --git a/package.json b/package.json index d5f3752b..b6ab91db 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "React components for drawing Diplodoc documentation", "author": "YFM Team ", "license": "MIT", - "version": "3.0.0-alpha-1", + "version": "3.0.0-alpha-4", "repository": { "type": "git", "url": "git@github.com:yandex-cloud/docs-components.git" diff --git a/src/components/Controls/Controls.scss b/src/components/Controls/Controls.scss index 44867139..54859f90 100644 --- a/src/components/Controls/Controls.scss +++ b/src/components/Controls/Controls.scss @@ -39,8 +39,6 @@ } @media (min-width: map-get($screenBreakpoints, 'md')) { - right: 0; - &_vertical { flex-direction: column; } diff --git a/src/components/DocPage/DocPage.scss b/src/components/DocPage/DocPage.scss index ab4d847e..5cb4ffba 100644 --- a/src/components/DocPage/DocPage.scss +++ b/src/components/DocPage/DocPage.scss @@ -48,7 +48,7 @@ &__controls { display: flex; - top: var(--dc-header-height, #{$headerHeight}); + top: 0; align-items: center; height: 40px; z-index: 102; diff --git a/src/components/TocNavPanel/TocNavPanel.tsx b/src/components/TocNavPanel/TocNavPanel.tsx index 07296bfb..9ac1ab30 100644 --- a/src/components/TocNavPanel/TocNavPanel.tsx +++ b/src/components/TocNavPanel/TocNavPanel.tsx @@ -55,12 +55,12 @@ function getBoundingItems(flatToc: FlatTocItem[], router: Router) { }; } -const TocNavControl = memo<{isNext?: boolean; item: FlatTocItem}>(({item, isNext}) => { +const TocNavControl = memo<{isNext?: boolean; item: FlatTocItem | null}>(({item, isNext}) => { const {t} = useTranslation('toc-nav-panel'); const keyHint = isNext ? 'hint_next' : 'hint_previous'; - const isExternal = isExternalHref(item.href); + const isExternal = item && isExternalHref(item.href); const linkAttributes = { - href: item.href, + href: item?.href, target: isExternal ? '_blank' : '_self', rel: isExternal ? 'noopener noreferrer' : undefined, }; @@ -99,8 +99,8 @@ const TocNavPanel = memo(({items, router, fixed, className}) = return (
- {prevItem && } - {nextItem && } + {} + {}
); diff --git a/src/internal-typings/global.d.ts b/src/internal-typings/global.d.ts index dc3ef110..cd401cc5 100644 --- a/src/internal-typings/global.d.ts +++ b/src/internal-typings/global.d.ts @@ -1,3 +1,10 @@ +declare module 'url' { + export const parse: (href: string) => { + hash?: string; + pathname?: string; + }; +} + declare module '*.svg' { const content: SVGIconData; diff --git a/tsconfig.esm.json b/tsconfig.esm.json index b6d0894c..7100d0a9 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -3,7 +3,7 @@ "compilerOptions": { "module": "ESNext", "target": "ES2017", - "outDir": "build/cjs", + "outDir": "build/esm", }, "include": ["src/**/*.ts", "src/**/*.tsx"] }