侧边栏详情默认 pin 住;下载进度提示浮于最上层
This commit is contained in:
@@ -12,7 +12,7 @@ const Header = () => {
|
|||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'sticky top-0 z-10 h-16 bg-dark-bg text-dark-text flex items-center justify-between pl-[14px] lg:pl-[281px] pr-4',
|
'sticky top-0 z-10 h-16 bg-dark-bg text-dark-text flex items-center justify-between pl-[14px] lg:pl-[281px] pr-4',
|
||||||
{ 'mr-[404px]': pinned }
|
{ 'lg:mr-[404px]': pinned }
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<h1 className="mr-4 lg:mr-8 flex-shrink-0 flex items-center">
|
<h1 className="mr-4 lg:mr-8 flex-shrink-0 flex items-center">
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ const Container = styled.div`
|
|||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
width: 500px;
|
width: 500px;
|
||||||
|
/* Keep notifications above the sidebar (z-40) and modals (z-40) */
|
||||||
|
z-index: 50;
|
||||||
|
|
||||||
@media (max-width: 1000px) {
|
@media (max-width: 1000px) {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -41,9 +41,21 @@ export const SidebarProvider = ({ children }: SidebarProviderProps) => {
|
|||||||
pinned: false,
|
pinned: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const defaultPinned = () =>
|
||||||
|
typeof window !== 'undefined' &&
|
||||||
|
typeof window.matchMedia === 'function'
|
||||||
|
? window.matchMedia('(min-width: 1024px)').matches
|
||||||
|
: false
|
||||||
|
|
||||||
const updateSidebar = (content: React.ReactNode | null) => {
|
const updateSidebar = (content: React.ReactNode | null) => {
|
||||||
if (content) {
|
if (content) {
|
||||||
setState(state => ({ ...state, content }))
|
setState(state => ({
|
||||||
|
...state,
|
||||||
|
content,
|
||||||
|
// Pin the sidebar by default when it is opened on a large screen, but
|
||||||
|
// keep the user's choice if the sidebar is already open.
|
||||||
|
pinned: state.content == null ? defaultPinned() : state.pinned,
|
||||||
|
}))
|
||||||
} else {
|
} else {
|
||||||
setState(state => ({ ...state, content: null, pinned: false }))
|
setState(state => ({ ...state, content: null, pinned: false }))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user