Skip to content

Commit

Permalink
perf(button): update styles
Browse files Browse the repository at this point in the history
  • Loading branch information
alyleui committed Aug 18, 2018
1 parent c3677ca commit 8efee2b
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 171 deletions.
5 changes: 1 addition & 4 deletions src/lib/button/button.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ export const styles = theme => {
userSelect: 'none',
textDecorationLine: 'none',
'-webkit-text-decoration-line': 'none',
transition: 'all 375ms cubic-bezier(0.23, 1, 0.32, 1) 0ms',
transition: 'background 375ms cubic-bezier(0.23, 1, 0.32, 1) 0ms, box-shadow 280ms cubic-bezier(.4,0,.2,1) 0ms',
overflow: 'hidden',
...button
},
outlined: {
border: '1px solid currentColor'
},
content: {
padding: 0,
display: 'flex',
Expand Down
59 changes: 28 additions & 31 deletions src/lib/button/button.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {
AfterViewInit,
ChangeDetectionStrategy,
Component,
ElementRef,
Input,
Optional,
Renderer2,
ViewChild,
NgZone,
OnDestroy,
OnInit,
Expand Down Expand Up @@ -60,18 +58,17 @@ export class LyButton implements OnInit, OnDestroy {
};
public _disabled = false;
private _rippleSensitive = false;
private _disabledClassName: string;
private _outlinedClassName: string;
// private _outlinedClassName: string;
private _rippleContainer: Ripple;
private _size: string;
private _sizeClass: string;

@Input()
set outlined(val: boolean) {
const classname = toBoolean(val) === true ? this.classes.outlined : '';
this.theme.updateClassName(this.elementRef.nativeElement, this.renderer, classname, this._outlinedClassName);
this._outlinedClassName = classname;
}
// @Input()
// set outlined(val: boolean) {
// const classname = toBoolean(val) === true ? this.classes.outlined : '';
// this.theme.updateClassName(this.elementRef.nativeElement, this.renderer, classname, this._outlinedClassName);
// this._outlinedClassName = classname;
// }

@Input('sensitive')
get rippleSensitive(): boolean {
Expand All @@ -97,16 +94,16 @@ export class LyButton implements OnInit, OnDestroy {
return this._size;
}

@Input()
set disabled(value: boolean) {
this._disabled = toBoolean(value);
if (this._disabled) {
const key = this.bgAndColor && (this.bgAndColor.raised || this.bgAndColor.bg) ? 'r' : 'f';
this._disabledClassName = this.theme.addStyle(`lyButton-disabled:${key}`, this.disableStyle.bind(this), this.elementRef.nativeElement, this._disabledClassName);
} else {
this.renderer.removeClass(this.elementRef.nativeElement, this._disabledClassName);
}
}
// @Input()
// set disabled(value: boolean) {
// this._disabled = toBoolean(value);
// if (this._disabled) {
// const key = this.bgAndColor && (this.bgAndColor.raised || this.bgAndColor.bg) ? 'r' : 'f';
// this._disabledClassName = this.theme.addStyle(`lyButton-disabled:${key}`, this.disableStyle.bind(this), this.elementRef.nativeElement, this._disabledClassName);
// } else {
// this.renderer.removeClass(this.elementRef.nativeElement, this._disabledClassName);
// }
// }
get disabled() {
return this._disabled;
}
Expand Down Expand Up @@ -140,17 +137,17 @@ export class LyButton implements OnInit, OnDestroy {
this.elementRef.nativeElement.focus();
}

private disableStyle() {
let style =
`box-shadow: 0 0 0 rgba(0, 0, 0, 0) !important;` +
`cursor: default;` +
`color: ${this.theme.config.text.disabled} !important;` +
`pointer-events: none;`;
if (this.bgAndColor && (this.bgAndColor.raised || this.bgAndColor.bg)) {
style += `background-color: ${this.theme.config.button.disabled} !important;`;
}
return style;
}
// private disableStyle() {
// let style =
// `box-shadow: 0 0 0 rgba(0, 0, 0, 0) !important;` +
// `cursor: default;` +
// `color: ${this.theme.config.text.disabled} !important;` +
// `pointer-events: none;`;
// if (this.bgAndColor && (this.bgAndColor.raised || this.bgAndColor.bg)) {
// style += `background-color: ${this.theme.config.button.disabled} !important;`;
// }
// return style;
// }

ngOnDestroy() {
if (Platform.isBrowser) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export * from './src/focus-state/focus-state.module';
export * from './src/version';
export * from './src/gesture/gesture-config';
export * from './src/theme/contrast';
export * from './src/theme/bg-color-and-raised.directive';
export * from './src/theme/common.directive';
export * from './src/theme/shadow.service';
export * from './src/theme/core-theme.service';
export * from './src/theme/theme-config';
Expand Down
130 changes: 0 additions & 130 deletions src/lib/src/theme/bg-color-and-raised.directive.ts

This file was deleted.

Loading

0 comments on commit 8efee2b

Please sign in to comment.