Created
August 17, 2020 12:08
-
-
Save cados/2b93d45dd854bc4065a9f7db74c47887 to your computer and use it in GitHub Desktop.
Конструктор плейлистов // source https://jsbin.com/yomixip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <link rel="stylesheet" href="style.css"> | |
| <title>Конструктор плейлистов</title> | |
| <style id="jsbin-css"> | |
| html, body { | |
| font-family: Helvetica, Arial, sans-serif; | |
| -webkit-font-smoothing: antialiased; | |
| } | |
| input, button { | |
| border: none; | |
| } | |
| .header { | |
| max-width: 468px; | |
| height: 80px; | |
| margin: auto; | |
| display: flex; | |
| align-items: center; | |
| } | |
| .header__logo { | |
| width: 150px; | |
| } | |
| .header__logo-sub { | |
| margin-left: 10px; | |
| margin-bottom: 25px; | |
| font-size: 0.6em; | |
| } | |
| .container { | |
| max-width: 468px; | |
| margin: auto; | |
| } | |
| .cover { | |
| display: flex; | |
| align-items: center; | |
| margin-top: 30px; | |
| margin-bottom: 20px; | |
| } | |
| .cover__image { | |
| width: 110px; | |
| min-width: 110px; | |
| height: 110px; | |
| background-image: url(https://code.s3.yandex.net/web-code/dom/cover.jpg); | |
| background-size: cover; | |
| background-position: center; | |
| border-radius: 50%; | |
| } | |
| .cover__heading { | |
| margin-left: 30px; | |
| font-size: 2.5em; | |
| line-height: 1; | |
| } | |
| .block { | |
| margin-top: 60px; | |
| border-radius: 3px; | |
| } | |
| h3 { | |
| font-weight: bold; | |
| } | |
| .input { | |
| display: flex; | |
| justify-content: space-between; | |
| } | |
| .input__submit { | |
| display: flex; | |
| justify-content: flex-end; | |
| margin-top: 30px; | |
| } | |
| .input__text { | |
| font-size: 0.8em; | |
| width: 150px; | |
| height: 50px; | |
| border-bottom: 1px solid #f1f1f1; | |
| padding: 0 10px; | |
| box-sizing: border-box; | |
| } | |
| .input__elem_text::placeholder { | |
| color: #d3d3d3; | |
| } | |
| .input__btn { | |
| font-size: 0.8em; | |
| width: 150px; | |
| height: 50px; | |
| background-color: #ffdb4d; | |
| border-radius: 2px; | |
| cursor: pointer; | |
| } | |
| .input__btn_disabled { | |
| background-color: #f1f1f1; | |
| cursor: default; | |
| } | |
| .no-songs { | |
| height: 70px; | |
| display: flex; | |
| } | |
| .no-songs_hidden { | |
| display: none; | |
| } | |
| .no-songs__text { | |
| margin: auto; | |
| text-align: center; | |
| font-size: 1.2em; | |
| color: #d3d3d3; | |
| } | |
| .song { | |
| align-items: center; | |
| display: flex; | |
| position: relative; | |
| margin-top: 5px; | |
| border: 1px solid #f1f1f1; | |
| border-radius: 5px; | |
| font-size: 0.8em; | |
| padding: 0 10px; | |
| } | |
| .song__artist { | |
| margin-right: 10px; | |
| } | |
| .song__like { | |
| border: none; | |
| background: url(https://code.s3.yandex.net/web-code/dom/heart.svg) center no-repeat; | |
| background-size: 100%; | |
| cursor: pointer; | |
| height: 15px; | |
| width: 15px; | |
| position: absolute; | |
| right: 10px; | |
| opacity: 0.5; | |
| transition: 0.3s; | |
| } | |
| .song__like:hover { | |
| transform: scale(1.3); | |
| } | |
| .song__like_active { | |
| opacity: 1; | |
| background: url(https://code.s3.yandex.net/web-code/dom/heart-filled.svg) center no-repeat; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header class="header"> | |
| <img src="https://code.s3.yandex.net/web-code/dom/logo.svg" alt="" class="header__logo"> | |
| <p class="header__logo-sub">Конструктор плейлистов</p> | |
| </header> | |
| <main class="container"> | |
| <div class="cover"> | |
| <div class="cover__image"></div> | |
| <h1 class="cover__heading">Плейлист</h1> | |
| </div> | |
| <div class="block"> | |
| <h3>Добавить песню</h3> | |
| <div class="input"> | |
| <input type="text" placeholder="Название" class="input__text input__text_type_title"> | |
| <input type="text" placeholder="Исполнитель" class="input__text input__text_type_artist"> | |
| <button class="input__btn input__btn_action_add"> | |
| Добавить | |
| </button> | |
| </div> | |
| </div> | |
| <div class="block"> | |
| <h3>Добавленные</h3> | |
| <div class="no-songs"> | |
| <p class="no-songs__text">Нет добавленных песен</p> | |
| </div> | |
| <div class="songs-container"> | |
| </div> | |
| <div class="input__submit"> | |
| <button class="input__btn input__btn_action_reset input__btn_disabled" disabled> | |
| Очистить плейлист | |
| </button> | |
| </div> | |
| </div> | |
| </main> | |
| <template id="song-template"> | |
| <div class="song"> | |
| <h4 class="song__artist"></h4> | |
| <p class="song__title"></p> | |
| <button class="song__like"></button> | |
| </div> | |
| </template> | |
| <script src="script.js"></script> | |
| <script id="jsbin-javascript"> | |
| const container = document.querySelector('.container'); | |
| const songsContainer = container.querySelector('.songs-container'); | |
| const addButton = container.querySelector('.input__btn_action_add'); | |
| const resetButton = container.querySelector('.input__btn_action_reset'); | |
| const noSongsElement = container.querySelector('.no-songs'); | |
| function renderHasSongs() { | |
| resetButton.removeAttribute('disabled'); | |
| resetButton.classList.remove('input__btn_disabled'); | |
| noSongsElement.classList.add('no-songs_hidden'); | |
| } | |
| function renderNoSongs() { | |
| resetButton.setAttribute('disabled', true); | |
| resetButton.classList.add('input__btn_disabled'); | |
| noSongsElement.classList.remove('no-songs_hidden'); | |
| } | |
| function addSong(artistValue, titleValue) { | |
| const songTemplate = document.querySelector('#song-template').content; | |
| const songElement = songTemplate.cloneNode(true); | |
| songElement.querySelector('.song__artist').textContent = artistValue; | |
| songElement.querySelector('.song__title').textContent = titleValue; | |
| songElement.querySelector('.song__like').addEventListener("click", function(evt){ | |
| evt.target.classList.toggle('song__like_active'); | |
| }) | |
| songsContainer.append(songElement); | |
| } | |
| addButton.addEventListener('click', function () { | |
| const artist = document.querySelector('.input__text_type_artist'); | |
| const title = document.querySelector('.input__text_type_title'); | |
| addSong(artist.value, title.value); | |
| renderHasSongs(); | |
| artist.value = ''; | |
| title.value = ''; | |
| }); | |
| resetButton.addEventListener('click', function () { | |
| const songs = document.querySelectorAll('.song') | |
| songs.forEach((item) => { | |
| item.remove(); | |
| }); | |
| renderNoSongs(); | |
| }); | |
| </script> | |
| <script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <link rel="stylesheet" href="style.css"> | |
| <title>Конструктор плейлистов</title> | |
| </head> | |
| <body> | |
| <header class="header"> | |
| <img src="https://code.s3.yandex.net/web-code/dom/logo.svg" alt="" class="header__logo"> | |
| <p class="header__logo-sub">Конструктор плейлистов</p> | |
| </header> | |
| <main class="container"> | |
| <div class="cover"> | |
| <div class="cover__image"></div> | |
| <h1 class="cover__heading">Плейлист</h1> | |
| </div> | |
| <div class="block"> | |
| <h3>Добавить песню</h3> | |
| <div class="input"> | |
| <input type="text" placeholder="Название" class="input__text input__text_type_title"> | |
| <input type="text" placeholder="Исполнитель" class="input__text input__text_type_artist"> | |
| <button class="input__btn input__btn_action_add"> | |
| Добавить | |
| </button> | |
| </div> | |
| </div> | |
| <div class="block"> | |
| <h3>Добавленные</h3> | |
| <div class="no-songs"> | |
| <p class="no-songs__text">Нет добавленных песен</p> | |
| </div> | |
| <div class="songs-container"> | |
| </div> | |
| <div class="input__submit"> | |
| <button class="input__btn input__btn_action_reset input__btn_disabled" disabled> | |
| Очистить плейлист | |
| </button> | |
| </div> | |
| </div> | |
| </main> | |
| <template id="song-template"> | |
| <div class="song"> | |
| <h4 class="song__artist"></h4> | |
| <p class="song__title"></p> | |
| <button class="song__like"></button> | |
| </div> | |
| </template> | |
| <script src="script.js"><\/script> | |
| </body> | |
| </html> | |
| </script> | |
| <script id="jsbin-source-css" type="text/css">html, body { | |
| font-family: Helvetica, Arial, sans-serif; | |
| -webkit-font-smoothing: antialiased; | |
| } | |
| input, button { | |
| border: none; | |
| } | |
| .header { | |
| max-width: 468px; | |
| height: 80px; | |
| margin: auto; | |
| display: flex; | |
| align-items: center; | |
| } | |
| .header__logo { | |
| width: 150px; | |
| } | |
| .header__logo-sub { | |
| margin-left: 10px; | |
| margin-bottom: 25px; | |
| font-size: 0.6em; | |
| } | |
| .container { | |
| max-width: 468px; | |
| margin: auto; | |
| } | |
| .cover { | |
| display: flex; | |
| align-items: center; | |
| margin-top: 30px; | |
| margin-bottom: 20px; | |
| } | |
| .cover__image { | |
| width: 110px; | |
| min-width: 110px; | |
| height: 110px; | |
| background-image: url(https://code.s3.yandex.net/web-code/dom/cover.jpg); | |
| background-size: cover; | |
| background-position: center; | |
| border-radius: 50%; | |
| } | |
| .cover__heading { | |
| margin-left: 30px; | |
| font-size: 2.5em; | |
| line-height: 1; | |
| } | |
| .block { | |
| margin-top: 60px; | |
| border-radius: 3px; | |
| } | |
| h3 { | |
| font-weight: bold; | |
| } | |
| .input { | |
| display: flex; | |
| justify-content: space-between; | |
| } | |
| .input__submit { | |
| display: flex; | |
| justify-content: flex-end; | |
| margin-top: 30px; | |
| } | |
| .input__text { | |
| font-size: 0.8em; | |
| width: 150px; | |
| height: 50px; | |
| border-bottom: 1px solid #f1f1f1; | |
| padding: 0 10px; | |
| box-sizing: border-box; | |
| } | |
| .input__elem_text::placeholder { | |
| color: #d3d3d3; | |
| } | |
| .input__btn { | |
| font-size: 0.8em; | |
| width: 150px; | |
| height: 50px; | |
| background-color: #ffdb4d; | |
| border-radius: 2px; | |
| cursor: pointer; | |
| } | |
| .input__btn_disabled { | |
| background-color: #f1f1f1; | |
| cursor: default; | |
| } | |
| .no-songs { | |
| height: 70px; | |
| display: flex; | |
| } | |
| .no-songs_hidden { | |
| display: none; | |
| } | |
| .no-songs__text { | |
| margin: auto; | |
| text-align: center; | |
| font-size: 1.2em; | |
| color: #d3d3d3; | |
| } | |
| .song { | |
| align-items: center; | |
| display: flex; | |
| position: relative; | |
| margin-top: 5px; | |
| border: 1px solid #f1f1f1; | |
| border-radius: 5px; | |
| font-size: 0.8em; | |
| padding: 0 10px; | |
| } | |
| .song__artist { | |
| margin-right: 10px; | |
| } | |
| .song__like { | |
| border: none; | |
| background: url(https://code.s3.yandex.net/web-code/dom/heart.svg) center no-repeat; | |
| background-size: 100%; | |
| cursor: pointer; | |
| height: 15px; | |
| width: 15px; | |
| position: absolute; | |
| right: 10px; | |
| opacity: 0.5; | |
| transition: 0.3s; | |
| } | |
| .song__like:hover { | |
| transform: scale(1.3); | |
| } | |
| .song__like_active { | |
| opacity: 1; | |
| background: url(https://code.s3.yandex.net/web-code/dom/heart-filled.svg) center no-repeat; | |
| } | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">const container = document.querySelector('.container'); | |
| const songsContainer = container.querySelector('.songs-container'); | |
| const addButton = container.querySelector('.input__btn_action_add'); | |
| const resetButton = container.querySelector('.input__btn_action_reset'); | |
| const noSongsElement = container.querySelector('.no-songs'); | |
| function renderHasSongs() { | |
| resetButton.removeAttribute('disabled'); | |
| resetButton.classList.remove('input__btn_disabled'); | |
| noSongsElement.classList.add('no-songs_hidden'); | |
| } | |
| function renderNoSongs() { | |
| resetButton.setAttribute('disabled', true); | |
| resetButton.classList.add('input__btn_disabled'); | |
| noSongsElement.classList.remove('no-songs_hidden'); | |
| } | |
| function addSong(artistValue, titleValue) { | |
| const songTemplate = document.querySelector('#song-template').content; | |
| const songElement = songTemplate.cloneNode(true); | |
| songElement.querySelector('.song__artist').textContent = artistValue; | |
| songElement.querySelector('.song__title').textContent = titleValue; | |
| songElement.querySelector('.song__like').addEventListener("click", function(evt){ | |
| evt.target.classList.toggle('song__like_active'); | |
| }) | |
| songsContainer.append(songElement); | |
| } | |
| addButton.addEventListener('click', function () { | |
| const artist = document.querySelector('.input__text_type_artist'); | |
| const title = document.querySelector('.input__text_type_title'); | |
| addSong(artist.value, title.value); | |
| renderHasSongs(); | |
| artist.value = ''; | |
| title.value = ''; | |
| }); | |
| resetButton.addEventListener('click', function () { | |
| const songs = document.querySelectorAll('.song') | |
| songs.forEach((item) => { | |
| item.remove(); | |
| }); | |
| renderNoSongs(); | |
| }); | |
| </script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| html, body { | |
| font-family: Helvetica, Arial, sans-serif; | |
| -webkit-font-smoothing: antialiased; | |
| } | |
| input, button { | |
| border: none; | |
| } | |
| .header { | |
| max-width: 468px; | |
| height: 80px; | |
| margin: auto; | |
| display: flex; | |
| align-items: center; | |
| } | |
| .header__logo { | |
| width: 150px; | |
| } | |
| .header__logo-sub { | |
| margin-left: 10px; | |
| margin-bottom: 25px; | |
| font-size: 0.6em; | |
| } | |
| .container { | |
| max-width: 468px; | |
| margin: auto; | |
| } | |
| .cover { | |
| display: flex; | |
| align-items: center; | |
| margin-top: 30px; | |
| margin-bottom: 20px; | |
| } | |
| .cover__image { | |
| width: 110px; | |
| min-width: 110px; | |
| height: 110px; | |
| background-image: url(https://code.s3.yandex.net/web-code/dom/cover.jpg); | |
| background-size: cover; | |
| background-position: center; | |
| border-radius: 50%; | |
| } | |
| .cover__heading { | |
| margin-left: 30px; | |
| font-size: 2.5em; | |
| line-height: 1; | |
| } | |
| .block { | |
| margin-top: 60px; | |
| border-radius: 3px; | |
| } | |
| h3 { | |
| font-weight: bold; | |
| } | |
| .input { | |
| display: flex; | |
| justify-content: space-between; | |
| } | |
| .input__submit { | |
| display: flex; | |
| justify-content: flex-end; | |
| margin-top: 30px; | |
| } | |
| .input__text { | |
| font-size: 0.8em; | |
| width: 150px; | |
| height: 50px; | |
| border-bottom: 1px solid #f1f1f1; | |
| padding: 0 10px; | |
| box-sizing: border-box; | |
| } | |
| .input__elem_text::placeholder { | |
| color: #d3d3d3; | |
| } | |
| .input__btn { | |
| font-size: 0.8em; | |
| width: 150px; | |
| height: 50px; | |
| background-color: #ffdb4d; | |
| border-radius: 2px; | |
| cursor: pointer; | |
| } | |
| .input__btn_disabled { | |
| background-color: #f1f1f1; | |
| cursor: default; | |
| } | |
| .no-songs { | |
| height: 70px; | |
| display: flex; | |
| } | |
| .no-songs_hidden { | |
| display: none; | |
| } | |
| .no-songs__text { | |
| margin: auto; | |
| text-align: center; | |
| font-size: 1.2em; | |
| color: #d3d3d3; | |
| } | |
| .song { | |
| align-items: center; | |
| display: flex; | |
| position: relative; | |
| margin-top: 5px; | |
| border: 1px solid #f1f1f1; | |
| border-radius: 5px; | |
| font-size: 0.8em; | |
| padding: 0 10px; | |
| } | |
| .song__artist { | |
| margin-right: 10px; | |
| } | |
| .song__like { | |
| border: none; | |
| background: url(https://code.s3.yandex.net/web-code/dom/heart.svg) center no-repeat; | |
| background-size: 100%; | |
| cursor: pointer; | |
| height: 15px; | |
| width: 15px; | |
| position: absolute; | |
| right: 10px; | |
| opacity: 0.5; | |
| transition: 0.3s; | |
| } | |
| .song__like:hover { | |
| transform: scale(1.3); | |
| } | |
| .song__like_active { | |
| opacity: 1; | |
| background: url(https://code.s3.yandex.net/web-code/dom/heart-filled.svg) center no-repeat; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const container = document.querySelector('.container'); | |
| const songsContainer = container.querySelector('.songs-container'); | |
| const addButton = container.querySelector('.input__btn_action_add'); | |
| const resetButton = container.querySelector('.input__btn_action_reset'); | |
| const noSongsElement = container.querySelector('.no-songs'); | |
| function renderHasSongs() { | |
| resetButton.removeAttribute('disabled'); | |
| resetButton.classList.remove('input__btn_disabled'); | |
| noSongsElement.classList.add('no-songs_hidden'); | |
| } | |
| function renderNoSongs() { | |
| resetButton.setAttribute('disabled', true); | |
| resetButton.classList.add('input__btn_disabled'); | |
| noSongsElement.classList.remove('no-songs_hidden'); | |
| } | |
| function addSong(artistValue, titleValue) { | |
| const songTemplate = document.querySelector('#song-template').content; | |
| const songElement = songTemplate.cloneNode(true); | |
| songElement.querySelector('.song__artist').textContent = artistValue; | |
| songElement.querySelector('.song__title').textContent = titleValue; | |
| songElement.querySelector('.song__like').addEventListener("click", function(evt){ | |
| evt.target.classList.toggle('song__like_active'); | |
| }) | |
| songsContainer.append(songElement); | |
| } | |
| addButton.addEventListener('click', function () { | |
| const artist = document.querySelector('.input__text_type_artist'); | |
| const title = document.querySelector('.input__text_type_title'); | |
| addSong(artist.value, title.value); | |
| renderHasSongs(); | |
| artist.value = ''; | |
| title.value = ''; | |
| }); | |
| resetButton.addEventListener('click', function () { | |
| const songs = document.querySelectorAll('.song') | |
| songs.forEach((item) => { | |
| item.remove(); | |
| }); | |
| renderNoSongs(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment