From 296bd7d1cb37f9527f6f0bdcac37975896c19df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Fri, 27 Sep 2019 14:32:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Switch=20Description=20to=20use?= =?UTF-8?q?=20useOvermind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Project/Description/Description.tsx | 116 +++++++++--------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/Description/Description.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/Description/Description.tsx index 9b6bba4cbf9..c8123174f39 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/Description/Description.tsx +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/Description/Description.tsx @@ -1,70 +1,68 @@ -import React, { useState } from 'react'; -import { inject, hooksObserver } from 'app/componentConnectors'; +import { ENTER } from '@codesandbox/common/lib/utils/keycodes'; +import React, { FunctionComponent, useState } from 'react'; + +import { useOvermind } from 'app/overmind'; import { WorkspaceInputContainer } from '../../elements'; + import { EditPen } from '../elements'; + import { SandboxDescription } from './elements'; -interface IDescriptionProps { +type Props = { editable: boolean; - store: any; - signals: any; -} - -export const Description = inject('store', 'signals')( - hooksObserver( - ({ - editable, - signals: { - workspace: { sandboxInfoUpdated, valueChanged }, +}; +export const Description: FunctionComponent = ({ editable }) => { + const { + actions: { + workspace: { sandboxInfoUpdated, valueChanged }, + }, + state: { + workspace: { + project: { description }, }, - store: { - workspace: { - project: { description }, - }, - }, - }: IDescriptionProps) => { - const [editing, setEditing] = useState(false); + }, + } = useOvermind(); + const [editing, setEditing] = useState(false); + + const onKeyDown = (event: React.KeyboardEvent) => { + if (event.keyCode === ENTER && !event.shiftKey) { + event.preventDefault(); + event.stopPropagation(); + sandboxInfoUpdated(); + setEditing(false); + } + }; - const onKeyDown = (event: React.KeyboardEvent) => { - if (event.keyCode === 13 && !event.shiftKey) { - event.preventDefault(); - event.stopPropagation(); + return editing ? ( + +