-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathVFolderNodeIdenticon.tsx
More file actions
54 lines (50 loc) · 1.33 KB
/
VFolderNodeIdenticon.tsx
File metadata and controls
54 lines (50 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
@license
Copyright (c) 2015-2026 Lablup Inc. All rights reserved.
*/
import { VFolderNodeIdenticonFragment$key } from '../__generated__/VFolderNodeIdenticonFragment.graphql';
import { createAvatar } from '@dicebear/core';
import * as shapes from '@dicebear/shapes';
import { theme } from 'antd';
import React from 'react';
import { graphql, useFragment } from 'react-relay';
interface VFolderNodeIdenticonProps {
vfolderNodeIdenticonFrgmt: VFolderNodeIdenticonFragment$key;
style?: React.CSSProperties;
}
const VFolderNodeIdenticon: React.FC<VFolderNodeIdenticonProps> = ({
vfolderNodeIdenticonFrgmt,
style,
}) => {
const { token } = theme.useToken();
const vfolder = useFragment(
graphql`
fragment VFolderNodeIdenticonFragment on VirtualFolderNode {
id
}
`,
vfolderNodeIdenticonFrgmt,
);
return (
<img
draggable={false}
onDragStart={(e) => e.preventDefault()}
style={{
borderRadius: '0.25em',
width: '1em',
height: '1em',
borderWidth: 0.5,
borderStyle: 'solid',
borderColor: token.colorBorder,
userSelect: 'none',
...style,
}}
src={createAvatar(shapes, {
seed: vfolder?.id,
shape3: [],
})?.toDataUri()}
alt="VFolder Identicon"
/>
);
};
export default VFolderNodeIdenticon;