mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
Add files
This commit is contained in:
commit
e87c814068
266 changed files with 63938 additions and 0 deletions
54
src/renderer/components/page-header/index.tsx
Normal file
54
src/renderer/components/page-header/index.tsx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import { motion } from 'framer-motion';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { useShouldPadTitlebar } from '/@/renderer/hooks';
|
||||
|
||||
const Container = styled(motion.div)<{ $useOpacity?: boolean; height?: string }>`
|
||||
z-index: 100;
|
||||
width: 100%;
|
||||
height: ${(props) => props.height || '55px'};
|
||||
opacity: ${(props) => props.$useOpacity && 'var(--header-opacity)'};
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
`;
|
||||
|
||||
const Header = styled(motion.div)<{ $padRight?: boolean }>`
|
||||
height: 100%;
|
||||
margin-right: ${(props) => props.$padRight && '170px'};
|
||||
padding: 1rem;
|
||||
-webkit-app-region: drag;
|
||||
|
||||
button {
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
`;
|
||||
|
||||
interface PageHeaderProps {
|
||||
backgroundColor?: string;
|
||||
children?: React.ReactNode;
|
||||
height?: string;
|
||||
useOpacity?: boolean;
|
||||
}
|
||||
|
||||
export const PageHeader = ({ height, backgroundColor, useOpacity, children }: PageHeaderProps) => {
|
||||
const ref = useRef(null);
|
||||
const padRight = useShouldPadTitlebar();
|
||||
|
||||
useEffect(() => {
|
||||
const rootElement = document.querySelector(':root') as HTMLElement;
|
||||
rootElement?.style?.setProperty('--header-opacity', '0');
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Container
|
||||
ref={ref}
|
||||
$useOpacity={useOpacity}
|
||||
animate={{
|
||||
backgroundColor,
|
||||
transition: { duration: 1.5 },
|
||||
}}
|
||||
height={height}
|
||||
>
|
||||
<Header $padRight={padRight}>{children}</Header>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue