-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
193c475
commit e452e71
Showing
16 changed files
with
1,245 additions
and
0 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
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,47 @@ | ||
// tslint:disable:no-console | ||
import { Component, NgModule, ViewEncapsulation } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
|
||
import { McButtonModule } from '../../lib/button/'; | ||
import { McToggleModule } from '../../lib/toggle/'; | ||
|
||
|
||
@Component({ | ||
selector: 'app', | ||
template: require('./template.html'), | ||
styleUrls: ['./styles.scss'], | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class DemoComponent { | ||
valueSmallOff: boolean = false; | ||
valueSmallOn: boolean = true; | ||
|
||
valueBigOff: boolean = false; | ||
valueBigOn: boolean = true; | ||
|
||
disabled: boolean = false; | ||
} | ||
|
||
|
||
@NgModule({ | ||
declarations: [ | ||
DemoComponent | ||
], | ||
imports: [ | ||
BrowserModule, | ||
FormsModule, | ||
McToggleModule, | ||
McButtonModule | ||
], | ||
bootstrap: [ | ||
DemoComponent | ||
] | ||
}) | ||
export class DemoModule {} | ||
|
||
platformBrowserDynamic() | ||
.bootstrapModule(DemoModule) | ||
.catch((error) => console.error(error)); | ||
|
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,22 @@ | ||
@import '../../lib/core/theming/prebuilt/default-theme'; | ||
|
||
@import '../../lib/core/visual/prebuilt/default-visual'; | ||
|
||
.container { | ||
margin-top: 32px; | ||
margin-left: 16px; | ||
} | ||
|
||
.toggle-demo-container { | ||
margin-bottom: 8px; | ||
} | ||
|
||
.control-buttons-container { | ||
display: inline-block; | ||
margin-right: 16px; | ||
margin-bottom: 16px; | ||
} | ||
|
||
.toggles-container { | ||
max-width: 500px; | ||
} |
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,67 @@ | ||
<div class="container"> | ||
<h1>Toggles</h1> | ||
|
||
<div class="control-buttons-container"> | ||
<button mc-button (click)="disabled = false">Set Enabled</button> | ||
</div> | ||
<div class="control-buttons-container"> | ||
<button mc-button (click)="disabled = true">Set Disabled</button> | ||
</div> | ||
|
||
<div class="layout-row flex-100 toggles-container"> | ||
<div class="flex-50"> | ||
<h3>Small Toggles</h3> | ||
<div class="layout-row flex-100 toggle-demo-container"> | ||
<div class="flex-33"> | ||
<mc-toggle class="mc-toggle_small" [(ngModel)]="valueSmallOff" [disabled]="disabled"> | ||
</mc-toggle> | ||
</div> | ||
<div class="flex-33"> | ||
<mc-toggle class="mc-toggle_small" color="primary" [(ngModel)]="valueSmallOn" [disabled]="disabled"> | ||
</mc-toggle> | ||
</div> | ||
<div class="flex-33"> | ||
<mc-toggle class="mc-toggle_small" color="error" [(ngModel)]="valueSmallOn" [disabled]="disabled"> | ||
</mc-toggle> | ||
</div> | ||
</div> | ||
<div class="toggle-demo-container"> | ||
<mc-toggle class="mc-toggle_small" [(ngModel)]="valueSmallOff" [disabled]="disabled"> | ||
Quack like a duck | ||
</mc-toggle> | ||
</div> | ||
<div class="toggle-demo-container"> | ||
<mc-toggle class="mc-toggle_small cdk-keyboard-focused" labelPosition="left" [(ngModel)]="valueSmallOff" [disabled]="disabled"> | ||
Quack like a duck | ||
</mc-toggle> | ||
</div> | ||
</div> | ||
<div class="flex-50"> | ||
<h3>Big Toggles</h3> | ||
<div class="layout-row flex-100 toggle-demo-container"> | ||
<div class="flex-33"> | ||
<mc-toggle [(ngModel)]="valueBigOff" [disabled]="disabled"> | ||
</mc-toggle> | ||
</div> | ||
<div class="flex-33"> | ||
<mc-toggle color="primary" [(ngModel)]="valueBigOn" [disabled]="disabled"> | ||
</mc-toggle> | ||
</div> | ||
<div class="flex-33"> | ||
<mc-toggle color="error" [(ngModel)]="valueBigOn" [disabled]="disabled"> | ||
</mc-toggle> | ||
</div> | ||
</div> | ||
<div class="toggle-demo-container"> | ||
<mc-toggle [(ngModel)]="valueBigOff" [disabled]="disabled"> | ||
Quack like a duck | ||
</mc-toggle> | ||
</div> | ||
<div class="toggle-demo-container"> | ||
<mc-toggle class="cdk-keyboard-focused" labelPosition="left" [(ngModel)]="valueBigOff" [disabled]="disabled"> | ||
Quack like a duck | ||
</mc-toggle> | ||
</div> | ||
</div> | ||
</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
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
Empty file.
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,118 @@ | ||
$hover-darken: 5%; | ||
|
||
@mixin _mc-toggle-color($palette) { | ||
$color: mc-color($palette, 500); | ||
|
||
.mc-toggle-bar { | ||
background: $color; | ||
} | ||
} | ||
|
||
@mixin _mc-toggle-border-color($palette) { | ||
$color: mc-color($palette, 500); | ||
|
||
.mc-toggle-bar { | ||
border: 1px solid $color; | ||
} | ||
} | ||
|
||
@mixin _mc-toggle-circle-color($darken) { | ||
$toggle-circle-color-1: darken(white, $darken); | ||
$toggle-circle-color-2: darken(mc-color($mc-grey, 100), $darken); | ||
|
||
border: 1px solid mc-color($mc-grey, 300); | ||
background: | ||
$toggle-circle-color-1 | ||
linear-gradient(to bottom, $toggle-circle-color-1, $toggle-circle-color-2); | ||
} | ||
|
||
@mixin _mc-toggle-off-color($darken) { | ||
$toggle-off-color-1: darken(mc-color($second, 100), $darken); | ||
$toggle-off-color-2: darken(mc-color($second, 60), $darken); | ||
|
||
background: $toggle-off-color-1 linear-gradient(to bottom, $toggle-off-color-1, $toggle-off-color-2); | ||
} | ||
|
||
@mixin mc-toggle-theme($theme) { | ||
$primary: map-get($theme, primary); | ||
$second: map-get($theme, second); | ||
$error: map-get($theme, error); | ||
$background: map-get($theme, background); | ||
|
||
$toggle-off-color-1: mc-color($second, 100); | ||
$toggle-off-color-2: mc-color($second, 60); | ||
|
||
mc-toggle { | ||
.mc-toggle__circle { | ||
@include _mc-toggle-circle-color(0); | ||
} | ||
|
||
.mc-toggle-bar { | ||
border: 1px solid mc-color($mc-grey, 300); | ||
} | ||
|
||
&.mc-toggle-off { | ||
.mc-toggle-input { | ||
~ .mc-toggle-bar-container .mc-toggle-bar { | ||
@include _mc-toggle-off-color(0) | ||
} | ||
} | ||
} | ||
|
||
&.mc-primary:not(.mc-toggle-off) { | ||
@include _mc-toggle-color($primary); | ||
@include _mc-toggle-border-color($primary); | ||
} | ||
|
||
&.mc-error:not(.mc-toggle-off) { | ||
@include _mc-toggle-color($error); | ||
@include _mc-toggle-border-color($error); | ||
} | ||
} | ||
|
||
mc-toggle:not(.mc-disabled) { | ||
.mc-toggle-input { | ||
&:hover { | ||
~ .mc-toggle-bar-container .mc-toggle-bar { | ||
.mc-toggle__circle { | ||
@include _mc-toggle-circle-color($hover-darken); | ||
} | ||
} | ||
} | ||
} | ||
|
||
&.cdk-keyboard-focused { | ||
.mc-toggle-input { | ||
+ .mc-toggle-bar-container .mc-toggle__focus-frame { | ||
border: 2px solid map-get($primary, 500); | ||
box-shadow: inset 0 0 0 1px map-get($background, background); | ||
} | ||
} | ||
} | ||
|
||
&.mc-toggle-off { | ||
.mc-toggle-input { | ||
&:hover { | ||
~ .mc-toggle-bar-container .mc-toggle-bar { | ||
@include _mc-toggle-off-color($hover-darken) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
mc-toggle.mc-disabled { | ||
opacity: 0.5; | ||
} | ||
} | ||
|
||
|
||
@mixin mc-toggle-typography($config) { | ||
mc-toggle:not(.mc-toggle_small) { | ||
@include mc-typography-level-to-styles($config, body); | ||
} | ||
|
||
mc-toggle.mc-toggle_small { | ||
@include mc-typography-level-to-styles($config, caption); | ||
} | ||
} |
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 @@ | ||
export * from './public-api'; |
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,2 @@ | ||
export * from './toggle.module'; | ||
export * from './toggle.component'; |
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 @@ | ||
<label [attr.for]="inputId" class="mc-toggle-layout" #label> | ||
<div class="mc-toggle__container" [class.left]="labelPosition === 'left'"> | ||
<input #input | ||
type="checkbox" | ||
class="mc-toggle-input cdk-visually-hidden" | ||
[id]="inputId" | ||
[checked]="checked" | ||
[attr.value]="value" | ||
[disabled]="disabled" | ||
[attr.name]="name" | ||
[tabIndex]="tabIndex" | ||
[attr.aria-label]="ariaLabel || null" | ||
[attr.aria-labelledby]="ariaLabelledby" | ||
[attr.aria-checked]="_getAriaChecked()" | ||
(click)="_onInputClick($event)" | ||
(change)="_onInteractionEvent($event)"/> | ||
<div class="mc-toggle-bar-container"> | ||
<div class="mc-toggle__focus-frame"></div> | ||
<div class="mc-toggle-bar"> | ||
<div class="mc-toggle__circle" [@switch]="checked"></div> | ||
</div> | ||
</div> | ||
<div class="mc-toggle__content" | ||
[class.left]="labelPosition === 'left'" | ||
[class.right]="labelPosition === 'right'"> | ||
<span class="mc-toggle-label" (cdkObserveContent)="_onLabelTextChange()"> | ||
<ng-content></ng-content> | ||
</span> | ||
</div> | ||
</div> | ||
</label> |
Oops, something went wrong.