Skip to content

Commit 9cf1106

Browse files
committed
feat(package): added the appearance input to style the address mat-form-field #5
1 parent 3373266 commit 9cf1106

8 files changed

+30
-10
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ add `mat-google-maps-auto-complete` element to your template
160160
### `mat-google-maps-auto-complete`
161161

162162
```html
163-
<mat-google-maps-autocomplete (onAddressSelected)="onAddressSelected($event)"
163+
<mat-google-maps-autocomplete [appearance]="appearance.OUTLINE"
164+
(onAddressSelected)="onAddressSelected($event)"
164165
(onLocationSelected)="onLocationSelected($event)">
165166
</mat-google-maps-autocomplete>
166167
```
@@ -204,7 +205,7 @@ in your component, the code will be similar to -->
204205
```typescript
205206
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
206207
import {Title} from '@angular/platform-browser';
207-
import {Location} from '@angular-material-extensions/google-maps-autocomplete';
208+
import {Location, Appearance} from '@angular-material-extensions/google-maps-autocomplete';
208209
import {} from '@types/googlemaps';
209210
import PlaceResult = google.maps.places.PlaceResult;
210211

@@ -216,6 +217,7 @@ import PlaceResult = google.maps.places.PlaceResult;
216217
})
217218
export class HomeComponent implements OnInit {
218219

220+
public appearance = Appearance;
219221
public zoom: number;
220222
public latitude: number;
221223
public longitude: number;
@@ -266,6 +268,7 @@ export class HomeComponent implements OnInit {
266268

267269
| option | bind | type | default | description |
268270
|:-------------------|:--------:|:------:|:------------:|:-------------------------------------------------------------------------------------------------|
271+
| appearance | Input() | Appearance | string; | Appearance.STANDARD | Style the `mat-form-field` by setting the appearance option : standard, fill, outline or legacy
269272
| address | Input() | PlaceResult | string; | - |
270273
| country | Input() | string | string[]; | - | can be used to restrict results to specific groups. Currently, you can use componentRestrictions to filter by up to 5 countries. Countries must be passed as as a two-character, ISO 3166-1 Alpha-2 compatible country code. Multiple countries must be passed as a list of country codes.
271274
| placeIdOnly | Input() | boolean | - | can be used to instruct the Autocomplete widget to retrieve only Place IDs. On calling getPlace() on the Autocomplete object, the PlaceResult made available will only have the place id, types and name properties set. You can use the returned place ID with calls to the Places, Geocoding, Directions or Distance Matrix services.

demo/src/app/app.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import {AppComponent} from './app.component';
1010
import {HttpClientModule} from '@angular/common/http';
1111
import {environment} from '../environments/environment';
1212
import {AgmCoreModule} from '@agm/core';
13+
import {MatGoogleMapsAutocompleteModule} from '@angular-material-extensions/google-maps-autocomplete';
1314
import {FlexLayoutModule} from '@angular/flex-layout';
1415
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
1516
import {MatJumbotronModule} from '@angular-material-extensions/jumbotron';
17+
1618
// import {} from '@types/googlemaps';
1719

1820
const googleMapsParams = {
@@ -32,6 +34,7 @@ const googleMapsParams = {
3234
// the page.
3335
BrowserModule.withServerTransition({appId: '@angular-material-extensions/google-maps-autocomplete-demo-id'}),
3436
AgmCoreModule.forRoot(googleMapsParams),
37+
MatGoogleMapsAutocompleteModule.forRoot(),
3538
MatJumbotronModule.forRoot(),
3639
BrowserAnimationsModule,
3740
FlexLayoutModule,

demo/src/app/home/home.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ <h1>@angular-material-extensions/google-maps-autocomplete</h1>
7878
class="autocomplete-container"
7979
[ngStyle.xs]="{'min-width.%': 100}"
8080
[ngStyle.sm]="{'width.%': 70}">
81-
<mat-google-maps-autocomplete (onAutocompleteSelected)="onAutocompleteSelected($event)"
81+
<mat-google-maps-autocomplete [appearance]="appearance.STANDARD"
82+
(onAutocompleteSelected)="onAutocompleteSelected($event)"
8283
(onLocationSelected)="onLocationSelected($event)">
8384
</mat-google-maps-autocomplete>
8485

demo/src/app/home/home.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, OnInit, ViewEncapsulation} from '@angular/core';
22
import {Title} from '@angular/platform-browser';
3-
import {Location} from '@angular-material-extensions/google-maps-autocomplete';
3+
import {Location, Appearance} from '@angular-material-extensions/google-maps-autocomplete';
44
import sdk from '@stackblitz/sdk';
55
import {} from '@types/googlemaps';
66
import PlaceResult = google.maps.places.PlaceResult;
@@ -23,14 +23,15 @@ export class HomeComponent implements OnInit {
2323
class="autocomplete-container"
2424
[ngStyle.xs]="{'min-width.%': 100}"
2525
[ngStyle.sm]="{'width.%': 70}">
26-
<mat-google-maps-autocomplete (onAddressSelected)="onAddressSelected($event)"
27-
(onLocationSelected)="onLocationSelected($event)">
26+
<mat-google-maps-autocomplete [appearance]="appearance.OUTLINE"
27+
(onAutocompleteSelected)="onAutocompleteSelected($event)"
28+
(onLocationSelected)="onLocationSelected($event)">
2829
</mat-google-maps-autocomplete>
2930
</div>`;
3031

3132
ts = `import {Component, OnInit, ViewEncapsulation} from '@angular/core';
3233
import {Title} from '@angular/platform-browser';
33-
import {Location} from '@angular-material-extensions/google-maps-autocomplete';
34+
import {Location, Appearance} from '@angular-material-extensions/google-maps-autocomplete';
3435
import sdk from '@stackblitz/sdk';
3536
import {} from '@types/googlemaps';
3637
import PlaceResult = google.maps.places.PlaceResult;
@@ -43,6 +44,7 @@ import PlaceResult = google.maps.places.PlaceResult;
4344
})
4445
export class HomeComponent implements OnInit {
4546
47+
public appearance = Appearance;
4648
public zoom: number;
4749
public latitude: number;
4850
public longitude: number;
@@ -92,6 +94,7 @@ export class HomeComponent implements OnInit {
9294
width: 50%;
9395
}`;
9496

97+
public appearance = Appearance;
9598
public zoom: number;
9699
public latitude: number;
97100
public longitude: number;

demo/src/app/home/home.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {MatJumbotronModule} from '@angular-material-extensions/jumbotron';
1414
imports: [
1515
CommonModule,
1616
FlexLayoutModule,
17-
MatGoogleMapsAutocompleteModule.forRoot(),
17+
MatGoogleMapsAutocompleteModule,
1818
HighlightModule.forRoot({theme: 'vs2015'}),
1919
HomeRoutingModule,
2020
MatJumbotronModule,

src/module/component/mat-google-maps-autocomplete.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<mat-form-field class="full-width" appearance="outline">
1+
<mat-form-field class="full-width" [appearance]="appearance">
22
<mat-label>Address</mat-label>
33
<input matInput
44
[(ngModel)]="address"

src/module/component/mat-google-maps-autocomplete.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ export interface Location {
1010
longitude: number;
1111
}
1212

13+
export enum Appearance {
14+
STANDARD = 'standard',
15+
FILL = 'fill',
16+
OUTLINE = 'outline',
17+
LEGACY = 'legacy',
18+
}
19+
1320
@Component({
1421
selector: 'mat-google-maps-autocomplete',
1522
templateUrl: './mat-google-maps-autocomplete.component.html',
@@ -20,6 +27,9 @@ export class MatGoogleMapsAutocompleteComponent implements OnInit {
2027
@ViewChild('search')
2128
public searchElementRef: ElementRef;
2229

30+
@Input()
31+
appearance: string | Appearance = Appearance.STANDARD;
32+
2333
@Input()
2434
address: PlaceResult | string;
2535

src/module/mat-google-maps-autocomplete.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
77
import {MatValidateAddressDirective} from './directives/address-validator/mat-address-validator.directive';
88

99
// Export module's public API
10-
export {MatGoogleMapsAutocompleteComponent, Location} from './component/mat-google-maps-autocomplete.component';
10+
export {MatGoogleMapsAutocompleteComponent, Location, Appearance} from './component/mat-google-maps-autocomplete.component';
1111

1212
// export {MatValidateAddressDirective} from './directives/address-validator/mat-address-validator.directive';
1313

0 commit comments

Comments
 (0)