Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(design): remove error message dependency on form-field #553

Merged
merged 2 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../../scss/daff-util';
@import '../../../scss/daff-util';

.daff-error-message {
display: block;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Component, DebugElement } from '@angular/core';
import { By } from '@angular/platform-browser';

import { DaffErrorMessageComponent } from './error-message.component';

@Component ({
template: `<daff-error-message></daff-error-message>`
})

class WrapperComponent {}

describe('DaffErrorMessageComponent', () => {
let fixture: ComponentFixture<WrapperComponent>;
let de: DebugElement;
let wrapper: WrapperComponent;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
DaffErrorMessageComponent,
WrapperComponent
]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(WrapperComponent);
wrapper = fixture.componentInstance;
de = fixture.debugElement.query(By.css('daff-error-message'));
fixture.detectChanges();
});

it('should create', () => {
expect(wrapper).toBeTruthy();
});

describe('<daff-error-message>', () => {
it('should add a class of "daff-error-message" to the host element', () => {
expect(de.classes).toEqual(jasmine.objectContaining({
'daff-error-message': true,
}));
});
});
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { Component, ViewEncapsulation, HostBinding } from '@angular/core';

@Component({
selector: 'daff-error-message',
template: '<ng-content></ng-content>',
styleUrls: ['./error-message.component.scss'],
host: {
'class': 'daff-error-message'
},
encapsulation: ViewEncapsulation.None
damienwebdev marked this conversation as resolved.
Show resolved Hide resolved
})
export class DaffErrorMessageComponent {}
export class DaffErrorMessageComponent {

@HostBinding('class.daff-error-message') class = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DaffErrorMessageComponent } from './error-message.component';

@NgModule({
imports: [
CommonModule
damienwebdev marked this conversation as resolved.
Show resolved Hide resolved
],
exports: [
DaffErrorMessageComponent
],
declarations: [
DaffErrorMessageComponent
]
})
export class DaffErrorMessageModule { }

This file was deleted.

10 changes: 5 additions & 5 deletions libs/design/src/atoms/form/form-field/form-field.module.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DaffFormFieldComponent } from './form-field/form-field.component';
import { DaffErrorMessageComponent } from './error-message/error-message.component';

import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { DaffErrorMessageModule } from '../error-message/error-message.module';

@NgModule({
imports: [
CommonModule,

FontAwesomeModule
FontAwesomeModule,
DaffErrorMessageModule
],
exports: [
DaffFormFieldComponent,
DaffErrorMessageComponent
DaffErrorMessageModule
],
declarations: [
DaffFormFieldComponent,
DaffErrorMessageComponent
DaffFormFieldComponent
]
})
export class DaffFormFieldModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { By } from '@angular/platform-browser';
import { ReactiveFormsModule, FormControl, Validators } from '@angular/forms';

import { DaffFormFieldComponent } from './form-field.component';
import { DaffErrorMessageComponent } from '../error-message/error-message.component';
import { DaffErrorMessageComponent } from '../../error-message/error-message.component';
import { DaffFormFieldMissingControlMessage } from '../form-field-errors';
import { DaffFormFieldControl } from '../form-field-control';
import { DaffInputModule } from '../../input/public_api';
Expand Down
1 change: 0 additions & 1 deletion libs/design/src/atoms/form/form-field/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { DaffFormFieldModule } from './form-field.module';
export * from './form-field/form-field.component';
export { DaffFormFieldControl } from './form-field-control';
export * from './error-message/error-message.component';
2 changes: 1 addition & 1 deletion libs/design/src/scss/theming/_theme.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../../atoms/button/button-theme';
@import '../../atoms/form/form-field/error-message/error-message-theme';
@import '../../atoms/form/error-message/error-message-theme';
@import '../../atoms/form/form-field/form-field/form-field-theme';
@import '../../atoms/form/input/input/input-theme';
@import '../../atoms/form/select/select/select-theme';
Expand Down