/** * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Sebastian Bittrich */ import * as React from 'react'; import {Button} from 'molstar/lib/mol-plugin-ui/controls/common'; export const DefaultExchanges = [ ['ALA', 'Alanine'], ['CYS', 'Cysteine'], ['ASP', 'Aspartic Acid'], ['GLU', 'Glutamic Acid'], ['PHE', 'Phenylalanine'], ['GLY', 'Glycine'], ['HIS', 'Histidine'], ['ILE', 'Isoleucine'], ['LYS', 'Lysine'], ['LEU', 'Leucine'], ['MET', 'Methionine'], ['ASN', 'Asparagine'], ['PRO', 'Proline'], ['GLN', 'Glutamine'], ['ARG', 'Arginine'], ['SER', 'Serine'], ['THR', 'Threonine'], ['VAL', 'Valine'], ['TRP', 'Tryptophan'], ['TYR', 'Tyrosine'], ['A', 'Adenosine'], ['C', 'Cytidine'], ['DA', 'Deoxyadenosine'], ['DC', 'Deoxycytidine'], ['DG', 'Deoxyguanosine'], ['G', ',Guanosine'], ['T', 'Thymidine'], ['U', 'Uridine'] ]; export class ExchangesControl extends React.PureComponent<{}, { exchanges: Set }> { state = { exchanges: new Set() } onClickSwatch = (e: React.MouseEvent) => { const tlc = e.currentTarget.getAttribute('data-id')!; if (this.state.exchanges.has(tlc)) { this.setState(({ exchanges }) => { const newExchanges = new Set(exchanges); newExchanges.delete(tlc); return { exchanges: newExchanges }; }); } else { this.setState(({ exchanges }) => ({ exchanges: new Set(exchanges).add(tlc) })); } } swatch() { // TODO it would be nice to only display relevant exchanges (amino acids for amino acids, nucleotides for nucl) // TODO update of isSelected style is delayed return
{DefaultExchanges.map(e => { const isSelected = this.state.exchanges.has(e[0]); const className = isSelected ? 'msp-control-current' : ''; return ; })}
; } render() { return <>
{this.swatch()}
; } }