Skip to content

Commit a0fa232

Browse files
authored
feat(FilePreview): add file preview to landing (#524)
* feat(FilePreview): add file preview to landing * feat(FilePreview): add file preview to landing
1 parent b5a6ae5 commit a0fa232

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {Link, Xmark} from '@gravity-ui/icons';
2+
import {FilePreview} from '@gravity-ui/uikit';
3+
import type {FilePreviewProps} from '@gravity-ui/uikit';
4+
5+
type FilePreviewComponentProps = Omit<FilePreviewProps, 'className'>;
6+
7+
export const FilePreviewComponent = (props: FilePreviewComponentProps) => {
8+
const {selected, imageSrc, description, view = 'default'} = props;
9+
10+
const file = {name: 'my-file.docs', type: 'text/docs'} as File;
11+
12+
if (view === 'default') {
13+
const actions = [
14+
{icon: <Link width={14} height={14} />, title: 'Link', onClick: () => {}},
15+
{icon: <Xmark width={14} height={14} />, title: 'Close', onClick: () => {}},
16+
];
17+
18+
return (
19+
<FilePreview
20+
file={file}
21+
onClick={() => {}}
22+
selected={selected}
23+
imageSrc={imageSrc}
24+
description={description}
25+
view="default"
26+
actions={actions}
27+
/>
28+
);
29+
}
30+
31+
return (
32+
<FilePreview
33+
file={file}
34+
onClick={() => {}}
35+
selected={selected}
36+
imageSrc={imageSrc}
37+
description={description}
38+
view="compact"
39+
/>
40+
);
41+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import dynamic from 'next/dynamic';
2+
3+
import {Repos} from '../../../../types/common';
4+
import {getGithubUrl, getReadmeUrl, mappingOptions} from '../../utils';
5+
6+
const getterOptions = {repoName: Repos.Uikit, componentName: 'FilePreview'};
7+
8+
export const filePreviewConfig = {
9+
id: 'file-preview',
10+
title: 'FilePreview',
11+
githubUrl: getGithubUrl(getterOptions),
12+
isSupportRTL: true,
13+
content: {
14+
readmeUrl: getReadmeUrl(getterOptions),
15+
},
16+
sandbox: {
17+
component: dynamic(() =>
18+
import('./FilePreviewComponent').then((mod) => mod.FilePreviewComponent),
19+
),
20+
props: {
21+
view: {
22+
type: 'radioButton',
23+
values: mappingOptions(['default', 'compact']),
24+
defaultValue: 'default',
25+
},
26+
selected: {
27+
type: 'switch',
28+
defaultValue: false,
29+
},
30+
imageSrc: {
31+
type: 'input',
32+
},
33+
description: {
34+
type: 'input',
35+
},
36+
},
37+
},
38+
};

src/content/components/uikit/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {checkboxConfig} from './Checkbox';
1515
import {disclosureConfig} from './Disclosure';
1616
import {dividerConfig} from './Divider';
1717
import {dropdownMenuConfig} from './DropdownMenu';
18+
import {filePreviewConfig} from './FilePreview';
1819
import {helpMarkConfig} from './HelpMark';
1920
import {hotkeyConfig} from './Hotkey';
2021
import {iconConfig} from './Icon';
@@ -105,6 +106,7 @@ const uikitComponents: Component[] = [
105106
stepperConfig,
106107
helpMarkConfig,
107108
hotkeyConfig,
109+
filePreviewConfig,
108110
];
109111

110112
export const uikit: Lib = {

0 commit comments

Comments
 (0)