Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RadioControl: Clean up CSS #43868

Merged
merged 2 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

### Internal

- `RadioControl`: Clean up styles to use less custom CSS ([#43868](https://github.com/WordPress/gutenberg/pull/43868)).
- Remove unused `normalizeArrowKey` utility function ([#43640](https://github.com/WordPress/gutenberg/pull/43640/)).
- `ToggleGroupControl`: Rename `__experimentalIsIconGroup` prop to `__experimentalIsBorderless` ([#43771](https://github.com/WordPress/gutenberg/pull/43771/)).
- Refactor `FocalPointPicker` to function component ([#39168](https://github.com/WordPress/gutenberg/pull/39168)).
Expand Down
50 changes: 27 additions & 23 deletions packages/components/src/radio-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useInstanceId } from '@wordpress/compose';
import BaseControl from '../base-control';
import type { WordPressComponentProps } from '../ui/context';
import type { RadioControlProps } from './types';
import { VStack } from '../v-stack';

/**
* Render a user interface to select the user type using radio inputs.
Expand Down Expand Up @@ -65,35 +66,38 @@ export function RadioControl(

return (
<BaseControl
__nextHasNoMarginBottom
label={ label }
id={ id }
hideLabelFromVision={ hideLabelFromVision }
help={ help }
className={ classnames( className, 'components-radio-control' ) }
>
{ options.map( ( option, index ) => (
<div
key={ `${ id }-${ index }` }
className="components-radio-control__option"
>
<input
id={ `${ id }-${ index }` }
className="components-radio-control__input"
type="radio"
name={ id }
value={ option.value }
onChange={ onChangeValue }
checked={ option.value === selected }
aria-describedby={
!! help ? `${ id }__help` : undefined
}
{ ...additionalProps }
/>
<label htmlFor={ `${ id }-${ index }` }>
{ option.label }
</label>
</div>
) ) }
<VStack spacing={ 1 }>
{ options.map( ( option, index ) => (
<div
key={ `${ id }-${ index }` }
className="components-radio-control__option"
>
<input
id={ `${ id }-${ index }` }
className="components-radio-control__input"
type="radio"
name={ id }
value={ option.value }
onChange={ onChangeValue }
checked={ option.value === selected }
aria-describedby={
!! help ? `${ id }__help` : undefined
}
{ ...additionalProps }
/>
<label htmlFor={ `${ id }-${ index }` }>
{ option.label }
</label>
</div>
) ) }
</VStack>
</BaseControl>
);
}
Expand Down
17 changes: 0 additions & 17 deletions packages/components/src/radio-control/style.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
.components-radio-control {
display: flex;
flex-direction: column;

.components-base-control__help {
margin-top: 0;
}

.components-base-control__field {
margin-bottom: 0;
}
}

.components-radio-control__option:not(:last-child) {
margin-bottom: 4px;
}

.components-radio-control__input[type="radio"] {
@include radio-control;
margin-top: 0;
Expand Down