Skip to content

Commit

Permalink
Merge pull request #120 from Duke-MatSci/#97_Header_tab_panel
Browse files Browse the repository at this point in the history
#97 Header Tab Panel
  • Loading branch information
aswallace authored Feb 22, 2022
2 parents ba64ce1 + 04313ed commit 58984e3
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 5 deletions.
31 changes: 31 additions & 0 deletions app/src/assets/css/modules/_pages.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,37 @@
}

.explorer_page {
&_header {
margin: 5rem 10rem;
.md-tabs-navigation {
border-bottom: 1px solid $primary !important;
}
.md-tabs.md-theme-default .md-tabs-indicator {
background-color: $primary-white !important;
height: 0.5rem;
bottom: -0.25rem;
}
.md-tab-nav-button {
background-color: $primary !important;
padding: 0.5rem;
transition: background-color 0.2s;
border: 1px solid $primary !important;
border-radius: 0.7rem 0.7rem 0 0;
margin-right: 1rem;
height: max-content;
.md-button-content{
color: $primary-white !important;
font-size: 1.4rem;
}
}
.md-active {
background-color: transparent !important;
border-bottom-color: $primary-white !important;
.md-button-content {
color: $primary !important;
}
}
}
&_footer {
color: $primary;
margin-top: 5rem;
Expand Down
4 changes: 0 additions & 4 deletions app/src/components/explorer/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
</div>

<div class="md-toolbar-section-end">
<div class="u_margin-top-small u_width--small u_margin-right-small" v-if="searchEnabled">
<input type="text" class="form__input form__input--flat" placeholder="Searching..." name="search" id="search" v-model="searchTerm" />
<label htmlFor="search" class="form__label form__input--flat-label">Searching...</label>
</div>
<md-badge id="header-badge" class="md-primary" md-content="12">
<md-avatar>
<img src="@/assets/img/brinson.jpeg" alt="Avatar">
Expand Down
62 changes: 62 additions & 0 deletions app/src/components/explorer/SearchHeader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<div class="explorer_page_header">
<md-card style="padding:2rem; margin:2rem;">
<div class="search_box_form">
<div class="form__group search_box_form-item-1">
<input type="text" ref="search_input" class="form__input form__input--adjust" placeholder="Search" name="search" id="search" required v-model="searchWord" />
<label htmlFor="search" class="form__label search_box_form_label">Search</label>
</div>
<div class="form__group search_box_form-item-2">
<button type="submit" class="btn btn--primary btn--noradius search_box_form_btn">Search</button>
</div>
</div>
<div style="text-align:right"> Query "{{searchWord}}" found 12345 results </div>
</md-card>
<md-tabs class="btn--primary">
<md-tab :md-label="'Articles (' + articles + ')'" @click="setResultsTab('Articles')"></md-tab>
<md-tab :md-label="'Samples (' + samples + ')'" @click="setResultsTab('Samples')"></md-tab>
<md-tab :md-label="'Images (' + images + ')'" @click="setResultsTab('Images')"></md-tab>
<md-tab :md-label="'Charts (' + charts + ')'" @click="setResultsTab('Charts')"></md-tab>
<md-tab :md-label="'Materials (' + materials + ')'" @click="setResultsTab('Materials')"></md-tab>
<!-- <md-tab :md-label="'Other (' + other + ')'" @click="setResultsTab('Other')"></md-tab> -->
</md-tabs>
</div>
</template>
<script>
import { mapMutations } from 'vuex'
export default {
name: 'SearchHeader',
props: ['searchEnabled'],
computed: {
searchWord: {
get () {
return this.$store.getters['explorer/getSearchKeyword']
},
set (payload) {
return this.$store.commit('explorer/setSearchKeyword', payload)
}
},
images () {
return 0
},
samples () {
return 0
},
articles () {
return 0
},
charts () {
return 0
},
materials () {
return 0
}
// other () {
// return 0
// }
},
methods: {
...mapMutations('explorer', ['setResultsTab'])
}
}
</script>
5 changes: 4 additions & 1 deletion app/src/pages/explorer/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</div>
</div>
</div>
<search-header v-if="searchEnabled"/>
<div class="explorer_page_footer">
<span class="explorer_page_footer-text">&copy; 2022 MaterialsMine Project</span>
</div>
Expand All @@ -43,6 +44,7 @@
<script>
import { mapMutations } from 'vuex'
import FacetPanel from '@/components/explorer/Facet.vue'
import SearchHeader from '@/components/explorer/SearchHeader.vue'
export default {
name: 'ExplorerHome',
data () {
Expand All @@ -68,7 +70,8 @@ export default {
}
},
components: {
FacetPanel
FacetPanel,
SearchHeader
},
methods: {
...mapMutations('explorer', ['setSearching'])
Expand Down
3 changes: 3 additions & 0 deletions app/src/store/modules/explorer/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ export default {
menuVisible (state) {
return state.toggleMenuVisibility
},
getResultsTab (state) {
return state.resultsTab
},
getSearchKeyword (state) {
return state.searchKeyword
},
Expand Down
1 change: 1 addition & 0 deletions app/src/store/modules/explorer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
state () {
return {
toggleMenuVisibility: false,
resultsTab: '',
searchKeyword: '',
searching: false
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/store/modules/explorer/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ export default {
setMenuVisible (state) {
state.toggleMenuVisibility = !state.toggleMenuVisibility
},
setResultsTab (state, payload) {
state.resultsTab = payload
},
setSearchKeyword (state, payload) {
state.searchKeyword = payload
},
Expand Down
18 changes: 18 additions & 0 deletions app/tests/unit/components/explorer/SearchHeader.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import createWrapper from '../../../jest/script/wrapper'
import SearchHeader from '@/components/explorer/SearchHeader.vue'
describe('SearchHeader.vue', () => {
let wrapper
beforeEach(() => {
wrapper = createWrapper(SearchHeader, {}, true)
})
it('renders search bar', async () => {
expect.assertions(1)
const searchBar = wrapper.find('.search_box_form')
expect(searchBar.text()).toContain('Search')
})
it('renders header tabs correctly', async () => {
expect.assertions(1)
const headerTabs = wrapper.findAll('.md-tab')
expect(headerTabs.length).toBe(5)
})
})

0 comments on commit 58984e3

Please sign in to comment.