cloudflare / cf-ui

:gem: Cloudflare UI Framework
Other
1.29k stars 81 forks source link

feat(cf-component-radio): abstract children out of group #333

Closed koddsson closed 7 years ago

koddsson commented 7 years ago

BREAKING CHANGE: Changed the API that accepts radio options as props and rather accept the whole <Radio /> components as children. This allows us to pass in <Radio /> components that have different themes or even behave differently.

Before:

<RadioGroup
  value={this.state.radioValue}
  onChange={this.onRadioChange}
  options={[
    { label: 'Option 1', name: 'group-option-1', value: 'option1' },
    { label: 'Option 2', name: 'group-option-2', value: 'option2' }
  ]}
/>

After:

<RadioGroup value={this.state.radioValue} onChange={this.onRadioChange}>
  <RadioGroupItem
    label="Option 1"
    name="group-option-1"
    value="option1"
  />
  <RadioGroupItem
    label="Option 2"
    name="group-option-2"
    value="option2"
  />
</RadioGroup>