diff --git a/common/src/constants.ts b/common/src/constants.ts index 9bab04a5..3f54ca89 100644 --- a/common/src/constants.ts +++ b/common/src/constants.ts @@ -18,3 +18,5 @@ export const formLink = "https://forms.gle/tKnXUMAbEreMK6FC6" export const pStyle = "mt-1 text-gray-800 dark:text-white whitespace-pre-line"; export const IS_MAINTENANCE = false; // set to true to enable maintenance mode banner + +export const MIN_BIO_LENGTH = 300; diff --git a/web/components/bio/editable-bio.tsx b/web/components/bio/editable-bio.tsx index 45eaf470..ca02adb4 100644 --- a/web/components/bio/editable-bio.tsx +++ b/web/components/bio/editable-bio.tsx @@ -1,16 +1,17 @@ -import { JSONContent } from '@tiptap/core' -import { MAX_DESCRIPTION_LENGTH } from 'common/envs/constants' -import { Profile } from 'common/love/profile' -import { tryCatch } from 'common/util/try-catch' -import { Button } from 'web/components/buttons/button' -import { Col } from 'web/components/layout/col' -import { Row } from 'web/components/layout/row' -import { TextEditor, useTextEditor } from 'web/components/widgets/editor' -import { updateProfile } from 'web/lib/api' -import { track } from 'web/lib/service/analytics' -import React, {useState} from "react"; +import {JSONContent} from '@tiptap/core' +import {MAX_DESCRIPTION_LENGTH} from 'common/envs/constants' +import {Profile} from 'common/love/profile' +import {tryCatch} from 'common/util/try-catch' +import {Button} from 'web/components/buttons/button' +import {Col} from 'web/components/layout/col' +import {Row} from 'web/components/layout/row' +import {TextEditor, useTextEditor} from 'web/components/widgets/editor' +import {updateProfile} from 'web/lib/api' +import {track} from 'web/lib/service/analytics' +import React, {useEffect, useState} from "react"; import ReactMarkdown from "react-markdown"; import Link from "next/link" +import {MIN_BIO_LENGTH} from "common/constants"; const placeHolder = "Tell us about yourself — and what you're looking for!"; @@ -23,10 +24,6 @@ Write a clear and engaging bio to help others understand who you are and the con - Optional: romantic preferences, lifestyle habits, and conversation starters ` -export function CharLimitText() { - return
Profiles with fewer than 250 characters will be hidden by default from the profile grid — write a meaningful bio so others can find you through keyword search and connect intentionally.
-} - export function BioTips() { const [showMoreInfo, setShowMoreInfo] = useState(false) @@ -62,18 +59,15 @@ export function EditableBio(props: { onSave: () => void onCancel?: () => void }) { - const { profile, onCancel, onSave } = props - const editor = useTextEditor({ - max: MAX_DESCRIPTION_LENGTH, - defaultValue: (profile.bio as JSONContent) ?? '', - placeholder: placeHolder, - }) + const {profile, onCancel, onSave} = props + const [editor, setEditor] = useState{charLength} / 250
*/} ) } + +interface BaseBioProps { + defaultValue?: any + onBlur?: (editor: any) => void + onEditor?: (editor: any) => void +} + +export function BaseBio({defaultValue, onBlur, onEditor}: BaseBioProps) { + const editor = useTextEditor({ + // extensions: [StarterKit], + max: MAX_DESCRIPTION_LENGTH, + defaultValue: defaultValue, + placeholder: placeHolder, + }) + const textLength = editor?.getText().length ?? 0 + + useEffect(() => { + onEditor?.(editor) + }, [editor, onEditor]) + + return ( ++ Write {MIN_BIO_LENGTH - textLength} more {MIN_BIO_LENGTH - textLength === 1 ? 'character' : 'characters'} so + others can find you through keyword + search and connect intentionally. +
+ } +