From ccb466e26477e3fe72427e88e193cb74e4f12df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <645381995@qq.com> Date: Thu, 12 Oct 2023 10:12:28 +0800 Subject: [PATCH 1/3] fix: search not empty to hide icon --- src/client/theme-default/slots/SearchBar/index.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/client/theme-default/slots/SearchBar/index.tsx b/src/client/theme-default/slots/SearchBar/index.tsx index 2b22865383..fb9e1082f1 100644 --- a/src/client/theme-default/slots/SearchBar/index.tsx +++ b/src/client/theme-default/slots/SearchBar/index.tsx @@ -2,13 +2,11 @@ import { ReactComponent as IconArrowDown } from '@ant-design/icons-svg/inline-sv import { ReactComponent as IconArrowUp } from '@ant-design/icons-svg/inline-svg/outlined/arrow-up.svg'; import { ReactComponent as IconSearch } from '@ant-design/icons-svg/inline-svg/outlined/search.svg'; import { useSiteSearch } from 'dumi'; -import React, { useEffect, useRef, useState, type FC } from 'react'; import SearchResult from 'dumi/theme/slots/SearchResult'; -import './index.less'; +import React, { useEffect, useRef, useState, type FC } from 'react'; import { Input } from './Input'; import { Mask } from './Mask'; -export { Input as SearchInput } from './Input'; -export { Mask as SearchMask } from './Mask'; +import './index.less'; const isAppleDevice = /(mac|iphone|ipod|ipad)/i.test( typeof navigator !== 'undefined' ? navigator?.platform : '', @@ -87,7 +85,9 @@ const SearchBar: FC = () => { onChange={(keywords) => setKeywords(keywords)} ref={inputRef} /> - {symbol} K + {!keywords && ( + {symbol} K + )} {keywords.trim() && focusing && (result.length || !loading) && @@ -163,4 +163,7 @@ const SearchBar: FC = () => { ); }; +export { Input as SearchInput } from './Input'; +export { Mask as SearchMask } from './Mask'; + export default SearchBar; From 5b7480f32bfc8a6e19e35befea97b1f3b3fc1848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <645381995@qq.com> Date: Tue, 26 Dec 2023 17:20:04 +0800 Subject: [PATCH 2/3] feat: css --- src/client/theme-default/slots/SearchBar/index.less | 3 +++ src/client/theme-default/slots/SearchBar/index.tsx | 9 +++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/theme-default/slots/SearchBar/index.less b/src/client/theme-default/slots/SearchBar/index.less index dc974fdc58..533deaa9ca 100644 --- a/src/client/theme-default/slots/SearchBar/index.less +++ b/src/client/theme-default/slots/SearchBar/index.less @@ -56,7 +56,10 @@ background-color: @c-site-bg-dark; box-shadow: 0 0 0 3px fade(@c-primary-dark, 10%); } + } + &:focus, + &:not(:placeholder-shown) { ~ .@{prefix}-search-shortcut { opacity: 0; } diff --git a/src/client/theme-default/slots/SearchBar/index.tsx b/src/client/theme-default/slots/SearchBar/index.tsx index fb9e1082f1..34df5b30ca 100644 --- a/src/client/theme-default/slots/SearchBar/index.tsx +++ b/src/client/theme-default/slots/SearchBar/index.tsx @@ -7,6 +7,8 @@ import React, { useEffect, useRef, useState, type FC } from 'react'; import { Input } from './Input'; import { Mask } from './Mask'; import './index.less'; +export { Input as SearchInput } from './Input'; +export { Mask as SearchMask } from './Mask'; const isAppleDevice = /(mac|iphone|ipod|ipad)/i.test( typeof navigator !== 'undefined' ? navigator?.platform : '', @@ -85,9 +87,7 @@ const SearchBar: FC = () => { onChange={(keywords) => setKeywords(keywords)} ref={inputRef} /> - {!keywords && ( - {symbol} K - )} + {symbol} K {keywords.trim() && focusing && (result.length || !loading) && @@ -163,7 +163,4 @@ const SearchBar: FC = () => { ); }; -export { Input as SearchInput } from './Input'; -export { Mask as SearchMask } from './Mask'; - export default SearchBar; From de3a23869cc1a404ba76e10b026636338808e532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <645381995@qq.com> Date: Tue, 26 Dec 2023 17:20:57 +0800 Subject: [PATCH 3/3] feat: css --- src/client/theme-default/slots/SearchBar/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/theme-default/slots/SearchBar/index.tsx b/src/client/theme-default/slots/SearchBar/index.tsx index 34df5b30ca..2b22865383 100644 --- a/src/client/theme-default/slots/SearchBar/index.tsx +++ b/src/client/theme-default/slots/SearchBar/index.tsx @@ -2,11 +2,11 @@ import { ReactComponent as IconArrowDown } from '@ant-design/icons-svg/inline-sv import { ReactComponent as IconArrowUp } from '@ant-design/icons-svg/inline-svg/outlined/arrow-up.svg'; import { ReactComponent as IconSearch } from '@ant-design/icons-svg/inline-svg/outlined/search.svg'; import { useSiteSearch } from 'dumi'; -import SearchResult from 'dumi/theme/slots/SearchResult'; import React, { useEffect, useRef, useState, type FC } from 'react'; +import SearchResult from 'dumi/theme/slots/SearchResult'; +import './index.less'; import { Input } from './Input'; import { Mask } from './Mask'; -import './index.less'; export { Input as SearchInput } from './Input'; export { Mask as SearchMask } from './Mask';