Skip to content
This repository was archived by the owner on Feb 29, 2020. It is now read-only.

Commit 3ef6227

Browse files
authored
Bug 1552596 - Revert dynamic line clamping in favor of performant static line clamping (#5044)
1 parent 59d65fa commit 3ef6227

File tree

9 files changed

+12
-204
lines changed

9 files changed

+12
-204
lines changed

content-src/components/DiscoveryStreamComponents/DSCard/DSCard.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {actionCreators as ac} from "common/Actions.jsm";
2-
import {clampTotalLines} from "content-src/lib/clamp-total-lines";
32
import {DSImage} from "../DSImage/DSImage.jsx";
43
import {DSLinkMenu} from "../DSLinkMenu/DSLinkMenu";
54
import {ImpressionStats} from "../../DiscoveryStreamImpressionStats/ImpressionStats";
@@ -41,11 +40,9 @@ export class DSCard extends React.PureComponent {
4140
<DSImage extraClassNames="img" source={this.props.image_src} rawSource={this.props.raw_image_src} />
4241
</div>
4342
<div className="meta">
44-
<div className="info-wrap"
45-
data-total-lines="7"
46-
ref={clampTotalLines}>
47-
<p className="source clamp" data-clamp="1">{this.props.source}</p>
48-
<header className="title clamp" data-clamp="4">{this.props.title}</header>
43+
<div className="info-wrap">
44+
<p className="source clamp">{this.props.source}</p>
45+
<header className="title clamp">{this.props.title}</header>
4946
{this.props.excerpt && <p className="excerpt clamp">{this.props.excerpt}</p>}
5047
</div>
5148
{this.props.context && (

content-src/components/DiscoveryStreamComponents/DSCard/_DSCard.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ $excerpt-line-height: 20;
101101
}
102102

103103
.source {
104+
-webkit-line-clamp: 1;
104105
margin-bottom: 2px;
105106
}
106107

content-src/components/DiscoveryStreamComponents/Hero/Hero.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {DSCard, PlaceholderDSCard} from "../DSCard/DSCard.jsx";
22
import {actionCreators as ac} from "common/Actions.jsm";
3-
import {clampTotalLines} from "content-src/lib/clamp-total-lines";
43
import {DSEmptyState} from "../DSEmptyState/DSEmptyState.jsx";
54
import {DSImage} from "../DSImage/DSImage.jsx";
65
import {DSLinkMenu} from "../DSLinkMenu/DSLinkMenu";
@@ -77,15 +76,13 @@ export class Hero extends React.PureComponent {
7776
<DSImage extraClassNames="img" source={heroRec.image_src} rawSource={heroRec.raw_image_src} />
7877
</div>
7978
<div className="meta">
80-
<div className="header-and-excerpt"
81-
data-total-lines="7"
82-
ref={clampTotalLines}>
79+
<div className="header-and-excerpt">
8380
{heroRec.context ? (
8481
<p className="context">{heroRec.context}</p>
8582
) : (
86-
<p className="source clamp" data-clamp="1">{heroRec.domain}</p>
83+
<p className="source clamp">{heroRec.domain}</p>
8784
)}
88-
<header className="clamp" data-clamp="4">{heroRec.title}</header>
85+
<header className="clamp">{heroRec.title}</header>
8986
<p className="excerpt clamp">{heroRec.excerpt}</p>
9087
</div>
9188
</div>

content-src/components/DiscoveryStreamComponents/Hero/_Hero.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ $card-header-in-hero-line-height: 20;
147147

148148
font-size: 13px;
149149
color: $grey-50;
150+
-webkit-line-clamp: 1;
150151
margin-bottom: 0;
151152
}
152153
}

content-src/components/DiscoveryStreamComponents/List/List.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {actionCreators as ac} from "common/Actions.jsm";
2-
import {clampTotalLines} from "content-src/lib/clamp-total-lines";
32
import {connect} from "react-redux";
43
import {DSEmptyState} from "../DSEmptyState/DSEmptyState.jsx";
54
import {DSImage} from "../DSImage/DSImage.jsx";
@@ -44,15 +43,14 @@ export class ListItem extends React.PureComponent {
4443
onLinkClick={!this.props.placeholder ? this.onLinkClick : undefined}
4544
url={this.props.url}>
4645
<div className="ds-list-item-text">
47-
<div data-total-lines="4"
48-
ref={clampTotalLines}>
46+
<div>
4947
<div className="ds-list-item-title clamp">{this.props.title}</div>
5048
{this.props.excerpt && <div className="ds-list-item-excerpt clamp">{this.props.excerpt}</div>}
5149
</div>
5250
<p>
5351
{this.props.context && (
5452
<span>
55-
<span className="ds-list-item-context">{this.props.context}</span>
53+
<span className="ds-list-item-context clamp">{this.props.context}</span>
5654
<br />
5755
</span>
5856
)}

content-src/components/DiscoveryStreamComponents/List/_List.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ $item-line-height: 20;
228228

229229
color: $grey-50;
230230
font-size: 13px;
231-
-webkit-line-clamp: 1;
232231
}
233232

234233
.ds-list-item-title {

content-src/lib/clamp-total-lines.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

content-src/styles/_mixins.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
}
1010

1111
// Note: lineHeight and fontSize should be unitless but can be derived from pixel values
12-
// Bug 1550624 to clean up / remove this mixin that no longer limits lines
12+
// Bug 1550624 to clean up / remove this mixin to avoid duplicate styles
1313
@mixin limit-visibile-lines($line-count, $line-height, $font-size) {
1414
font-size: $font-size * 1px;
15+
-webkit-line-clamp: $line-count;
1516
line-height: $line-height * 1px;
1617
}
1718

test/unit/content-src/lib/clamp-total-lines.test.js

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)