Skip to content

Commit

Permalink
Issue 227 (#247)
Browse files Browse the repository at this point in the history
* fix: ajuste na função setcheck do component checkbox

* fix: atualiza lista de eventos do checkbox

* feat: adiciona radiobutton sem borda

* fix: ajusta tamanho do radiobutton sem borda
  • Loading branch information
klebsonmateus committed May 22, 2024
1 parent 22f62a1 commit 83c773a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/Checkbox/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Component } from 'pet-dex-utilities';
import './index.scss';

const events = ['change', 'text:change', 'disable', 'value:change'];
const events = [
'change',
'value:change',
'text:change',
'name:change',
'disable',
];

const html = `
<label class="checkbox-container">
Expand All @@ -28,7 +34,7 @@ export default function Checkbox({
const $checkbox = this.selected.get('checkbox');

$checkbox.addEventListener('change', (e) => {
this.setChecked(e.target.checked);
this.setCheck(e.target.checked);
});
}

Expand Down
11 changes: 11 additions & 0 deletions src/components/RadioButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function RadioButton({
value = '',
name = '',
disabled = false,
borderless = false,
} = {}) {
Component.call(this, { html, events });

Expand All @@ -30,6 +31,7 @@ export default function RadioButton({
this.setValue(value);
this.setName(name);
this.setDisabled(disabled);
this.setBorderless(borderless);
const $radioButton = this.selected.get('radio-button');

$radioButton.addEventListener('change', (e) => {
Expand Down Expand Up @@ -85,5 +87,14 @@ RadioButton.prototype = Object.assign(
$radioButton.name = name;
this.emit('name:change', name);
},

setBorderless(borderless = false) {
const $radioContainer = this.selected.get('radio-container');
if (borderless) {
$radioContainer.classList.add('radio-container--borderless');
} else {
$radioContainer.classList.remove('radio-container--borderless');
}
},
},
);
5 changes: 5 additions & 0 deletions src/components/RadioButton/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

cursor: pointer;

&--borderless {
padding: 0;
border: 0;
}

&:has(&__input:checked) {
color: colors.$primary200;

Expand Down
7 changes: 7 additions & 0 deletions src/stories/RadioButton.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ export const Disabled = {
disabled: true,
},
};

export const Borderless = {
args: {
...Default.args,
borderless: true,
},
};

0 comments on commit 83c773a

Please sign in to comment.