-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(archive-viewer): Add search (#1121)
* feat(archive-viewer): Add search * feat(archive-viewer): address comments * feat(archive-viewer): address comments * feat(archive-viewer): address comments
- Loading branch information
1 parent
8abfb53
commit 2897851
Showing
7 changed files
with
158 additions
and
24 deletions.
There are no files selected for viewing
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
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,24 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import './SearchBar.scss'; | ||
|
||
const SearchBar = ({ onSearch, searchQuery }) => { | ||
return ( | ||
<div className="bp-SearchBar"> | ||
<input | ||
aria-label={__('search')} | ||
onChange={({ currentTarget }) => onSearch(currentTarget.value)} | ||
placeholder={__('search_placeholder')} | ||
type="search" | ||
value={searchQuery} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
SearchBar.propTypes = { | ||
onSearch: PropTypes.func.isRequired, | ||
searchQuery: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default SearchBar; |
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,16 @@ | ||
@import '~box-ui-elements/es/styles/variables'; | ||
|
||
.bp-SearchBar { | ||
display: flex; | ||
flex: 0 0 70px; | ||
align-items: center; | ||
padding: 0 20px; | ||
background: $almost-white; | ||
border-bottom: 1px solid $bdl-gray-10; | ||
|
||
// override .be input[type='serach'] | ||
input[type='search'] { | ||
width: 100%; | ||
font: inherit; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import sinon from 'sinon'; | ||
import SearchBar from '../SearchBar'; | ||
|
||
const sandbox = sinon.sandbox.create(); | ||
let searchQuery; | ||
let onSearch; | ||
|
||
describe('lib/viewers/archive/SearchBar', () => { | ||
beforeEach(() => { | ||
searchQuery = 'test'; | ||
onSearch = sandbox.stub(); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.verifyAndRestore(); | ||
}); | ||
|
||
describe('render()', () => { | ||
it('should render correct components', () => { | ||
const component = shallow(<SearchBar onSearch={onSearch} searchQuery={searchQuery} />); | ||
|
||
expect(component.find('.bp-SearchBar').length).to.equal(1); | ||
expect(component.find('input').length).to.equal(1); | ||
}); | ||
}); | ||
}); |