Skip to content

Commit

Permalink
fix(field): fix bg filled in mode dark
Browse files Browse the repository at this point in the history
  • Loading branch information
alyleui committed Oct 13, 2018
1 parent 8542964 commit 7c085f2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
13 changes: 5 additions & 8 deletions src/lib/field/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ViewChild,
ViewEncapsulation
} from '@angular/core';
import { LY_COMMON_STYLES, LyTheme2, ThemeVariables } from '@alyle/ui';
import { LY_COMMON_STYLES, LyTheme2, ThemeVariables, mergeDeep } from '@alyle/ui';
import { LyInputNative } from './input';
import { LyLabel } from './label';
import { LyPlaceholder } from './placeholder';
Expand All @@ -21,11 +21,6 @@ const STYLE_PRIORITY = -2;
const DEFAULT_APPEARANCE = 'standard';
const DEFAULT_WITH_COLOR = 'primary';
const styles = (theme: ThemeVariables) => {
const placeholderAndLabel = {
...LY_COMMON_STYLES.fill,
pointerEvents: 'none',
color: theme.input.label
};
return {
root: {
display: 'inline-block',
Expand Down Expand Up @@ -67,7 +62,9 @@ const styles = (theme: ThemeVariables) => {
fontSize: '75%'
},
placeholder: {
...placeholderAndLabel
...LY_COMMON_STYLES.fill,
pointerEvents: 'none',
color: theme.input.label
},
focused: {},
hint: {},
Expand Down Expand Up @@ -137,7 +134,7 @@ export class LyField implements OnInit, AfterContentInit, AfterViewInit {
throw new Error(`${val} not found in theme.input.appearance`);
}
this._appearanceClass = this._theme.addStyle(`ly-field.appearance:${val}`, (theme: ThemeVariables) => {
const appearance = (theme.input as any).appearance[val];
const appearance = mergeDeep({}, theme.input.appearance.any, theme.input.appearance[val]);
return {
[`& .${this.classes.container}`]: appearance.container,
[`& .${this.classes.inputNative}`]: appearance.input,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/src/style-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}

export function mergeDeep<T, U>(target: T, source: U): T & U;
export function mergeDeep<T, U, V>(target: T, source1: U, source2: V): T & U & V;
export function mergeDeep<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
export function mergeDeep(target: object, ...sources: any[]): any;

/**
* Deep merge two objects.
* @param target
Expand Down
16 changes: 11 additions & 5 deletions src/lib/themes/minima/dark.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { input } from './variables';
import { ThemeConfig } from '@alyle/ui';
import { ThemeConfig, mergeDeep } from '@alyle/ui';
import { MinimaBase } from './base';

const contrast = '#fff';
Expand Down Expand Up @@ -52,12 +52,18 @@ export class MinimaDark extends MinimaBase implements ThemeConfig {
divider = 'rgba(255, 255, 255, 0.12)';
colorShadow = shadow;
shadow = shadow;
input = {
input = mergeDeep({}, input, {
/** @deprecated */
label: 'rgba(255, 255, 255, 0.4)',
/** @deprecated */
underline: 'rgba(255, 255, 255, 0.11)',
...input,
borderColor: 'rgba(255, 255, 255, 0.12)'
};
borderColor: 'rgba(255, 255, 255, 0.12)',
appearance: {
filled: {
container: {
backgroundColor: 'rgba(255, 255, 255, 0.04)',
}
}
}
});
}
16 changes: 11 additions & 5 deletions src/lib/themes/minima/light.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeConfig } from '@alyle/ui';
import { ThemeConfig, mergeDeep } from '@alyle/ui';
import { input } from './variables';
import { MinimaBase } from './base';

Expand Down Expand Up @@ -52,12 +52,18 @@ export class MinimaLight extends MinimaBase implements ThemeConfig {
backdrop: 'rgba(0,0,0,.6)'
};
bar = '#f5f5f5';
input = {
input = mergeDeep({}, input, {
/** @deprecated */
label: 'rgba(0, 0, 0, 0.6)',
/** @deprecated */
underline: 'rgba(0, 0, 0, 0.11)',
...input,
borderColor: 'rgba(0, 0, 0, 0.12)'
};
borderColor: 'rgba(0, 0, 0, 0.12)',
appearance: {
filled: {
container: {
backgroundColor: 'rgba(0, 0, 0, 0.04)',
}
}
}
});
}
2 changes: 1 addition & 1 deletion src/lib/themes/minima/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const input = {
},
filled: {
container: {
backgroundColor: 'rgba(0, 0, 0, 0.04)',
// backgroundColor: 'rgba(0, 0, 0, 0.04)',
borderRadius: '5px 5px 0 0'
},
containerLabel: {
Expand Down

0 comments on commit 7c085f2

Please sign in to comment.