Truncate articles titles when needed

This commit is contained in:
Eduardo Gomez 2019-11-21 16:48:21 +01:00
parent cd0d910c1c
commit 3e2252c250
11 changed files with 38 additions and 7 deletions

View file

@ -60,7 +60,9 @@ into the {body} of the default.hbs template --}}
<span>{{t "Featured"}}</span> <span>{{t "Featured"}}</span>
</div> </div>
<a href="{{url}}" class="m-featured-article__content"> <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"> <div class="m-featured-article__timestamp">
<span>{{date published_at timeago="true"}}</span> <span>{{date published_at timeago="true"}}</span>
<span>&bull;</span> <span>&bull;</span>

View file

@ -54,5 +54,5 @@
"desktop": "assets/screenshot-desktop.jpg", "desktop": "assets/screenshot-desktop.jpg",
"mobile": "assets/screenshot-mobile.jpg" "mobile": "assets/screenshot-mobile.jpg"
}, },
"version": "0.6.1" "version": "0.6.2"
} }

View file

@ -38,7 +38,9 @@ into the {body} of the default.hbs template --}}
<div class="m-article-card__info"> <div class="m-article-card__info">
<a href="{{url}}" class="m-article-card__info-link"> <a href="{{url}}" class="m-article-card__info-link">
{{#if bio}} {{#if bio}}
<p class="m-article-card__excerpt">{{bio}}</p> <p class="m-article-card__excerpt js-article-card-title">
{{bio}}
</p>
{{/if}} {{/if}}
</a> </a>
<div class="m-article-card__author-stats"> <div class="m-article-card__author-stats">

View file

@ -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> <div class="no-image lozad" data-background-image="{{asset "images/no-image.png"}}"></div>
{{/if}} {{/if}}
</div> </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> <span class="m-recent-article__date">{{date published_at timeago="true"}}</span>
</a> </a>
</div> </div>

View file

@ -33,7 +33,9 @@
{{/if}} {{/if}}
<a href="{{url}}" class="m-article-card__info-link"> <a href="{{url}}" class="m-article-card__info-link">
<div> <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>
<div class="m-article-card__timestamp"> <div class="m-article-card__timestamp">
<span>{{date published_at timeago="true"}}</span> <span>{{date published_at timeago="true"}}</span>

View file

@ -4,6 +4,7 @@ import lozad from 'lozad'
import Headroom from "headroom.js" import Headroom from "headroom.js"
import slick from 'slick-carousel' import slick from 'slick-carousel'
import tippy from 'tippy.js' import tippy from 'tippy.js'
import shave from 'shave'
import AOS from 'aos' import AOS from 'aos'
import Fuse from 'fuse.js' import Fuse from 'fuse.js'
import { import {
@ -213,6 +214,10 @@ $(document).ready(() => {
} }
if ($recentArticles.length > 0) { if ($recentArticles.length > 0) {
$recentArticles.on('init', function () {
shave('.js-recent-article-title', 50)
})
$recentArticles.slick({ $recentArticles.slick({
adaptiveHeight: true, adaptiveHeight: true,
arrows: false, arrows: false,
@ -241,5 +246,8 @@ $(document).ready(() => {
tippy('.js-tooltip') tippy('.js-tooltip')
shave('.js-article-card-title', 100)
shave('.js-article-card-title-no-image', 250)
trySearchFeature() trySearchFeature()
}) })

View file

@ -1,11 +1,16 @@
import $ from 'jquery' import $ from 'jquery'
import slick from 'slick-carousel' import slick from 'slick-carousel'
import shave from 'shave'
import { isRTL } from './helpers' import { isRTL } from './helpers'
$(document).ready(() => { $(document).ready(() => {
const $featuredArticles = $('.js-featured-articles') const $featuredArticles = $('.js-featured-articles')
if ($featuredArticles.length > 0) { if ($featuredArticles.length > 0) {
$featuredArticles.on('init', function () {
shave('.js-featured-article-title', 200)
})
$featuredArticles.slick({ $featuredArticles.slick({
arrows: true, arrows: true,
infinite: true, infinite: true,

View file

@ -3,6 +3,7 @@ import slick from 'slick-carousel'
import stickybits from 'stickybits' import stickybits from 'stickybits'
import mediumZoom from 'medium-zoom' import mediumZoom from 'medium-zoom'
import fitvids from 'fitvids' import fitvids from 'fitvids'
import shave from 'shave'
import { import {
isRTL, isRTL,
isMobile isMobile
@ -128,6 +129,9 @@ $(document).ready(() => {
if ($recommendedArticles.length > 0) { if ($recommendedArticles.length > 0) {
$recommendedArticles.on('init', function () { $recommendedArticles.on('init', function () {
prepareProgressCircle() prepareProgressCircle()
shave('.js-article-card-title', 100)
shave('.js-article-card-title-no-image', 250)
}) })
$recommendedArticles.slick({ $recommendedArticles.slick({

5
src/package-lock.json generated
View file

@ -11843,6 +11843,11 @@
"sha.js": "~2.4.4" "sha.js": "~2.4.4"
} }
}, },
"shave": {
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/shave/-/shave-2.5.6.tgz",
"integrity": "sha512-cIeMhSuOEIyG79sCrMMcQqinM8FCmlJw1yjG0yYy+uufYnWmJSC0yZHxOcGmQwm2RgLlCCK/0cSGpMXAequbrw=="
},
"shebang-command": { "shebang-command": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",

View file

@ -39,6 +39,7 @@
"jquery": "^3.3.1", "jquery": "^3.3.1",
"lozad": "^1.14.0", "lozad": "^1.14.0",
"medium-zoom": "^1.0.3", "medium-zoom": "^1.0.3",
"shave": "^2.5.6",
"slick-carousel": "^1.8.1", "slick-carousel": "^1.8.1",
"stickybits": "^3.6.1", "stickybits": "^3.6.1",
"tippy.js": "^4.0.1" "tippy.js": "^4.0.1"

View file

@ -39,7 +39,7 @@
&.no-picture { &.no-picture {
.m-article-card__picture { .m-article-card__picture {
height: 85px; height: 85px !important;
} }
.m-article-card__info { .m-article-card__info {
@ -48,7 +48,7 @@
.m-article-card__title { .m-article-card__title {
line-height: 1.4; line-height: 1.4;
font-size: 1.750rem; font-size: 1.625rem;
} }
} }