fix: adjust some styles (#2438)

This commit is contained in:
Peng Xiao
2023-05-18 17:24:23 +08:00
committed by GitHub
parent 89310c9b97
commit b2556db33b
13 changed files with 110 additions and 40 deletions

View File

@@ -16,7 +16,7 @@ export const spotlight = style({
background: `radial-gradient(${spotlightSize} circle at ${spotlightX} ${spotlightY}, var(--affine-text-primary-color), transparent)`,
inset: '0px',
pointerEvents: 'none',
willChange: 'background',
willChange: 'background, opacity',
opacity: spotlightOpacity,
zIndex: 1,
transition: 'all 0.2s',

View File

@@ -0,0 +1,30 @@
import type { Meta, StoryFn } from '@storybook/react';
import { type PropsWithChildren } from 'react';
import { Spotlight } from '.';
export default {
title: 'Components/AppSidebar/Spotlight',
component: Spotlight,
} satisfies Meta;
const Container = ({ children }: PropsWithChildren) => (
<main
style={{
position: 'relative',
width: '320px',
height: '320px',
border: '1px solid #ccc',
}}
>
{children}
</main>
);
export const Default: StoryFn = () => {
return (
<Container>
<Spotlight />
</Container>
);
};

View File

@@ -12,10 +12,10 @@ function useMouseOffset() {
useEffect(() => {
if (ref.current && ref.current.parentElement) {
const el = ref.current.parentElement;
const bound = el.getBoundingClientRect();
// debounce?
const onMouseMove = (e: MouseEvent) => {
const bound = el.getBoundingClientRect();
setOffset({ x: e.clientX - bound.x, y: e.clientY - bound.y });
setOutside(false);
};