From c563e5834432bae8d0e3d69e8a908958b653b114 Mon Sep 17 00:00:00 2001 From: TheYoungManLi Date: Mon, 17 Jan 2022 14:42:32 +0800 Subject: [PATCH] feat: Support for expanding and collapsing course lists Signed-off-by: TheYoungManLi --- assets/scss/learn.scss | 46 ++++++++++++++++++++++++++++++++++++++- layouts/learn/list.html | 48 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 5 deletions(-) diff --git a/assets/scss/learn.scss b/assets/scss/learn.scss index 61dd52a7e..5f39cfe07 100644 --- a/assets/scss/learn.scss +++ b/assets/scss/learn.scss @@ -252,7 +252,7 @@ h2 { margin-top: 68px; & > li { position: relative; - padding: 50px 39px 20px 40px; + padding: 50px 39px 40px 40px; margin-bottom: 58px; border-radius: 8px; background-color: #ffffff; @@ -278,6 +278,10 @@ h2 { top: -20px; left: 30px; border-radius: 5px; + white-space: nowrap; + text-overflow: ellipsis; + max-width: 75%; + overflow: hidden; } } @@ -373,6 +377,46 @@ h2 { } } } + + .button{ + position: absolute; + height: 48px; + width: 100%; + bottom: 0; + left: 0; + background: linear-gradient(360deg, rgba(85, 188, 138, 0.25) 0%, rgba(85, 188, 138, 0) 100%); + border: none; + font-weight: 600; + font-size: 14px; + line-height: 20px; + color: #0F8049; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + + #close{ + display: none; + } + } + + .hideButton{ + display: none; + } + + .active{ + #open{ + display: none; + } + + #close{ + display: block; + } + + svg{ + transform: rotateX(180deg); + } + } } } } diff --git a/layouts/learn/list.html b/layouts/learn/list.html index 16be0ee89..df18b239e 100644 --- a/layouts/learn/list.html +++ b/layouts/learn/list.html @@ -22,7 +22,7 @@ - + {{ end }} @@ -78,7 +78,7 @@

{{ .Params.section6.title }}

@@ -129,7 +139,7 @@ {{ i18n "Apply for the job" }} - {{ end }} + {{ end }}
{{ i18n "View more jobs" }} @@ -210,8 +220,38 @@ var bindScrollEvent = function() { topActive() }) } + +var tableInit = function () { + const tableLi = $('.tableLi') + tableLi.each((index,item)=>{ + const eachLi = $(item) + const allTrLine = eachLi.find('table tbody') + dealWithTableBody(eachLi[0], allTrLine) + }) +} +var dealWithTableBody = function (line, tbody) { + const positionLine = $(line) + const originBody = $(tbody).clone() + const button = positionLine.find('button') + if (tbody.children().length < 6) { + button.addClass('hideButton') + } else { + const allTR = tbody.children().slice(0, 5) + tbody.empty().append(allTR) + } + button.on('click', function () { + button.toggleClass('active') + if (tbody.children().length > 5) { + const allTR = tbody.children().slice(0, 5) + tbody.empty().append(allTR) + } else { + tbody.empty().append(originBody.clone().children()) + } + }) +} bindScrollEvent() initScrollByHash() bindClickTopLink() +tableInit() {{ end }} \ No newline at end of file