Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: converts SearchResults to typescript #1619

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/js/components/SearchResults/HighlightedResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux';
import { getMahankoshTooltipAttributes } from '../MahankoshTooltip/util';
import { getVisraamClass } from '../../util';

interface IHighlightedSearchResultProps {
interface Props {
children: React.ReactChildren;
darkMode: boolean;
highlightIndex: string[];
Expand All @@ -14,16 +14,16 @@ interface IHighlightedSearchResultProps {
mahankoshIndex?: number;
onMouseOver?: (word: string, index: number) => void;
isShowMahankoshTooltip: boolean;
};
}

const HighlightedSearchResult: React.FC<IHighlightedSearchResultProps> = ({
const HighlightedSearchResult = ({
children,
highlightIndex,
visraams,
mahankoshIndex = -1,
onMouseOver,
isShowMahankoshTooltip,
}) => {
}: Props) => {
const darkMode = useSelector(state => state.darkMode);
const mahankoshTooltipAttributes = useMemo(() => {
if (isShowMahankoshTooltip) {
Expand Down
49 changes: 0 additions & 49 deletions src/js/components/SearchResults/SearchResults.js

This file was deleted.

51 changes: 51 additions & 0 deletions src/js/components/SearchResults/SearchResults.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from 'react';
import cx from 'classnames';

import SearchResult from './Result';
import { SEARCH_TYPES, SOURCES } from '@/constants';
import { getVerseId } from '@/util/api/shabad';
import { IShabad } from '@/types';

type Source = keyof typeof SOURCES;

interface Props {
shabads: IShabad[],
q: string,
type: number,
source: Source,
translationLanguages: string[],
transliterationLanguages: string[],
larivaarAssist: boolean,
larivaar: boolean,
unicode: boolean,
fontSize: number,
fontFamily: string,
}

export const SearchResults = (props: Props) => {

const { shabads, type, ...rest } = props;

const searchResultsClassName = cx({
'search-results-display': true,
'english-translation-search': type === SEARCH_TYPES.ENGLISH_WORD,
'main-letter-search': type === SEARCH_TYPES.MAIN_LETTERS
});

return (
<ul className={searchResultsClassName}>
{
shabads.map(shabad => {
return (
<SearchResult
key={getVerseId(shabad)}
type={type}
shabad={shabad}
{...rest} />
);
})
}
</ul>
);
}

4 changes: 2 additions & 2 deletions src/js/pages/Search/Layout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable react/prop-types */
import React from 'react';
import PropTypes from 'prop-types';
import { Link, Redirect, withRouter } from 'react-router-dom';
import { Redirect, withRouter } from 'react-router-dom';
import { connect } from 'react-redux';

import Pagination from '../../components/Pagination';
Expand All @@ -25,7 +26,6 @@ class Layout extends React.PureComponent {
static propTypes = {
pages: PropTypes.array,
offset: PropTypes.number,
...SearchResults.propTypes,
};

render() {
Expand Down