Skip to content

Commit

Permalink
feat(core): add property ly-text
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Dec 9, 2018
1 parent 210b3b4 commit 430fccb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/lib/src/theme/paper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Directive, OnChanges, ElementRef, NgZone, OnDestroy } from '@angular/core';
import { Directive, OnChanges, ElementRef, NgZone, OnDestroy, Input, OnInit } from '@angular/core';
import { LyTheme2 } from './theme2.service';
import { mixinStyleUpdater, mixinBg, mixinRaised, mixinOutlined, mixinElevation, mixinShadowColor, mixinDisableRipple, mixinColor } from '../common/index';
import { toBoolean } from '../minimal/is-boolean';

const DEFAULT_BG = 'paper';

export class LyPaperBase {
constructor(
Expand All @@ -19,7 +22,7 @@ mixinBg(
mixinDisableRipple(LyPaperBase))))))));

@Directive({
selector: `ly-paper, [ly-paper]`,
selector: `ly-paper, [ly-paper], [ly-text]`,
inputs: [
'bg',
'flat',
Expand All @@ -31,7 +34,16 @@ mixinBg(
'disableRipple'
]
})
export class LyPaper extends LyPaperMixinBase implements OnChanges, OnDestroy {
export class LyPaper extends LyPaperMixinBase implements OnChanges, OnInit, OnDestroy {
_hasText: boolean;

@Input('ly-text')
set hasText(val: any) {
this._hasText = toBoolean(val);
}
get hasText() {
return this._hasText;
}

constructor(
theme: LyTheme2,
Expand All @@ -48,6 +60,12 @@ export class LyPaper extends LyPaperMixinBase implements OnChanges, OnDestroy {
this.updateStyle(this._el);
}

ngOnInit() {
if (!this.bg && !this.hasText) {
this.bg = DEFAULT_BG;
}
}

ngOnDestroy() {
this._removeRippleEvents();
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/themes/minima/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class MinimaDark extends MinimaBase implements ThemeConfig {
tertiary: '#212121',
base: '#0E0E0E'
};
paper = {
default: '#2b2b2b',
shadow
};
text = {
default: '#fff',
primary: '#fff',
Expand Down
4 changes: 4 additions & 0 deletions src/lib/themes/minima/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class MinimaLight extends MinimaBase implements ThemeConfig {
tertiary: '#efefef',
base: '#E0E0E0'
};
paper = {
default: '#fff',
shadow
};
text = {
default: 'rgba(0, 0, 0, 0.87)',
primary: 'rgba(0, 0, 0, 0.87)',
Expand Down

0 comments on commit 430fccb

Please sign in to comment.