This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.8.0 make toggle elemnts position absolute inside. add storys for co…
…mponent doc.
- Loading branch information
clouless
committed
Mar 27, 2018
1 parent
d89e53a
commit 2340289
Showing
13 changed files
with
8,259 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,5 @@ documentation | |
src/*.js | ||
src/components/*.js | ||
tsconfig-*.json | ||
yarn.lock | ||
_dist_demo_node_modules | ||
dist-demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.yarnpkg.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,13 @@ | ||
<div | ||
class="demo" | ||
[formGroup]="form" | ||
> | ||
<h3>Toggle</h3> | ||
<table class="demotable"> | ||
<tr> | ||
<td>Is Schrödingers cat dead?</td> | ||
<td> | ||
<cloukit-toggle | ||
formControlName="isCatDead" | ||
></cloukit-toggle> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Are you sure? (different theme)</td> | ||
<td> | ||
<cloukit-toggle | ||
formControlName="areYouSure" | ||
theme="toggle--cornered" | ||
></cloukit-toggle> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Disabled states:</td> | ||
<td> | ||
<cloukit-toggle | ||
formControlName="youCantTouchThisOff" | ||
></cloukit-toggle> | ||
<div style="padding:10px;"> | ||
|
||
<cloukit-toggle | ||
formControlName="youCantTouchThisOn" | ||
></cloukit-toggle> | ||
<cloukit-story title="Basic Usage" story="story-00-basic"> | ||
<story-00-basic></story-00-basic> | ||
</cloukit-story> | ||
|
||
<br><br> | ||
<br><br> | ||
|
||
<cloukit-toggle | ||
formControlName="youCantTouchThisOffAlt" | ||
theme="toggle--cornered" | ||
></cloukit-toggle> | ||
|
||
<cloukit-toggle | ||
formControlName="youCantTouchThisOnAlt" | ||
theme="toggle--cornered" | ||
></cloukit-toggle> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<hr><br> | ||
|
||
Reactive Form Result: | ||
<pre>{{getFormResult()}}</pre> | ||
<cloukit-story title="Using Custom Theme" story="story-01-themed"> | ||
<story-01-themed></story-01-themed> | ||
</cloukit-story> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,16 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormGroup, FormBuilder } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'demo', | ||
templateUrl: './demo.component.html', | ||
styles: [ | ||
'.demo { font-family: sans-serif; }', | ||
'.demotable td { vertical-align:top; padding:10px; }', | ||
], | ||
styles: [], | ||
}) | ||
export class DemoComponent { | ||
styles = { }; | ||
form: FormGroup; | ||
|
||
constructor(fb: FormBuilder) { | ||
this.form = fb.group({ | ||
isCatDead: false, | ||
areYouSure: true, | ||
youCantTouchThisOn: { value: true, disabled: true }, | ||
youCantTouchThisOff: { value: false, disabled: true }, | ||
youCantTouchThisOnAlt: { value: true, disabled: true }, | ||
youCantTouchThisOffAlt: { value: false, disabled: true }, | ||
}); | ||
} | ||
|
||
getFormResult() { | ||
return JSON.stringify(this.form.value, null, 2); | ||
} | ||
public static sharedStyles = [ | ||
'.row { display: flex; align-items:center; }', | ||
'.row span { margin-right:10px; }', | ||
'.row button { margin-left:50px; }', | ||
'.superButton, .superButtonSecondary { border:2px solid #710ECC; outline:0; background-color:#710ECC; color:#fff; border-radius:0px; padding:4px 8px 4px 8px; color:#fff; cursor:pointer; font-size:1rem; }', | ||
'.superButton:hover, .superButtonSecondary:hover { border:2px solid #710ECC; background-color:#fff; color:#710ECC; }', | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="demo" [formGroup]="form"> | ||
|
||
<div class="row"> | ||
<span>Is Schrödingers cat dead?</span> | ||
|
||
<cloukit-toggle | ||
formControlName="isCatDead" | ||
></cloukit-toggle> | ||
|
||
<button | ||
type="button" | ||
(click)="toggleFormDisabled()" | ||
class="superButton" | ||
>{{ isFormDisabled ? 'enable' : 'disable' }} form</button> | ||
</div> | ||
|
||
|
||
<br><br> | ||
|
||
Reactive Form Result: | ||
<pre *ngIf="form?.value">{{form.value | json}}</pre> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormGroup, FormControl } from '@angular/forms'; | ||
import { DemoComponent } from '../demo.component'; | ||
|
||
@Component({ | ||
selector: 'story-00-basic', | ||
templateUrl: './story-00-basic.html', | ||
styles: [ ].concat(DemoComponent.sharedStyles), | ||
}) | ||
export class Story00Component { | ||
|
||
public isFormDisabled = false; | ||
|
||
public form = new FormGroup({ | ||
isCatDead: new FormControl(false) | ||
}); | ||
|
||
public toggleFormDisabled() { | ||
if (this.isFormDisabled) { | ||
this.form.enable(); | ||
this.isFormDisabled = false; | ||
} else { | ||
this.form.disable(); | ||
this.isFormDisabled = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="demo" [formGroup]="form"> | ||
|
||
<div class="row"> | ||
|
||
<span>Theme: toggle--cornered</span> | ||
|
||
<cloukit-toggle | ||
formControlName="myBool" | ||
theme="toggle--cornered" | ||
></cloukit-toggle> | ||
|
||
</div> | ||
|
||
<br><br> | ||
|
||
<div class="row"> | ||
|
||
<span>Theme: toggle--awesome</span> | ||
|
||
<cloukit-toggle | ||
formControlName="myBoolTwo" | ||
theme="toggle--awesome" | ||
></cloukit-toggle> | ||
|
||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormGroup, FormControl } from '@angular/forms'; | ||
import { DemoComponent } from '../demo.component'; | ||
import { CloukitThemeService } from '@cloukit/theme'; | ||
import { CloukitToggleComponentThemeDefault } from '../../index'; | ||
|
||
export class AwesomeToggleTheme extends CloukitToggleComponentThemeDefault { | ||
constructor() { | ||
super(); | ||
const wrapperUntoggledBase = this.getElementTheme('wrapper', 'toggled', 'base'); | ||
wrapperUntoggledBase.styleDef.style.backgroundColor = 'blue'; | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'story-01-themed', | ||
templateUrl: './story-01-themed.html', | ||
styles: [ '.row span { width:200px; }' ].concat(DemoComponent.sharedStyles), | ||
}) | ||
export class Story01Component { | ||
|
||
public form = new FormGroup({ | ||
myBool: new FormControl(false), | ||
myBoolTwo: new FormControl(true), | ||
}); | ||
|
||
constructor(private cloukitThemeService: CloukitThemeService) { | ||
this.cloukitThemeService.registerComponentTheme('toggle--awesome', new AwesomeToggleTheme()); | ||
} | ||
|
||
} |
Oops, something went wrong.