mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(electron): drag window behavior in header
This commit is contained in:
@@ -7,6 +7,7 @@ export const StyledSidebarSwitch = styled(IconButton, {
|
|||||||
})<{ visible: boolean }>(({ visible }) => {
|
})<{ visible: boolean }>(({ visible }) => {
|
||||||
return {
|
return {
|
||||||
opacity: visible ? 1 : 0,
|
opacity: visible ? 1 : 0,
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
transition: 'all 0.2s ease-in-out',
|
transition: 'all 0.2s ease-in-out',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export const StyledSwitchItem = styled('button')<{
|
|||||||
width: '24px',
|
width: '24px',
|
||||||
height: '24px',
|
height: '24px',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
boxShadow: active ? 'var(--affine-shadow)' : 'none',
|
boxShadow: active ? 'var(--affine-shadow)' : 'none',
|
||||||
color: active ? 'var(--affine-primary-color)' : 'var(--affine-icon-color)',
|
color: active ? 'var(--affine-primary-color)' : 'var(--affine-icon-color)',
|
||||||
display: hide ? 'none' : 'inline-flex',
|
display: hide ? 'none' : 'inline-flex',
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const IconWrapper = styled('div')(({ theme }) => {
|
|||||||
marginRight: '12px',
|
marginRight: '12px',
|
||||||
fontSize: '24px',
|
fontSize: '24px',
|
||||||
color: 'var(--affine-icon-color)',
|
color: 'var(--affine-icon-color)',
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
...displayFlex('center', 'center'),
|
...displayFlex('center', 'center'),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export const StyledThemeModeSwitch = styled('button')(({ theme }) => {
|
|||||||
height: '32px',
|
height: '32px',
|
||||||
borderRadius: '6px',
|
borderRadius: '6px',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
color: 'var(--affine-icon-color)',
|
color: 'var(--affine-icon-color)',
|
||||||
|
|||||||
@@ -144,7 +144,12 @@ export const Header = forwardRef<
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledHeaderContainer ref={ref} hasWarning={showWarning} {...props}>
|
<StyledHeaderContainer
|
||||||
|
ref={ref}
|
||||||
|
hasWarning={showWarning}
|
||||||
|
data-open={open}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
<BrowserWarning
|
<BrowserWarning
|
||||||
show={showWarning}
|
show={showWarning}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
|||||||
@@ -14,7 +14,13 @@ export const StyledHeaderContainer = styled('div')<{
|
|||||||
position: 'sticky',
|
position: 'sticky',
|
||||||
top: 0,
|
top: 0,
|
||||||
background: 'var(--affine-background-primary-color)',
|
background: 'var(--affine-background-primary-color)',
|
||||||
|
WebkitAppRegion: 'drag',
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
|
'@media (max-width: 768px)': {
|
||||||
|
'&[data-open="true"]': {
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
export const StyledHeader = styled('div')<{ hasWarning: boolean }>(
|
export const StyledHeader = styled('div')<{ hasWarning: boolean }>(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { baseTheme } from '@toeverything/theme';
|
import { baseTheme } from '@toeverything/theme';
|
||||||
|
import type { ComplexStyleRule } from '@vanilla-extract/css';
|
||||||
import { createVar, style } from '@vanilla-extract/css';
|
import { createVar, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
export const floatingMaxWidth = 768;
|
export const floatingMaxWidth = 768;
|
||||||
@@ -49,12 +50,21 @@ export const navHeaderStyle = style({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
'@media': {
|
||||||
|
[`(max-width: ${floatingMaxWidth}px)`]: {
|
||||||
|
selectors: {
|
||||||
|
'&[data-open="true"]': {
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as ComplexStyleRule,
|
||||||
|
},
|
||||||
selectors: {
|
selectors: {
|
||||||
'&[data-is-macos-electron="true"]': {
|
'&[data-is-macos-electron="true"]': {
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
} as ComplexStyleRule);
|
||||||
|
|
||||||
export const navBodyStyle = style({
|
export const navBodyStyle = style({
|
||||||
flex: '1 1 auto',
|
flex: '1 1 auto',
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export const AppSidebar = forwardRef<HTMLElement, AppSidebarProps>(
|
|||||||
<div
|
<div
|
||||||
className={navHeaderStyle}
|
className={navHeaderStyle}
|
||||||
data-is-macos-electron={isMacosDesktop}
|
data-is-macos-electron={isMacosDesktop}
|
||||||
|
data-open={open}
|
||||||
>
|
>
|
||||||
{isMacosDesktop && (
|
{isMacosDesktop && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export const StyledIconButton = styled('button', {
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
fontSize,
|
fontSize,
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
color: 'var(--affine-icon-color)',
|
color: 'var(--affine-icon-color)',
|
||||||
...displayInlineFlex('center', 'center'),
|
...displayInlineFlex('center', 'center'),
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
@@ -184,6 +185,7 @@ export const StyledButton = styled('button', {
|
|||||||
paddingLeft: padding,
|
paddingLeft: padding,
|
||||||
paddingRight: padding,
|
paddingRight: padding,
|
||||||
border: noBorder ? 'none' : '1px solid',
|
border: noBorder ? 'none' : '1px solid',
|
||||||
|
WebkitAppRegion: 'no-drag',
|
||||||
...displayInlineFlex('center', 'center'),
|
...displayInlineFlex('center', 'center'),
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
// TODO: disabled color is not decided
|
// TODO: disabled color is not decided
|
||||||
|
|||||||
Reference in New Issue
Block a user