-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.tsx
More file actions
27 lines (21 loc) · 994 Bytes
/
index.tsx
File metadata and controls
27 lines (21 loc) · 994 Bytes
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
import { classes } from '@tomic/react';
import React from 'react';
import { NewBookmarkButton } from './NewBookmarkButton';
import { NewInstanceButtonProps } from './NewInstanceButtonProps';
import { NewInstanceButtonDefault } from './NewInstanceButtonDefault';
import { useSettings } from '../../helpers/AppSettings';
type InstanceButton = (props: NewInstanceButtonProps) => JSX.Element;
/** If your New Instance button requires custom logic, such as a custom dialog */
const classMap = new Map<string, InstanceButton>([
[classes.bookmark, NewBookmarkButton],
]);
/** A button for creating a new instance of some thing */
export default function NewInstanceButton(
props: NewInstanceButtonProps,
): JSX.Element {
const { klass, parent } = props;
const { drive } = useSettings();
const Comp = classMap.get(klass) ?? NewInstanceButtonDefault;
return <Comp {...props} parent={parent ?? drive} />;
}
export { useDefaultNewInstanceHandler } from './useDefaultNewInstanceHandler';