docs: website SearchBar support dark theme (#40652)

This commit is contained in:
KuangPengfei 2023-02-09 12:59:10 +08:00 committed by GitHub
parent 8ecb4cdc60
commit b0ea26bf64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import {
PreviewImage,
Reset,
Responsive,
SearchBar,
} from './styles';
const GlobalStyles = () => (
@ -30,6 +31,7 @@ const GlobalStyles = () => (
<PreviewImage />
<ColorStyle />
<HeadingAnchor />
<SearchBar />
</>
);

View File

@ -0,0 +1,57 @@
import React from 'react';
import { css, Global } from '@emotion/react';
import useSiteToken from '../../../hooks/useSiteToken';
const THEME_PREFIX = 'dumi-default-';
export default () => {
const { token } = useSiteToken();
return (
<Global
styles={css`
html {
.${THEME_PREFIX}search-bar {
&-input {
color: ${token.colorText};
background: ${token.colorBgContainer};
&:focus {
background: ${token.colorBgContainer};
}
&::placeholder {
color: ${token.colorTextPlaceholder} !important;
}
}
}
.${THEME_PREFIX}search-popover {
background-color: ${token.colorBgElevated} !important;
&::before {
border-bottom-color: ${token.colorBgElevated} !important;
}
}
.${THEME_PREFIX}search-result {
dl {
dt {
background-color: ${token.controlItemBgActive} !important;
}
dd {
a {
&:hover {
background-color: ${token.controlItemBgHover};
h4,
p {
color: ${token.colorText} !important;
}
svg {
fill: ${token.colorText} !important;
}
}
}
}
}
}
}
`}
/>
);
};

View File

@ -10,3 +10,4 @@ export { default as BrowserMockup } from './BrowserMockup';
export { default as Responsive } from './Responsive';
export { default as NProgress } from './NProgress';
export { default as PreviewImage } from './PreviewImage';
export { default as SearchBar } from './SearchBar';