mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 11:52:44 +00:00
Render tags as "write" or "read"
Tags are now either "readTag" or "writeTag", with the former being a div with the tag value and the latter a text input with the value. Minor class name change in LESS.
This commit is contained in:
@@ -270,7 +270,7 @@
|
|||||||
&:last-child { border-radius : 0 0.5em 0.5em 0; }
|
&:last-child { border-radius : 0 0.5em 0.5em 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
.tag {
|
||||||
padding : 0.3em;
|
padding : 0.3em;
|
||||||
margin : 2px;
|
margin : 2px;
|
||||||
font-size : 0.9em;
|
font-size : 0.9em;
|
||||||
|
|||||||
@@ -7,9 +7,15 @@ const TagInput = ({unique = true, values = [], ...props})=>{
|
|||||||
const [temporaryValue, setTemporaryValue] = useState('');
|
const [temporaryValue, setTemporaryValue] = useState('');
|
||||||
const [valueContext, setValueContext] = useState(values.map((value)=>({ value: value, editing : false })));
|
const [valueContext, setValueContext] = useState(values.map((value)=>({ value: value, editing : false })));
|
||||||
|
|
||||||
const tagElement = (value)=>{
|
const readTag = (value)=>{
|
||||||
return (
|
return (
|
||||||
<div className={`badge`}>{value}</div>
|
<div className={`tag`}>{value}</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const writeTag = (value)=>{
|
||||||
|
return (
|
||||||
|
<input type='text' value={value} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,13 +23,16 @@ const TagInput = ({unique = true, values = [], ...props})=>{
|
|||||||
<div className='field'>
|
<div className='field'>
|
||||||
|
|
||||||
<label>{props.label}</label>
|
<label>{props.label}</label>
|
||||||
{Object.values(valueContext).map((context, i)=>{ return context.editing ? tagElement('editing') : tagElement(context.value) })}
|
<div className='list'>
|
||||||
|
|
||||||
<input type='text'
|
{Object.values(valueContext).map((context, i)=>{ return context.editing ? writeTag(context.value) : readTag(context.value) })}
|
||||||
className={`value`}
|
|
||||||
placeholder={props.placeholder}
|
<input type='text'
|
||||||
value={temporaryValue}
|
className={`value`}
|
||||||
onChange={(e)=>setTemporaryValue(e.target.value)} />
|
placeholder={props.placeholder}
|
||||||
|
value={temporaryValue}
|
||||||
|
onChange={(e)=>setTemporaryValue(e.target.value)} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user