Skip to content

Commit 2334de2

Browse files
committed
feat(lib): added mat algolia select component
1 parent 6c9575b commit 2334de2

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<select
2+
(change)="state.refine($event.target.value)"
3+
class="menu-select"
4+
>
5+
<option
6+
*ngFor="let item of state.items"
7+
[selected]="item.isRefined"
8+
[value]="item.value"
9+
>
10+
{{item.label}}
11+
</option>
12+
</select>

projects/angular-material-extensions/algolia/src/lib/components/mat-algolia-menu-select/mat-algolia-menu-select.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { MatAlgoliaMenuSelectComponent } from './mat-algolia-menu-select.component';
4+
5+
describe('MatAlgoliaMenuSelectComponent', () => {
6+
let component: MatAlgoliaMenuSelectComponent;
7+
let fixture: ComponentFixture<MatAlgoliaMenuSelectComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [MatAlgoliaMenuSelectComponent]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(MatAlgoliaMenuSelectComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component, forwardRef, Inject, OnInit } from '@angular/core';
2+
import { BaseWidget, NgAisInstantSearch } from 'angular-instantsearch';
3+
import { connectMenu } from 'instantsearch.js/es/connectors';
4+
5+
@Component({
6+
selector: 'mat-algolia-menu-select',
7+
templateUrl: './mat-algolia-menu-select.component.html',
8+
styleUrls: ['./mat-algolia-menu-select.component.scss']
9+
})
10+
export class MatAlgoliaMenuSelectComponent extends BaseWidget implements OnInit {
11+
12+
state: {
13+
items: { label: string; value: string }[];
14+
createURL: () => string;
15+
refine: (value: string) => void;
16+
canRefine: boolean;
17+
isShowingMore: boolean;
18+
toggleShowMore: () => void;
19+
canToggleShowMore: boolean;
20+
};
21+
22+
constructor(
23+
@Inject(forwardRef(() => NgAisInstantSearch))
24+
public instantSearchParent: NgAisInstantSearch) {
25+
super('MatAlgoliaMenuSelectComponent');
26+
}
27+
28+
public ngOnInit() {
29+
this.createWidget(connectMenu, { attribute: 'categories' });
30+
super.ngOnInit();
31+
}
32+
}

0 commit comments

Comments
 (0)