Meilleur rendu des resultats de recherche

pull/171/head
Mael 2018-02-21 15:53:45 +01:00
parent b5aa0c041b
commit 2e46639abb
2 changed files with 25 additions and 23 deletions

View File

@ -10,7 +10,10 @@
"engines": {
"node": ">=6.2.0 <10.0.0"
},
"browserslist": ["> 1% in FR", "not ie < 11"],
"browserslist": [
"> 1% in FR",
"not ie < 11"
],
"dependencies": {
"@babel/polyfill": "^7.0.0-beta.34",
"classnames": "^2.2.5",
@ -99,21 +102,13 @@
},
"scripts": {
"start": "node source/server.js",
"compile":
"NODE_ENV='production' webpack --config source/webpack.config.js",
"surge":
"npm run compile && surge --domain scientific-wish.surge.sh -p ./ && rm -rf dist/",
"test":
"mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\"",
"test-watch":
"mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\" --watch",
"test-meca":
"mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js test/mecanisms.test.js --watch",
"test-rules":
"mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js test/real-rules.test.js --watch",
"heroku-postbuild":
"npm install --dev && webpack --config source/webpack.config.js --progress",
"test-inversions":
"mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/inversion.test.js\" --watch"
"compile": "NODE_ENV='production' webpack --config source/webpack.config.js",
"surge": "npm run compile && surge --domain scientific-wish.surge.sh -p ./ && rm -rf dist/",
"test": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\"",
"test-watch": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\" --watch",
"test-meca": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js test/mecanisms.test.js --watch",
"test-rules": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js test/real-rules.test.js --watch",
"heroku-postbuild": "npm install --dev && webpack --config source/webpack.config.js --progress",
"test-inversions": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/inversion.test.js\" --watch"
}
}

View File

@ -44,7 +44,9 @@ export class SearchBar extends React.Component {
]
}
this.fuse = new Fuse(
rules.map(pick(['title', 'espace', 'description', 'name', 'dottedName'])),
rules.map(
pick(['title', 'espace', 'description', 'name', 'dottedName', 'ns'])
),
options
)
}
@ -55,11 +57,16 @@ export class SearchBar extends React.Component {
handleChange = selectedOption => {
this.setState({ selectedOption })
}
renderOption = option => (
<Highlighter
searchWords={[this.state.inputValue]}
textToHighlight={option.title}
/>
renderOption = ({ title, ns }) => (
<span>
<Highlighter
searchWords={[this.state.inputValue]}
textToHighlight={title}
/>
<span style={{ opacity: 0.6, fontSize: '80%', marginLeft: '.6em' }}>
{ns}
</span>
</span>
)
filterOptions = (options, filter) => this.fuse.search(filter)
render() {