Commit 14fa8c1b authored by Olivia Madrid's avatar Olivia Madrid

(refactor): change dropdownv2 to filter and pass tests

1 merge request!662Generic dropdown component
Pipeline #97746670 running with stages
......@@ -121,7 +121,7 @@ import { PageLayoutComponent } from './components/page-layout/page-layout.compon
import { DashboardLayoutComponent } from './components/dashboard-layout/dashboard-layout.component';
import { ShadowboxLayoutComponent } from './components/shadowbox-layout/shadowbox-layout.component';
import { ShadowboxHeaderComponent } from './components/shadowbox-header/shadowbox-header.component';
import { DropdownV2Component } from './components/dropdown-v2/dropdown-v2.component';
import { FilterComponent } from './components/filter/filter.component';
PlotlyModule.plotlyjs = PlotlyJS;
......@@ -233,7 +233,7 @@ PlotlyModule.plotlyjs = PlotlyJS;
DashboardLayoutComponent,
ShadowboxLayoutComponent,
ShadowboxHeaderComponent,
DropdownV2Component,
FilterComponent,
],
exports: [
MINDS_PIPES,
......@@ -329,7 +329,7 @@ PlotlyModule.plotlyjs = PlotlyJS;
PageLayoutComponent,
DashboardLayoutComponent,
ShadowboxLayoutComponent,
DropdownV2Component,
FilterComponent,
],
providers: [
SiteService,
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DropdownV2Component } from './dropdown-v2.component';
describe('DropdownV2Component', () => {
let component: DropdownV2Component;
let fixture: ComponentFixture<DropdownV2Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [DropdownV2Component],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DropdownV2Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
<div class="m-dropdownV2__labelWrapper" *ngIf="showLabel">
<div class="m-filter__labelWrapper" *ngIf="showLabel">
<span>{{ filter.label }}</span>
<m-tooltip icon="help">
<div>{{ filter?.description }}</div>
......@@ -13,7 +13,7 @@
</m-tooltip>
</div>
<div
class="m-dropdownV2__wrapper"
class="m-filter__wrapper"
[ngClass]="{
expanded: expanded,
dropUp: dropUp
......@@ -21,17 +21,17 @@
(blur)="expanded = false"
tabindex="0"
>
<div class="m-dropdownV2__header" (click)="expanded = !expanded">
<span class="m-dropdownV2__option">
<div class="m-filter__header" (click)="expanded = !expanded">
<span class="m-filter__option">
{{ selectedOption.label }}
</span>
<i class="material-icons" *ngIf="!expanded">keyboard_arrow_down</i>
<i class="material-icons" *ngIf="expanded">keyboard_arrow_up</i>
</div>
<div class="m-dropdownV2__optionsContainer">
<div class="m-filter__optionsContainer">
<ng-container *ngFor="let option of filter.options">
<div
class="m-dropdownV2__option"
class="m-filter__option"
(click)="updateFilter(option)"
[ngClass]="{
unavailable: option.available === false
......
$rounded-top: 3px 3px 0 0;
$rounded-bottom: 0 0 3px 3px;
m-dropdownV2 {
m-filter {
position: relative;
margin: 0 24px 36px 0;
z-index: 2;
display: block;
}
.m-dropdownV2__labelWrapper {
.m-filter__labelWrapper {
position: absolute;
bottom: 115%;
white-space: nowrap;
......@@ -45,7 +45,7 @@ m-dropdownV2 {
}
}
.m-dropdownV2__wrapper {
.m-filter__wrapper {
cursor: pointer;
&:focus {
......@@ -56,31 +56,31 @@ m-dropdownV2 {
@include m-theme() {
box-shadow: 0px 1px 15px 0 rgba(themed($m-black), 0.15);
}
.m-dropdownV2__header {
.m-filter__header {
@include m-theme() {
border-color: themed($m-blue);
}
}
.m-dropdownV2__optionsContainer {
.m-filter__optionsContainer {
display: block;
}
&:not(.dropUp) {
.m-dropdownV2__header {
.m-filter__header {
@include m-theme() {
border-radius: $rounded-top;
}
}
.m-dropdownV2__optionsContainer {
.m-filter__optionsContainer {
border-top: none;
border-radius: $rounded-bottom;
}
}
&.dropUp {
.m-dropdownV2__header {
.m-filter__header {
border-radius: $rounded-bottom;
}
.m-dropdownV2__optionsContainer {
.m-filter__optionsContainer {
bottom: 100%;
border-radius: $rounded-top;
border-bottom: none;
......@@ -97,7 +97,7 @@ m-dropdownV2 {
}
}
.m-dropdownV2__header {
.m-filter__header {
position: relative;
border-radius: 3px;
transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
......@@ -109,7 +109,7 @@ m-dropdownV2 {
@include m-theme() {
border: 1px solid themed($m-grey-100);
}
.m-dropdownV2__label {
.m-filter__label {
margin-right: 10px;
}
i {
......@@ -118,14 +118,14 @@ m-dropdownV2 {
height: 24px;
padding-top: 2px;
}
.m-dropdownV2__option {
.m-filter__option {
@include m-theme() {
color: themed($m-grey-500);
}
}
}
.m-dropdownV2__optionsContainer {
.m-filter__optionsContainer {
box-sizing: border-box;
position: absolute;
display: none;
......@@ -139,7 +139,7 @@ m-dropdownV2 {
box-shadow: 0px 8px 16px 0px rgba(themed($m-black), 0.15);
}
.m-dropdownV2__option {
.m-filter__option {
&:hover:not(.unavailable) {
@include m-theme() {
color: themed($m-grey-500);
......@@ -155,13 +155,13 @@ m-dropdownV2 {
}
}
.m-dropdownV2__header {
.m-filter__header {
display: flex;
justify-content: space-between;
align-items: center;
padding-right: 10px;
}
.m-dropdownV2__option {
.m-filter__option {
display: inline-block;
padding: 10px 20px;
box-sizing: border-box;
......@@ -184,8 +184,8 @@ m-dropdownV2 {
}
@media screen and (max-width: $min-tablet) {
m-dropdownV2 {
.m-dropdownV2__labelWrapper {
m-filter {
.m-filter__labelWrapper {
.m-tooltip--bubble {
width: 120px;
}
......@@ -194,19 +194,19 @@ m-dropdownV2 {
}
@media screen and (max-width: $max-mobile) {
m-dropdownV2 {
.m-dropdownV2__wrapper {
m-filter {
.m-filter__wrapper {
> * {
width: 160px;
}
.m-dropdownV2__header {
.m-filter__header {
padding-right: 10px;
i {
display: none;
}
}
.m-dropdownV2__optionsContainer {
.m-dropdownV2__option {
.m-filter__optionsContainer {
.m-filter__option {
&:first-child {
padding-top: 11px;
}
......@@ -215,7 +215,7 @@ m-dropdownV2 {
}
}
}
.m-dropdownV2__option {
.m-filter__option {
margin-right: 0;
padding: 8px 18px;
}
......
......@@ -11,11 +11,11 @@ import { Session } from '../../../services/session';
import { Filter, Option } from '../../../interfaces/dashboard';
@Component({
selector: 'm-dropdownV2',
templateUrl: './dropdown-v2.component.html',
selector: 'm-filter',
templateUrl: './filter.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DropdownV2Component implements OnInit {
export class FilterComponent implements OnInit {
@Input() filter: Filter;
@Input() dropUp: boolean = false;
@Input() showLabel: boolean = true;
......
<div class="m-analytics__filtersContainer">
<ng-container *ngFor="let filter of filters">
<m-dropdownV2
class="filter"
<m-filter
[filter]="filter"
[dropUp]="true"
(selectionMade)="selectionMade($event)"
></m-dropdownV2>
></m-filter>
</ng-container>
</div>
......@@ -16,14 +16,14 @@
<m-analytics__search></m-analytics__search>
</div> -->
<!-- <div class="m-analyticsDashboard__channelFilter" *ngIf="session.isAdmin()">
<m-dropdownV2 [filter]="channelFilter"></m-dropdownV2>
<m-filter [filter]="channelFilter"></m-filter>
</div> -->
<div class="m-analyticsDashboard__timespanFilter">
<m-dropdownV2
<m-filter
[filter]="timespanFilter"
[showLabel]="false"
(selectionMade)="filterSelectionMade($event)"
></m-dropdownV2>
></m-filter>
</div>
</div>
</ng-container>
......
......@@ -30,10 +30,10 @@ m-analytics__dashboard {
}
}
}
m-dropdownV2 {
m-filter {
margin: 0;
}
.m-dropdownV2__wrapper {
.m-filter__wrapper {
> * {
width: 180px;
}
......@@ -56,11 +56,11 @@ m-analytics__dashboard {
@media screen and (max-width: $min-tablet) {
.m-dashboardLayout__header {
m-dropdownV2 {
m-filter {
margin: 0 16px 8px 0;
.m-dropdownV2__wrapper {
.m-filter__wrapper {
> * {
width: 160px;
width: 180px;
}
}
}
......@@ -72,9 +72,11 @@ m-analytics__dashboard {
@media screen and (max-width: $max-mobile) {
.m-dashboardLayout__header {
.m-dropdownV2__wrapper {
> * {
width: 140px;
m-filter {
.m-filter__wrapper {
> * {
width: 160px;
}
}
}
}
......
<form class="m-form">
<p>
You can receive Bitcoin (BTC) payments via wire by inputing a receiver
You can receive Bitcoin (BTC) payments via wire by inputting a receiver
address below. Note: You may want to rotate this address frequently to avoid
3rd parties tracking your transactions.
</p>
......
Please register or to comment