Skip to content

Commit f0be244

Browse files
committed
refactor(list): move radio button template from list folder to radio-button-group folder
Move radio button template and styles from `list/radio-button/` to `radio-button-group/` to better organize radio button related code in a single location. Also added a comprehensive documentation to radio button template and marked it as `@internal` since it's not for direct consumer use.
1 parent ec290a4 commit f0be244

File tree

6 files changed

+67
-39
lines changed

6 files changed

+67
-39
lines changed

src/components/list/list-renderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MenuItem } from '../menu/menu.types';
44
import { h } from '@stencil/core';
55
import { CheckboxTemplate } from '../checkbox/checkbox.template';
66
import { ListRendererConfig } from './list-renderer-config';
7-
import { RadioButtonTemplate } from './radio-button/radio-button.template';
7+
import { RadioButtonTemplate } from '../radio-button-group/radio-button.template';
88
import {
99
getIconColor,
1010
getIconName,

src/components/list/list.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ img {
310310

311311
@import '../checkbox/checkbox.scss';
312312

313-
@import './radio-button/radio-button.scss';
313+
@import '../radio-button-group/radio-button.scss';
314314

315315
@import './partial-styles/custom-styles.scss';
316316
@import './partial-styles/enable-multiline-text.scss';

src/components/list/radio-button/radio-button.template.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/components/radio-button-group/radio-button-group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { LimelListCustomEvent } from '@limetech/lime-elements';
2020
*/
2121
@Component({
2222
tag: 'limel-radio-button-group',
23-
shadow: true,
23+
shadow: false,
2424
})
2525
export class RadioButtonGroup {
2626
/**
File renamed without changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { FunctionalComponent, h } from '@stencil/core';
2+
3+
/**
4+
* Radio Button Template
5+
*
6+
* This is a low-level template component that renders individual radio button elements
7+
* using Material Design Components (MDC) styling and structure. It's used internally
8+
* by the list component to render radio buttons when `type="radio"` is specified.
9+
*
10+
* ## Usage in the Library
11+
*
12+
* This template is primarily used by:
13+
* - `limel-list` component when `type="radio"`
14+
* - `limel-radio-button-group` component (which wraps `limel-list`)
15+
*
16+
* ## Why This Exists
17+
*
18+
* While we have `limel-radio-button-group` for most use cases, this template provides
19+
* the actual radio button HTML structure with proper MDC classes and accessibility
20+
* attributes. It ensures consistent styling and behavior across all radio button
21+
* implementations in the library.
22+
*
23+
* ## Design Philosophy
24+
*
25+
* This follows the principle that individual radio buttons should not be standalone
26+
* components, as a single radio button is never useful in a UI. Instead, this template
27+
* is used to build groups of radio buttons through higher-level components.
28+
*
29+
* @internal
30+
*/
31+
interface RadioButtonTemplateProps {
32+
disabled?: boolean;
33+
id: string;
34+
checked?: boolean;
35+
onChange?: (event: Event) => void;
36+
label?: string;
37+
}
38+
39+
export const RadioButtonTemplate: FunctionalComponent<
40+
RadioButtonTemplateProps
41+
> = (props) => {
42+
return (
43+
<div
44+
class={{
45+
'boolean-input': true,
46+
'radio-button': true,
47+
checked: props.checked,
48+
disabled: props.disabled,
49+
}}
50+
>
51+
<input
52+
type="radio"
53+
id={props.id}
54+
checked={props.checked}
55+
disabled={props.disabled}
56+
onChange={props.onChange}
57+
/>
58+
<div class="box" />
59+
<label class="boolean-input-label" htmlFor={props.id}>
60+
{props.label}
61+
</label>
62+
</div>
63+
);
64+
};

0 commit comments

Comments
 (0)