From 526750887a25e12a9e10a25a12f58273d8a45007 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 1 Aug 2019 15:59:17 +0200 Subject: [PATCH] prototype filter sidebar --- client/src/routes/Search/Sidebar.module.scss | 37 +++++++ client/src/routes/Search/Sidebar.tsx | 65 ++++++++++++ .../index.module.scss} | 18 +++- .../index.test.tsx} | 6 +- .../routes/{Search.tsx => Search/index.tsx} | 98 +++++++------------ 5 files changed, 157 insertions(+), 67 deletions(-) create mode 100644 client/src/routes/Search/Sidebar.module.scss create mode 100644 client/src/routes/Search/Sidebar.tsx rename client/src/routes/{Search.module.scss => Search/index.module.scss} (63%) rename client/src/routes/{Search.test.tsx => Search/index.test.tsx} (88%) rename client/src/routes/{Search.tsx => Search/index.tsx} (66%) diff --git a/client/src/routes/Search/Sidebar.module.scss b/client/src/routes/Search/Sidebar.module.scss new file mode 100644 index 0000000..463bf10 --- /dev/null +++ b/client/src/routes/Search/Sidebar.module.scss @@ -0,0 +1,37 @@ +@import '../../styles/variables'; + +.sidebar { + @media (min-width: $break-point--medium) { + margin-top: $spacer * 1.1; + } + + > div:first-child { + label { + visibility: hidden; + } + } +} + +.filter { + // ul { + // padding-left: 0; + + // li:before { + // display: none; + // } + // } + + button { + text-align: left; + color: $brand-grey; + font-size: $font-size-small; + } +} + +.filterTitle { + font-size: $font-size-base; + color: $brand-grey-light; + margin-top: 0; + border-bottom: 1px solid $brand-grey-lighter; + padding-bottom: $spacer / 2; +} diff --git a/client/src/routes/Search/Sidebar.tsx b/client/src/routes/Search/Sidebar.tsx new file mode 100644 index 0000000..0b0d12c --- /dev/null +++ b/client/src/routes/Search/Sidebar.tsx @@ -0,0 +1,65 @@ +import React, { PureComponent } from 'react' +import Button from '../../components/atoms/Button' +import Input from '../../components/atoms/Form/Input' +import styles from './Sidebar.module.scss' +import data from '../../data/form-publish.json' + +export default class Sidebar extends PureComponent<{ + search: string + inputChange: any + category: string + license: string +}> { + public render() { + const { search, inputChange, category, license } = this.props + const { steps }: any = data + + return ( + + ) + } +} diff --git a/client/src/routes/Search.module.scss b/client/src/routes/Search/index.module.scss similarity index 63% rename from client/src/routes/Search.module.scss rename to client/src/routes/Search/index.module.scss index eccc96f..d738505 100644 --- a/client/src/routes/Search.module.scss +++ b/client/src/routes/Search/index.module.scss @@ -1,9 +1,19 @@ -@import '../styles/variables'; +@import '../../styles/variables'; + +.content { + display: grid; + grid-gap: $spacer * 2; + grid-template-columns: 1fr; + + @media (min-width: $break-point--medium) { + grid-template-columns: 1fr 3fr; + } +} .resultsTitle { color: $brand-grey-light; font-size: $font-size-h3; - margin-top: -($spacer / 2); + margin-top: 0; margin-bottom: $spacer; span { @@ -16,11 +26,11 @@ grid-template-columns: 1fr; grid-gap: $spacer; - @media (min-width: $break-point--small) { + @media (min-width: $break-point--medium) { grid-template-columns: repeat(2, 1fr); } - @media (min-width: $break-point--medium) { + @media (min-width: $break-point--large) { grid-template-columns: repeat(3, 1fr); } } diff --git a/client/src/routes/Search.test.tsx b/client/src/routes/Search/index.test.tsx similarity index 88% rename from client/src/routes/Search.test.tsx rename to client/src/routes/Search/index.test.tsx index 0541ac7..3e4b3b4 100644 --- a/client/src/routes/Search.test.tsx +++ b/client/src/routes/Search/index.test.tsx @@ -1,10 +1,10 @@ import React from 'react' import { render } from '@testing-library/react' -import Search from './Search' -import { User } from '../context' +import Search from '.' +import { User } from '../../context' import { createMemoryHistory } from 'history' import { BrowserRouter as Router } from 'react-router-dom' -import { userMockConnected } from '../../__mocks__/user-mock' +import { userMockConnected } from '../../../__mocks__/user-mock' const history = createMemoryHistory() diff --git a/client/src/routes/Search.tsx b/client/src/routes/Search/index.tsx similarity index 66% rename from client/src/routes/Search.tsx rename to client/src/routes/Search/index.tsx index a1e5f0c..62feeac 100644 --- a/client/src/routes/Search.tsx +++ b/client/src/routes/Search/index.tsx @@ -1,19 +1,17 @@ import React, { PureComponent, ChangeEvent } from 'react' -import Button from '../components/atoms/Button' -import Input from '../components/atoms/Form/Input' import { Link } from 'react-router-dom' import queryString from 'query-string' import { History, Location } from 'history' import { Logger } from '@oceanprotocol/squid' -import Spinner from '../components/atoms/Spinner' -import Route from '../components/templates/Route' -import { User } from '../context' -import AssetTeaser from '../components/molecules/AssetTeaser' -import Pagination from '../components/molecules/Pagination' -import styles from './Search.module.scss' -import Content from '../components/atoms/Content' -import withTracker from '../hoc/withTracker' -import data from '../data/form-publish.json' +import Spinner from '../../components/atoms/Spinner' +import Route from '../../components/templates/Route' +import { User } from '../../context' +import AssetTeaser from '../../components/molecules/AssetTeaser' +import Pagination from '../../components/molecules/Pagination' +import styles from './index.module.scss' +import Content from '../../components/atoms/Content' +import withTracker from '../../hoc/withTracker' +import Sidebar from './Sidebar' interface SearchProps { location: Location @@ -186,59 +184,39 @@ class Search extends PureComponent { public render() { const { totalResults, totalPages, currentPage } = this.state - const { steps }: any = data + return ( - - Search - - } - /> - - - {!this.state.isLoading && ( -

- {totalResults} results for{' '} - - {decodeURIComponent( - this.state.searchTerm || - this.state.searchCategories - )} - -

- )} - {this.renderResults()} +
+ - +
+ {!this.state.isLoading && ( +

+ {totalResults} results for{' '} + + {decodeURIComponent( + this.state.searchTerm || + this.state.searchCategories + )} + +

+ )} + {this.renderResults()} + + +
+
)