add starting sound change rule for empty rules

This commit is contained in:
Sorrel Bri 2019-11-29 19:32:42 -08:00
parent 2f989364fa
commit 07100ccaa9
3 changed files with 5 additions and 4 deletions

View file

@ -10,7 +10,7 @@ const PhonoChangeApplier = () => {
const [ phonemes, setPhonemes ] = useState( const [ phonemes, setPhonemes ] = useState(
{ phoneme: [ 'feature' ] } { phoneme: [ 'feature' ] }
); );
const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ feature]>[+ new feature]/[]_[]']}]); const [ epochs, setEpochs ] = useState([{name: 'epoch 1', changes:['[+ feature]>[- feature]/_#']}]);
return ( return (
<div className="PhonoChangeApplier" data-testid="PhonoChangeApplier"> <div className="PhonoChangeApplier" data-testid="PhonoChangeApplier">

View file

@ -6,7 +6,7 @@ import SoundChangeSuite from './SoundChangeSuite';
const addEpoch = (e, props) => { const addEpoch = (e, props) => {
e.preventDefault() e.preventDefault()
let index = props.epochs.length + 1; let index = props.epochs.length + 1;
props.setEpochs([...props.epochs, {name: `epoch ${index}`, changes:['[+ feature]>[+ new feature]/[]_[]']}]) props.setEpochs([...props.epochs, {name: `epoch ${index}`, changes:['[+ feature]>[- feature]/_#']}])
} }

View file

@ -2,7 +2,8 @@ import React, { useState } from 'react';
import './SoundChangeSuite.scss'; import './SoundChangeSuite.scss';
const SoundChangeSuite = props => { const SoundChangeSuite = props => {
const [ epoch, setEpoch ] = useState(props.epoch ? props.epoch : {name:'', changes:['']}) const [ epoch, setEpoch ] = useState(props.epoch ? props.epoch : {name:'', changes:['']});
return ( return (
<div className="SoundChangeSuite" data-testid={`${epoch.name}_SoundChangeSuite`}> <div className="SoundChangeSuite" data-testid={`${epoch.name}_SoundChangeSuite`}>
<h4>{epoch.name}</h4> <h4>{epoch.name}</h4>
@ -10,7 +11,7 @@ const SoundChangeSuite = props => {
<textarea name="epoch" id="" cols="30" rows="1" value={epoch.name} onChange={e=>setEpoch({...epoch, name:e.target.value})} ></textarea> <textarea name="epoch" id="" cols="30" rows="1" value={epoch.name} onChange={e=>setEpoch({...epoch, name:e.target.value})} ></textarea>
<textarea name="changes" id="" cols="30" rows="10" <textarea name="changes" id="" cols="30" rows="10"
value={epoch.changes.join('\n')} value={epoch.changes.join('\n')}
onChange={e=>setEpoch({...epoch, changes:e.target.value.split(/\n/)})} onChange={e=>setEpoch({...epoch, changes:e.target.value.split(/\n/).map(change=>change === '' ? '[+ feature]>[- feature]/_#' : change)})}
></textarea> ></textarea>
</form> </form>
<form onSubmit={e=>props.removeEpoch(e, epoch.name)}> <form onSubmit={e=>props.removeEpoch(e, epoch.name)}>