Skip to content
Closed
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
32 changes: 0 additions & 32 deletions packages/app/src/app/pages/Search/elements.js

This file was deleted.

38 changes: 38 additions & 0 deletions packages/app/src/app/pages/Search/elements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Row from '@codesandbox/common/lib/components/flex/Row';
import styled, { css } from 'styled-components';

import { Title as TitleBase } from 'app/components/Title';

export const Content = styled.div`
margin-top: 5%;
text-align: left;
color: white;
`;

export const Title = styled(TitleBase)`
${({ theme }) => css`
font-family: 'Poppins', sans-serif;
font-weight: 600;
font-size: 36px;
display: flex;
color: ${theme.lightText};
margin-bottom: 16px;
`};
`;

export const Main = styled(Row)`
display: grid;
grid-template-columns: 1fr 340px;
grid-gap: 24px;

@media (max-width: 768px) {
grid-template-columns: 1fr;
}
`;

export const Container = styled.div`
${({ theme }) => css`
background: ${theme.background5};
width: 100vw;
`};
`;
35 changes: 18 additions & 17 deletions packages/app/src/app/pages/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,47 @@ import {
ALGOLIA_APPLICATION_ID,
ALGOLIA_DEFAULT_INDEX,
} from '@codesandbox/common/lib/utils/config';
import { Helmet } from 'react-helmet';
import MaxWidth from '@codesandbox/common/lib/components/flex/MaxWidth';
import Margin from '@codesandbox/common/lib/components/spacing/Margin';
import { RouteComponentProps } from 'react-router-dom';
import qs from 'qs';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, {
FunctionComponent,
useCallback,
useEffect,
useRef,
useState,
} from 'react';
import { Helmet } from 'react-helmet';
import {
Configure,
InstantSearch,
SearchBox,
PoweredBy,
Configure,
SearchBox,
} from 'react-instantsearch/dom';
import { History, Location } from 'history';

import { Navigation } from 'app/pages/common/Navigation';
import { useOvermind } from 'app/overmind';
import { Navigation } from 'app/pages/common/Navigation';

import 'instantsearch.css/themes/reset.css';

import { Container, Content, Main, StyledTitle } from './elements';
import { Container, Content, Main, Title } from './elements';
import Filters from './Filters';
import Results from './Results';
import Styles from './search';

interface ISearchProps {
history: History;
location: Location;
}

const updateAfter = 700;

const createURL = state => `?${qs.stringify(state)}`;

const searchStateToUrl = (location, searchState) =>
searchState ? `${location.pathname}${createURL(searchState)}` : '';

const Search: React.FC<ISearchProps> = ({ history, location }) => {
type Props = RouteComponentProps;
const Search: FunctionComponent<Props> = ({ history, location }) => {
Comment on lines +42 to +43
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaraVieira Props are still present.

const {
actions: { searchMounted },
} = useOvermind();

const [searchState, setSearchState] = useState(
qs.parse(location.search.slice(1))
);
Expand Down Expand Up @@ -83,6 +84,7 @@ const Search: React.FC<ISearchProps> = ({ history, location }) => {
<Helmet>
<title>Search - CodeSandbox</title>
</Helmet>

<Styles />

<MaxWidth>
Expand All @@ -91,8 +93,8 @@ const Search: React.FC<ISearchProps> = ({ history, location }) => {

<Content>
<InstantSearch
appId={ALGOLIA_APPLICATION_ID}
apiKey={ALGOLIA_API_KEY}
appId={ALGOLIA_APPLICATION_ID}
createURL={createURL}
indexName={ALGOLIA_DEFAULT_INDEX}
onSearchStateChange={onSearchStateChange}
Expand All @@ -102,7 +104,7 @@ const Search: React.FC<ISearchProps> = ({ history, location }) => {

<Main alignItems="flex-start">
<div>
<StyledTitle>Search</StyledTitle>
<Title>Search</Title>

<PoweredBy />

Expand All @@ -124,5 +126,4 @@ const Search: React.FC<ISearchProps> = ({ history, location }) => {
);
};

// eslint-disable-next-line import/no-default-export
export default Search;
Loading