From 31e58793beab20160f8f116b3c7cc109e2c4758f Mon Sep 17 00:00:00 2001 From: Varun Raj Date: Mon, 30 Dec 2024 22:02:44 +0530 Subject: [PATCH] feat: added preview in find Signed-off-by: Varun Raj --- postcss.config.js | 6 -- postcss.config.mjs | 1 + src/components/find/FindInput.tsx | 18 ++--- src/components/find/findInputStyle.ts | 33 +++++---- src/components/find/findMentionStyle.ts | 5 +- src/components/layouts/PageLayout.tsx | 4 +- src/pages/find/index.tsx | 99 ++++++++++++++++--------- src/styles/globals.scss | 2 +- 8 files changed, 98 insertions(+), 70 deletions(-) delete mode 100644 postcss.config.js diff --git a/postcss.config.js b/postcss.config.js deleted file mode 100644 index 33ad091..0000000 --- a/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -} diff --git a/postcss.config.mjs b/postcss.config.mjs index 1a69fd2..2ef30fc 100644 --- a/postcss.config.mjs +++ b/postcss.config.mjs @@ -2,6 +2,7 @@ const config = { plugins: { tailwindcss: {}, + autoprefixer: {}, }, }; diff --git a/src/components/find/FindInput.tsx b/src/components/find/FindInput.tsx index d0cb03e..094985e 100644 --- a/src/components/find/FindInput.tsx +++ b/src/components/find/FindInput.tsx @@ -1,10 +1,10 @@ import React, { useState } from 'react' -import style from './findInputStyle' +import inputStyle from './findInputStyle' import { MentionsInput, Mention } from 'react-mentions' import { searchPeople } from '@/handlers/api/people.handler'; import mentionStyle from './findMentionStyle'; -import { PERSON_THUBNAIL_PATH } from '@/config/routes'; -import Image from 'next/image'; +import classNames from './FindInput.module.css'; + interface FindInputProps { onSearch: (query: string) => void; @@ -26,13 +26,8 @@ export default function FindInput({ onSearch }: FindInputProps) { { if (e.key === 'Enter') { onSearch(query); @@ -41,14 +36,13 @@ export default function FindInput({ onSearch }: FindInputProps) { onChange={(e) => setQuery(e.target.value)}> ( -
- +
{highlightedDisplay.display}
)} diff --git a/src/components/find/findInputStyle.ts b/src/components/find/findInputStyle.ts index 9e6a587..4d44afe 100644 --- a/src/components/find/findInputStyle.ts +++ b/src/components/find/findInputStyle.ts @@ -1,37 +1,42 @@ const findInputStyle = { control: { - backgroundColor: '#fff', - fontSize: 14, + backgroundColor: 'hsl(var(--input))', + fontSize: 20, fontWeight: 'normal', + outline: 'none', + borderRadius: '15px', + }, - '&singleLine': { - display: 'inline-block', + // display: 'inline-block', + width: '100%', highlighter: { - padding: '10px', - border: '2px inset transparent', + padding: '10px 15px', + border: 'none', + outline: 'none', }, input: { - width: "100%", - padding: '10px', - borderRadius: '4px', - border: '1px solid #e0e0e0', + padding: '10px 15px', + border: 'none', + outline: 'none', }, }, suggestions: { + list: { - backgroundColor: 'white', - border: '1px solid rgba(0,0,0,0.15)', + backgroundColor: 'hsl(var(--background))', fontSize: 14, + border: '1px solid hsl(var(--border))', + overflow: 'hidden', }, item: { padding: '5px 15px', - borderBottom: '1px solid rgba(0,0,0,0.15)', + border: 'none', '&focused': { - backgroundColor: '#cee4e5', + backgroundColor: 'hsl(var(--chart-2))', }, }, }, diff --git a/src/components/find/findMentionStyle.ts b/src/components/find/findMentionStyle.ts index 802b1e4..721bc59 100644 --- a/src/components/find/findMentionStyle.ts +++ b/src/components/find/findMentionStyle.ts @@ -1,3 +1,4 @@ export default { - backgroundColor: '#cee4e5', -} \ No newline at end of file + backgroundColor: 'hsla(var(--chart-2) / 0.3)', + position: 'relative', +} diff --git a/src/components/layouts/PageLayout.tsx b/src/components/layouts/PageLayout.tsx index fb22e9c..16a3e52 100644 --- a/src/components/layouts/PageLayout.tsx +++ b/src/components/layouts/PageLayout.tsx @@ -23,11 +23,11 @@ export default function PageLayout({ children, className, title }: IProps) { : children; return ( -
+
{header}
([]); const [loading, setLoading] = useState(false); + const slides = useMemo( + () => + assets.map((asset) => ({ + src: ASSET_PREVIEW_PATH(asset.id), + width: 1000, + height: 1000, + })), + [assets] + ); + + const handleSearch = (query: string) => { setQuery(query); setLoading(true); @@ -42,6 +59,9 @@ export default function FindPage() {

Example: Sunset photos from last week. Use @ to search for photos of a specific person.

+

+ Power tools uses Google Gemini only for parsing your query. None of your data is sent to Gemini. +

} else if (assets.length === 0) { @@ -50,23 +70,37 @@ export default function FindPage() {
} return ( -
- {assets.map((asset) => ( -
- {asset.id} -
- ))} -
+ <> + = 0} + index={index} + close={() => setIndex(-1)} + /> +
+ {assets.map((asset, idx) => ( +
+ + Open in Immich + + {asset.id} setIndex(idx)} + /> +
+ ))} +
+ ) } @@ -74,25 +108,24 @@ export default function FindPage() {
{geminiEnabled ? ( -
-
- -
- {renderContent()} -
+ <> +
+ +
+ {renderContent()} + ) : ( -
- +
+

Google Gemini is not enabled

Currently, the Power Tools Find is relying on Google Gemini for parsing the query. Please enable Gemini by adding GEMINI_API_KEY in the .env file.

-

- - Power tools uses Gemini only for parsing your query. None of your data is sent to Gemini. -

+

+ Power tools uses Google Gemini only for parsing your query. None of your data is sent to Gemini. +

)} diff --git a/src/styles/globals.scss b/src/styles/globals.scss index 08b7916..f8be68f 100644 --- a/src/styles/globals.scss +++ b/src/styles/globals.scss @@ -31,7 +31,6 @@ --chart-3: 197 37% 24%; --chart-4: 43 74% 66%; --chart-5: 27 87% 67%; - } .dark { @@ -88,3 +87,4 @@ --chart-5: 340 75% 55%; } } +