diff --git a/.changeset/fifty-frogs-itch.md b/.changeset/fifty-frogs-itch.md new file mode 100644 index 000000000..93f14cc9a --- /dev/null +++ b/.changeset/fifty-frogs-itch.md @@ -0,0 +1,5 @@ +--- +'gitbook': patch +--- + +Update styling of search+ask modal diff --git a/packages/gitbook/src/components/Search/HighlightQuery.tsx b/packages/gitbook/src/components/Search/HighlightQuery.tsx index 86538b68d..0f8c41896 100644 --- a/packages/gitbook/src/components/Search/HighlightQuery.tsx +++ b/packages/gitbook/src/components/Search/HighlightQuery.tsx @@ -11,17 +11,32 @@ export function HighlightQuery(props: { /** Style to apply on matching parts (default to primary) */ highlight?: ClassValue; }): React.ReactElement { - const { query, text, highlight = ['text-bold', 'text-primary'] } = props; + const { + query, + text, + highlight = [ + 'text-bold', + 'bg-primary-100', + 'text-contrast-primary-100', + 'dark:bg-primary-700', + 'dark:text-contrast-primary-700', + 'px-0.5', + '-mx-0.5', + 'py-0.5', + 'rounded', + 'straight-corners:rounded-sm', + ], + } = props; const matches = matchString(text, query); return ( - +
{matches.map((entry, index) => ( {entry.text} ))} - +
); } diff --git a/packages/gitbook/src/components/Search/SearchAskAnswer.tsx b/packages/gitbook/src/components/Search/SearchAskAnswer.tsx index c6a32ad9f..f4ea387e7 100644 --- a/packages/gitbook/src/components/Search/SearchAskAnswer.tsx +++ b/packages/gitbook/src/components/Search/SearchAskAnswer.tsx @@ -101,20 +101,12 @@ export function SearchAskAnswer(props: { spaceId: string; query: string }) { const loading = (
- +
); return ( -
+
{state?.type === 'answer' ? ( <> {state.answer ? ( @@ -166,13 +158,20 @@ function AnswerBody(props: { answer: AskAnswerResult }) { <>
{answer.hasAnswer ? answer.body : t(language, 'search_ask_no_answer')} + {answer.followupQuestions.length > 0 ? ( + + ) : null}
- {answer.followupQuestions.length > 0 ? ( - - ) : null} {answer.sources.length > 0 ? ( +
{followupQuestions.map((question) => ( {question} @@ -236,7 +243,8 @@ function AnswerSources(props: { 'flex', 'flex-wrap', 'gap-2', - 'mt-7', + 'mt-4', + 'sm:mt-6', 'py-4', 'px-4', 'border-t', @@ -244,7 +252,7 @@ function AnswerSources(props: { 'dark:border-light/1', )} > - + {t(language, hasAnswer ? 'search_ask_sources' : 'search_ask_sources_no_answer')} @@ -253,7 +261,9 @@ function AnswerSources(props: { diff --git a/packages/gitbook/src/components/Search/SearchModal.tsx b/packages/gitbook/src/components/Search/SearchModal.tsx index 53de6f4f3..937485cf7 100644 --- a/packages/gitbook/src/components/Search/SearchModal.tsx +++ b/packages/gitbook/src/components/Search/SearchModal.tsx @@ -182,7 +182,7 @@ function SearchModalBody( }; return ( -
{ event.stopPropagation(); }} > -
-
+
+
-
+
+ {isMultiVariants ? : null}
{!state.ask || !withAsk ? ( @@ -261,15 +288,11 @@ function SearchModalBody( global: state.global, }); }} - > - {isMultiVariants && state.query ? ( - - ) : null} - + > ) : null} {state.query && state.ask && withAsk ? ( ) : null} -
+ ); } diff --git a/packages/gitbook/src/components/Search/SearchPageResultItem.tsx b/packages/gitbook/src/components/Search/SearchPageResultItem.tsx index af0525c46..6765d6086 100644 --- a/packages/gitbook/src/components/Search/SearchPageResultItem.tsx +++ b/packages/gitbook/src/components/Search/SearchPageResultItem.tsx @@ -1,3 +1,4 @@ +import { Icon } from '@gitbook/icons'; import React from 'react'; import { tcls } from '@/lib/tailwind'; @@ -23,25 +24,46 @@ export const SearchPageResultItem = React.forwardRef(function SearchPageResultIt className={tcls( 'flex', 'flex-row', - 'px-6', - 'py-3', + 'items-center', + 'px-4', + 'sm:px-12', + 'py-4', + 'sm:py-6', + 'border-t', + 'first:border-t-0', + 'border-dark/2', + 'dark:border-light/2', 'hover:bg-dark-4/2', 'text-base', 'text-dark', - 'font-semibold', + 'font-medium', 'first:mt-0', - '[&:has(+.search-section-result-item):not(:first-child)]:mt-6', 'dark:text-light', 'dark:hover:bg-light-4/2', active ? ['bg-dark/1', 'dark:bg-light/1'] : null, )} > - {item.spaceTitle ? ( - - {item.spaceTitle + ' ›'} - - ) : null} - +
+ {item.spaceTitle ? ( +
+ {item.spaceTitle} +
+ ) : null} + +
+ ); }); diff --git a/packages/gitbook/src/components/Search/SearchQuestionResultItem.tsx b/packages/gitbook/src/components/Search/SearchQuestionResultItem.tsx index 403f04c69..bee3a827d 100644 --- a/packages/gitbook/src/components/Search/SearchQuestionResultItem.tsx +++ b/packages/gitbook/src/components/Search/SearchQuestionResultItem.tsx @@ -31,8 +31,6 @@ export const SearchQuestionResultItem = React.forwardRef(function SearchQuestion 'py-2', 'hover:bg-dark-4/2', 'text-dark/7', - 'text-sm', - 'font-medium', 'first:mt-0', 'last:pb-3', 'dark:text-light/8', @@ -47,11 +45,11 @@ export const SearchQuestionResultItem = React.forwardRef(function SearchQuestion +
{children} {results.length === 0 ? (
void; children: React.ReactNode; a aria-selected={active} onClick={onClick} className={tcls( - 'text-xs', + 'text-sm', 'transition-colors', - 'duration-75', - 'px-2.5', - 'py-1.5', - 'border-t', - 'relative', - 'top-[0px]', - 'z-[1]', - 'border-dark/2', + 'px-3', + 'py-2', + 'border-b-2', 'whitespace-pre', - 'hover:border-dark/6', - 'dark:hover:border-light/6', - 'md:px-1', - active - ? [ - 'text-primary-400', - 'border-primary-400', - 'hover:border-primary-400', - 'dark:hover:text-primary-400', - 'dark:border-primary-400', - 'dark:hover:border-primary-400', - ] - : null, + '-mb-[1px]', + active ? ['text-primary-500', 'border-primary-500'] : ['border-transparent'], )} > {children} diff --git a/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx b/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx index b620a7651..82784f113 100644 --- a/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx +++ b/packages/gitbook/src/components/Search/SearchSectionResultItem.tsx @@ -25,15 +25,29 @@ export const SearchSectionResultItem = React.forwardRef(function SearchSectionRe '[&:has(+:not(&))]:mb-6', 'flex', 'flex-col', - 'pl-6', + 'mb-2', + 'px-4', + 'sm:px-12', 'hover:bg-dark-4/2', 'dark:hover:bg-light-4/2', + 'text-dark/8', + 'dark:text-light/8', + 'font-normal', + 'transition-colors', active ? ['bg-dark/1', 'dark:bg-light/1'] : null, )} > -
+
{item.title ? ( -

+

) : null} @@ -41,12 +55,9 @@ export const SearchSectionResultItem = React.forwardRef(function SearchSectionRe

diff --git a/packages/gitbook/src/components/Search/server-actions.tsx b/packages/gitbook/src/components/Search/server-actions.tsx index 01c685526..f4aeae84f 100644 --- a/packages/gitbook/src/components/Search/server-actions.tsx +++ b/packages/gitbook/src/components/Search/server-actions.tsx @@ -82,7 +82,7 @@ async function searchSiteContent(args: { ...siteSpace, space: { ...siteSpace.space, - title: section.title + ' › ' + siteSpace.space.title, + title: section.title || siteSpace.space.title, }, })); diff --git a/packages/gitbook/src/intl/translations/de.ts b/packages/gitbook/src/intl/translations/de.ts index 5c0f16e83..c3d707a1d 100644 --- a/packages/gitbook/src/intl/translations/de.ts +++ b/packages/gitbook/src/intl/translations/de.ts @@ -10,7 +10,7 @@ export const de = { search_input_placeholder: 'Inhalt durchsuchen', search_ask_input_placeholder: 'Inhalt durchsuchen oder eine Frage stellen', search_no_results: 'Keine Ergebnisse für "${1}".', - search_scope_space: 'Nur in ${1}', + search_scope_space: '${1}', search_scope_all: 'Alle Inhalte', search_ask: 'Fragen "${1}"', search_ask_sources: 'Quellen', diff --git a/packages/gitbook/src/intl/translations/en.ts b/packages/gitbook/src/intl/translations/en.ts index dc74cee6c..c471bbffe 100644 --- a/packages/gitbook/src/intl/translations/en.ts +++ b/packages/gitbook/src/intl/translations/en.ts @@ -10,8 +10,8 @@ export const en = { search_input_placeholder: 'Search content', search_ask_input_placeholder: 'Search content or ask a question', search_no_results: 'No results for "${1}".', - search_scope_space: 'Only in ${1}', - search_scope_all: 'All the content', + search_scope_space: '${1}', + search_scope_all: 'All content', search_ask: 'Ask "${1}"', search_ask_sources: 'Sources', search_ask_sources_no_answer: 'Related pages', diff --git a/packages/gitbook/src/intl/translations/es.ts b/packages/gitbook/src/intl/translations/es.ts index 2b3bf7930..4c499b3ae 100644 --- a/packages/gitbook/src/intl/translations/es.ts +++ b/packages/gitbook/src/intl/translations/es.ts @@ -12,7 +12,7 @@ export const es: TranslationLanguage = { search_input_placeholder: 'Buscar contenido', search_ask_input_placeholder: 'Buscar contenido o hacer una pregunta', search_no_results: 'No hay resultados para "${1}".', - search_scope_space: 'Solo en ${1}', + search_scope_space: '${1}', search_scope_all: 'Todo el contenido', search_ask: 'Preguntar "${1}"', search_ask_sources: 'Fuentes', diff --git a/packages/gitbook/src/intl/translations/fr.ts b/packages/gitbook/src/intl/translations/fr.ts index cec5f0aa9..fe5797132 100644 --- a/packages/gitbook/src/intl/translations/fr.ts +++ b/packages/gitbook/src/intl/translations/fr.ts @@ -12,7 +12,7 @@ export const fr: TranslationLanguage = { search_input_placeholder: 'Rechercher le contenu', search_ask_input_placeholder: 'Rechercher du contenu ou poser une question', search_no_results: 'Aucun résultat pour "${1}".', - search_scope_space: 'Uniquement dans ${1}', + search_scope_space: '${1}', search_scope_all: 'Tout le contenu', search_ask: 'Demander "${1}"', search_ask_sources: 'Sources', diff --git a/packages/gitbook/src/intl/translations/ja.ts b/packages/gitbook/src/intl/translations/ja.ts index 7005c3da3..538f647e6 100644 --- a/packages/gitbook/src/intl/translations/ja.ts +++ b/packages/gitbook/src/intl/translations/ja.ts @@ -12,7 +12,7 @@ export const ja: TranslationLanguage = { search_input_placeholder: 'コンテンツを検索', search_ask_input_placeholder: 'コンテンツを検索するか質問をする', search_no_results: '"${1}" の結果はありません。', - search_scope_space: '${1}内のみ', + search_scope_space: '${1}', search_scope_all: '全てのコンテンツ', search_ask: '"${1}" を質問する', search_ask_sources: '情報源', diff --git a/packages/gitbook/src/intl/translations/nl.ts b/packages/gitbook/src/intl/translations/nl.ts index 104de4ff1..06a32ebf7 100644 --- a/packages/gitbook/src/intl/translations/nl.ts +++ b/packages/gitbook/src/intl/translations/nl.ts @@ -12,7 +12,7 @@ export const nl: TranslationLanguage = { search_input_placeholder: 'Zoek inhoud', search_ask_input_placeholder: 'Zoek inhoud of stel een vraag', search_no_results: 'Geen resultaten voor "${1}".', - search_scope_space: 'Alleen in ${1}', + search_scope_space: '${1}', search_scope_all: 'Alle inhoud', search_ask: 'Vraag "${1}"', search_ask_sources: 'Bronnen', diff --git a/packages/gitbook/src/intl/translations/no.ts b/packages/gitbook/src/intl/translations/no.ts index ff1d1667f..02d602330 100644 --- a/packages/gitbook/src/intl/translations/no.ts +++ b/packages/gitbook/src/intl/translations/no.ts @@ -12,7 +12,7 @@ export const no: TranslationLanguage = { search_input_placeholder: 'Søk i innhold', search_ask_input_placeholder: 'Søk i innhold eller still et spørsmål', search_no_results: 'Ingen resultater for "${1}".', - search_scope_space: 'Kun i ${1}', + search_scope_space: '${1}', search_scope_all: 'Alt innhold', search_ask: 'Spør "${1}"', search_ask_sources: 'Kilder', diff --git a/packages/gitbook/src/intl/translations/pt-br.ts b/packages/gitbook/src/intl/translations/pt-br.ts index f4e43f4fb..b7e8feb39 100644 --- a/packages/gitbook/src/intl/translations/pt-br.ts +++ b/packages/gitbook/src/intl/translations/pt-br.ts @@ -10,7 +10,7 @@ export const pt_br = { search_input_placeholder: 'Buscar conteúdo', search_ask_input_placeholder: 'Buscar conteúdo ou fazer uma pergunta', search_no_results: 'Sem resultados para "${1}".', - search_scope_space: 'Somente em ${1}', + search_scope_space: '${1}', search_scope_all: 'Todo o conteúdo', search_ask: 'Perguntar "${1}"', search_ask_sources: 'Fontes', diff --git a/packages/gitbook/src/intl/translations/zh.ts b/packages/gitbook/src/intl/translations/zh.ts index 376171e7b..616662ba1 100644 --- a/packages/gitbook/src/intl/translations/zh.ts +++ b/packages/gitbook/src/intl/translations/zh.ts @@ -12,7 +12,7 @@ export const zh: TranslationLanguage = { search_input_placeholder: '搜索内容', search_ask_input_placeholder: '搜索内容或提问', search_no_results: '没有找到"${1}"的结果。', - search_scope_space: '仅在${1}中', + search_scope_space: '${1}', search_scope_all: '所有内容', search_ask: '询问"${1}"', search_ask_sources: '来源', diff --git a/packages/gitbook/tailwind.config.ts b/packages/gitbook/tailwind.config.ts index cffcb2731..7a2266b01 100644 --- a/packages/gitbook/tailwind.config.ts +++ b/packages/gitbook/tailwind.config.ts @@ -99,6 +99,9 @@ const config: Config = { pomegranate: generateShades('#f25b3a'), periwinkle: generateShades('#acc6ee'), }, + animation: { + present: 'present .5s ease-out both', + }, keyframes: { pulseAlt: { '0%': { @@ -121,6 +124,16 @@ const config: Config = { opacity: '1', }, }, + present: { + from: { + opacity: '0', + transform: 'translateY(2rem) scale(0.9)', + }, + to: { + opacity: '1', + transform: 'translateY(0) scale(1)', + }, + }, rotateLoop: { '0%': { transform: 'rotate(0deg) scaleY(2.5) scaleX(2.5)',