@@ -21,16 +21,20 @@ import {
21
21
useDisclosure ,
22
22
} from '@nextui-org/react'
23
23
24
- import { ColorPicker } from '../../components/color-picker'
25
- import { randomColor } from '../../utils/color'
24
+ import { ColorPicker } from '~/components/color-picker'
25
+ import { randomColor } from '~/utils/color'
26
+ import { useWindowDimensions } from '~/utils/use-window-dimensions'
27
+
26
28
import { IconButton , colorsAtom , optionsAtom } from './utils'
27
29
28
30
export function PaletteTools ( ) {
31
+ const { height = 600 } = useWindowDimensions ( )
32
+
29
33
const [ inPaletteView , setInPaletteView ] = useState ( false )
30
34
const [ options , setOptions ] = useAtom ( optionsAtom )
31
35
const [ colors , setColors ] = useAtom ( colorsAtom )
32
36
const { isOpen, onOpen, onOpenChange } = useDisclosure ( )
33
- const toolsRef = useRef ( )
37
+ const toolsRef = useRef < HTMLDivElement > ( null )
34
38
35
39
const [ , startTransition ] = useTransition ( )
36
40
@@ -48,7 +52,7 @@ export function PaletteTools() {
48
52
const { scrollY } = useScroll ( )
49
53
50
54
useMotionValueEvent ( scrollY , 'change' , latest => {
51
- if ( latest > window . innerHeight / 2 ) {
55
+ if ( latest > height / 2 ) {
52
56
! inPaletteView && setInPaletteView ( true )
53
57
} else {
54
58
inPaletteView && setInPaletteView ( false )
@@ -113,7 +117,7 @@ export function PaletteTools() {
113
117
</ IconButton >
114
118
</ Tooltip >
115
119
116
- < Popover placement = "top-start" portalContainer = { toolsRef . current } shouldCloseOnBlur >
120
+ < Popover placement = "top-start" portalContainer = { toolsRef . current ! } shouldCloseOnBlur >
117
121
< PopoverTrigger >
118
122
< IconButton >
119
123
< CogIcon width = { 14 } />
@@ -167,7 +171,7 @@ export function PaletteTools() {
167
171
< Modal backdrop = "blur" isOpen = { isOpen } onOpenChange = { onOpenChange } scrollBehavior = "inside" size = "xl" >
168
172
< ModalContent >
169
173
< ModalHeader className = "text-xl" > How to configure your Tailwind.CSS?</ ModalHeader >
170
- < ModalBody className = "prose dark:prose-invert max-h-[50vh] overflow-y-auto" >
174
+ < ModalBody className = "prose max-h-[50vh] overflow-y-auto dark:prose-invert " >
171
175
< div >
172
176
< h4 > 1. Install tailwind-plugin-palette</ h4 >
173
177
< div className = "not-prose flex gap-2" >
0 commit comments