-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
821 additions
and
198 deletions.
There are no files selected for viewing
234 changes: 166 additions & 68 deletions
234
build/assets/index-1194f5b5.js → build/assets/index-d57b3dfa.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/components/App/SideBar/Trending/BriefDescriptionModal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FC } from 'react' | ||
import styled from 'styled-components' | ||
import { BaseModal } from '~/components/Modal' | ||
import { Flex } from '~/components/common/Flex' | ||
import { Text } from '~/components/common/Text' | ||
import { useModal } from '~/stores/useModalStore' | ||
|
||
type Props = { | ||
text: string | ||
onClose: () => void | ||
} | ||
|
||
export const BriefDescription: FC<Props> = ({ text, onClose }) => { | ||
const { close } = useModal('briefDescription') | ||
|
||
const handleClose = () => { | ||
onClose() | ||
close() | ||
} | ||
|
||
return ( | ||
<BaseModal id="briefDescription" kind="regular" onClose={handleClose} preventOutsideClose> | ||
<Flex py={16}> | ||
<StyledText>{text}</StyledText> | ||
</Flex> | ||
</BaseModal> | ||
) | ||
} | ||
|
||
const StyledText = styled(Text)` | ||
font-size: 18px; | ||
font-weight: 400; | ||
font-family: 'Barlow'; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
192 changes: 192 additions & 0 deletions
192
...ponents/SourcesTableModal/SourcesView/Topics/MergeTopicModal/Title/Autocomplete/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
import { Divider, IconButton, InputBase, Paper, Popper } from '@mui/material' | ||
import clsx from 'clsx' | ||
import { debounce } from 'lodash' | ||
import React, { useEffect, useMemo, useRef, useState } from 'react' | ||
import { ClipLoader } from 'react-spinners' | ||
import styled from 'styled-components' | ||
import ClearIcon from '~/components/Icons/ClearIcon' | ||
import SearchIcon from '~/components/Icons/SearchIcon' | ||
import { ALPHABETICALLY } from '~/components/SourcesTableModal/SourcesView/constants' | ||
import { Flex } from '~/components/common/Flex' | ||
import { getTopicsData } from '~/network/fetchSourcesData' | ||
import { FetchTopicResponse, Topic } from '~/types' | ||
import { colors } from '~/utils/colors' | ||
|
||
type Props = { | ||
onSelect: (topic: Topic | null) => void | ||
selectedTopic: Topic | null | ||
} | ||
|
||
export const DropdownSearch: React.FC<Props> = ({ onSelect, selectedTopic }) => { | ||
const [isPopperOpen, setIsPopperOpen] = useState(false) | ||
const [search, setSearch] = useState('') | ||
const [options, setOptions] = useState<Topic[]>([]) | ||
const [optionsIsLoading, setOptionsIsLoading] = useState(false) | ||
const inputRef = useRef<HTMLFormElement>(null) | ||
|
||
useEffect(() => () => setOptions([]), [setOptions]) | ||
|
||
const handleSearch = async (val: string) => { | ||
const filters = { | ||
muted: 'False', | ||
sort_by: ALPHABETICALLY, | ||
search: val, | ||
skip: '0', | ||
limit: '1000', | ||
} | ||
|
||
setOptionsIsLoading(true) | ||
|
||
try { | ||
const responseData: FetchTopicResponse = await getTopicsData(filters) | ||
|
||
setOptions(responseData.data) | ||
} catch (error) { | ||
setOptions([]) | ||
} finally { | ||
setOptionsIsLoading(false) | ||
} | ||
} | ||
|
||
const debouncedSearch = useMemo(() => debounce(handleSearch, 300), []) | ||
|
||
const handleSelectChange = (val: Topic) => { | ||
onSelect(val) | ||
} | ||
|
||
const handleChange = (e: string) => { | ||
setSearch(e) | ||
|
||
if (!e) { | ||
setOptions([]) | ||
|
||
return | ||
} | ||
|
||
if (e.length > 2) { | ||
debouncedSearch(e) | ||
} | ||
} | ||
|
||
return selectedTopic ? ( | ||
<SelectedValue> | ||
<div className="value">{selectedTopic.topic}</div> | ||
<Flex className="icon" onClick={() => onSelect(null)}> | ||
<ClearIcon /> | ||
</Flex> | ||
</SelectedValue> | ||
) : ( | ||
<> | ||
<Paper | ||
ref={inputRef} | ||
component="form" | ||
onSubmit={(e) => e.preventDefault()} | ||
sx={{ p: '2px 4px', display: 'flex', alignItems: 'center', width: 200 }} | ||
> | ||
<InputBase | ||
inputProps={{ 'aria-label': 'search topic' }} | ||
onChange={(e) => handleChange(e.target.value)} | ||
onFocus={() => setIsPopperOpen(true)} | ||
placeholder="Search" | ||
size="small" | ||
sx={{ ml: 1, flex: 1 }} | ||
value={search} | ||
/> | ||
{search && ( | ||
<> | ||
<StyledButton aria-label="search" onClick={() => handleChange('')} type="button"> | ||
<ClearIcon /> | ||
</StyledButton> | ||
<Divider orientation="vertical" sx={{ height: 28, m: 0.5 }} /> | ||
</> | ||
)} | ||
<StyledButton aria-label="search" type="button"> | ||
{optionsIsLoading ? <ClipLoader color={colors.white} size={24} /> : <SearchIcon />} | ||
</StyledButton> | ||
</Paper> | ||
{inputRef.current && options.length ? ( | ||
<StyledPopover anchorEl={inputRef.current} open={isPopperOpen} placement="bottom"> | ||
<> | ||
{options.map((option) => ( | ||
<MenuItem | ||
key="option" | ||
className={clsx({ active: selectedTopic === option.ref_id })} | ||
onClick={() => handleSelectChange(option)} | ||
> | ||
{option.topic} | ||
</MenuItem> | ||
))} | ||
</> | ||
</StyledPopover> | ||
) : null} | ||
</> | ||
) | ||
} | ||
|
||
const MenuItem = styled(Flex).attrs({ | ||
direction: 'row', | ||
align: 'center', | ||
})` | ||
font-family: Barlow; | ||
font-size: 13px; | ||
font-style: normal; | ||
font-weight: 500; | ||
overflow: hidden; | ||
width: 200px; | ||
color: ${colors.GRAY3}; | ||
margin-bottom: 4px; | ||
cursor: pointer; | ||
&.active { | ||
color: ${colors.white}; | ||
} | ||
&:hover { | ||
color: ${colors.white}; | ||
} | ||
.icon { | ||
margin-right: 8px; | ||
width: 9px; | ||
font-size: 10px; | ||
} | ||
` | ||
|
||
const StyledPopover = styled(Popper)` | ||
&& { | ||
z-index: 99999; | ||
background: ${colors.BUTTON1}; | ||
min-width: 200px; | ||
padding: 16px; | ||
color: ${colors.GRAY3}; | ||
box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.2); | ||
border-radius: 6px; | ||
max-height: 200px; | ||
overflow: auto; | ||
} | ||
` | ||
|
||
const SelectedValue = styled(Flex).attrs({ | ||
direction: 'row', | ||
justify: 'flex-start', | ||
align: 'center', | ||
})` | ||
.value { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
.icon { | ||
margin-left: 8px; | ||
width: 20px; | ||
height: 20px; | ||
color: ${colors.white}; | ||
background: ${colors.primaryBlue}; | ||
border-radius: 50%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
} | ||
` | ||
|
||
const StyledButton = styled(IconButton)` | ||
font-size: 24px; | ||
` |
58 changes: 58 additions & 0 deletions
58
src/components/SourcesTableModal/SourcesView/Topics/MergeTopicModal/Title/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { FC } from 'react' | ||
import styled from 'styled-components' | ||
import { Flex } from '~/components/common/Flex' | ||
import { Text } from '~/components/common/Text' | ||
import { Topic } from '~/types' | ||
import { colors } from '~/utils/colors' | ||
import { DropdownSearch } from './Autocomplete' | ||
|
||
type Props = { | ||
from: string | ||
onSelect: (topic: Topic | null) => void | ||
selectedTopic: Topic | null | ||
} | ||
|
||
export const TitleEditor: FC<Props> = ({ from, onSelect, selectedTopic }) => ( | ||
<Flex> | ||
<Flex align="center" direction="row" justify="space-between" mb={18}> | ||
<Flex align="center" direction="row"> | ||
<StyledText>Merge topic</StyledText> | ||
</Flex> | ||
</Flex> | ||
|
||
<Content mb={12}> | ||
<SectionWrapper> | ||
<div className="label">From</div> | ||
<div>{from}</div> | ||
</SectionWrapper> | ||
<SectionWrapper ml={24}> | ||
<div className="label">To</div> | ||
<DropdownSearch onSelect={onSelect} selectedTopic={selectedTopic} /> | ||
</SectionWrapper> | ||
</Content> | ||
</Flex> | ||
) | ||
|
||
const StyledText = styled(Text)` | ||
font-size: 22px; | ||
font-weight: 600; | ||
font-family: 'Barlow'; | ||
` | ||
|
||
const Content = styled(Flex).attrs({ | ||
align: 'flex-start', | ||
direction: 'row', | ||
justify: 'flex-start', | ||
})` | ||
color: ${colors.white}; | ||
.label { | ||
margin-bottom: 8px; | ||
font-weight: 500; | ||
font-size: 14px; | ||
color: ${colors.GRAY3}; | ||
} | ||
` | ||
|
||
const SectionWrapper = styled(Flex)` | ||
flex: 1 1 100%; | ||
` |
Oops, something went wrong.