Skip to content

Commit

Permalink
#144 separate components types
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonatai committed Jan 5, 2024
1 parent 31cdb36 commit 7ef1343
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 68 deletions.
8 changes: 4 additions & 4 deletions src/Hooks/useGenerateSearchEntries.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useEffect, useState } from 'react';

import { cleanedSearchData } from '../components/Search/generateSearchEntries';
import { ISpecification } from 'spock-react-types';
import { IGenerateSearchEntries } from 'spock-react/hooks-types';
import {
cleanedSearchData,
IMinimizedSummaryEntry,
ISearchEntry,
} from '../components/Search/generateSearchEntries';
import { ISpecification } from 'spock-react-types';
import { IGenerateSearchEntries } from 'spock-react/hooks-types';
} from 'spock-react/components/search-types';

export const useGenerateSearchEntries = (
props: IGenerateSearchEntries
Expand Down
8 changes: 2 additions & 6 deletions src/components/MainNav/MainNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ import { Link } from 'react-router-dom';
import { faBook, faHouseChimney } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { IMainNav } from 'spock-react/components/main-nav-types';
import * as config from '../../../environment.json';
import { useActiveLink } from '../../Hooks';
import GithubLogo from '../../assets/img/github-mark-white.png';
import { Search } from '../Search';
import { NavLink } from '../shared';
import { useActiveLink } from '../../Hooks';
import { ISummary } from 'spock-react-types';

interface IMainNav {
summary: ISummary;
}

export const MainNav = (props: IMainNav) => {
const { summary } = props;
Expand Down
7 changes: 7 additions & 0 deletions src/components/MainNav/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module 'spock-react/components/main-nav-types' {
import { ISummary } from 'spock-react-types';

export interface IMainNav {
summary: ISummary;
}
}
13 changes: 2 additions & 11 deletions src/components/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@ import { SearchButton } from './SearchButton';
import { SearchFooter } from './SearchFooter';
import { SearchHits } from './SearchHits';
import { SearchInput } from './SearchInput';
import { ISummary } from 'spock-react-types';
import { ISearch, ISearchHit } from 'spock-react/components/search-types';

export interface ISearchHit {
score: number;
key: string;
}

interface ISearchInput {
summary: ISummary;
}

export const Search = (props: ISearchInput): JSX.Element => {
export const Search = (props: ISearch): JSX.Element => {
const { summary } = props;

const dialog = useDialogState();
Expand Down
6 changes: 1 addition & 5 deletions src/components/Search/SearchButton/SearchButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import './styles.css';

import { DialogDisclosure } from 'reakit';
import { DialogStateReturn } from 'reakit/ts/Dialog/DialogState';

import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

interface ISearchButton {
dialog: DialogStateReturn;
}
import { ISearchButton } from 'spock-react/components/search-button-types';

export const SearchButton = (props: ISearchButton): JSX.Element => {
const { dialog } = props;
Expand Down
7 changes: 7 additions & 0 deletions src/components/Search/SearchButton/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module 'spock-react/components/search-button-types' {
import { DialogStateReturn } from 'reakit/ts/Dialog/DialogState';

interface ISearchButton {
dialog: DialogStateReturn;
}
}
11 changes: 1 addition & 10 deletions src/components/Search/SearchHits/SearchCard/SearchCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ import { Link } from 'react-router-dom';

import { faAngleRight } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { ISearchHit } from '../../Search';
import { IExecutedFeatures, ISpecification } from 'spock-react-types';

interface ISearchCard {
onClick: (e?: any) => void;
hit: ISearchHit;
spec?: ISpecification;
feature?: IExecutedFeatures;
}
import { ISearchCard } from 'spock-react/components/search-card-types';

export const SearchCard = (props: ISearchCard): JSX.Element => {
const { onClick, hit, spec, feature } = props;
Expand Down
11 changes: 11 additions & 0 deletions src/components/Search/SearchHits/SearchCard/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare module 'spock-react/components/search-card-types' {
import { IExecutedFeatures, ISpecification } from 'spock-react-types';
import { ISearchHit } from 'spock-react/components/search-types';

interface ISearchCard {
onClick: (e?: any) => void;
hit: ISearchHit;
spec?: ISpecification;
feature?: IExecutedFeatures;
}
}
12 changes: 1 addition & 11 deletions src/components/Search/SearchHits/SearchHits.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import './styles.css';

import { nanoid } from 'nanoid';
import { DialogStateReturn } from 'reakit/ts';

import { ISearchHit } from '../Search';
import { SearchCard } from './SearchCard';
import { ISummary } from 'spock-react-types';

interface ISearchHits {
searchHits: ISearchHit[] | null;
setSearchHits: (searchHits: ISearchHit[] | null) => void;
summary: ISummary;
setSearchInput: (input: string) => void;
dialog: DialogStateReturn;
}
import { ISearchHits } from 'spock-react/components/search-hits-types';

export const SearchHits = (props: ISearchHits): JSX.Element => {
const { searchHits, summary, setSearchHits, setSearchInput, dialog } =
Expand Down
13 changes: 13 additions & 0 deletions src/components/Search/SearchHits/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare module 'spock-react/components/search-hits-types' {
import { ISummary } from 'spock-react-types';
import { ISearchHit } from 'spock-react/components/search-types';
import { DialogStateReturn } from 'reakit/ts';

interface ISearchHits {
searchHits: ISearchHit[] | null;
setSearchHits: (searchHits: ISearchHit[] | null) => void;
summary: ISummary;
setSearchInput: (input: string) => void;
dialog: DialogStateReturn;
}
}
11 changes: 2 additions & 9 deletions src/components/Search/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ import { Input } from 'reakit';
import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { ISearchInput } from 'spock-react/components/search-input-types';
import { ISearchHit } from 'spock-react/components/search-types';
import { useGenerateSearchEntries } from '../../../Hooks/useGenerateSearchEntries';
import { getSearchScore } from '../getSearchScore';
import { ISearchHit } from '../Search';
import { ISummary } from 'spock-react-types';

interface ISearchInput {
summary: ISummary;
setSearchHits: (searchHits: ISearchHit[] | null) => void;
setSearchInput: (input: string) => void;
searchInput: string;
}

export const SearchInput = (props: ISearchInput): JSX.Element => {
const { summary, setSearchHits, setSearchInput, searchInput } = props;
Expand Down
11 changes: 11 additions & 0 deletions src/components/Search/SearchInput/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare module 'spock-react/components/search-input-types' {
import { ISummary } from 'spock-react-types';
import { ISearchHit } from 'spock-react/components/search-types';

interface ISearchInput {
summary: ISummary;
setSearchHits: (searchHits: ISearchHit[] | null) => void;
setSearchInput: (input: string) => void;
searchInput: string;
}
}
16 changes: 4 additions & 12 deletions src/components/Search/generateSearchEntries.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
export interface IMinimizedSummaryEntry {
className: string;
title: string;
narrative: string;
features: Array<{ id: string }>;
}

export interface ISearchEntry {
key: string;
href?: string;
keywords: string[];
}
import {
IMinimizedSummaryEntry,
ISearchEntry,
} from 'spock-react/components/search-types';

const fillWords = [
'the',
Expand Down
25 changes: 25 additions & 0 deletions src/components/Search/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
declare module 'spock-react/components/search-types' {
import { ISummary } from 'spock-react-types';

export interface ISearchHit {
score: number;
key: string;
}

interface ISearch {
summary: ISummary;
}

export interface IMinimizedSummaryEntry {
className: string;
title: string;
narrative: string;
features: Array<{ id: string }>;
}

export interface ISearchEntry {
key: string;
href?: string;
keywords: string[];
}
}

0 comments on commit 7ef1343

Please sign in to comment.