|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | 3 | import '../tailwind/home.global.css'; |
4 | | -import {DialogTrigger, Modal, ModalOverlay, Pressable} from 'react-aria-components'; |
| 4 | +import {Button, DialogTrigger, Modal, ModalOverlay} from 'react-aria-components'; |
5 | 5 | import {flushSync} from 'react-dom'; |
6 | 6 | import {preloadSearchMenu} from './SearchMenuTrigger'; |
7 | | -import React, {useState} from 'react'; |
| 7 | +import React, {lazy, useState} from 'react'; |
| 8 | +import {Modal as S2Modal} from '../../../@react-spectrum/s2/src/Modal'; |
8 | 9 | import {SearchMenu} from './SearchMenu'; |
9 | 10 | import {style} from '@react-spectrum/s2/style' with { type: 'macro' }; |
10 | 11 |
|
| 12 | +const MobileSearchMenu = lazy(() => import('./SearchMenu').then(({MobileSearchMenu}) => ({default: MobileSearchMenu}))); |
| 13 | + |
11 | 14 | let underlayStyle = style({ |
12 | 15 | position: 'absolute', |
13 | 16 | top: 0, |
@@ -81,20 +84,34 @@ export default function SearchMenuWrapper({pages, currentPage}) { |
81 | 84 | }; |
82 | 85 |
|
83 | 86 | return ( |
84 | | - <DialogTrigger isOpen={searchOpen} onOpenChange={() => {openSearchMenu();}} > |
85 | | - <Pressable><span role="button" className="no-underline bg-white/60 border border-black/10 bg-clip-padding text-base md:text-lg font-bold text-slate-800 px-8 py-3 rounded-full backdrop-saturate-150 backdrop-brightness-125 transition hover:bg-white/60 focus-ring dark:outline-white outline-offset-2 active:scale-95">Explore Components</span></Pressable> |
86 | | - <ModalOverlay |
87 | | - style={{zIndex: 21}} |
88 | | - isDismissable |
89 | | - className={underlayStyle}> |
90 | | - <Modal className={modalStyle}> |
91 | | - <SearchMenu |
92 | | - pages={pages} |
93 | | - currentPage={currentPage} |
94 | | - onClose={closeSearchMenu} |
95 | | - initialSearchValue="" /> |
96 | | - </Modal> |
97 | | - </ModalOverlay> |
98 | | - </DialogTrigger> |
| 87 | + <> |
| 88 | + <div className={style({display: {default: 'none', lg: 'flex'}})}> |
| 89 | + <DialogTrigger isOpen={searchOpen} onOpenChange={() => {openSearchMenu();}} > |
| 90 | + <Button className="font-spectrum no-underline bg-white/60 border border-black/10 bg-clip-padding text-base md:text-lg font-bold text-slate-800 px-8 py-3 rounded-full backdrop-saturate-150 backdrop-brightness-125 transition hover:bg-white/60 focus-ring dark:outline-white outline-offset-2 active:scale-95 cursor-pointer">Explore Components</Button> |
| 91 | + <ModalOverlay |
| 92 | + style={{zIndex: 21}} |
| 93 | + isDismissable |
| 94 | + className={underlayStyle}> |
| 95 | + <Modal className={modalStyle}> |
| 96 | + <SearchMenu |
| 97 | + pages={pages} |
| 98 | + currentPage={currentPage} |
| 99 | + onClose={closeSearchMenu} |
| 100 | + initialSearchValue="" /> |
| 101 | + </Modal> |
| 102 | + </ModalOverlay> |
| 103 | + </DialogTrigger> |
| 104 | + </div> |
| 105 | + <div className={style({display: {default: 'flex', lg: 'none'}})}> |
| 106 | + <DialogTrigger> |
| 107 | + <Button className="font-spectrum no-underline bg-white/60 border border-black/10 bg-clip-padding text-base md:text-lg font-bold text-slate-800 px-8 py-3 rounded-full backdrop-saturate-150 backdrop-brightness-125 transition hover:bg-white/60 focus-ring dark:outline-white outline-offset-2 active:scale-95 cursor-pointer">Explore Components</Button> |
| 108 | + <S2Modal size="fullscreenTakeover"> |
| 109 | + <MobileSearchMenu pages={pages} currentPage={currentPage} /> |
| 110 | + </S2Modal> |
| 111 | + </DialogTrigger> |
| 112 | + </div> |
| 113 | + </> |
99 | 114 | ); |
100 | 115 | } |
| 116 | + |
| 117 | + |
0 commit comments