-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
435 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.grid { | ||
display: grid; | ||
grid-template-rows: auto auto 1fr; | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/content/app/tools/vep/state/vep-form/vepFormSelectors.ts
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,20 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { RootState } from 'src/store'; | ||
|
||
export const getSelectedSpecies = (state: RootState) => | ||
state.vep.vepForm.selectedSpecies; |
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,46 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
|
||
import type { CommittedItem } from 'src/content/app/species-selector/types/committedItem'; | ||
|
||
type VepSelectedSpecies = Omit<CommittedItem, 'isEnabled'>; | ||
|
||
export type VepFormState = { | ||
selectedSpecies: VepSelectedSpecies | null; | ||
}; | ||
|
||
export const initialState: VepFormState = { | ||
selectedSpecies: null | ||
}; | ||
|
||
const vepFormSlice = createSlice({ | ||
name: 'vep-form', | ||
initialState, | ||
reducers: { | ||
setSelectedSpecies: ( | ||
state, | ||
action: PayloadAction<{ species: VepSelectedSpecies }> | ||
) => { | ||
state.selectedSpecies = action.payload.species; | ||
} | ||
} | ||
}); | ||
|
||
export const { setSelectedSpecies } = vepFormSlice.actions; | ||
|
||
export default vepFormSlice.reducer; |
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,23 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { combineReducers } from 'redux'; | ||
|
||
import vepFormReducer from './vep-form/vepFormSlice'; | ||
|
||
export default combineReducers({ | ||
vepForm: vepFormReducer | ||
}); |
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
3 changes: 3 additions & 0 deletions
3
...nt/app/tools/vep/views/vep-form/vep-form-species-section/VepFormSpeciesSection.module.css
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,3 @@ | ||
.commonName { | ||
font-weight: var(--font-weight-bold); | ||
} |
71 changes: 71 additions & 0 deletions
71
src/content/app/tools/vep/views/vep-form/vep-form-species-section/VepFormSpeciesSection.tsx
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,71 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Link } from 'react-router-dom'; | ||
|
||
import * as urlFor from 'src/shared/helpers/urlHelper'; | ||
|
||
import { useAppSelector } from 'src/store'; | ||
|
||
import { getSelectedSpecies } from 'src/content/app/tools/vep/state/vep-form/vepFormSelectors'; | ||
|
||
import { | ||
ScientificName, | ||
AssemblyName | ||
} from 'src/shared/components/species-name-parts'; | ||
import PlusButton from 'src/shared/components/plus-button/PlusButton'; | ||
import TextButton from 'src/shared/components/text-button/TextButton'; | ||
|
||
import styles from './VepFormSpeciesSection.module.css'; | ||
|
||
/** | ||
* TODO: Consider the following | ||
* The component below displays a species label after a species has been selected for VEP analysis. | ||
* - Is this going to be a recurring pattern of displaying species info outside of tables? | ||
* - Does it need to show the type information for the selected assembly (is reference, population)? | ||
* - Does it need to consider user's selection of species info display (as chosen in species manager) | ||
* The answer may justify exxtracting this into a reusable component. | ||
*/ | ||
|
||
const vepSpeciesSelectorUrl = urlFor.vepSpeciesSelector(); | ||
|
||
export const VepFormSpecies = (props: { className?: string }) => { | ||
const selectedSpecies = useAppSelector(getSelectedSpecies); | ||
|
||
if (!selectedSpecies) { | ||
return <Link to={vepSpeciesSelectorUrl}>Select a species / assembly</Link>; | ||
} | ||
|
||
return ( | ||
<div className={props.className}> | ||
{selectedSpecies.common_name && ( | ||
<span className={styles.commonName}>{selectedSpecies.common_name}</span> | ||
)} | ||
{!selectedSpecies.common_name && <ScientificName {...selectedSpecies} />}{' '} | ||
<AssemblyName {...selectedSpecies} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export const VepSpeciesSelectorNavButton = (props: { className?: string }) => { | ||
const selectedSpecies = useAppSelector(getSelectedSpecies); | ||
|
||
return ( | ||
<Link to={vepSpeciesSelectorUrl} className={props.className}> | ||
{!selectedSpecies ? <PlusButton /> : <TextButton>Change</TextButton>} | ||
</Link> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
src/content/app/tools/vep/views/vep-species-selector/VepSpeciesSelector.module.css
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,29 @@ | ||
.grid { | ||
display: grid; | ||
grid-template-rows: auto auto 1fr; | ||
margin-left: var(--global-padding-left); | ||
height: 100%; | ||
} | ||
|
||
.tableContainer { | ||
overflow: auto; | ||
padding-bottom: var(--global-padding-bottom); | ||
} | ||
|
||
/* Question to consider: is the top section of a species selector | ||
a sufficiently stable and repeatable component | ||
to be extracted into a shared component? | ||
Note: so far, the top section in vep species selector | ||
does not have a filter element in the design. | ||
We will see if we will need to bring it in. | ||
*/ | ||
.topSection { | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: 32px; | ||
} | ||
|
||
.loader { | ||
margin-top: 40px; | ||
margin-left: 60px; | ||
} |
Oops, something went wrong.