-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Bill2015/develop-resource-list-ui-change
Change the Resources display view UI
- Loading branch information
Showing
14 changed files
with
305 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import { useCallback } from 'react'; | ||
import { FcOpenedFolder } from 'react-icons/fc'; | ||
|
||
import { ResourceMutation } from '@api/resource'; | ||
|
||
import { TooltipActionIcon, TooltipActionIconProps } from './TooltipActionIcon'; | ||
|
||
export interface ActionFileIconProps extends Omit<TooltipActionIconProps, 'label'> { | ||
filePath: string | null; | ||
} | ||
|
||
/** | ||
* According URL host to determin which icon will be showing */ | ||
export function ActionFileIcon(props: ActionFileIconProps) { | ||
const { | ||
filePath, | ||
...actionIconProps | ||
} = props; | ||
|
||
const exporeFile = ResourceMutation.useExporeFile(); | ||
|
||
const handleExporeClick = useCallback(() => { | ||
if (filePath) { | ||
exporeFile.mutateAsync(filePath); | ||
} | ||
}, [exporeFile, filePath]); | ||
|
||
return ( | ||
<TooltipActionIcon | ||
label={`↖️ ${filePath}`} | ||
onClick={handleExporeClick} | ||
{...actionIconProps} | ||
> | ||
<FcOpenedFolder /> | ||
</TooltipActionIcon> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import { open } from '@tauri-apps/api/shell'; | ||
|
||
import { IconType } from 'react-icons'; | ||
import { FaYoutube } from 'react-icons/fa'; | ||
import { FaLink } from 'react-icons/fa6'; | ||
|
||
import { showNotification } from '@components/notification'; | ||
import { UrlHost } from '@declares/variables'; | ||
|
||
import classes from './ActionLinkIcon.module.scss'; | ||
import { TooltipActionIcon, TooltipActionIconProps } from './TooltipActionIcon'; | ||
|
||
const URL_ICON_MAPPER = new Map<string, IconType>(); | ||
URL_ICON_MAPPER.set(UrlHost.Youtube, FaYoutube); | ||
|
||
export interface ActionLinkIconProps extends Omit<TooltipActionIconProps, 'label'> { | ||
/** URLs */ | ||
url: { | ||
full: string; | ||
|
||
host: string; | ||
}; | ||
} | ||
|
||
/** | ||
* According URL host to determin which icon will be showing */ | ||
export function ActionLinkIcon(props: ActionLinkIconProps) { | ||
const { | ||
url, | ||
...actionIconProps | ||
} = props; | ||
|
||
const IconElement = (() => { | ||
if (URL_ICON_MAPPER.has(url.host)) { | ||
return URL_ICON_MAPPER.get(url.host)!; | ||
} | ||
// defualt icon | ||
return FaLink; | ||
})(); | ||
|
||
return ( | ||
<TooltipActionIcon | ||
label={`↖️ ${url.full}`} | ||
classNames={{ root: classes.ActionIconRoot }} | ||
onClick={() => { | ||
open(url.full) | ||
.catch(() => { | ||
showNotification('Invalid URL', url.full, 'error'); | ||
}); | ||
}} | ||
{...actionIconProps} | ||
> | ||
<IconElement /> | ||
</TooltipActionIcon> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.tooltip { | ||
background-color: var(--mantine-color-default-border); | ||
color: var(--mantine-color-text) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import { PropsWithChildren } from 'react'; | ||
|
||
import { ActionIcon, ActionIconProps, ElementProps, Tooltip, TooltipProps } from '@mantine/core'; | ||
|
||
import classes from './TooltipActionIcon.module.scss'; | ||
|
||
export interface TooltipActionIconProps extends ActionIconProps, ElementProps<'button', keyof ActionIconProps>, PropsWithChildren { | ||
tooltipProps?: TooltipProps & ElementProps<'div', keyof TooltipProps>; | ||
|
||
label: string; | ||
|
||
onTooltipChange?: (opened: boolean) => void; | ||
} | ||
|
||
/** | ||
* According URL host to determin which icon will be showing */ | ||
export function TooltipActionIcon(props: TooltipActionIconProps) { | ||
const { | ||
label, | ||
children, | ||
tooltipProps, | ||
onTooltipChange, | ||
...actionIconProps | ||
} = props; | ||
|
||
return ( | ||
<Tooltip | ||
withArrow | ||
label={label} | ||
classNames={{ tooltip: classes.tooltip }} | ||
offset={10} | ||
{...tooltipProps} | ||
> | ||
<ActionIcon | ||
classNames={{ root: classes.ActionIconRoot }} | ||
{...actionIconProps} | ||
onMouseEnter={() => onTooltipChange && onTooltipChange(true)} | ||
onMouseLeave={() => onTooltipChange && onTooltipChange(false)} | ||
> | ||
{children} | ||
</ActionIcon> | ||
</Tooltip> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './TooltipActionIcon'; | ||
export * from './ActionLinkIcon'; | ||
export * from './ActionFileIcon'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.