Skip to content

Commit 627f2ad

Browse files
committed
Facets customisation - #11
1 parent ee13781 commit 627f2ad

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ To show some examples and/or enable the Rfam search, use:
3939
/>
4040
```
4141

42+
If you want to hide one specific facet, use:
43+
```
44+
<rnacentral-sequence-search
45+
databases='["miRBase"]'
46+
hideFacet='["has_conserved_structure"]'
47+
/>
48+
```
49+
50+
You can hide any facet - ` "rna_type", "TAXONOMY", "expert_db", "qc_warning_found", "has_go_annotations",
51+
"has_conserved_structure", "has_genomic_coordinates" `
52+
4253
For a minimal example, see [index.html](./index.html). For an Rfam example, see [rfam.html](./rfam.html).
4354

4455
To change the layout, you will need to edit this file: [index.scss](./src/index.scss)

src/app.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class RNAcentralSequenceSearch extends HTMLElement {
3232
const databases = JSON.parse(this.attributes.databases.nodeValue);
3333
const examples = JSON.parse(this.attributes.examples ? this.attributes.examples.nodeValue : null);
3434
const rfam = JSON.parse(this.attributes.rfam ? this.attributes.rfam.nodeValue : null);
35+
const hideFacet = JSON.parse(this.attributes.hideFacet ? this.attributes.hideFacet.nodeValue : null);
3536

3637
// render React
3738
ReactDOM.render([
@@ -44,7 +45,7 @@ class RNAcentralSequenceSearch extends HTMLElement {
4445
<style key={customStyles} dangerouslySetInnerHTML={{__html: customStyles}}/>,
4546
<body key='body'>
4647
<Provider key='provider' store={store}>
47-
<SequenceSearch databases={databases} examples={examples} rfam={rfam}/>
48+
<SequenceSearch databases={databases} examples={examples} rfam={rfam} hideFacet={hideFacet}/>
4849
</Provider>
4950
</body>
5051
],

src/containers/SequenceSearch/components/Results/components/Facets.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class Facets extends React.Component {
3636
}
3737

3838
render() {
39+
let showFacet = this.props.hideFacet ? this.props.facets.filter(facet => !this.props.hideFacet.includes(facet.id)) : this.props.facets;
40+
3941
return (
4042
<div className="small-12 medium-2 medium-pull-10 columns">
4143
<label>Sort by:
@@ -52,7 +54,7 @@ class Facets extends React.Component {
5254
</label>
5355
<section>
5456
<div>
55-
{ this.props.facets.map(facet => this.renderFacet(facet)) }
57+
{ showFacet.map(facet => this.renderFacet(facet)) }
5658
</div>
5759
{
5860
this.props.textSearchError &&

src/containers/SequenceSearch/components/Results/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class Results extends React.Component {
9393
toggleFacet={ this.toggleFacet }
9494
ordering={ this.props.ordering }
9595
textSearchError={ this.props.textSearchError }
96+
hideFacet={ this.props.hideFacet}
9697
/> : ''}
9798
</div>
9899
]

src/containers/SequenceSearch/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SequenceSearch extends React.Component {
1414
render() {
1515
return [
1616
<SearchForm key={`searchForm`} databases={this.props.databases} examples={this.props.examples}/>,
17-
<Results key={`results`} rfam={this.props.rfam}/>
17+
<Results key={`results`} rfam={this.props.rfam} hideFacet={this.props.hideFacet}/>
1818
]
1919
}
2020
}

0 commit comments

Comments
 (0)