Skip to content
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

feat(FilePreview): add tooltip props for actions #174

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/FilePreview/FilePreviewAction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {ActionTooltip, Button, Icon, IconData} from '@gravity-ui/uikit';
import {ActionTooltip, ActionTooltipProps, Button, Icon, IconData} from '@gravity-ui/uikit';

export interface FilePreviewActionProps {
id?: string;
Expand All @@ -12,6 +12,7 @@ export interface FilePreviewActionProps {
extraProps?:
| React.ButtonHTMLAttributes<HTMLButtonElement>
| React.AnchorHTMLAttributes<HTMLAnchorElement>;
tooltipExtraProps?: Omit<ActionTooltipProps, 'id' | 'title' | 'children'>;
}

export function FilePreviewAction({
Expand All @@ -22,9 +23,10 @@ export function FilePreviewAction({
disabled,
onClick,
extraProps,
tooltipExtraProps,
}: FilePreviewActionProps) {
return (
<ActionTooltip id={id} title={title}>
<ActionTooltip id={id} title={title} {...tooltipExtraProps}>
<Button
onClick={onClick}
view="raised"
Expand Down
26 changes: 26 additions & 0 deletions src/components/FilePreview/__stories__/FilePreview.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,29 @@ const NoClickableTemplate: StoryFn<Omit<FilePreviewProps, 'actions'>> = (args) =
};

export const NoClickable = NoClickableTemplate.bind({});

const WithoutActionTooltipTemplate: StoryFn<Omit<FilePreviewProps, 'actions'>> = (args) => {
return (
<Flex gap={4}>
<FilePreview
{...args}
file={{name: 'Clicable without tooltip', type: 'text/docs'} as File}
onClick={() => {
window.open('https://disk.yandex.com', '_blank');
}}
actions={[
{
icon: Xmark,
onClick: () => alert('Are you sure you want to delete the file?'),
title: 'Close',
tooltipExtraProps: {
disabled: true,
},
},
]}
/>
</Flex>
);
};

export const WithoutActionTooltip = WithoutActionTooltipTemplate.bind({});
Loading