JSFiddle - React, Tailwind, and code Playground

by Michael Myers

HTML

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Movie DB</title>
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700&display=swap&subset=cyrillic-ext" rel="stylesheet">
    <link rel="stylesheet" href="css/style.min.css">
  </head>

  <body>
    <header class="header">
      <div class="header__search">
        <form action="#">
          <input type="text" placeholder="Поиск">
        </form>
      </div>
      <div class="header__logo">
        <img src="icons/Logotype.svg" alt="logo">
      </div>
    </header>
    <main class="promo">
      <div class="promo__menu">
        <nav class="promo__menu-list">
          <ul>
            <li><a class="promo__menu-item promo__menu-item_active" href="#">Фильмы</a></li>
            <li><a class="promo__menu-item" href="#">Сериалы</a></li>
            <li><a class="promo__menu-item" href="#">Мультфильмы</a></li>
            <li><a class="promo__menu-item" href="#">Клипы</a></li>
            <li><a class="promo__menu-item" href="#">Трейлеры</a></li>
          </ul>
        </nav>
      </div>
      <div class="promo__content">
        <div class="promo__bg">
          <div class="promo__genre">КОМЕДИЯ</div>
          <div class="promo__title">МАРСИАНИН</div>
          <div class="promo__descr">ИСТОРИЯ ЧЕЛОВЕКА, ВЫЖИВШЕГО НА ЧУЖОЙ ПЛАНЕТЕ В ОДИНОЧКУ</div>
          <div class="promo__ratings">
            <span>IMDb: 8.0</span>
            <span>Кинопоиск: 7.7</span>
          </div>
        </div>
        <div class="promo__interactive">
          <div>
            <div class="promo__interactive-title">ПРОСМОТРЕННЫЕ ФИЛЬМЫ</div>
            <ul class="promo__interactive-list">
              <li class="promo__interactive-item">ЛОГАН
                <div class="delete"></div>
              </li>
              <li class="promo__interactive-item">ЛИГА СПРАВЕДЛИВОСТИ
                <div...

CSS

* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Roboto', sans-serif
}

.header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  height: 100px
}

.header__search {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  height: 100%;
  width: 300px;
  background: #FFD500
}

.header__search form {
  position: relative;
  width: 260px;
  height: 30px
}

.header__search form input {
  width: 100%;
  border: none;
  border-bottom: 2px solid #fff;
  background-color: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 28px;
  padding-bottom: 5px;
  outline: none
}

.header__search form input::-webkit-input-placeholder {
  color: #fff
}

.header__search form input:-ms-input-placeholder {
  color: #fff
}

.header__search form input::-ms-input-placeholder {
  color: #fff
}

.header__search form input::placeholder {
  color: #fff
}

.header__search form:after {
  content: '';
  display: block;
  position: absolute;
  top: 2px;
  right: 10px;
  background: url("../icons/search.svg") center center/cover no-repeat;
  width: 24px;
  height: 24px
}

.header__logo {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  height: 100%;
  width: calc(100% - 360px)
}

.promo {
  height: 780px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex
}

.promo__menu {
  width: 300px;
  height: 100%;
  background: #212121;
  padding: 60px 0 0 10px
}

.promo__menu-item {
  display: block;
  font-size: 28px;
  line-height: 33px;
  color: #D6D9DC;
  text-decoration: none;
  font-weight: 300;
  padding-left: 40px;
  margin-top: 18px
}

.promo__menu-item:hover {
...

JavaScript

const movieDB = {
  movies: [
    "Логан",
    "Лига справедливости",
    "Ла-ла лэнд",
    "Одержимость",
    "Скотт Пилигрим против..."
  ]
};

let truncate = function(elem, limit, after) {

  // Make sure an element and number of items to truncate is provided
  if (!elem || !limit) return;

  // Get the inner content of the element
  let content = elem.textContent.trim();

  // Convert the content into an array of words
  // Remove any words above the limit
  content = content.split(' ').slice(0, limit);

  // Convert the array of words back into a string
  // If there's content to add after it, add it
  content = content.join(' ') + (after ? after : '');

  // Inject the content back into the DOM
  elem.textContent = content;

};

var elem = document.querySelector('.truncate');
truncate(elem, 7, '...');