-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d21b2f
commit bff0cec
Showing
9 changed files
with
125 additions
and
47 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 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
47 changes: 47 additions & 0 deletions
47
packages/jdm-editor/src/components/function/function-library-item.tsx
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,47 @@ | ||
import { ExportOutlined, PlusOutlined } from '@ant-design/icons'; | ||
import { Button, Tooltip, Typography } from 'antd'; | ||
import React, { useMemo } from 'react'; | ||
|
||
import typeScriptIcon from '../../assets/typescript.svg?inline'; | ||
import type { FunctionLibrary } from './helpers/libs'; | ||
|
||
type FunctionLibraryItemProps = { | ||
lib: FunctionLibrary; | ||
onImport?: () => void; | ||
editorValue?: string; | ||
}; | ||
|
||
export const FunctionLibraryItem: React.FC<FunctionLibraryItemProps> = ({ lib, onImport, editorValue }) => { | ||
const canImport = useMemo(() => { | ||
if (!editorValue) { | ||
return true; | ||
} | ||
|
||
return !editorValue.includes(`from "${lib.name}"`) && !editorValue.includes(`from '${lib.name}'`); | ||
}, [lib.name, editorValue]); | ||
|
||
return ( | ||
<div key={lib.name} className='grl-function__libraries__item'> | ||
<img alt='TypeScript Library' src={typeScriptIcon} height={18} /> | ||
<Typography.Text strong>{lib.name}</Typography.Text> | ||
<Typography.Text type='secondary' style={{ fontSize: 12, marginTop: 1.5 }}> | ||
{lib.tagline} | ||
</Typography.Text> | ||
<div className='grl-function__libraries__item__actions'> | ||
<Tooltip title='Import library' placement='bottomLeft'> | ||
<Button type='text' size='small' icon={<PlusOutlined />} disabled={!canImport} onClick={onImport} /> | ||
</Tooltip> | ||
<Tooltip title='Go to documentation' placement='bottomLeft'> | ||
<Button | ||
type='text' | ||
size='small' | ||
icon={<ExportOutlined />} | ||
href={lib.documentationUrl} | ||
target='_blank' | ||
disabled={!lib.documentationUrl} | ||
/> | ||
</Tooltip> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './function'; | ||
export { FunctionDebuggerLog } from './function-debugger-log'; | ||
export { FunctionLibraryItem } from './function-library-item'; |
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
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