Skip to content

Commit

Permalink
feat: selected state - first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Pajung authored and nowseemee committed Aug 2, 2021
1 parent c194375 commit a5c4b8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,19 @@

.toggle-button:disabled.toggle-button--primary {
background: var(--color-primary-background-disabled);
}
}

.toggle-button--selected {
color: white;
background: var( --scl-color-primary);
}

.toggle-button--selected:not(.button--disabled):hover {
color: white;
background: var(--color-primary-hover);
}

.toggle-button--selected:not(.button--disabled):active {
color: white;
background: var(--scl-color-primary-active);
}
13 changes: 10 additions & 3 deletions packages/components/src/components/toggle-button/toggle-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ToggleButton {
/** (optional) If `true`, the button is disabled */
@Prop() disabled?: boolean = false;
/** (optional) If `true`, the button is selected */
@Prop() selected?: boolean = false;
@Prop({ mutable: true }) selected?: boolean = true;
/** (optional) Button type */
@Prop() iconOnly?: boolean = false;
/** (optional) Icon position related to the label */
Expand All @@ -41,7 +41,11 @@ export class ToggleButton {
this.setIconPositionProp();
}

handleClick() {}
handleClick(event: MouseEvent) {
event.preventDefault();
this.selected = !this.selected;
// console.log(this.selected)
}

/**
* Detect whether the last node is an element (not text).
Expand All @@ -64,6 +68,7 @@ export class ToggleButton {
}

render() {
console.log('render called!')
return (
<Host>
{this.styles && <style>{this.styles}</style>}
Expand Down Expand Up @@ -99,7 +104,9 @@ export class ToggleButton {
!this.iconOnly &&
this.iconPosition &&
`toggle-button--icon-${this.iconPosition}`,
this.iconOnly && `${prefix}icon-only`
this.iconOnly && `${prefix}icon-only`,
!this.disabled &&
this.selected && `${prefix}selected`,
);
}
}

0 comments on commit a5c4b8a

Please sign in to comment.