Skip to content

Commit 5894c23

Browse files
committed
feat: add three line lists (modifying MintyMods code)
1 parent f145a81 commit 5894c23

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
lines changed

packages/list/List.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class:mdc-list--dense={dense}
99
class:mdc-list--avatar-list={avatarList}
1010
class:mdc-list--two-line={twoLine}
11-
class:mdc-list--three-line={threeLine}
11+
class:smui-list--three-line={threeLine && !twoLine}
1212
on:MDCList:action={handleAction}
1313
{...props}
1414
><slot></slot></nav>
@@ -22,7 +22,7 @@
2222
class:mdc-list--dense={dense}
2323
class:mdc-list--avatar-list={avatarList}
2424
class:mdc-list--two-line={twoLine}
25-
class:mdc-list--three-line={threeLine}
25+
class:smui-list--three-line={threeLine && !twoLine}
2626
{role}
2727
on:MDCList:action={handleAction}
2828
{...props}

packages/list/_mixins.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Temporary addition until support for three-line added to @material
3+
https://github.com/material-components/material-components-web/issues/31
4+
*/
5+
@import "@material/feature-targeting/functions";
6+
@import "@material/feature-targeting/mixins";
7+
8+
@mixin smui-list-core-styles($query: mdc-feature-all()) {
9+
$feat-structure: mdc-feature-create-target($query, structure);
10+
11+
.smui-list--three-line .mdc-list-item__text {
12+
@include mdc-feature-targets($feat-structure) {
13+
align-self: flex-start;
14+
}
15+
}
16+
17+
.smui-list--three-line .mdc-list-item {
18+
@include mdc-feature-targets($feat-structure) {
19+
height: 88px;
20+
}
21+
}
22+
23+
.smui-list--three-line.mdc-list--dense .mdc-list-item {
24+
@include mdc-feature-targets($feat-structure) {
25+
height: 76px;
26+
}
27+
}
28+
}

packages/list/_style.scss

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
11
@import "@material/list/mdc-list";
22
@import "@smui/ripple/style";
3-
4-
5-
/*
6-
Temporary addition until support for three-line added to @material
7-
https://github.com/material-components/material-components-web/issues/31
8-
*/
9-
.mdc-list--three-line .mdc-list-item__text {
10-
align-self: flex-start;
11-
}
12-
13-
.mdc-list--three-line .mdc-list-item {
14-
height: 88px;
15-
}
16-
17-
.mdc-list--three-line.mdc-list--dense .mdc-list-item,
18-
.mdc-list--avatar-list.mdc-list--dense .mdc-list-item {
19-
height: 76px;
20-
}
3+
@import "./mixins";
4+
@include smui-list-core-styles;

packages/list/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"license": "Apache-2.0",
3030
"dependencies": {
31+
"@material/feature-targeting": "^3.1.0",
3132
"@material/list": "^3.1.0",
3233
"@smui/common": "^1.0.0-beta.15",
3334
"@smui/ripple": "^1.0.0-beta.16"

site/src/routes/demo/list.svelte

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@
7373

7474
<pre class="status">Selected: {selectionTwoLine}, value of selectedIndex: {selectionIndex}</pre>
7575

76+
<div>
77+
A three-line list:
78+
<List class="demo-list" threeLine nonInteractive>
79+
<Item>
80+
<Text>
81+
<PrimaryText>FruitPhone 11</PrimaryText>
82+
<SecondaryText>$1,100</SecondaryText>
83+
<SecondaryText>A beautiful phone with good specs.</SecondaryText>
84+
</Text>
85+
</Item>
86+
<Item>
87+
<Text>
88+
<PrimaryText>Addition Phone</PrimaryText>
89+
<SecondaryText>$700</SecondaryText>
90+
<SecondaryText>Pretty much the same phone, but a different brand name and OS.</SecondaryText>
91+
</Text>
92+
</Item>
93+
</List>
94+
</div>
95+
7696
<div>
7797
A list group:
7898
<Group>

0 commit comments

Comments
 (0)