详情侧边栏收窄至 380px;分享页加载时自动打开首张照片详情
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import React from 'react'
|
||||
import React, { useContext, useEffect, useRef } from 'react'
|
||||
import Layout from '../../components/layout/Layout'
|
||||
import AlbumGallery from '../../components/albumGallery/AlbumGallery'
|
||||
import { SidebarContext } from '../../components/sidebar/Sidebar'
|
||||
import MediaSidebar from '../../components/sidebar/MediaSidebar/MediaSidebar'
|
||||
import styled from 'styled-components'
|
||||
import { gql, useQuery } from '@apollo/client'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@@ -103,6 +105,9 @@ type AlbumSharePageProps = {
|
||||
const AlbumSharePage = ({ albumID, token, password }: AlbumSharePageProps) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { updateSidebar } = useContext(SidebarContext)
|
||||
const openedAlbumID = useRef<string | null>(null)
|
||||
|
||||
const urlParams = useURLParameters()
|
||||
const orderParams = useOrderingParams(
|
||||
urlParams,
|
||||
@@ -133,12 +138,23 @@ const AlbumSharePage = ({ albumID, token, password }: AlbumSharePageProps) => {
|
||||
getItems: data => data.album.media,
|
||||
})
|
||||
|
||||
const album = data?.album
|
||||
|
||||
// Open the detail sidebar with the first (newest) photo when the page loads.
|
||||
useEffect(() => {
|
||||
if (!album || openedAlbumID.current === album.id) return
|
||||
|
||||
const firstMedia = album.media[0]
|
||||
if (!firstMedia) return
|
||||
|
||||
openedAlbumID.current = album.id
|
||||
updateSidebar(<MediaSidebar media={firstMedia} />)
|
||||
}, [album, updateSidebar])
|
||||
|
||||
if (error) {
|
||||
return <div>{error.message}</div>
|
||||
}
|
||||
|
||||
const album = data?.album
|
||||
|
||||
return (
|
||||
<AlbumSharePageWrapper data-testid="AlbumSharePage">
|
||||
<Layout
|
||||
|
||||
@@ -12,7 +12,7 @@ const Header = () => {
|
||||
<div
|
||||
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',
|
||||
{ 'lg:mr-[404px]': pinned }
|
||||
{ 'lg:mr-[364px]': pinned }
|
||||
)}
|
||||
>
|
||||
<h1 className="mr-4 lg:mr-8 flex-shrink-0 flex items-center">
|
||||
|
||||
@@ -37,7 +37,7 @@ const Layout = ({ children, title, ...otherProps }: LayoutProps) => {
|
||||
</Authorized>
|
||||
<div
|
||||
className={`mx-6 my-3 lg:mt-5 lg:mr-16 lg:ml-[292px] ${
|
||||
pinned && sidebarContent ? 'lg:pr-[420px]' : ''
|
||||
pinned && sidebarContent ? 'lg:pr-[380px]' : ''
|
||||
}`}
|
||||
id="layout-content"
|
||||
>
|
||||
|
||||
@@ -11,7 +11,7 @@ const Container = styled.div`
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
/* Match the sidebar width */
|
||||
width: 420px;
|
||||
width: 380px;
|
||||
/* Keep notifications above the sidebar (z-40) and modals (z-40) */
|
||||
z-index: 50;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ export const Sidebar = () => {
|
||||
content == null && !pinned ? 'translate-x-full' : 'translate-x-0'
|
||||
} ${
|
||||
pinned ? 'lg:border-l' : 'lg:shadow-separator'
|
||||
} lg:w-[420px] lg:right-0 lg:top-0 lg:z-40`}
|
||||
} lg:w-[380px] lg:right-0 lg:top-0 lg:z-40`}
|
||||
>
|
||||
{content}
|
||||
<div className="h-24"></div>
|
||||
|
||||
Reference in New Issue
Block a user