mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 21:06:22 +08:00
fix(core): page header style changes (#5279)

This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
|||||||
|
|
||||||
import type { PageMode } from '../../../atoms';
|
import type { PageMode } from '../../../atoms';
|
||||||
import { EditorModeSwitch } from '../block-suite-mode-switch';
|
import { EditorModeSwitch } from '../block-suite-mode-switch';
|
||||||
import { PageMenu } from './operation-menu';
|
import { PageHeaderMenuButton } from './operation-menu';
|
||||||
import * as styles from './styles.css';
|
import * as styles from './styles.css';
|
||||||
|
|
||||||
export interface BlockSuiteHeaderTitleProps {
|
export interface BlockSuiteHeaderTitleProps {
|
||||||
@@ -81,9 +81,6 @@ const StableTitle = ({
|
|||||||
pageId={pageId}
|
pageId={pageId}
|
||||||
isPublic={isPublic}
|
isPublic={isPublic}
|
||||||
publicMode={publicMode}
|
publicMode={publicMode}
|
||||||
style={{
|
|
||||||
marginRight: '12px',
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
data-testid="title-edit-button"
|
data-testid="title-edit-button"
|
||||||
@@ -92,7 +89,9 @@ const StableTitle = ({
|
|||||||
>
|
>
|
||||||
{title || 'Untitled'}
|
{title || 'Untitled'}
|
||||||
</span>
|
</span>
|
||||||
{isPublic ? null : <PageMenu rename={onRename} pageId={pageId} />}
|
{isPublic ? null : (
|
||||||
|
<PageHeaderMenuButton rename={onRename} pageId={pageId} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-8
@@ -1,5 +1,4 @@
|
|||||||
import { FlexWrapper } from '@affine/component';
|
import { Export, FavoriteTag, MoveToTrash } from '@affine/component/page-list';
|
||||||
import { Export, MoveToTrash } from '@affine/component/page-list';
|
|
||||||
import {
|
import {
|
||||||
Menu,
|
Menu,
|
||||||
MenuIcon,
|
MenuIcon,
|
||||||
@@ -22,7 +21,7 @@ import {
|
|||||||
import type { PageMeta } from '@blocksuite/store';
|
import type { PageMeta } from '@blocksuite/store';
|
||||||
import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';
|
import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import { useCallback, useRef, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
import { currentModeAtom } from '../../../atoms/mode';
|
import { currentModeAtom } from '../../../atoms/mode';
|
||||||
import { useBlockSuiteMetaHelper } from '../../../hooks/affine/use-block-suite-meta-helper';
|
import { useBlockSuiteMetaHelper } from '../../../hooks/affine/use-block-suite-meta-helper';
|
||||||
@@ -39,9 +38,8 @@ type PageMenuProps = {
|
|||||||
pageId: string;
|
pageId: string;
|
||||||
};
|
};
|
||||||
// fixme: refactor this file
|
// fixme: refactor this file
|
||||||
export const PageMenu = ({ rename, pageId }: PageMenuProps) => {
|
export const PageHeaderMenuButton = ({ rename, pageId }: PageMenuProps) => {
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
const ref = useRef(null);
|
|
||||||
|
|
||||||
// fixme(himself65): remove these hooks ASAP
|
// fixme(himself65): remove these hooks ASAP
|
||||||
const [workspace] = useCurrentWorkspace();
|
const [workspace] = useCurrentWorkspace();
|
||||||
@@ -148,7 +146,7 @@ export const PageMenu = ({ rename, pageId }: PageMenuProps) => {
|
|||||||
? t['com.affine.favoritePageOperation.remove']()
|
? t['com.affine.favoritePageOperation.remove']()
|
||||||
: t['com.affine.favoritePageOperation.add']()}
|
: t['com.affine.favoritePageOperation.add']()}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
{/* {TODO: add tag and duplicate function support} */}
|
{/* {TODO: add tag function support} */}
|
||||||
{/* <MenuItem
|
{/* <MenuItem
|
||||||
icon={<TagsIcon />}
|
icon={<TagsIcon />}
|
||||||
data-testid="editor-option-menu-add-tag"
|
data-testid="editor-option-menu-add-tag"
|
||||||
@@ -211,7 +209,7 @@ export const PageMenu = ({ rename, pageId }: PageMenuProps) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<FlexWrapper alignItems="center" justifyContent="center" ref={ref}>
|
<>
|
||||||
<Menu
|
<Menu
|
||||||
items={EditMenu}
|
items={EditMenu}
|
||||||
contentOptions={{
|
contentOptions={{
|
||||||
@@ -228,6 +226,7 @@ export const PageMenu = ({ rename, pageId }: PageMenuProps) => {
|
|||||||
onOpenChange={setHistoryModalOpen}
|
onOpenChange={setHistoryModalOpen}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</FlexWrapper>
|
<FavoriteTag active={!!pageMeta?.favorite} onClick={handleFavorite} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+1
@@ -7,6 +7,7 @@ export const headerTitleContainer = style({
|
|||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
columnGap: 12,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const titleEditButton = style({
|
export const titleEditButton = style({
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { IconButton, type IconButtonProps } from '@affine/component/ui/button';
|
import { IconButton, type IconButtonProps } from '@affine/component/ui/button';
|
||||||
import { ArrowDownSmallIcon } from '@blocksuite/icons';
|
import { MoreHorizontalIcon } from '@blocksuite/icons';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
|
|
||||||
import { headerMenuTrigger } from './styles.css';
|
import { headerMenuTrigger } from './styles.css';
|
||||||
@@ -17,7 +17,7 @@ export const HeaderDropDownButton = forwardRef<
|
|||||||
withoutHoverStyle={true}
|
withoutHoverStyle={true}
|
||||||
type="plain"
|
type="plain"
|
||||||
>
|
>
|
||||||
<ArrowDownSmallIcon />
|
<MoreHorizontalIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { globalStyle, style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
export const headerMenuTrigger = style({});
|
export const headerMenuTrigger = style({
|
||||||
|
selectors: {
|
||||||
globalStyle(`${headerMenuTrigger} svg`, {
|
'&[data-state=open], &:hover': {
|
||||||
transition: 'transform 0.15s ease-in-out',
|
backgroundColor: 'var(--affine-hover-color)',
|
||||||
});
|
},
|
||||||
globalStyle(`${headerMenuTrigger}:hover svg`, {
|
},
|
||||||
transform: 'translateY(3px)',
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ export async function enableCloudWorkspace(page: Page) {
|
|||||||
|
|
||||||
export async function enableCloudWorkspaceFromShareButton(page: Page) {
|
export async function enableCloudWorkspaceFromShareButton(page: Page) {
|
||||||
const shareMenuButton = page.getByTestId('local-share-menu-button');
|
const shareMenuButton = page.getByTestId('local-share-menu-button');
|
||||||
expect(await shareMenuButton.isVisible()).toBeTruthy();
|
await expect(shareMenuButton).toBeVisible();
|
||||||
|
|
||||||
// FIXME: this is a workaround for the flaky test
|
// FIXME: this is a workaround for the flaky test
|
||||||
// For unknown reasons,
|
// For unknown reasons,
|
||||||
|
|||||||
Reference in New Issue
Block a user