Skip to content

Commit f5fec17

Browse files
authored
Merge branch 'master' into master
2 parents c7db7b0 + bd086d5 commit f5fec17

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

src/tiles/clickable-tile.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ import { Router } from "@angular/router";
2424
<a
2525
ibmLink
2626
class="bx--tile bx--tile--clickable"
27-
[ngClass]="{'bx--tile--light': theme === 'light'}"
27+
[ngClass]="{
28+
'bx--tile--light': theme === 'light',
29+
'bx--tile--disabled bx--link--disabled' : disabled
30+
}"
2831
tabindex="0"
2932
(click)="navigate($event)"
30-
[href]="href"
33+
[attr.href]="disabled ? null : href"
3134
[attr.target]="target"
3235
[attr.aria-disabled]="disabled">
3336
<ng-content></ng-content>
@@ -71,7 +74,7 @@ export class ClickableTile {
7174
constructor(@Optional() protected router: Router) {}
7275

7376
navigate(event) {
74-
if (this.router && this.route) {
77+
if (this.router && this.route && !this.disabled) {
7578
event.preventDefault();
7679
const status = this.router.navigate(this.route, this.routeExtras);
7780
this.navigation.emit(status);

src/tiles/selection-tile.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ import { I18n } from "carbon-components-angular/i18n";
1515
template: `
1616
<label
1717
class="bx--tile bx--tile--selectable"
18-
tabindex="0"
18+
tabindex="disabled ? null : 0"
1919
[for]="id"
2020
[ngClass]="{
2121
'bx--tile--is-selected' : selected,
22-
'bx--tile--light': theme === 'light'
22+
'bx--tile--light': theme === 'light',
23+
'bx--tile--disabled' : disabled
2324
}"
2425
[attr.aria-label]="i18n.get('TILES.TILE') | async">
2526
<input
2627
#input
2728
tabindex="-1"
2829
class="bx--tile-input"
2930
[id]="id"
31+
[disabled]="disabled"
3032
[type]="(multiple ? 'checkbox': 'radio')"
3133
[value]="value"
3234
[name]="name"
@@ -78,6 +80,11 @@ export class SelectionTile implements AfterViewInit {
7880
*/
7981
@Output() change: EventEmitter<Event> = new EventEmitter();
8082

83+
/**
84+
* Set to `true` to disable the selection tile.
85+
*/
86+
@Input() disabled = false;
87+
8188
/**
8289
* Set by the containing `TileGroup`. Used for the `name` property on the input.
8390
*/

src/tiles/tiles.stories.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { storiesOf, moduleMetadata } from "@storybook/angular";
2-
import { select, withKnobs } from "@storybook/addon-knobs/angular";
2+
import { select, withKnobs, boolean } from "@storybook/addon-knobs/angular";
33
import { action } from "@storybook/addon-actions";
44

55
import { TilesModule } from "../tiles/tiles.module";
@@ -99,26 +99,28 @@ storiesOf("Components|Tiles", module)
9999
Edit on Carbon UI Builder
100100
</a>
101101
<br><br>
102-
<ibm-clickable-tile href="https://www.carbondesignsystem.com/" target="_blank" [theme]="theme">
102+
<ibm-clickable-tile href="https://www.carbondesignsystem.com/" target="_blank" [theme]="theme" [disabled]="disabled">
103103
Click the tile to open the Carbon Design System
104104
</ibm-clickable-tile>
105105
`,
106106
props: {
107-
theme: select("theme", ["dark", "light"], "dark")
107+
theme: select("theme", ["dark", "light"], "dark"),
108+
disabled: boolean("disabled", false)
108109
}
109110
}))
110111
.add("Routable", () => ({
111112
template: `
112-
<ibm-clickable-tile [route]="['foo']" [theme]="theme">
113+
<ibm-clickable-tile [route]="['foo']" [theme]="theme" [disabled]="disabled">
113114
Click to trigger the <code>foo</code> route
114115
</ibm-clickable-tile>
115-
<ibm-clickable-tile [route]="['bar']" [theme]="theme">
116+
<ibm-clickable-tile [route]="['bar']" [theme]="theme" [disabled]="disabled">
116117
Click to trigger the <code>bar</code> route
117118
</ibm-clickable-tile>
118119
<router-outlet></router-outlet>
119120
`,
120121
props: {
121-
theme: select("theme", ["dark", "light"], "dark")
122+
theme: select("theme", ["dark", "light"], "dark"),
123+
disabled: boolean("disabled", false)
122124
}
123125
}))
124126
.add("Selectable", () => ({
@@ -135,14 +137,15 @@ storiesOf("Components|Tiles", module)
135137
</a>
136138
<br><br>
137139
<ibm-tile-group (selected)="selected($event)" [multiple]="false">
138-
<ibm-selection-tile value="tile1" [selected]="true" [theme]="theme">Selectable Tile</ibm-selection-tile>
139-
<ibm-selection-tile value="tile2" [theme]="theme">Selectable Tile</ibm-selection-tile>
140-
<ibm-selection-tile value="tile3" [theme]="theme">Selectable Tile</ibm-selection-tile>
140+
<ibm-selection-tile value="tile1" [disabled]="disabled" [selected]="true" [theme]="theme">Selectable Tile</ibm-selection-tile>
141+
<ibm-selection-tile value="tile2" [disabled]="disabled" [theme]="theme">Selectable Tile</ibm-selection-tile>
142+
<ibm-selection-tile value="tile3" [disabled]="disabled" [theme]="theme">Selectable Tile</ibm-selection-tile>
141143
</ibm-tile-group>
142144
`,
143145
props: {
144146
selected: action("tile selected"),
145-
theme: select("theme", ["dark", "light"], "dark")
147+
theme: select("theme", ["dark", "light"], "dark"),
148+
disabled: boolean("disabled", false)
146149
}
147150
}))
148151
.add("Multi-select", () => ({
@@ -172,14 +175,15 @@ storiesOf("Components|Tiles", module)
172175
</a>
173176
<br><br>
174177
<ibm-tile-group (selected)="selected($event)" [multiple]="true">
175-
<ibm-selection-tile value="tile1" [selected]="true" [theme]="theme">Selectable Tile</ibm-selection-tile>
176-
<ibm-selection-tile value="tile2" [theme]="theme">Selectable Tile</ibm-selection-tile>
177-
<ibm-selection-tile value="tile3" [theme]="theme">Selectable Tile</ibm-selection-tile>
178+
<ibm-selection-tile value="tile1" [selected]="true" [theme]="theme" [disabled]="disabled">Selectable Tile</ibm-selection-tile>
179+
<ibm-selection-tile value="tile2" [theme]="theme" [disabled]="disabled">Selectable Tile</ibm-selection-tile>
180+
<ibm-selection-tile value="tile3" [theme]="theme" [disabled]="disabled">Selectable Tile</ibm-selection-tile>
178181
</ibm-tile-group>
179182
`,
180183
props: {
181184
selected: action("tile selected"),
182-
theme: select("theme", ["dark", "light"], "dark")
185+
theme: select("theme", ["dark", "light"], "dark"),
186+
disabled: boolean("disabled", false)
183187
}
184188
}))
185189
.add("Expandable", () => ({

0 commit comments

Comments
 (0)