From 3ba517a787fce091fbfc532a505007a860a59d2a Mon Sep 17 00:00:00 2001 From: ElpisHelle Date: Wed, 7 Jun 2023 16:01:58 +0100 Subject: [PATCH] feat: implement user collaboration features (#1221) --- components/atoms/Textarea/text-area.tsx | 28 ++- .../CollaborationCard/collaboration-card.tsx | 43 +++-- .../contributor-highlight-card.tsx | 28 ++- .../contributor-profile-header.tsx | 177 ++++++++++++++---- .../HighlightInput/highlight-input-form.tsx | 28 +-- .../collaboration-requests-wrapper.tsx | 72 +++++++ .../contributor-profile-page.tsx | 2 + .../contributor-profile-tab.tsx | 122 ++++++------ lib/hooks/useUserCollaborations.ts | 84 +++++++++ next-types.d.ts | 14 ++ .../molecules/collaboration-card.stories.tsx | 4 +- .../collaboration-summary-card.stories.tsx | 21 ++- 12 files changed, 468 insertions(+), 155 deletions(-) create mode 100644 components/organisms/CollaborationRequestWrapper/collaboration-requests-wrapper.tsx create mode 100644 lib/hooks/useUserCollaborations.ts diff --git a/components/atoms/Textarea/text-area.tsx b/components/atoms/Textarea/text-area.tsx index d4a6c65..3a09dcc 100644 --- a/components/atoms/Textarea/text-area.tsx +++ b/components/atoms/Textarea/text-area.tsx @@ -1,16 +1,34 @@ -import * as React from "react"; +import React, { ChangeEvent, useRef } from "react"; import clsx from "clsx"; -interface TextareaProps extends React.TextareaHTMLAttributes {} +interface TextareaProps extends React.TextareaHTMLAttributes { + defaultRow?: number; + onChangeText?: (value: string) => void; +} + +const Textarea = React.forwardRef(({ className, onChangeText, ...props }, ref) => { + const textareaRef = useRef(null); + const autoGrowTextarea = () => { + const textarea = textareaRef.current; + if (textarea) { + textarea.style.height = "auto"; + textarea.style.height = `${textarea.scrollHeight}px`; + } + }; + + const handleInputChange = (event: ChangeEvent) => { + onChangeText?.(event.target.value); + autoGrowTextarea(); + }; -const Textarea = React.forwardRef(({ className, ...props }, ref) => { return (