-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: add optional color for slide-toggle when unactivated #90
Changes from 1 commit
a4e74d8
b3388ad
d11f70c
d891178
0621d9f
31a753e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { FormControl } from "@angular/forms"; | |
export class SlideToggleComponent implements OnInit { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OnInit interface can be removed |
||
checked = true; | ||
colorFormControl = new FormControl("#08B25A"); | ||
uncheckedColorFormControl = new FormControl("#000000") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing ; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, please add the access modifier for these properties |
||
disabled = false; | ||
titleFormControl = new FormControl("click me"); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,12 @@ | |
[id]="toggle?.cod" | ||
[checked]="toggle?.checked" | ||
[color]="toggle?.color" | ||
[uncheckedColor]="toggle?.uncheckedColor" | ||
[title]="toggle?.title" | ||
(toggleChange)="toggleChange(toggle?.cod, $event)" | ||
ngDefaultControl | ||
></gor-slide-toggle> | ||
</div> | ||
</ng-container> | ||
</div> | ||
</ng-container> | ||
</ng-container> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline at end of file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<div class="toggle" [ngClass]="{ disabled: disabled }"> | ||
<label class="switch"> | ||
<input type="checkbox" [checked]="checked" (change)="changeChecked()" /> | ||
<span class="slider round" [style.backgroundColor]="checked ? color : ''"> | ||
<span class="slider round" [style.backgroundColor]="checked ? color : uncheckedColor"> | ||
<span class="slider-before" [ngClass]="{ active: checked }"></span> | ||
</span> | ||
</label> | ||
<span class="title">{{ title }}</span> | ||
</div> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline at end of file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,15 @@ export interface ToggleData { | |
|
||
|
||
/** | ||
* The custom color for the toggle. | ||
* The custom color for the toggle when activated. | ||
* @Optional | ||
*/ | ||
color?: string; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove extra empty line |
||
/** | ||
* The custom color for the toggle when unactivated. | ||
* @Optional | ||
*/ | ||
uncheckedColor?: string; | ||
guilhermejcgois marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { storiesOf, moduleMetadata } from '@storybook/angular'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice stories, keep up the good work |
||
import { CommonModule } from '@angular/common'; | ||
import { SlideToggleComponent } from './slide-toggle.component'; | ||
import { SlideToggleGroupComponent } from './slide-toggle-group.component'; | ||
import { ToggleData } from './slide-toggle.model'; | ||
import { text, withKnobs, boolean } from '@storybook/addon-knobs'; | ||
|
||
storiesOf('slide-toggle', module) | ||
.addDecorator( | ||
moduleMetadata({ | ||
imports: [CommonModule], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if this import is necessary |
||
declarations: [SlideToggleComponent, SlideToggleGroupComponent], | ||
}) | ||
) | ||
.addDecorator(withKnobs) | ||
.add( | ||
'three different cases about slide-toggle', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Summary should be descriptive of functionality being demonstrated - in this case, color configurations |
||
() => { | ||
const data: Array<ToggleData> = [{ | ||
cod: "1", | ||
checked: true, | ||
title: "activate color", | ||
color: "#10c0c6", | ||
uncheckedColor: "" | ||
}, | ||
{ | ||
cod: "2", | ||
checked: true, | ||
title: "both colors", | ||
color: "#10c0c6", | ||
uncheckedColor: "#456888" | ||
}, | ||
{ | ||
cod: "3", | ||
checked: false, | ||
title: "UNACTIVATE COLOR", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the title be 'Inactive'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe 'unchecked', to keep consistency with component property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep text capitalization consistent across titles |
||
color: "", | ||
uncheckedColor: "#456888" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check code identation in all this file |
||
} | ||
]; | ||
|
||
const labels = ['title']; | ||
|
||
return { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove extra empty line |
||
template: ` | ||
<gor-slide-toggle-group | ||
[data]='${JSON.stringify(data)}' | ||
[labels]='${JSON.stringify(labels)}' | ||
> | ||
</gor-slide-toggle-group> | ||
` | ||
}} | ||
) | ||
|
||
.add('editable', () => ({ | ||
props: { | ||
cod: text("cod","1"), | ||
checked: boolean("checked", true), | ||
title: text("title", "slide-toggle"), | ||
color: text("color", "#10c0c6"), | ||
uncheckedColor: text("uncheckedColor", "#456888"), | ||
}, | ||
template: ` | ||
<gor-slide-toggle | ||
[id]="cod" | ||
[checked]="checked" | ||
[color]="color" | ||
[uncheckedColor]="uncheckedColor" | ||
[title]="title" | ||
> | ||
</gor-slide-toggle> | ||
` | ||
})); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/>
could be moved to the previous line