From 35a0327387d1fd985ed8bca9969ef9861f07effb Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Tue, 28 Dec 2021 10:35:46 +0100 Subject: [PATCH] Added quick actions + some styling fixes --- CHANGELOG.md | 1 + .../components/Header/Header.tsx | 2 +- .../components/Header/Searchbox.tsx | 8 ++-- .../components/Header/Sorting.tsx | 2 +- .../components/Media/Item.tsx | 48 +++++++++++++++++-- .../components/Media/MediaHeaderTop.tsx | 4 +- .../components/Media/QuickAction.tsx | 19 ++++++++ .../components/Menu/MenuItem.tsx | 2 +- .../components/Menu/MenuItems.tsx | 2 +- 9 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 src/dashboardWebView/components/Media/QuickAction.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e245164..e7324f8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### 🎨 Enhancements - Fixing the spinner which overlaps the global navigation bar +- Quick actions added for media files (edit, delete, insert markdown, insert snippet) - [#199](https://github.com/estruyf/vscode-front-matter/issues/199): Search media files in the currently selected folder - [#211](https://github.com/estruyf/vscode-front-matter/issues/211): Replace text selection on media inserts - [#212](https://github.com/estruyf/vscode-front-matter/issues/212): Create folder watchers for content folders. When new content gets created, the dashboard updates. diff --git a/src/dashboardWebView/components/Header/Header.tsx b/src/dashboardWebView/components/Header/Header.tsx index 8afbb253..028f5f2d 100644 --- a/src/dashboardWebView/components/Header/Header.tsx +++ b/src/dashboardWebView/components/Header/Header.tsx @@ -105,7 +105,7 @@ export const Header: React.FunctionComponent = ({totalPages, folde -
+
diff --git a/src/dashboardWebView/components/Header/Searchbox.tsx b/src/dashboardWebView/components/Header/Searchbox.tsx index a9840a80..3e088732 100644 --- a/src/dashboardWebView/components/Header/Searchbox.tsx +++ b/src/dashboardWebView/components/Header/Searchbox.tsx @@ -4,9 +4,11 @@ import { useRecoilState } from 'recoil'; import { useDebounce } from '../../../hooks/useDebounce'; import { SearchAtom } from '../../state'; -export interface ISearchboxProps {} +export interface ISearchboxProps { + placeholder?: string; +} -export const Searchbox: React.FunctionComponent = ({}: React.PropsWithChildren) => { +export const Searchbox: React.FunctionComponent = ({placeholder}: React.PropsWithChildren) => { const [ value, setValue ] = React.useState(''); const [ debounceSearchValue, setDebounceValue ] = useRecoilState(SearchAtom); const debounceSearch = useDebounce(value, 500); @@ -38,7 +40,7 @@ export const Searchbox: React.FunctionComponent = ({}: React.Pr type="search" name="search" className={`block w-full py-2 pl-10 pr-3 sm:text-sm bg-white dark:bg-vulcan-300 border border-gray-300 dark:border-vulcan-100 text-vulcan-500 dark:text-whisper-500 placeholder-gray-400 dark:placeholder-whisper-800 focus:outline-none`} - placeholder="Search" + placeholder={placeholder || "Search"} value={value} onChange={handleChange} /> diff --git a/src/dashboardWebView/components/Header/Sorting.tsx b/src/dashboardWebView/components/Header/Sorting.tsx index d5d4d9f8..4e35c6f5 100644 --- a/src/dashboardWebView/components/Header/Sorting.tsx +++ b/src/dashboardWebView/components/Header/Sorting.tsx @@ -78,7 +78,7 @@ export const Sorting: React.FunctionComponent = ({disableCustomSo key={option.id} title={option.title || option.name} value={option} - isCurrent={option.id === crntSorting?.id} + isCurrent={option.id === crntSort.id} onClick={(value) => updateSorting(value)} /> ))} diff --git a/src/dashboardWebView/components/Media/Item.tsx b/src/dashboardWebView/components/Media/Item.tsx index 044fd57f..1a0e8c3b 100644 --- a/src/dashboardWebView/components/Media/Item.tsx +++ b/src/dashboardWebView/components/Media/Item.tsx @@ -1,6 +1,6 @@ import { Messenger } from '@estruyf/vscode/dist/client'; import { Menu } from '@headlessui/react'; -import {PhotographIcon} from '@heroicons/react/outline'; +import {ArchiveIcon, ClipboardIcon, CodeIcon, PhotographIcon, PlusIcon} from '@heroicons/react/outline'; import { basename, dirname } from 'path'; import * as React from 'react'; import { useEffect } from 'react'; @@ -15,6 +15,7 @@ import { MenuItem, MenuItems } from '../Menu'; import { Alert } from '../Modals/Alert'; import { Metadata } from '../Modals/Metadata'; import { MenuButton } from './MenuButton' +import { QuickAction } from './QuickAction'; export interface IItemProps { media: MediaInfo; @@ -206,11 +207,50 @@ export const Item: React.FunctionComponent = ({media}: React.PropsWi
-
- +
+ +
+ { + viewData?.data?.filePath ? ( + <> + + + + { + (viewData?.data?.position && settings?.mediaSnippet && settings?.mediaSnippet.length > 0) && ( + + + ) + } + + ) : ( + <> + + + + + + + ) + } +
+ + - + = ({} return (