From 8613f8d31a44b322efeb75c364860591d24c1273 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 31 Aug 2023 13:33:05 +0200 Subject: [PATCH] [DOCS]chore: small style changes in search (#841) --- .changeset/empty-donkeys-design.md | 2 + packages/apps/docs/.eslintrc.cjs | 1 + packages/apps/docs/package.json | 4 +- .../Layout/Full/components/Aside/ListItem.tsx | 2 +- .../components/Markdown/Heading/Heading.tsx | 12 +- .../docs/src/components/Search/Search.tsx | 7 +- .../Search/components/SearchResults.tsx | 60 +- .../Search/components/StaticResults.tsx | 3 +- .../docs/src/components/Search/styles.css.ts | 3 +- .../apps/docs/src/components/Search/utils.ts | 11 + packages/apps/docs/src/pages/_app.tsx | 17 +- packages/apps/docs/src/pages/api/search.ts | 15 +- .../apps/docs/src/pages/api/semanticsearch.ts | 10 +- .../docs/pact/reference/functions/database.md | 32 +- packages/apps/docs/src/utils/createSlug.ts | 35 +- pnpm-lock.yaml | 576 ++++++++++++++---- 16 files changed, 591 insertions(+), 199 deletions(-) create mode 100644 .changeset/empty-donkeys-design.md create mode 100644 packages/apps/docs/src/components/Search/utils.ts diff --git a/.changeset/empty-donkeys-design.md b/.changeset/empty-donkeys-design.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/empty-donkeys-design.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/docs/.eslintrc.cjs b/packages/apps/docs/.eslintrc.cjs index 8022e1e8f4..db48a2f109 100644 --- a/packages/apps/docs/.eslintrc.cjs +++ b/packages/apps/docs/.eslintrc.cjs @@ -5,6 +5,7 @@ module.exports = { extends: ['@kadena-dev/eslint-config/profile/next'], parserOptions: { tsconfigRootDir: __dirname }, rules: { + '@typescript-eslint/strict-boolean-expressions': 'off', '@kadena-dev/typedef-var': 'off', }, }; diff --git a/packages/apps/docs/package.json b/packages/apps/docs/package.json index 0757f0ca82..845fa9076d 100644 --- a/packages/apps/docs/package.json +++ b/packages/apps/docs/package.json @@ -30,7 +30,7 @@ "test": "echo 'No tests, until there is time to debug the build'" }, "dependencies": { - "@7-docs/edge": "~0.3.1", + "@7-docs/edge": "~0.3.2", "@google-analytics/data": "~3.2.2", "@kadena/react-components": "workspace:*", "@kadena/react-ui": "workspace:*", @@ -62,7 +62,7 @@ "styled-components": "~5.3.10" }, "devDependencies": { - "@7-docs/cli": "~0.3.1", + "@7-docs/cli": "~0.3.2", "@babel/preset-env": "^7.22.9", "@babel/preset-react": "^7.18.6", "@babel/preset-typescript": "^7.21.0", diff --git a/packages/apps/docs/src/components/Layout/Full/components/Aside/ListItem.tsx b/packages/apps/docs/src/components/Layout/Full/components/Aside/ListItem.tsx index 633bb0dea0..cb3398aa63 100644 --- a/packages/apps/docs/src/components/Layout/Full/components/Aside/ListItem.tsx +++ b/packages/apps/docs/src/components/Layout/Full/components/Aside/ListItem.tsx @@ -23,7 +23,7 @@ export const ListItem: FC = ({ const router = useRouter(); if (item.title === undefined || item.title === '') return null; - const slug = `#${createSlug(item.title, item.index, item.parentTitle)}`; + const slug = `#${createSlug(item.title)}`; const handleItemClick = (ev: MouseEvent): void => { ev.preventDefault(); diff --git a/packages/apps/docs/src/components/Markdown/Heading/Heading.tsx b/packages/apps/docs/src/components/Markdown/Heading/Heading.tsx index 69af062928..4933887f57 100644 --- a/packages/apps/docs/src/components/Markdown/Heading/Heading.tsx +++ b/packages/apps/docs/src/components/Markdown/Heading/Heading.tsx @@ -10,21 +10,13 @@ interface IProp { as: TagType; variant?: TagType; children: ReactNode; - index?: number; - parentTitle?: string; } export interface IHeader { children: string; } -export const TaggedHeading: FC = ({ - children, - as, - variant, - index, - parentTitle, -}) => { +export const TaggedHeading: FC = ({ children, as, variant }) => { let slugInputStr = ''; if (Array.isArray(children)) { @@ -42,7 +34,7 @@ export const TaggedHeading: FC = ({ slugInputStr = children; } - const slug = createSlug(slugInputStr, index, parentTitle); + const slug = createSlug(slugInputStr); const content = ( <> diff --git a/packages/apps/docs/src/components/Search/Search.tsx b/packages/apps/docs/src/components/Search/Search.tsx index 9d1ee41df1..768f822044 100644 --- a/packages/apps/docs/src/components/Search/Search.tsx +++ b/packages/apps/docs/src/components/Search/Search.tsx @@ -1,4 +1,5 @@ import { SearchResults } from './components/SearchResults'; +import { removeUnnecessarySearchRecords } from './utils'; import { useSearch } from '@/hooks'; import { mapMatches } from '@/pages/api/semanticsearch'; @@ -22,9 +23,9 @@ export const Search: FC = ({ query, hasScroll, limitResults }) => { isLoading, } = useSearch(limitResults); - const semanticResults = metadata - .map((metadata) => ({ ...metadata, filePath: metadata.filePath })) // TODO delete this line - .map(mapMatches); + const semanticResults = removeUnnecessarySearchRecords( + metadata.map(mapMatches), + ); useEffect(() => { if ( diff --git a/packages/apps/docs/src/components/Search/components/SearchResults.tsx b/packages/apps/docs/src/components/Search/components/SearchResults.tsx index 8be780772b..13d326d397 100644 --- a/packages/apps/docs/src/components/Search/components/SearchResults.tsx +++ b/packages/apps/docs/src/components/Search/components/SearchResults.tsx @@ -1,6 +1,14 @@ -import { Button, Notification, Stack, Tabs, useModal } from '@kadena/react-ui'; +import { + Button, + Heading, + Notification, + Stack, + Tabs, + useModal, +} from '@kadena/react-ui'; import type { IQueryResult } from '../../../types'; +import { removeUnnecessarySearchRecords } from '../utils'; import { loadingWrapperClass, @@ -10,7 +18,7 @@ import { import { ResultCount } from './ResultCount'; import { StaticResults } from './StaticResults'; -import { Loading } from '@/components'; +import { BrowseSection, Loading } from '@/components'; import { IConversation } from '@/hooks/useSearch/useConversation'; import { filePathToRoute } from '@/pages/api/semanticsearch'; import classnames from 'classnames'; @@ -75,6 +83,7 @@ export const SearchResults: FC = ({ }, [isMounted]); if (!isMounted) return null; + return (
@@ -103,7 +112,9 @@ export const SearchResults: FC = ({ limitResults={limitResults} results={semanticResults} /> - {limitResults !== undefined && query !== undefined ? ( + {limitResults !== undefined && + limitResults < semanticResults.length && + query !== undefined ? (