From b0c8b2378be8cdce1e84df62a6cb8811d6280dc2 Mon Sep 17 00:00:00 2001 From: Katalina Okano Date: Mon, 5 Jul 2021 21:35:53 -0500 Subject: [PATCH] add databinding for editor actions and message --- .../atoms/text-input/TextInput.tsx | 17 +++++++-- .../organisms/app-shell/AppShell.styled.tsx | 4 +- .../organisms/app-shell/AppShell.tsx | 5 ++- .../organisms/editor-shell/EditorShell.tsx | 37 ++++++++++++++++--- .../organisms/masthead/Masthead.styled.tsx | 2 +- .../organisms/masthead/Secondary.tsx | 6 ++- .../design-system/templates/editor/Editor.tsx | 2 +- 7 files changed, 57 insertions(+), 16 deletions(-) diff --git a/packages/design-system/atoms/text-input/TextInput.tsx b/packages/design-system/atoms/text-input/TextInput.tsx index 2abf17c..9bfbec3 100644 --- a/packages/design-system/atoms/text-input/TextInput.tsx +++ b/packages/design-system/atoms/text-input/TextInput.tsx @@ -94,18 +94,27 @@ const StyledTextarea = styled.textarea` export const MultilineTextInput = ( props: TextInputProps & { rows?: number } ) => { - const { ...rest } = props; + const { children, ...rest } = props; const [value, setValue] = React.useState(String(props.value)); - const rows = Math.min(10, Math.max(props.rows || 2, value.split(/\r?\n/).length)); + const rows = React.useMemo( + () => Math.min(10, Math.max(props.rows || 2, value.split(/\r?\n/).length)), + [value] + ); + + React.useEffect(() => { + setValue(String(props.value)); + }, [props.value]); + return ( { setValue(eventData.target.value); props.onChange?.(eventData); }} - /> + > + {value} + ); }; diff --git a/packages/design-system/organisms/app-shell/AppShell.styled.tsx b/packages/design-system/organisms/app-shell/AppShell.styled.tsx index 9ff0c68..bc0b6bb 100644 --- a/packages/design-system/organisms/app-shell/AppShell.styled.tsx +++ b/packages/design-system/organisms/app-shell/AppShell.styled.tsx @@ -2,9 +2,9 @@ import { palette } from '@roleypoly/design-system/atoms/colors'; import { fontCSS } from '@roleypoly/design-system/atoms/fonts'; import styled, { createGlobalStyle } from 'styled-components'; -export const Content = styled.div<{ small?: boolean }>` +export const Content = styled.div<{ small?: boolean; double?: boolean }>` margin: 0 auto; - margin-top: 50px; + margin-top: ${(props) => (props.double ? '100px' : '50px')}; width: ${(props) => (props.small ? '960px' : '1024px')}; max-width: 98vw; max-height: calc(100vh - 50px); diff --git a/packages/design-system/organisms/app-shell/AppShell.tsx b/packages/design-system/organisms/app-shell/AppShell.tsx index 2e348cd..f19e2d5 100644 --- a/packages/design-system/organisms/app-shell/AppShell.tsx +++ b/packages/design-system/organisms/app-shell/AppShell.tsx @@ -11,6 +11,7 @@ export type AppShellProps = { user?: DiscordUser; showFooter?: boolean; small?: boolean; + double?: boolean; activeGuildId?: string | null; guilds?: GuildSlug[]; recentGuilds?: string[]; @@ -56,7 +57,9 @@ export const AppShell = (props: AppShellProps) => ( )} <> - {props.children} + + {props.children} + {props.showFooter &&