Newer
Older
import styled from 'styled-components';
import FeedbackComponent from './FeedbackComponent';
const MatchingContainer = styled.div`
border: 3px solid #f5f5f7;
margin-bottom: 30px;
padding: 10px;
`;
const QuestionWrapper = styled.div`
display: flex;
flex-direction: row;
`;
const InputsContainer = styled.div`
display: flex;
flex-direction: column;
`;
const StyledIconAction = styled(Icon)`
height: 24px;
width: 24px;
const CreateOptions = styled.div`
display: flex;
flex-direction: column;
ul {
display: flex;
flex-wrap: wrap;
flex-direction: row;
margin: 0;
padding: 0;
li {
list-style-type: none;
padding-right: 7px;
padding-bottom: 7px;
span {
background: #535e76;
color: white;
padding: 3px 3px 3px 10px;
border-radius: 12px;
}
buttton {
}
svg {
fill: white;
width: 16px;
height: 16px;
}
}
}
export default ({ node, view, getPos }) => {
const context = useContext(WaxContext);
const {
pmViews: { main },
} = context;
const [options, setOptions] = useState([]);
const addOptionRef = useRef(null);
const customProps = main.props.customValues;
const isEditable = main.props.editable(editable => {
return editable;
});
const readOnly = !isEditable;
const obj = { label: addOptionRef.current.value, key: uuidv4() };
setOptions(prevOptions => [...prevOptions, obj]);
const removeOption = key => {
setOptions(options.filter(option => option.key !== key));
};
return (
<MatchingWrapper>
<span>Matching</span>
<MatchingContainer className="matching">
<InputsContainer>
<Option>
<ContainerEditor getPos={getPos} node={node} view={view} />
<OptionArea>
<ul>
{options.map((option, index) => {
return (
<li key={option.key}>
<span>
{option.label}
<ActionButton
onClick={() => removeOption(option.key)}
type="button"
>
<StyledIconAction name="deleteOutlined" />
</ActionButton>
</span>
</li>
);
})}
</ul>
</OptionArea>
<AddOption>
<input placeholder="Add Option" ref={addOptionRef} type="text" />
<button onClick={addOption} type="button">
Add
</button>
</AddOption>
</CreateOptions>
)}