Skip to content

Commit

Permalink
chore: enhance radio and checkbox wrappers and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
joneff committed Oct 17, 2021
1 parent 821b3a8 commit 9386a0f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 29 deletions.
22 changes: 22 additions & 0 deletions packages/html/src/checkbox/README.md
@@ -0,0 +1,22 @@
```html
<!-- default rendering -->
<input type="checkbox" class="k-checkbox k-checkbox-md k-rounded-md" />

<!-- canonical rendering -->
<input type="checkbox"
class="
k-checkbox
k-checkbox-${size}
k-rounded-${rounded}
${checked && 'k-checked'}
${indeterminate && 'k-indeterminate'}
${valid && 'k-valid'}
${invalid && 'k-invalid'}
${required && 'k-required'}
${disabled && 'k-disabled'}
"
disabled={disabled}
/>
```
35 changes: 20 additions & 15 deletions packages/html/src/checkbox/checkbox.jsx
Expand Up @@ -58,20 +58,21 @@ function CheckboxStatic(props) {
}
];

let legacyClasses = [
ownClassName,
'k-checkbox',
{
'k-state-hover': hover === true,
'k-state-focus': focus === true,
'k-state-invalid': invalid === true,
'k-state-disabled': disabled === true,
'k-checked': checked === true,
'k-state-indeterminate': isIndeterminate,
}
];

if (legacy) {

let legacyClasses = [
ownClassName,
'k-checkbox',
{
'k-state-hover': hover === true,
'k-state-focus': focus === true,
'k-state-invalid': invalid === true,
'k-state-disabled': disabled === true,
'k-checked': checked === true,
'k-state-indeterminate': isIndeterminate,
}
];

return (
<input type="checkbox" className={legacyClasses} {...ariaAttr} {...htmlAttributes} />
);
Expand All @@ -86,10 +87,15 @@ CheckboxStatic.defaultProps = {
...globalDefaultProps,

id: '',
name: ''
name: '',

size: 'medium',
rounded: 'medium'
};

CheckboxStatic.propTypes = {
className: typeof '',

id: typeof '',
name: typeof '',
value: typeof '',
Expand All @@ -110,7 +116,6 @@ CheckboxStatic.propTypes = {
aria: typeof false,
legacy: typeof false,

className: typeof '',
htmlAttributes: typeof []
};

Expand Down
21 changes: 21 additions & 0 deletions packages/html/src/radio/README.md
@@ -0,0 +1,21 @@
```html
<!-- default rendering -->
<input type="radio" class="k-radio k-radio-md k-rounded-md" />

<!-- canonical rendering -->
<input type="radio"
class="
k-radio
k-radio-${size}
k-rounded-${rounded}
${checked && 'k-checked'}
${valid && 'k-valid'}
${invalid && 'k-invalid'}
${required && 'k-required'}
${disabled && 'k-disabled'}
"
disabled={disabled}
/>
```
32 changes: 18 additions & 14 deletions packages/html/src/radio/radio.jsx
Expand Up @@ -48,19 +48,20 @@ function RadioStatic(props) {
}
];

let legacyClasses = [
ownClassName,
'k-radio',
{
'k-state-hover': hover === true,
'k-state-focus': focus === true,
'k-state-invalid': invalid === true,
'k-state-disabled': disabled === true,
'k-state-checked': checked === true,
}
];

if (legacy) {

let legacyClasses = [
ownClassName,
'k-radio',
{
'k-state-hover': hover === true,
'k-state-focus': focus === true,
'k-state-invalid': invalid === true,
'k-state-disabled': disabled === true,
'k-state-checked': checked === true,
}
];

return <input type="radio" className={legacyClasses} {...ariaAttr} {...htmlAttributes}/>;
}

Expand All @@ -71,10 +72,14 @@ RadioStatic.defaultProps = {
...globalDefaultProps,

id: '',
name: ''
name: '',

size: 'medium'
};

RadioStatic.propTypes = {
className: typeof '',

id: typeof '',
name: typeof '',
value: typeof '',
Expand All @@ -92,7 +97,6 @@ RadioStatic.propTypes = {
aria: typeof false,
legacy: typeof false,

className: typeof '',
htmlAttributes: typeof []
};

Expand Down

0 comments on commit 9386a0f

Please sign in to comment.