Skip to content

Commit 8641edb

Browse files
MoizMasudAkshat55
andauthored
feat: Add theme inputs (#2451)
Signed-off-by: Moiz Masud <[email protected]> Co-authored-by: Akshat Patel <[email protected]>
1 parent 274c9a8 commit 8641edb

File tree

4 files changed

+51
-22
lines changed

4 files changed

+51
-22
lines changed

src/tiles/clickable-tile.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Router } from "@angular/router";
2424
<a
2525
ibmLink
2626
class="bx--tile bx--tile--clickable"
27+
[ngClass]="{'bx--tile--light': theme === 'light'}"
2728
tabindex="0"
2829
(click)="navigate($event)"
2930
[href]="href"
@@ -33,6 +34,8 @@ import { Router } from "@angular/router";
3334
</a>`
3435
})
3536
export class ClickableTile {
37+
@Input() theme: "light" | "dark" = "dark";
38+
3639
/**
3740
* Sets the `href` attribute on the `ibm-clickable-tile` element.
3841
*/

src/tiles/expandable-tile.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export interface ExpandableTileTranslations {
1717
template: `
1818
<button
1919
class="bx--tile bx--tile--expandable"
20-
[ngClass]="{'bx--tile--is-expanded' : expanded}"
20+
[ngClass]="{
21+
'bx--tile--is-expanded' : expanded,
22+
'bx--tile--light': theme === 'light'
23+
}"
2124
[ngStyle]="{'max-height': expandedHeight + 'px'}"
2225
type="button"
2326
(click)="onClick()">
@@ -39,6 +42,8 @@ export interface ExpandableTileTranslations {
3942
`
4043
})
4144
export class ExpandableTile implements AfterContentInit {
45+
@Input() theme: "light" | "dark" = "dark";
46+
4247
@Input() expanded = false;
4348
/**
4449
* Expects an object that contains some or all of:

src/tiles/selection-tile.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import { I18n } from "carbon-components-angular/i18n";
1717
class="bx--tile bx--tile--selectable"
1818
tabindex="0"
1919
[for]="id"
20-
[ngClass]="{'bx--tile--is-selected' : selected}"
20+
[ngClass]="{
21+
'bx--tile--is-selected' : selected,
22+
'bx--tile--light': theme === 'light'
23+
}"
2124
[attr.aria-label]="i18n.get('TILES.TILE') | async">
2225
<input
2326
#input
@@ -42,10 +45,14 @@ import { I18n } from "carbon-components-angular/i18n";
4245
})
4346
export class SelectionTile implements AfterViewInit {
4447
static tileCount = 0;
48+
49+
@Input() theme: "light" | "dark" = "dark";
50+
4551
/**
4652
* The unique id for the input.
4753
*/
4854
@Input() id = `tile-${SelectionTile.tileCount}`;
55+
4956
/**
5057
* Updating the state of the input to match the state of the parameter passed in.
5158
* Set to `true` if this tile should be selected.

src/tiles/tiles.stories.ts

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { storiesOf, moduleMetadata } from "@storybook/angular";
22
import { select, withKnobs } from "@storybook/addon-knobs/angular";
33
import { action } from "@storybook/addon-actions";
44

5-
import { TilesModule } from "../";
5+
import { TilesModule } from "../tiles/tiles.module";
66
import { SkeletonModule } from "../skeleton/index";
77
import { RouterModule } from "@angular/router";
88
import { APP_BASE_HREF } from "@angular/common";
@@ -72,17 +72,20 @@ storiesOf("Components|Tiles", module)
7272
.add("Multiple", () => ({
7373
template: `
7474
<div style="display: flex; flex-flow: row wrap; justify-content: space-around;">
75-
<ibm-tile>
75+
<ibm-tile [theme]="theme">
7676
Tile 1
7777
</ibm-tile>
78-
<ibm-tile>
78+
<ibm-tile [theme]="theme">
7979
Tile 2
8080
</ibm-tile>
81-
<ibm-tile>
81+
<ibm-tile [theme]="theme">
8282
Tile 3
8383
</ibm-tile>
8484
</div>
85-
`
85+
`,
86+
props: {
87+
theme: select("theme", ["dark", "light"], "dark")
88+
}
8689
}))
8790
.add("Clickable", () => ({
8891
template: `
@@ -96,21 +99,27 @@ storiesOf("Components|Tiles", module)
9699
Edit on Carbon UI Builder
97100
</a>
98101
<br><br>
99-
<ibm-clickable-tile href="https://www.carbondesignsystem.com/" target="_blank">
102+
<ibm-clickable-tile href="https://www.carbondesignsystem.com/" target="_blank" [theme]="theme">
100103
Click the tile to open the Carbon Design System
101104
</ibm-clickable-tile>
102-
`
105+
`,
106+
props: {
107+
theme: select("theme", ["dark", "light"], "dark")
108+
}
103109
}))
104110
.add("Routable", () => ({
105111
template: `
106-
<ibm-clickable-tile [route]="['foo']">
112+
<ibm-clickable-tile [route]="['foo']" [theme]="theme">
107113
Click to trigger the <code>foo</code> route
108114
</ibm-clickable-tile>
109-
<ibm-clickable-tile [route]="['bar']">
115+
<ibm-clickable-tile [route]="['bar']" [theme]="theme">
110116
Click to trigger the <code>bar</code> route
111117
</ibm-clickable-tile>
112118
<router-outlet></router-outlet>
113-
`
119+
`,
120+
props: {
121+
theme: select("theme", ["dark", "light"], "dark")
122+
}
114123
}))
115124
.add("Selectable", () => ({
116125
template: `
@@ -126,13 +135,14 @@ storiesOf("Components|Tiles", module)
126135
</a>
127136
<br><br>
128137
<ibm-tile-group (selected)="selected($event)" [multiple]="false">
129-
<ibm-selection-tile value="tile1" [selected]="true">Selectable Tile</ibm-selection-tile>
130-
<ibm-selection-tile value="tile2">Selectable Tile</ibm-selection-tile>
131-
<ibm-selection-tile value="tile3">Selectable Tile</ibm-selection-tile>
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>
132141
</ibm-tile-group>
133142
`,
134143
props: {
135-
selected: action("tile selected")
144+
selected: action("tile selected"),
145+
theme: select("theme", ["dark", "light"], "dark")
136146
}
137147
}))
138148
.add("Multi-select", () => ({
@@ -162,13 +172,14 @@ storiesOf("Components|Tiles", module)
162172
</a>
163173
<br><br>
164174
<ibm-tile-group (selected)="selected($event)" [multiple]="true">
165-
<ibm-selection-tile value="tile1" [selected]="true">Selectable Tile</ibm-selection-tile>
166-
<ibm-selection-tile value="tile2">Selectable Tile</ibm-selection-tile>
167-
<ibm-selection-tile value="tile3">Selectable Tile</ibm-selection-tile>
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>
168178
</ibm-tile-group>
169179
`,
170180
props: {
171-
selected: action("tile selected")
181+
selected: action("tile selected"),
182+
theme: select("theme", ["dark", "light"], "dark")
172183
}
173184
}))
174185
.add("Expandable", () => ({
@@ -187,11 +198,14 @@ storiesOf("Components|Tiles", module)
187198
Edit on Carbon UI Builder
188199
</a>
189200
<br><br>
190-
<ibm-expandable-tile>
201+
<ibm-expandable-tile [theme]="theme">
191202
<span class="bx--tile-content__above-the-fold" style="height: 200px">Above the fold content here</span>
192203
<span class="bx--tile-content__below-the-fold" style="height: 400px">Below the fold content here</span>
193204
</ibm-expandable-tile>
194-
`
205+
`,
206+
props: {
207+
theme: select("theme", ["dark", "light"], "dark")
208+
}
195209
}))
196210
.add("Skeleton", () => ({
197211
template: `

0 commit comments

Comments
 (0)