Skip to content

Commit

Permalink
feat(stark-ui): added white theme and full width for dropdown component
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #642, #640
  • Loading branch information
Mallikki authored and catlabs committed Sep 7, 2018
1 parent 09ada00 commit c8c998e
Show file tree
Hide file tree
Showing 21 changed files with 149 additions and 41 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"lint:stark-ui": "cd packages/stark-ui && npm run lint && cd ../..",
"lint:showcase": "cd showcase && npm run lint && cd ..",
"lint:starter": "cd starter && npm run lint && cd ..",
"lint:all": "npm run lint && npm run lint:stark-core && npm run lint:stark-ui && npm run lint:starter && npm run lint:showcase",
"lint:all": "npm run lint:stark-core && npm run lint:stark-ui && npm run lint:starter && npm run lint:showcase",
"install:all": "npm run install:stark-build && npm run install:stark-testing && npm run install:stark-core && npm run install:stark-ui && npm run build && npm run install:starter && npm run install:showcase",
"install:stark-build": "cd packages/stark-build && npm install --no-optional && cd ../..",
"install:stark-core": "cd packages/stark-core && npm install --no-optional && cd ../..",
Expand Down
5 changes: 5 additions & 0 deletions packages/stark-ui/assets/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ $button-theme: (
contrast: $light-primary-text
)
);
$dropdown-theme: (
white-transp: (
color: rgba(255, 255, 255, 0.87)
)
);
$card-theme: (
border-radius: $border-radius
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@mixin stark-dropdown-color($color) {
.mat-form-field-label {
color: rgba($color: $color, $alpha: 0.87);
}

// arrow color change
.mat-select-arrow,
.mat-form-field.mat-focused .mat-select-arrow {
color: rgba($color: $color, $alpha: 0.87);
}

// arrow color change
.mat-select-value {
color: rgba($color: $color, $alpha: 0.87);
}

// underline color change (normal and focus)
.mat-form-field-underline,
.mat-form-field.mat-focused .mat-form-field-ripple {
background-color: rgba($color: $color, $alpha: 0.87);
}
}

.stark-dropdown {
&[color="white"] {
@include stark-dropdown-color(map-get(map-get($dropdown-theme, white-transp), color));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@
mat-select {
margin: 0;
}
width: 150px;

.mat-form-field-infix {
width: 150px;
}

&.stark-full-width {
.mat-form-field-infix {
width: 100%;
}
}
}

@media #{$tablet-only-query} {
.stark-dropdown {
width: 300px;
.mat-form-field-infix {
width: 300px;
}
}
}

/* compact */

@media #{$desktop-query} {
.stark-dropdown {
width: 350px;
.mat-form-field-infix {
width: 350px;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
import {
Component,
EventEmitter,
HostBinding,
Inject,
Input,
OnChanges,
OnInit,
Output,
SimpleChanges,
ViewEncapsulation
} from "@angular/core";
import { Component, EventEmitter, Inject, Input, OnChanges, OnInit, Output, SimpleChanges, ViewEncapsulation } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";

/**
Expand All @@ -24,15 +13,13 @@ const componentName: string = "stark-dropdown";
@Component({
selector: "stark-dropdown",
templateUrl: "./dropdown.component.html",
encapsulation: ViewEncapsulation.None
encapsulation: ViewEncapsulation.None,
// We need to use host instead of @HostBinding: https://github.com/NationalBankBelgium/stark/issues/664
host: {
class: componentName
}
})
export class StarkDropdownComponent implements OnInit, OnChanges, OnInit {
/**
* Adds class="stark-dropdown" attribute on the host component
*/
@HostBinding("class")
public class: string = componentName;

/**
* If the dropdown will contain a default blank (optional)
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/stark-ui/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
}
],
"jsdoc-format": [true, "check-multiline-start"],
"no-redundant-jsdoc": true
"no-redundant-jsdoc": true,
"use-host-property-decorator": false
}
}
3 changes: 0 additions & 3 deletions showcase/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
<a mat-list-item uiSref="demo-slider" uiSrefActive="active">
<span matLine>Slider</span>
</a>
<a mat-list-item uiSref="demo-table" uiSrefActive="active">
<span matLine>Table</span>
</a>
<a mat-list-item uiSref="stark-header" uiSrefActive="active">
<span matLine>Stark header</span>
</a>
Expand Down
4 changes: 2 additions & 2 deletions showcase/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DateRangePickerComponent,
DemoBreadcrumbComponent,
DemoSidebarComponent,
DropdownComponent,
DemoDropdownComponent,
ExampleViewerComponent,
HeaderComponent,
KeyboardDirectivesComponent,
Expand Down Expand Up @@ -35,6 +35,6 @@ export const APP_STATES: Ng2StateDeclaration[] = [
{ name: "demo-slider", url: "/demo/slider", component: SliderComponent },
{ name: "demo-sidebar", url: "/demo/sidebar", component: DemoSidebarComponent },
{ name: "demo-table", url: "/demo/table", component: TableComponent },
{ name: "demo-dropdown", url: "/demo/dropdown", component: DropdownComponent },
{ name: "demo-dropdown", url: "/demo/dropdown", component: DemoDropdownComponent },
{ name: "otherwise", url: "/otherwise", component: NoContentComponent }
];
6 changes: 3 additions & 3 deletions showcase/src/app/demo/demo.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ButtonComponent } from "./button/button.component";
import { DatePickerComponent } from "./date-picker/date-picker.component";
import { DateRangePickerComponent } from "./date-range-picker/date-range-picker.component";
import { DemoSidebarComponent } from "./sidebar/demo-sidebar.component";
import { DropdownComponent } from "./dropdown/dropdown.component";
import { DemoDropdownComponent } from "./dropdown/demo-dropdown.component";
import { ExampleViewerComponent } from "./example-viewer/example-viewer.component";
import { HeaderComponent } from "./header/header.component";
import { KeyboardDirectivesComponent } from "./keyboard-directives/keyboard-directives.component";
Expand Down Expand Up @@ -77,7 +77,7 @@ import { MAT_DATE_FORMATS } from "@angular/material/core";
ButtonComponent,
DatePickerComponent,
DateRangePickerComponent,
DropdownComponent,
DemoDropdownComponent,
ExampleViewerComponent,
HeaderComponent,
KeyboardDirectivesComponent,
Expand All @@ -97,7 +97,7 @@ import { MAT_DATE_FORMATS } from "@angular/material/core";
ButtonComponent,
DatePickerComponent,
DateRangePickerComponent,
DropdownComponent,
DemoDropdownComponent,
ExampleViewerComponent,
HeaderComponent,
KeyboardDirectivesComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<example-viewer [extensions]="['HTML', 'TS']" filesPath="dropdown/single-required-selection" [exampleTitle]="'SHOWCASE.DEMO.DROPDOWNS.REQUIRED' | translate">
<stark-dropdown
<stark-dropdown
dropdownId="serviceDropdown"
[options]="serviceDropdownOptions"
[value]="selectedService"
Expand All @@ -9,6 +9,7 @@
(dropdownSelectionChanged)="serviceDropdownOnChange($event)"
required>
</stark-dropdown>

<div *ngIf="selectedService"> {{ 'SHOWCASE.DEMO.DROPDOWNS.SELECTED_VALUE' | translate }}: {{ selectedService }}</div>
</example-viewer>

Expand Down Expand Up @@ -67,3 +68,19 @@
</stark-dropdown>
</example-viewer>

<example-viewer class="dark" [extensions]="['HTML', 'TS', 'CSS']" filesPath="dropdown/white" [exampleTitle]="'SHOWCASE.DEMO.DROPDOWNS.WHITE' | translate">
<stark-dropdown
class="stark-full-width"
color="white"
dropdownId="serviceWhiteDropdown"
[options]="serviceDropdownOptions"
[value]="selectedServiceWhiteDropdown"
placeholder="SHOWCASE.DEMO.DROPDOWNS.SELECT_SERVICE"
optionIdProperty="id"
optionLabelProperty="value"
(dropdownSelectionChanged)="whiteDropdownOnChange($event)"
required>
</stark-dropdown>

<div class="result-display" *ngIf="selectedServiceWhiteDropdown"> {{ 'SHOWCASE.DEMO.DROPDOWNS.SELECTED_VALUE' | translate }}: {{ selectedServiceWhiteDropdown }}</div>
</example-viewer>
7 changes: 7 additions & 0 deletions showcase/src/app/demo/dropdown/demo-dropdown.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.dark .example-viewer-body {
background: #333;
}

.result-display {
color: #fff;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { Component, OnInit } from "@angular/core";
import { Component, OnInit, ViewEncapsulation } from "@angular/core";

@Component({
selector: "showcase-demo-dropdown",
styleUrls: ["./dropdown.component.scss"],
templateUrl: "./dropdown.component.html"
styleUrls: ["./demo-dropdown.component.scss"],
templateUrl: "./demo-dropdown.component.html",
encapsulation: ViewEncapsulation.None //used here to be able to customize the example-viewer background color
})
export class DropdownComponent implements OnInit {
export class DemoDropdownComponent implements OnInit {
public selectedService: string;
public selectedServiceWhiteDropdown: string;
public selectedServices: string[];
public selectedRequiredServices: string[];
public selectedNumber: string;

public serviceDropdownOptions: any[];

/**
* Component lifecycle hook
*/
Expand All @@ -38,4 +41,8 @@ export class DropdownComponent implements OnInit {
public multipleServicesRequiredDropdownOnChange(selectedValues: string[]): void {
this.selectedRequiredServices = selectedValues;
}

public whiteDropdownOnChange(selectedValue: string): void {
this.selectedServiceWhiteDropdown = selectedValue;
}
}
Empty file.
2 changes: 1 addition & 1 deletion showcase/src/app/demo/dropdown/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./dropdown.component";
export * from "./demo-dropdown.component";
3 changes: 3 additions & 0 deletions showcase/src/assets/examples/dropdown/white.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.result-display {
color: #fff;
}
13 changes: 13 additions & 0 deletions showcase/src/assets/examples/dropdown/white.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<stark-dropdown
class="stark-full-width"
color="white"
dropdownId="serviceWhiteDropdown"
[options]="serviceDropdownOptions"
[value]="selectedServiceWhiteDropdown"
placeholder="SHOWCASE.DEMO.DROPDOWNS.SELECT_SERVICE"
optionIdProperty="id"
optionLabelProperty="value"
(dropdownSelectionChanged)="whiteDropdownOnChange($event)"
required>
</stark-dropdown>
<div class="result-display" *ngIf="selectedServiceWhiteDropdown"> {{ 'SHOWCASE.DEMO.DROPDOWNS.SELECTED_VALUE' | translate }}: {{ selectedServiceWhiteDropdown }}</div>
26 changes: 26 additions & 0 deletions showcase/src/assets/examples/dropdown/white.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component, OnInit } from "@angular/core";

@Component({
selector: "showcase-demo-dropdown",
styleUrls: ["./white.scss"],
templateUrl: "./white.html"
})
export class WhiteDropdownComponent implements OnInit {
public selectedServiceWhiteDropdown: string;

public serviceDropdownOptions: any[];
/**
* Component lifecycle hook
*/
public ngOnInit(): void {
this.serviceDropdownOptions = [
{ id: "PR", value: "IT application" },
{ id: "IO", value: "Informatics infrastructure and operations" },
{ id: "CS", value: "IT customer services" }
];
}

public whiteDropdownOnChange(selectedValue: string): void {
this.selectedServiceWhiteDropdown = selectedValue;
}
}
3 changes: 2 additions & 1 deletion showcase/src/assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"SELECT_NUMBER": "Select your lucky number",
"SELECT_SERVICES": "Select one or more services",
"SELECT_ONE_SERVICE": "Select at least one service",
"SELECT_DISABLED": "Sorry, it's disabled"
"SELECT_DISABLED": "Sorry, it's disabled",
"WHITE": "White dropdown on black background (full width)"
},
"HEADER": {
"TITLE": "Stark App Header Guidelines",
Expand Down
3 changes: 2 additions & 1 deletion showcase/src/assets/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"SELECT_NUMBER": "Sélectionnez votre chiffre porte-bonheur",
"SELECT_SERVICES": "Sélectionnez un service ou plus",
"SELECT_ONE_SERVICE": "Sélectionnez au moins un service",
"SELECT_DISABLED": "Désolé, ce dropdown est désactivé"
"SELECT_DISABLED": "Désolé, ce dropdown est désactivé",
"WHITE": "Dropdown blanc sur fond noir (largeur maximale)"
},
"HEADER": {
"TITLE": "Stark App Header Guidelines",
Expand Down
3 changes: 2 additions & 1 deletion showcase/src/assets/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"SELECT_NUMBER": "Selecteer uw geluksnummer",
"SELECT_SERVICES": "Selecteer een of meer diensten",
"SELECT_ONE_SERVICE": "Selecteer ten minsten een dienst",
"SELECT_DISABLED": "Sorry, ditdés dropdown is niet geactiveerd"
"SELECT_DISABLED": "Sorry, deze dropdown is niet geactiveerd",
"WHITE": "Witte dropdown met zwarte achtergrond (maximum breedte)"
},
"HEADER": {
"TITLE": "Stark App Header Guidelines",
Expand Down
1 change: 1 addition & 0 deletions showcase/src/styles/_stark-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ IMPORTANT: Stark styles are provided as SCSS styles so they should be imported i
@import "~@nationalbankbelgium/stark-ui/src/modules/pretty-print/components/pretty-print.component";
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/table.component";
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/dialogs/multisort.component";
@import "~@nationalbankbelgium/stark-ui/src/modules/dropdown/components/dropdown-theme";
@import "~@nationalbankbelgium/stark-ui/src/modules/dropdown/components/dropdown.component";

0 comments on commit c8c998e

Please sign in to comment.