Skip to content

Commit fd05d47

Browse files
authored
Merge branch 'master' into checkbox
2 parents f1dc84d + c9e05c8 commit fd05d47

File tree

3 files changed

+88
-28
lines changed

3 files changed

+88
-28
lines changed

src/button/button.stories.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ storiesOf("Button", module)
1414
.addDecorator(withKnobs)
1515
.add("Basic", () => ({
1616
template: `
17-
<button ibmButton [size]="size">A button</button>
18-
<br><br>
19-
<button ibmButton="secondary" [size]="size">A secondary button</button>
20-
<br><br>
21-
<button ibmButton="tertiary" [size]="size">A tertiary button</button>
22-
<br><br>
23-
<button ibmButton="ghost" [size]="size">A ghost button</button>
24-
<br><br>
25-
<button ibmButton="danger" [size]="size">A danger button</button>
26-
<br><br>
27-
<button ibmButton="danger--primary" [size]="size">A primary danger button</button>
17+
<button [ibmButton]="ibmButton" [size]="size">Button</button>
18+
&nbsp;
19+
<button [ibmButton]="ibmButton" [size]="size" disabled="true">Button</button>
20+
&nbsp;
21+
<button [ibmButton]="ibmButton" [size]="size">
22+
With icon
23+
<svg class="bx--btn__icon" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
24+
<path d="M7 7H4v2h3v3h2V9h3V7H9V4H7v3zm1 9A8 8 0 1 1 8 0a8 8 0 0 1 0 16z" fill-rule="evenodd" />
25+
</svg>
26+
</button>
2827
`,
2928
props: {
29+
ibmButton: select("Button kind", ["primary", "secondary", "tertiary", "ghost", "danger", "danger--primary"], "primary"),
3030
size: select("Size of the buttons", ["normal", "sm"], "normal")
3131
}
3232
}))

src/i18n/en.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@
117117
"NEXT_3": "Scroll to next 3 pages",
118118
"FILTER": "Filter",
119119
"END_OF_DATA": "You've reached the end of your content",
120-
"SCROLL_TOP": "Scroll to top"
120+
"SCROLL_TOP": "Scroll to top",
121+
"CHECKBOX_HEADER": "Select all rows",
122+
"CHECKBOX_ROW": "Select row",
123+
"EXPAND_BUTTON": "Expand row",
124+
"SORT_DESCENDING": "Sort rows by this header in descending order",
125+
"SORT_ASCENDING": "Sort rows by this header in ascending order"
126+
121127
},
122128
"TABS": {
123129
"BUTTON_ARIA_LEFT": "Go to the previous tab",

src/table/table.component.ts

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ import { I18n } from "./../i18n/i18n.module";
179179
[size]="size !== ('lg' ? 'sm' : 'md')"
180180
[(ngModel)]="selectAllCheckbox"
181181
[indeterminate]="selectAllCheckboxSomeSelected"
182-
aria-label="Select all rows"
182+
[attr.aria-label]="checkboxHeaderLabel | async"
183183
(change)="onSelectAllCheckboxChange()">
184184
</ibm-checkbox>
185185
</th>
@@ -200,7 +200,7 @@ import { I18n } from "./../i18n/i18n.module";
200200
<button
201201
class="bx--table-sort-v2"
202202
*ngIf="this.sort.observers.length > 0 && column.sortable"
203-
[attr.aria-label]="(column.sorted && column.ascending ? sortDescendingLabel : sortAscendingLabel)"
203+
[attr.aria-label]="(column.sorted && column.ascending ? sortDescendingLabel : sortAscendingLabel) | async"
204204
aria-live="polite"
205205
[ngClass]="{
206206
'bx--table-sort-v2--active': column.sorted,
@@ -233,7 +233,7 @@ import { I18n } from "./../i18n/i18n.module";
233233
aria-haspopup="true"
234234
[ibmTooltip]="column.filterTemplate"
235235
trigger="click"
236-
[title]="translations.FILTER"
236+
[title]="filterTitle | async"
237237
placement="bottom,top"
238238
[data]="column.filterData">
239239
<svg
@@ -308,7 +308,7 @@ import { I18n } from "./../i18n/i18n.module";
308308
<button
309309
*ngIf="model.isRowExpandable(i)"
310310
(click)="model.expandRow(i, !model.rowsExpanded[i])"
311-
[attr.aria-label]="expandButtonAriaLabel"
311+
[attr.aria-label]="expandButtonAriaLabel | async"
312312
class="bx--table-expand-v2__button">
313313
<svg class="bx--table-expand-v2__svg" width="7" height="12" viewBox="0 0 7 12">
314314
<path fill-rule="nonzero" d="M5.569 5.994L0 .726.687 0l6.336 5.994-6.335 6.002L0 11.27z" />
@@ -318,11 +318,11 @@ import { I18n } from "./../i18n/i18n.module";
318318
<td *ngIf="!skeleton && showSelectionColumn">
319319
<ibm-checkbox
320320
inline="true"
321-
aria-label="Select row"
321+
[attr.aria-label]="checkboxRowLabel | async"
322322
[size]="size !== ('lg' ? 'sm' : 'md')"
323323
[(ngModel)]="model.rowsSelected[i]"
324324
(change)="onRowCheckboxChange(i)">
325-
</ibm-checkbox>
325+
>/ibm-checkbox>
326326
</td>
327327
<ng-container *ngFor="let item of row; let i = index">
328328
<td *ngIf="model.header[i].visible"
@@ -358,9 +358,9 @@ import { I18n } from "./../i18n/i18n.module";
358358
</tr>
359359
<tr *ngIf="this.model.isEnd">
360360
<td class="table_end-indicator">
361-
<h5>{{translations.END_OF_DATA}}</h5>
361+
<h5>{{endOfDataText | async}}</h5>
362362
<button (click)="scrollToTop($event)" class="btn--secondary-sm">
363-
{{translations.SCROLL_TOP}}
363+
{{scrollTopText | async}}
364364
</button>
365365
</td>
366366
</tr>
@@ -411,11 +411,6 @@ export class Table {
411411
* Set to `true` for a loading table.
412412
*/
413413
@Input() skeleton = false;
414-
/**
415-
* Object of all the strings table needs.
416-
* Defaults to the `TABLE` value from the i18n service.
417-
*/
418-
@Input() translations = this.i18n.get().TABLE;
419414

420415
/**
421416
* `TableModel` with data the table is to display.
@@ -499,9 +494,64 @@ export class Table {
499494
*/
500495
@Input() columnsDraggable = false;
501496

502-
@Input() expandButtonAriaLabel = "Expand row";
503-
@Input() sortDescendingLabel = "Sort rows by this header in descending order";
504-
@Input() sortAscendingLabel = "Sort rows by this header in ascending order";
497+
@Input()
498+
set expandButtonAriaLabel(value) {
499+
this._expandButtonAriaLabel.next(value);
500+
}
501+
get expandButtonAriaLabel() {
502+
return this._expandButtonAriaLabel;
503+
}
504+
@Input()
505+
set sortDescendingLabel(value) {
506+
this._sortDescendingLabel.next(value);
507+
}
508+
get sortDescendingLabel() {
509+
return this._sortDescendingLabel;
510+
}
511+
@Input()
512+
set sortAscendingLabel(value) {
513+
this._sortAscendingLabel.next(value);
514+
}
515+
get sortAscendingLabel() {
516+
return this._sortAscendingLabel;
517+
}
518+
519+
/**
520+
* Expects an object that contains some or all of:
521+
* ```
522+
* {
523+
* "FILTER": "Filter",
524+
* "END_OF_DATA": "You've reached the end of your content",
525+
* "SCROLL_TOP": "Scroll to top",
526+
* "CHECKBOX_HEADER": "Select all rows",
527+
* "CHECKBOX_ROW": "Select row"
528+
* }
529+
* ```
530+
*/
531+
@Input()
532+
set translations (value) {
533+
if (value.FILTER) {
534+
this.filterTitle.next(value.FILTER);
535+
}
536+
if (value.END_OF_DATA) {
537+
this.endOfDataText.next(value.END_OF_DATA);
538+
}
539+
if (value.SCROLL_TOP) {
540+
this.scrollTopText.next(value.SCROLL_TOP);
541+
}
542+
if (value.CHECKBOX_HEADER) {
543+
this.checkboxHeaderLabel.next(value.CHECKBOX_HEADER);
544+
}
545+
if (value.CHECKBOX_ROW) {
546+
this.checkboxRowLabel.next(value.CHECKBOX_ROW);
547+
}
548+
}
549+
550+
checkboxHeaderLabel = this.i18n.get("TABLE.CHECKBOX_HEADER");
551+
checkboxRowLabel = this.i18n.get("TABLE.CHECKBOX_ROW");
552+
endOfDataText = this.i18n.get("TABLE.END_OF_DATA");
553+
scrollTopText = this.i18n.get("TABLE.SCROLL_TOP");
554+
filterTitle = this.i18n.get("TABLE.FILTER");
505555

506556
/**
507557
* Controls if all checkboxes are viewed as selected.
@@ -582,6 +632,10 @@ export class Table {
582632

583633
protected _model: TableModel;
584634

635+
protected _expandButtonAriaLabel = this.i18n.get("TABLE.EXPAND_BUTTON");
636+
protected _sortDescendingLabel = this.i18n.get("TABLE.SORT_DESCENDING");
637+
protected _sortAscendingLabel = this.i18n.get("TABLE.SORT_ASCENDING");
638+
585639
protected columnResizeWidth: number;
586640
protected columnResizeMouseX: number;
587641
protected mouseMoveSubscription: Subscription;

0 commit comments

Comments
 (0)