fix: header ui styles (#4156)

This commit is contained in:
Peng Xiao
2023-09-04 18:13:20 +08:00
committed by GitHub
parent e72a10153e
commit 5288645e33
6 changed files with 41 additions and 14 deletions

View File

@@ -64,8 +64,14 @@ export const Header = forwardRef<HTMLDivElement, HeaderPros>(function Header(
block: isTinyScreen,
})}
>
<div className={clsx(style.headerItem, 'top-item')}>
<div ref={sidebarSwitchRef} style={{ marginRight: open ? 0 : 20 }}>
<div
className={clsx(
style.headerItem,
'top-item',
!open ? 'top-item-visible' : ''
)}
>
<div ref={sidebarSwitchRef}>
<SidebarSwitch show={!open} />
</div>
</div>

View File

@@ -34,6 +34,9 @@ export const headerItem = style({
'&.top-item': {
height: '52px',
},
'&.top-item-visible': {
marginRight: '20px',
},
'&.left': {
justifyContent: 'left',
},

View File

@@ -38,7 +38,7 @@ async function createWindow() {
: isWindows()
? 'hidden'
: 'default',
trafficLightPosition: { x: 20, y: 18 },
trafficLightPosition: { x: 20, y: 16 },
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,

View File

@@ -45,6 +45,18 @@ export const navWrapperStyle = style({
},
});
export const navHeaderButton = style({
width: '32px',
height: '32px',
flexShrink: 0,
});
export const navHeaderNavigationButtons = style({
display: 'flex',
alignItems: 'center',
columnGap: '32px',
});
export const navStyle = style({
position: 'relative',
width: '100%',
@@ -61,11 +73,10 @@ export const navHeaderStyle = style({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
gap: '32px',
WebkitAppRegion: 'drag',
selectors: {
'&[data-is-macos-electron="true"]': {
justifyContent: 'flex-end',
paddingLeft: '90px',
},
},
} as ComplexStyleRule);

View File

@@ -3,7 +3,11 @@ import { IconButton } from '@toeverything/components/button';
import { useAtomValue } from 'jotai';
import type { History } from '..';
import { navHeaderStyle } from '../index.css';
import {
navHeaderButton,
navHeaderNavigationButtons,
navHeaderStyle,
} from '../index.css';
import { appSidebarOpenAtom } from '../index.jotai';
import { SidebarSwitch } from './sidebar-switch';
@@ -18,15 +22,16 @@ export type SidebarHeaderProps = {
export const SidebarHeader = (props: SidebarHeaderProps) => {
const open = useAtomValue(appSidebarOpenAtom);
return (
<div className={navHeaderStyle} data-open={open}>
{environment.isDesktop && environment.isMacOs && (
<div style={{ flex: 1 }} />
)}
<div
className={navHeaderStyle}
data-open={open}
data-is-macos-electron={environment.isDesktop && environment.isMacOs}
>
<SidebarSwitch show={open} />
{environment.isDesktop && (
<>
{!environment.isMacOs && <div style={{ flex: 1 }} />}
<div className={navHeaderNavigationButtons}>
<IconButton
className={navHeaderButton}
data-testid="app-sidebar-arrow-button-back"
disabled={props.router?.history.current === 0}
onClick={() => {
@@ -36,6 +41,7 @@ export const SidebarHeader = (props: SidebarHeaderProps) => {
<ArrowLeftSmallIcon />
</IconButton>
<IconButton
className={navHeaderButton}
data-testid="app-sidebar-arrow-button-forward"
disabled={
props.router
@@ -50,7 +56,7 @@ export const SidebarHeader = (props: SidebarHeaderProps) => {
>
<ArrowRightSmallIcon />
</IconButton>
</>
</div>
)}
</div>
);

View File

@@ -5,11 +5,12 @@ export const sidebarSwitch = style({
width: 0,
overflow: 'hidden',
pointerEvents: 'none',
transition: 'opacity .3s ease-in-out',
transition: 'all .3s ease-in-out',
selectors: {
'&[data-show=true]': {
opacity: 1,
width: '32px',
flexShrink: 0,
pointerEvents: 'auto',
},
},