Skip to content

Commit

Permalink
Merge pull request #4 from collective/buttons-radio-widget
Browse files Browse the repository at this point in the history
chg: used buttons instead of radio
  • Loading branch information
nzambello authored Sep 30, 2020
2 parents b5bcc55 + f3eeb26 commit 76b7a05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/widget/RadioWidget.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { Button } from 'semantic-ui-react';
import { FormFieldWrapper } from '@plone/volto/components';
import cx from 'classnames';
import './radio_widget.css';

const RadioWidget = ({
Expand Down Expand Up @@ -29,17 +31,19 @@ const RadioWidget = ({
>
<div className="radio-widget">
{valueList.map((opt) => (
<div className="radio-button" key={opt.value}>
<input
type="radio"
name={id}
id={id + opt.value}
value={opt.value}
checked={opt.value === value}
onChange={(e) => onChange(id, e.target.value)}
/>
<label htmlFor={id + opt.value}>{opt.label}</label>
</div>
<Button
key={opt.value}
id={id + opt.value}
className={cx('radio-button', { selected: opt.value === value })}
disabled={opt.value === value}
size="mini"
onClick={(e) => {
e.preventDefault();
onChange(id, opt.value);
}}
>
{opt.label}
</Button>
))}
</div>
</FormFieldWrapper>
Expand Down
6 changes: 6 additions & 0 deletions src/widget/radio_widget.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.radio-widget {
display: flex;
flex-wrap: wrap;
align-items: center;
}

.radio-widget .radio-button {
margin: 0.5rem 0;
}
Expand Down

0 comments on commit 76b7a05

Please sign in to comment.