-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(schematics): address form schematic #11425
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.full-width { | ||
width: 100%; | ||
} | ||
|
||
.shipping-card { | ||
width: 500px; | ||
margin: 20px auto; | ||
} | ||
|
||
mat-radio-button { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be a css class instead of styling the element directly? |
||
display: block; | ||
margin: 5px 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<form [formGroup]="addressForm" novalidate> | ||
<mat-card class="shipping-card"> | ||
<mat-card-header> | ||
<mat-card-title>Shipping Information</mat-card-title> | ||
</mat-card-header> | ||
<mat-card-content> | ||
<table cellspacing="0" class="full-width"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other examples used a table so I just carried that over here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which other examples? User-facing ones? |
||
<tr> | ||
<td colspan="2"> | ||
<mat-form-field class="full-width"> | ||
<input matInput placeholder="Company" formControlName="company"> | ||
</mat-form-field> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<mat-form-field class="full-width"> | ||
<input matInput placeholder="First name" formControlName="firstName"> | ||
<mat-error *ngIf="addressForm.controls['firstName'].hasError('required')"> | ||
First name is <strong>required</strong> | ||
</mat-error> | ||
</mat-form-field> | ||
</td> | ||
<td> | ||
<mat-form-field class="full-width"> | ||
<input matInput placeholder="Last name" formControlName="lastName"> | ||
<mat-error *ngIf="addressForm.controls['lastName'].hasError('required')"> | ||
Last name is <strong>required</strong> | ||
</mat-error> | ||
</mat-form-field> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td colspan="2"> | ||
<mat-form-field class="full-width"> | ||
<textarea matInput placeholder="Address" formControlName="address"></textarea> | ||
<mat-error *ngIf="addressForm.controls['address'].hasError('required')"> | ||
Address is <strong>required</strong> | ||
</mat-error> | ||
</mat-form-field> | ||
</td> | ||
</tr> | ||
<tr *ngIf="!hasUnitNumber"> | ||
<td> | ||
<button mat-button type="button" (click)="hasUnitNumber = !hasUnitNumber"> | ||
+ Add C/O, Apt, Suite, Unit | ||
</button> | ||
</td> | ||
</tr> | ||
<tr *ngIf="hasUnitNumber"> | ||
<td colspan="2"> | ||
<mat-form-field class="full-width"> | ||
<textarea matInput placeholder="Address 2" formControlName="address2"></textarea> | ||
</mat-form-field> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<mat-form-field class="full-width"> | ||
<input matInput placeholder="City" formControlName="city"> | ||
<mat-error *ngIf="addressForm.controls['city'].hasError('required')"> | ||
City is <strong>required</strong> | ||
</mat-error> | ||
</mat-form-field> | ||
</td> | ||
<td> | ||
<mat-form-field class="full-width"> | ||
<mat-select placeholder="State" formControlName="state"> | ||
<mat-option *ngFor="let state of states" [value]="state.abbreviation"> | ||
{{ state.name }} | ||
</mat-option> | ||
</mat-select> | ||
<mat-error *ngIf="addressForm.controls['state'].hasError('required')"> | ||
State is <strong>required</strong> | ||
</mat-error> | ||
</mat-form-field> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td colspan="2"> | ||
<mat-form-field class="full-width"> | ||
<input matInput #postalCode maxlength="5" placeholder="Postal Code" type="number" formControlName="postalCode"> | ||
<mat-hint align="end">{{postalCode.value.length}} / 5</mat-hint> | ||
</mat-form-field> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td colspan="2"> | ||
<mat-radio-group formControlName="shipping"> | ||
<mat-radio-button value="free">Free Shipping</mat-radio-button> | ||
<mat-radio-button value="priority">Priority Shipping</mat-radio-button> | ||
<mat-radio-button value="nextday">Next Day Shipping</mat-radio-button> | ||
</mat-radio-group> | ||
</td> | ||
</tr> | ||
</table> | ||
</mat-card-content> | ||
<mat-card-actions> | ||
<button mat-raised-button color="primary" type="submit">Submit</button> | ||
</mat-card-actions> | ||
</mat-card> | ||
</form> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
import { fakeAsync, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.component'; | ||
|
||
describe('<%= classify(name) %>Component', () => { | ||
let component: <%= classify(name) %>Component; | ||
let fixture: ComponentFixture<<%= classify(name) %>Component>; | ||
|
||
beforeEach(fakeAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ <%= classify(name) %>Component ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(<%= classify(name) %>Component); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should compile', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be something like
address-form
in case we want to add different forms later?