Skip to content

Commit

Permalink
Truncate articles titles when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Gomez committed Nov 21, 2019
1 parent cd0d910 commit 3e2252c
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 7 deletions.
4 changes: 3 additions & 1 deletion index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ into the {body} of the default.hbs template --}}
<span>{{t "Featured"}}</span>
</div>
<a href="{{url}}" class="m-featured-article__content">
<h1 class="m-featured-article__title">{{title}}</h1>
<h1 class="m-featured-article__title js-featured-article-title" title="{{title}}">
{{title}}
</h1>
<div class="m-featured-article__timestamp">
<span>{{date published_at timeago="true"}}</span>
<span>&bull;</span>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
"desktop": "assets/screenshot-desktop.jpg",
"mobile": "assets/screenshot-mobile.jpg"
},
"version": "0.6.1"
"version": "0.6.2"
}
4 changes: 3 additions & 1 deletion page-authors.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ into the {body} of the default.hbs template --}}
<div class="m-article-card__info">
<a href="{{url}}" class="m-article-card__info-link">
{{#if bio}}
<p class="m-article-card__excerpt">{{bio}}</p>
<p class="m-article-card__excerpt js-article-card-title">
{{bio}}
</p>
{{/if}}
</a>
<div class="m-article-card__author-stats">
Expand Down
4 changes: 3 additions & 1 deletion partials/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ This header template is shared across all the pages.
<div class="no-image lozad" data-background-image="{{asset "images/no-image.png"}}"></div>
{{/if}}
</div>
<h3 class="m-recent-article__title">{{title}}</h3>
<h3 class="m-recent-article__title js-recent-article-title" title="{{title}}">
{{title}}
</h3>
<span class="m-recent-article__date">{{date published_at timeago="true"}}</span>
</a>
</div>
Expand Down
4 changes: 3 additions & 1 deletion partials/loop.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
{{/if}}
<a href="{{url}}" class="m-article-card__info-link">
<div>
<h2 class="m-article-card__title">{{title}}</h2>
<h2 class="m-article-card__title js-article-card-title {{#unless feature_image}}js-article-card-title-no-image{{/unless}}" title="{{title}}">
{{title}}
</h2>
</div>
<div class="m-article-card__timestamp">
<span>{{date published_at timeago="true"}}</span>
Expand Down
8 changes: 8 additions & 0 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import lozad from 'lozad'
import Headroom from "headroom.js"
import slick from 'slick-carousel'
import tippy from 'tippy.js'
import shave from 'shave'
import AOS from 'aos'
import Fuse from 'fuse.js'
import {
Expand Down Expand Up @@ -213,6 +214,10 @@ $(document).ready(() => {
}

if ($recentArticles.length > 0) {
$recentArticles.on('init', function () {
shave('.js-recent-article-title', 50)
})

$recentArticles.slick({
adaptiveHeight: true,
arrows: false,
Expand Down Expand Up @@ -241,5 +246,8 @@ $(document).ready(() => {

tippy('.js-tooltip')

shave('.js-article-card-title', 100)
shave('.js-article-card-title-no-image', 250)

trySearchFeature()
})
5 changes: 5 additions & 0 deletions src/js/home.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import $ from 'jquery'
import slick from 'slick-carousel'
import shave from 'shave'
import { isRTL } from './helpers'

$(document).ready(() => {
const $featuredArticles = $('.js-featured-articles')

if ($featuredArticles.length > 0) {
$featuredArticles.on('init', function () {
shave('.js-featured-article-title', 200)
})

$featuredArticles.slick({
arrows: true,
infinite: true,
Expand Down
4 changes: 4 additions & 0 deletions src/js/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import slick from 'slick-carousel'
import stickybits from 'stickybits'
import mediumZoom from 'medium-zoom'
import fitvids from 'fitvids'
import shave from 'shave'
import {
isRTL,
isMobile
Expand Down Expand Up @@ -128,6 +129,9 @@ $(document).ready(() => {
if ($recommendedArticles.length > 0) {
$recommendedArticles.on('init', function () {
prepareProgressCircle()

shave('.js-article-card-title', 100)
shave('.js-article-card-title-no-image', 250)
})

$recommendedArticles.slick({
Expand Down
5 changes: 5 additions & 0 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"jquery": "^3.3.1",
"lozad": "^1.14.0",
"medium-zoom": "^1.0.3",
"shave": "^2.5.6",
"slick-carousel": "^1.8.1",
"stickybits": "^3.6.1",
"tippy.js": "^4.0.1"
Expand Down
4 changes: 2 additions & 2 deletions src/sass/components/articles/_article-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

&.no-picture {
.m-article-card__picture {
height: 85px;
height: 85px !important;
}

.m-article-card__info {
Expand All @@ -48,7 +48,7 @@

.m-article-card__title {
line-height: 1.4;
font-size: 1.750rem;
font-size: 1.625rem;
}
}

Expand Down

0 comments on commit 3e2252c

Please sign in to comment.