From 64113f48f1f23ff6039e19c8fbefbfef87e7d9d3 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 16 Sep 2022 20:48:01 +0800 Subject: [PATCH] client: simple template card usage --- .../src/components/template/card/index.tsx | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/packages/client/src/components/template/card/index.tsx b/packages/client/src/components/template/card/index.tsx index 86b365ef..d5fe8bdb 100644 --- a/packages/client/src/components/template/card/index.tsx +++ b/packages/client/src/components/template/card/index.tsx @@ -21,6 +21,17 @@ export interface IProps { onClosePreview?: () => void; } +const bodyStyle = { + overflow: 'auto', +}; +const titleContainerStyle = { + marginBottom: 12, + whiteSpace: 'nowrap', + textOverflow: 'ellipsis', + overflow: 'hidden', +} as React.CSSProperties; +const flexStyle = { display: 'flex' }; + export const TemplateCard: React.FC = ({ template, onClick, @@ -35,26 +46,35 @@ export const TemplateCard: React.FC = ({ Router.push(`/template/${template.id}/`); }, [template]); + const cancel = useCallback(() => { + toggleVisible(false); + onClosePreview && onClosePreview(); + }, [toggleVisible, onClosePreview]); + + const preview = useCallback(() => { + toggleVisible(true); + onOpenPreview && onOpenPreview(); + }, [toggleVisible, onOpenPreview]); + + const useTemplate = useCallback(() => { + onClick && onClick(template.id); + }, [onClick, template.id]); + return ( <> { - toggleVisible(false); - onClosePreview && onClosePreview(); - }} + onCancel={cancel} footer={null} fullScreen > -
+
@@ -68,14 +88,7 @@ export const TemplateCard: React.FC = ({
-
+
{template.title}
@@ -92,28 +105,16 @@ export const TemplateCard: React.FC = ({
-
+
已使用 {template.usageAmount}次
- - {onClick && ( - - )}