-
Notifications
You must be signed in to change notification settings - Fork 609
Feat/add global spotlight menu #3313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4b7d2c5
09154f2
952282a
0531769
2d094f3
a1d533b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| import { ActionIcon } from '@mantine/core'; | ||
| import { Spotlight, spotlight } from '@mantine/spotlight'; | ||
| import { useNavigate } from '@tanstack/react-router'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| import { navRoutes } from '@/config/navRoutes'; | ||
| import IconClose from '~icons/material-symbols/close'; | ||
| import IconDashboard from '~icons/material-symbols/dashboard-outline'; | ||
| import IconSearch from '~icons/material-symbols/search'; | ||
|
|
||
| export const GlobalSpotlight = () => { | ||
| const { t } = useTranslation(); | ||
| const navigate = useNavigate(); | ||
|
|
||
| const actions = navRoutes.map((route) => ({ | ||
| id: route.to, | ||
| label: t(`sources.${route.label}`), | ||
| description: t('spotlight.jumpToDashboard', { resource: t(`sources.${route.label}`) }), | ||
| leftSection: <IconDashboard style={{ width: 18, height: 18, opacity: 0.7 }} />, | ||
| onClick: () => { | ||
| navigate({ to: route.to }); | ||
| }, | ||
| })); | ||
|
|
||
| return ( | ||
| <Spotlight | ||
| actions={actions} | ||
| nothingFound={t('noData')} | ||
| highlightQuery | ||
| scrollAreaProps={{ type: 'always', offsetScrollbars: true, mah: 400 }} | ||
| searchProps={{ | ||
| leftSection: <IconSearch style={{ width: 22, height: 22 }} />, | ||
| placeholder: 'Search resources... (Ctrl + K)', | ||
| rightSectionPointerEvents: 'all', | ||
|
Comment on lines
+48
to
+50
|
||
| rightSection: ( | ||
| <ActionIcon | ||
| variant="subtle" | ||
| color="gray" | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| spotlight.close(); | ||
| }} | ||
| > | ||
| <IconClose style={{ width: 18, height: 18 }} /> | ||
| </ActionIcon> | ||
| ), | ||
| }} | ||
| /> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ import { createRootRoute, HeadContent, Outlet } from '@tanstack/react-router'; | |
| import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'; | ||
| import { I18nextProvider } from 'react-i18next'; | ||
|
|
||
| import { GlobalSpotlight } from '@/components/GlobalSpotlight'; | ||
| import { Header } from '@/components/Header'; | ||
| import { Navbar } from '@/components/Navbar'; | ||
| import { SettingsModal } from '@/components/page/SettingsModal'; | ||
|
|
@@ -55,6 +56,7 @@ const Root = () => { | |
| <TanStackRouterDevtools /> | ||
| <ReactQueryDevtools initialIsOpen={false} /> | ||
| <SettingsModal /> | ||
| <GlobalSpotlight /> | ||
| </I18nextProvider> | ||
|
Comment on lines
56
to
60
|
||
| ); | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mantine/spotlightis pinned to 8.3.15, but the repo is currently locked to@mantine/core/@mantine/hooks8.3.12 (see pnpm-lock peer deps). Please align Mantine package versions (core/hooks/spotlight/store) to the same patch version to avoid peer-dependency mismatches and potential runtime issues.