diff --git a/web/components/feed/category-selector.tsx b/web/components/feed/category-selector.tsx deleted file mode 100644 index a39f7402..00000000 --- a/web/components/feed/category-selector.tsx +++ /dev/null @@ -1,167 +0,0 @@ -import clsx from 'clsx' -import { PencilIcon } from '@heroicons/react/outline' -import { union, difference } from 'lodash' - -import { Row } from '../layout/row' -import { CATEGORIES, category, CATEGORY_LIST } from '../../../common/categories' -import { Modal } from '../layout/modal' -import { Col } from '../layout/col' -import { useState } from 'react' -import { updateUser, User } from 'web/lib/firebase/users' -import { Checkbox } from '../checkbox' -import { track } from 'web/lib/service/analytics' - -export function CategorySelector(props: { - category: string - setCategory: (category: string) => void - className?: string -}) { - const { className, category, setCategory } = props - - return ( - -
- { - setCategory('all') - }} - /> - - { - setCategory('following') - }} - /> - - {CATEGORY_LIST.map((cat) => ( - { - setCategory(cat) - }} - /> - ))} - - ) -} - -function CategoryButton(props: { - category: string - isFollowed: boolean - toggle: () => void - className?: string -}) { - const { toggle, category, isFollowed, className } = props - - return ( -
- {category} -
- ) -} - -export function EditCategoriesButton(props: { - user: User - className?: string -}) { - const { user, className } = props - const [isOpen, setIsOpen] = useState(false) - - return ( -
{ - setIsOpen(true) - track('edit categories button') - }} - > - - Categories - -
- ) -} - -function CategorySelectorModal(props: { - user: User - isOpen: boolean - setIsOpen: (isOpen: boolean) => void -}) { - const { user, isOpen, setIsOpen } = props - const followedCategories = - user?.followedCategories === undefined - ? CATEGORY_LIST - : user.followedCategories - - const selectAll = - user.followedCategories === undefined || - followedCategories.length < CATEGORY_LIST.length - - return ( - - - - - {CATEGORY_LIST.map((cat) => ( - { - updateUser(user.id, { - followedCategories: checked - ? difference(followedCategories, [cat]) - : union([cat], followedCategories), - }) - }} - /> - ))} - - - - ) -} diff --git a/web/components/tags-input.tsx b/web/components/tags-input.tsx deleted file mode 100644 index dd8a2f1d..00000000 --- a/web/components/tags-input.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import clsx from 'clsx' -import { useState } from 'react' -import { parseWordsAsTags } from 'common/util/parse' -import { Contract, updateContract } from 'web/lib/firebase/contracts' -import { Col } from './layout/col' -import { Row } from './layout/row' -import { TagsList } from './tags-list' -import { MAX_TAG_LENGTH } from 'common/contract' - -export function TagsInput(props: { contract: Contract; className?: string }) { - const { contract, className } = props - const { tags } = contract - - const [tagText, setTagText] = useState('') - const newTags = parseWordsAsTags(`${tags.join(' ')} ${tagText}`) - - const [isSubmitting, setIsSubmitting] = useState(false) - - const updateTags = async () => { - setIsSubmitting(true) - await updateContract(contract.id, { - tags: newTags, - lowercaseTags: newTags.map((tag) => tag.toLowerCase()), - }) - setIsSubmitting(false) - setTagText('') - } - - return ( - - - - - setTagText(e.target.value || '')} - onKeyDown={(e) => { - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault() - updateTags() - } - }} - /> - - - - ) -} diff --git a/web/components/tags-list.tsx b/web/components/tags-list.tsx deleted file mode 100644 index a13bcd35..00000000 --- a/web/components/tags-list.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import clsx from 'clsx' -import { CATEGORIES, category } from '../../common/categories' -import { Col } from './layout/col' - -import { Row } from './layout/row' -import { SiteLink } from './site-link' - -function Hashtag(props: { tag: string; noLink?: boolean }) { - const { tag, noLink } = props - const category = CATEGORIES[tag.replace('#', '').toLowerCase() as category] - - const body = ( -
- {category ? '#' + category : tag} -
- ) - - if (noLink) return body - return ( - - {body} - - ) -} - -export function TagsList(props: { - tags: string[] - className?: string - noLink?: boolean - noLabel?: boolean - label?: string -}) { - const { tags, className, noLink, noLabel, label } = props - return ( - - {!noLabel &&
{label || 'Tags'}
} - {tags.map((tag) => ( - - ))} -
- ) -} - -export function FoldTag(props: { fold: { slug: string; name: string } }) { - const { fold } = props - const { slug, name } = fold - - return ( - -
- {name} -
-
- ) -} - -export function FoldTagList(props: { - folds: { slug: string; name: string }[] - noLabel?: boolean - className?: string -}) { - const { folds, noLabel, className } = props - return ( - - {!noLabel &&
Communities
} - - {folds.length > 0 && ( - <> - {folds.map((fold) => ( - - ))} - - )} - - - ) -}