From 98ddee3fe77669d67da101f8f86e4e38dc71e81a Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Mon, 9 Jan 2023 20:19:33 +0530 Subject: [PATCH] Better loader UI animation --- css/main.css | 87 ++++++++++++----------------- css/main.min.css | 2 +- css/main.scss | 85 +++++++++++++--------------- index.html | 142 ++++++++++++++++++++++------------------------- 4 files changed, 139 insertions(+), 177 deletions(-) diff --git a/css/main.css b/css/main.css index 27e3aa9..2f83504 100644 --- a/css/main.css +++ b/css/main.css @@ -192,7 +192,9 @@ button:not(:disabled) { } button:disabled { - opacity: 0.5; + cursor: not-allowed; + filter: saturate(0.5); + opacity: 0.8; } ul { @@ -597,49 +599,25 @@ ul { .torrent-card__download-button { justify-self: flex-end; background-color: rgba(var(--text-color), 0.1); + overflow: hidden; +} +.torrent-card__download-button[data-collecting]::after { + content: ""; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + transform: translateX(calc(-100% + var(--progress, 0%))); + height: 0.3rem; + background-color: rgba(var(--foreground-color), 1); + z-index: 1; + transition: all 0.3s; + border-radius: 0.5rem; } .torrent-card__download-button .icon { - height: 1.4rem; margin-right: 0.5rem; } -.progress-indicator { - position: relative; - justify-self: flex-end; - height: 2.3rem; - padding: 0 0.6rem; -} - -.progress-percent { - font-size: 0.9rem; - font-weight: 500; - color: rgba(var(--text-color), 0.8); - width: 9ch; - text-align: right; -} - -.progress-loader, -.placeholder-loader { - fill: none; - padding: 0.1rem; - stroke-width: 12; - overflow: visible; -} - -.progress-loader { - stroke-dasharray: 201; - stroke-dashoffset: 201; - transform: rotate(-90deg); - stroke: var(--accent-color); - transition: stroke-dashoffset 0.3s; - z-index: 1; -} - -.placeholder-loader { - position: absolute; - stroke: rgba(var(--text-color), 0.1); -} - .torrent-preview { display: grid; justify-content: center; @@ -709,16 +687,24 @@ ul { background-color: rgba(var(--text-color), 0.1); } -#download_container { - display: flex; - align-items: center; - height: 3rem; - margin-top: 2rem; -} - #torrent_download_button { - width: auto; + position: relative; padding: 1rem; + margin-top: 1.5rem; + overflow: hidden; +} +#torrent_download_button[data-collecting]::after { + content: ""; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + transform: translateX(calc(-100% + var(--progress, 0%))); + height: 0.3rem; + background-color: rgba(var(--foreground-color), 1); + z-index: 1; + transition: all 0.3s; + border-radius: 0.5rem; } #torrent_download_button .icon { margin-right: 0.5rem; @@ -852,15 +838,10 @@ sm-option { .torrent-card__tags, .torrent-card__uploader { font-size: 0.7rem; } - .torrent-card__download-button, -.torrent-card .progress-indicator { - margin-top: 1rem; - } #torrent_tags { font-size: 0.8rem; } - #torrent_download_button, -#loader_container { + #torrent_download_button { width: 100%; justify-content: center; } diff --git a/css/main.min.css b/css/main.min.css index 28b5c0b..11d2380 100644 --- a/css/main.min.css +++ b/css/main.min.css @@ -1 +1 @@ -*{padding:0;margin:0;box-sizing:border-box;font-family:"Inter",sans-serif}:root{font-size:clamp(1rem,1.2vmax,3rem)}html,body{height:100%;scroll-behavior:smooth}body{--accent-color: #304ffe;--light-shade: rgba(var(--text-color), 0.06);--text-color: 17, 17, 17;--text-color-light: 100, 100, 100;--foreground-color: 255, 255, 255;--background-color: 243, 245, 250;--error-color: red;--green: #00843b;color:rgba(var(--text-color), 1);background:rgba(var(--background-color), 1);display:flex;flex-direction:column}body[data-theme=dark]{--accent-color: #a6b9ff;--green: #13ff5a;--text-color: 240, 240, 240;--text-color-light: 170, 170, 170;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--error-color: rgb(255, 106, 106)}main{flex:1}sm-chips{--gap: 0.3rem}sm-chip{position:relative;font-size:.9rem;--border-radius: 0.5rem;--padding: 0.5rem 0.8rem;--background: rgba(var(--text-color), 0.06);-webkit-user-select:none;-moz-user-select:none;user-select:none;font-weight:500}sm-chip[selected]{--background: var(--accent-color);color:rgba(var(--foreground-color), 1)}.full-bleed{grid-column:1/4}.h1{font-size:2.5rem}.h2{font-size:2rem}.h3{font-size:1.4rem}.h4{font-size:1rem}.h5{font-size:.8rem}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}p{font-size:.8;max-width:60ch;line-height:1.7;color:rgba(var(--text-color), 0.8)}p:not(:last-of-type){margin-bottom:1rem}img{-o-object-fit:cover;object-fit:cover}a{color:inherit;text-decoration:none}a:focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}.button,button{-webkit-user-select:none;-moz-user-select:none;user-select:none;position:relative;display:inline-flex;border:none;background-color:rgba(0,0,0,0);overflow:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);align-items:center;font-size:.9rem;font-weight:500;white-space:nowrap;padding:.8rem;border-radius:.5rem;justify-content:center;color:inherit;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content}.button:not(:disabled),button:not(:disabled){cursor:pointer}.button{color:var(--accent-color);background-color:var(--blue-accent-1)}.button .icon{fill:var(--accent-color)}.button--primary,.button--danger{color:rgba(var(--background-color), 1) !important}.button--primary .icon,.button--danger .icon{fill:rgba(var(--background-color), 1)}.button--primary{width:100%;background-color:var(--accent-color)}.button--danger{background-color:var(--danger-color)}.button--small{padding:.4rem .6rem}.cta{text-transform:uppercase;font-size:.8rem;font-weight:700;letter-spacing:.05em;padding:.8rem 1rem}.icon{width:1.2rem;height:1.2rem;fill:rgba(var(--text-color), 0.8);flex-shrink:0}.icon-only{padding:.5rem;border-radius:.3rem}button:disabled{opacity:.5}ul{list-style:none}.flex{display:flex}.grid{display:grid}.hide{opacity:0;pointer-events:none}.hidden{display:none !important}.no-transformations{transform:none !important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.breakable{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.flex{display:flex}.grid{display:grid}.flow-column{grid-auto-flow:column}.gap-0-5{gap:.5rem}.gap-1{gap:1rem}.gap-1-5{gap:1.5rem}.gap-2{gap:2rem}.gap-3{gap:3rem}.text-align-right{text-align:right}.align-start{align-items:flex-start}.align-center{align-items:center}.text-center{text-align:center}.justify-start{justify-content:start}.justify-center{justify-content:center}.justify-right{margin-left:auto}.align-self-center{align-self:center}.justify-self-center{justify-self:center}.justify-self-start{justify-self:start}.direction-column{flex-direction:column}.space-between{justify-content:space-between}.w-100{width:100%}.ripple{position:absolute;border-radius:50%;transform:scale(0);background:rgba(var(--text-color), 0.16);pointer-events:none}.interact{position:relative;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}.icon{width:1.5rem;height:1.5rem;fill:rgba(var(--text-color), 0.9)}.button__icon--left{margin-right:.5rem}.button__icon--right{margin-left:.5rem}.page-layout{position:relative;display:grid;grid-template-columns:1rem minmax(0, 1fr) 1rem}.page-layout>*{grid-column:2/3}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem 0 .5rem;align-items:center;grid-template-columns:auto 1fr}.popup__header__close{padding:.5rem;cursor:pointer}.button--primary{color:#fff;font-weight:500;padding:.5rem 1.2rem;background-color:var(--accent-color)}.auto-grid-2{gap:2rem;grid-template-columns:1fr}#loading_page,#error_page{position:relative;display:grid;height:100%;place-content:center;justify-items:center}#main_header{position:relative;display:grid;gap:1rem;padding:1rem;align-items:center;grid-template-columns:1fr auto auto}#main_header a.button{font-size:.9rem;font-weight:500;border:solid thin var(--accent-color)}#main_header__logo{height:1.8rem;width:1.8rem}.theme-switcher{position:relative;justify-self:flex-end;width:1.5rem;height:1.5rem;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.theme-switcher .icon{position:absolute;transition:transform .6s}.theme-switcher__checkbox{display:none}.theme-switcher__checkbox:checked~.moon-icon{transform:scale(0) rotate(90deg)}.theme-switcher__checkbox:not(:checked)~.sun-icon{transform:scale(0) rotate(-90deg)}.page{padding-bottom:3rem}.page__title{font-size:2rem}#search_section{position:relative;display:grid;gap:.5rem 0;padding:4rem 0;justify-items:center}.app-icon{height:3rem;width:3rem}.app-icon-loader{fill:none;stroke-width:2;justify-self:center;stroke-dasharray:202;margin:2rem 0;stroke:rgba(var(--text-color), 1);-webkit-animation:stroke-anim 2s infinite alternate;animation:stroke-anim 2s infinite alternate}@-webkit-keyframes stroke-anim{0%{stroke-dashoffset:202}100%{stroke-dashoffset:0}}@keyframes stroke-anim{0%{stroke-dashoffset:202}100%{stroke-dashoffset:0}}.app-name{font-weight:500;margin-bottom:1rem;font-size:.9rem;color:rgba(var(--text-color), 0.7)}.search-container{position:relative;margin-bottom:1rem;width:min(28rem,100%)}.search-torrent{--border-radius: 2rem;--background: rgba(var(--text-color), 0.06)}.search-torrent .icon{fill:rgba(var(--text-color), 0.7)}.search-suggestions-container{top:100%;position:absolute;z-index:1;width:100%;border-radius:1rem;margin-top:.5rem;box-shadow:0 .5rem 1rem -0.5rem rgba(0,0,0,.2);background-color:rgba(var(--foreground-color), 1)}.search-suggestions-container:not(:empty){padding:.5rem 0}.search-suggestion{display:flex;cursor:pointer;font-weight:700;font-size:.9rem;padding:.8rem 1rem;color:rgba(var(--text-color), 0.8);outline:none}.search-suggestion:focus,.search-suggestion:active{outline:none;border:0}.search-suggestion:focus,.search-suggestion:focus-visible{outline:rgba(0,0,0,0);background-color:rgba(var(--text-color), 0.1)}.search-suggestion span{font-weight:450}.search-suggestion pre{white-space:pre-wrap}.torrent-container{padding:1.5rem 0;display:grid;gap:.5rem;padding-bottom:4rem}.torrent-card{display:grid;gap:0 1rem;align-items:center;grid-template-columns:1fr auto;padding:1rem;border-radius:.3rem;-webkit-tap-highlight-color:rgba(0,0,0,0);background-color:rgba(var(--text-color), 0.06)}.torrent-card .torrent-info{gap:0 1rem;grid-template-columns:auto 1fr;grid-template-areas:"torrent-icon ." "torrent-icon ."}.torrent-card .torrent-type-icon{padding:.8rem}.torrent-card__icon{grid-area:torrent-icon}.torrent-card__icon .icon{height:1.4rem;width:1.4rem}.torrent-card__title{font-weight:600;font-size:1.1rem;margin-bottom:.5rem}.torrent-card__tags,.torrent-card__uploader{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:.85rem;color:rgba(var(--text-color), 0.7)}.torrent-card__download-button{justify-self:flex-end;background-color:rgba(var(--text-color), 0.1)}.torrent-card__download-button .icon{height:1.4rem;margin-right:.5rem}.progress-indicator{position:relative;justify-self:flex-end;height:2.3rem;padding:0 .6rem}.progress-percent{font-size:.9rem;font-weight:500;color:rgba(var(--text-color), 0.8);width:9ch;text-align:right}.progress-loader,.placeholder-loader{fill:none;padding:.1rem;stroke-width:12;overflow:visible}.progress-loader{stroke-dasharray:201;stroke-dashoffset:201;transform:rotate(-90deg);stroke:var(--accent-color);transition:stroke-dashoffset .3s;z-index:1}.placeholder-loader{position:absolute;stroke:rgba(var(--text-color), 0.1)}.torrent-preview{display:grid;justify-content:center}.torrent-preview__info-section{display:flex;flex-direction:column;align-content:flex-start}.torrent-type-icon{display:flex;padding:1rem;border-radius:50%;align-items:center;justify-content:center;align-self:flex-start;aspect-ratio:1/1;flex-shrink:0;background-color:var(--accent-color)}.torrent-type-icon .icon{fill:#fff}#torrent_type_icon{align-self:center;justify-self:center;padding:2rem;margin:3rem 0 4rem 0;background-color:rgba(var(--text-color), 0.06)}#torrent_type_icon .icon{height:3rem;width:3rem;fill:rgba(var(--text-color), 0.3)}#torrent_tags,#torrent_uploader{display:flex;width:100%;font-size:.85rem;margin-bottom:.5rem;color:rgba(var(--text-color), 0.8)}#torrent_name{line-height:1.1;font-size:1.8rem;margin-bottom:2rem}#torrent_description{font-size:1rem;color:rgba(var(--text-color), 0.8)}#torrent_uploader{font-weight:500;margin:1.5rem 0 1rem 0;width:auto;border-radius:1.5rem;padding:.3rem .8rem;align-self:flex-start;background-color:rgba(var(--text-color), 0.1)}#download_container{display:flex;align-items:center;height:3rem;margin-top:2rem}#torrent_download_button{width:auto;padding:1rem}#torrent_download_button .icon{margin-right:.5rem}#torrent_index_tx{padding:.4rem;font-size:.9rem;border-radius:.5rem;align-self:flex-start;border:solid var(--accent-color) thin}#torrent_index_tx .icon{margin-right:.5rem}#advance_search_section{align-items:flex-start;padding:1rem 0;margin-bottom:1rem}#filters_bar{padding:.5rem 0}sm-option{font-size:.9rem}#filter_popup{--width: min(32rem, 100%)}.option-selector{padding:1rem 0}.filter-option{display:inline-flex;margin:0 .5rem .8rem 0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.filter-option input{display:none}.filter-option input:checked~.option-text{color:rgba(255,255,255,.9);background-color:var(--accent-color);border:solid var(--accent-color) thin}.filter-option .option-text{cursor:pointer;font-weight:500;font-size:.95rem;-webkit-user-select:none;-moz-user-select:none;user-select:none;border-radius:.3rem;padding:.3rem .6rem;transition:background-color .3s;color:rgba(var(--text-color), 0.8);border:solid rgba(var(--text-color), 0.2) thin}#filters_bar{display:grid;gap:1rem;margin-top:1rem;align-items:flex-start;grid-template-columns:minmax(0, 1fr) auto}.selected-filter{-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;display:inline-flex;align-items:center;padding:.4rem .5rem;margin:0 .5rem .8rem 0;border:solid rgba(var(--text-color), 0.2) thin;border-radius:.3rem}.selected-filter .icon{width:1.2rem}#page_selector sm-chip,#search_page_selector sm-chip{--border-radius: 0.3rem;--active-option-color: white;--active-option-backgroud-color: var(--accent-color)}#how_it_works{padding-bottom:8rem}#how_it_works .page__title{margin:6rem 0 1rem 0}.info-section{display:grid;gap:1.5rem;margin-top:3rem;align-items:center;grid-template-columns:1fr}.info__title{margin-bottom:1rem}#main_footer{padding:2rem 0;background-color:rgba(var(--text-color), 0.06)}@media only screen and (max-width: 640px){.torrent-card{grid-template-columns:1fr}.torrent-card__icon{margin:0}.torrent-card__title{font-size:.95rem}.torrent-card__tags,.torrent-card__uploader{font-size:.7rem}.torrent-card__download-button,.torrent-card .progress-indicator{margin-top:1rem}#torrent_tags{font-size:.8rem}#torrent_download_button,#loader_container{width:100%;justify-content:center}}@media only screen and (min-width: 640px){.popup__header{padding:1.5rem 1.5rem 0 .5rem}.auto-grid-2{grid-template-columns:1fr 1fr}.page-layout{grid-template-columns:1fr 90vw 1fr}#main_header{padding:1.5rem}.page__title{font-size:3rem}.torrent-card{padding:1.5rem}.torrent-preview{gap:3rem}#torrent_name{font-size:4rem;max-width:16ch}.info-section{grid-template-columns:1fr 1fr}.info-section:nth-of-type(even) .info__image{grid-column:2/3}.info-section:nth-of-type(even) .textual-info{grid-row:1/2;grid-column:1/2}}@media only screen and (min-width: 1280px){.page-layout{grid-template-columns:1fr 80vw 1fr}}@media(any-hover: hover){::-webkit-scrollbar{width:.5rem;height:.5rem}::-webkit-scrollbar-thumb{background:rgba(var(--text-color), 0.3);border-radius:1rem}::-webkit-scrollbar-thumb:hover{background:rgba(var(--text-color), 0.5)}.search-suggestion:hover{background-color:rgba(var(--text-color), 0.1)}} \ No newline at end of file +*{padding:0;margin:0;box-sizing:border-box;font-family:"Inter",sans-serif}:root{font-size:clamp(1rem,1.2vmax,3rem)}html,body{height:100%;scroll-behavior:smooth}body{--accent-color: #304ffe;--light-shade: rgba(var(--text-color), 0.06);--text-color: 17, 17, 17;--text-color-light: 100, 100, 100;--foreground-color: 255, 255, 255;--background-color: 243, 245, 250;--error-color: red;--green: #00843b;color:rgba(var(--text-color), 1);background:rgba(var(--background-color), 1);display:flex;flex-direction:column}body[data-theme=dark]{--accent-color: #a6b9ff;--green: #13ff5a;--text-color: 240, 240, 240;--text-color-light: 170, 170, 170;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--error-color: rgb(255, 106, 106)}main{flex:1}sm-chips{--gap: 0.3rem}sm-chip{position:relative;font-size:.9rem;--border-radius: 0.5rem;--padding: 0.5rem 0.8rem;--background: rgba(var(--text-color), 0.06);-webkit-user-select:none;-moz-user-select:none;user-select:none;font-weight:500}sm-chip[selected]{--background: var(--accent-color);color:rgba(var(--foreground-color), 1)}.full-bleed{grid-column:1/4}.h1{font-size:2.5rem}.h2{font-size:2rem}.h3{font-size:1.4rem}.h4{font-size:1rem}.h5{font-size:.8rem}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}p{font-size:.8;max-width:60ch;line-height:1.7;color:rgba(var(--text-color), 0.8)}p:not(:last-of-type){margin-bottom:1rem}img{-o-object-fit:cover;object-fit:cover}a{color:inherit;text-decoration:none}a:focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}.button,button{-webkit-user-select:none;-moz-user-select:none;user-select:none;position:relative;display:inline-flex;border:none;background-color:rgba(0,0,0,0);overflow:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);align-items:center;font-size:.9rem;font-weight:500;white-space:nowrap;padding:.8rem;border-radius:.5rem;justify-content:center;color:inherit;min-width:-webkit-max-content;min-width:-moz-max-content;min-width:max-content}.button:not(:disabled),button:not(:disabled){cursor:pointer}.button{color:var(--accent-color);background-color:var(--blue-accent-1)}.button .icon{fill:var(--accent-color)}.button--primary,.button--danger{color:rgba(var(--background-color), 1) !important}.button--primary .icon,.button--danger .icon{fill:rgba(var(--background-color), 1)}.button--primary{width:100%;background-color:var(--accent-color)}.button--danger{background-color:var(--danger-color)}.button--small{padding:.4rem .6rem}.cta{text-transform:uppercase;font-size:.8rem;font-weight:700;letter-spacing:.05em;padding:.8rem 1rem}.icon{width:1.2rem;height:1.2rem;fill:rgba(var(--text-color), 0.8);flex-shrink:0}.icon-only{padding:.5rem;border-radius:.3rem}button:disabled{cursor:not-allowed;filter:saturate(0.5);opacity:.8}ul{list-style:none}.flex{display:flex}.grid{display:grid}.hide{opacity:0;pointer-events:none}.hidden{display:none !important}.no-transformations{transform:none !important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.breakable{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.flex{display:flex}.grid{display:grid}.flow-column{grid-auto-flow:column}.gap-0-5{gap:.5rem}.gap-1{gap:1rem}.gap-1-5{gap:1.5rem}.gap-2{gap:2rem}.gap-3{gap:3rem}.text-align-right{text-align:right}.align-start{align-items:flex-start}.align-center{align-items:center}.text-center{text-align:center}.justify-start{justify-content:start}.justify-center{justify-content:center}.justify-right{margin-left:auto}.align-self-center{align-self:center}.justify-self-center{justify-self:center}.justify-self-start{justify-self:start}.direction-column{flex-direction:column}.space-between{justify-content:space-between}.w-100{width:100%}.ripple{position:absolute;border-radius:50%;transform:scale(0);background:rgba(var(--text-color), 0.16);pointer-events:none}.interact{position:relative;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}.icon{width:1.5rem;height:1.5rem;fill:rgba(var(--text-color), 0.9)}.button__icon--left{margin-right:.5rem}.button__icon--right{margin-left:.5rem}.page-layout{position:relative;display:grid;grid-template-columns:1rem minmax(0, 1fr) 1rem}.page-layout>*{grid-column:2/3}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem 0 .5rem;align-items:center;grid-template-columns:auto 1fr}.popup__header__close{padding:.5rem;cursor:pointer}.button--primary{color:#fff;font-weight:500;padding:.5rem 1.2rem;background-color:var(--accent-color)}.auto-grid-2{gap:2rem;grid-template-columns:1fr}#loading_page,#error_page{position:relative;display:grid;height:100%;place-content:center;justify-items:center}#main_header{position:relative;display:grid;gap:1rem;padding:1rem;align-items:center;grid-template-columns:1fr auto auto}#main_header a.button{font-size:.9rem;font-weight:500;border:solid thin var(--accent-color)}#main_header__logo{height:1.8rem;width:1.8rem}.theme-switcher{position:relative;justify-self:flex-end;width:1.5rem;height:1.5rem;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.theme-switcher .icon{position:absolute;transition:transform .6s}.theme-switcher__checkbox{display:none}.theme-switcher__checkbox:checked~.moon-icon{transform:scale(0) rotate(90deg)}.theme-switcher__checkbox:not(:checked)~.sun-icon{transform:scale(0) rotate(-90deg)}.page{padding-bottom:3rem}.page__title{font-size:2rem}#search_section{position:relative;display:grid;gap:.5rem 0;padding:4rem 0;justify-items:center}.app-icon{height:3rem;width:3rem}.app-icon-loader{fill:none;stroke-width:2;justify-self:center;stroke-dasharray:202;margin:2rem 0;stroke:rgba(var(--text-color), 1);-webkit-animation:stroke-anim 2s infinite alternate;animation:stroke-anim 2s infinite alternate}@-webkit-keyframes stroke-anim{0%{stroke-dashoffset:202}100%{stroke-dashoffset:0}}@keyframes stroke-anim{0%{stroke-dashoffset:202}100%{stroke-dashoffset:0}}.app-name{font-weight:500;margin-bottom:1rem;font-size:.9rem;color:rgba(var(--text-color), 0.7)}.search-container{position:relative;margin-bottom:1rem;width:min(28rem,100%)}.search-torrent{--border-radius: 2rem;--background: rgba(var(--text-color), 0.06)}.search-torrent .icon{fill:rgba(var(--text-color), 0.7)}.search-suggestions-container{top:100%;position:absolute;z-index:1;width:100%;border-radius:1rem;margin-top:.5rem;box-shadow:0 .5rem 1rem -0.5rem rgba(0,0,0,.2);background-color:rgba(var(--foreground-color), 1)}.search-suggestions-container:not(:empty){padding:.5rem 0}.search-suggestion{display:flex;cursor:pointer;font-weight:700;font-size:.9rem;padding:.8rem 1rem;color:rgba(var(--text-color), 0.8);outline:none}.search-suggestion:focus,.search-suggestion:active{outline:none;border:0}.search-suggestion:focus,.search-suggestion:focus-visible{outline:rgba(0,0,0,0);background-color:rgba(var(--text-color), 0.1)}.search-suggestion span{font-weight:450}.search-suggestion pre{white-space:pre-wrap}.torrent-container{padding:1.5rem 0;display:grid;gap:.5rem;padding-bottom:4rem}.torrent-card{display:grid;gap:0 1rem;align-items:center;grid-template-columns:1fr auto;padding:1rem;border-radius:.3rem;-webkit-tap-highlight-color:rgba(0,0,0,0);background-color:rgba(var(--text-color), 0.06)}.torrent-card .torrent-info{gap:0 1rem;grid-template-columns:auto 1fr;grid-template-areas:"torrent-icon ." "torrent-icon ."}.torrent-card .torrent-type-icon{padding:.8rem}.torrent-card__icon{grid-area:torrent-icon}.torrent-card__icon .icon{height:1.4rem;width:1.4rem}.torrent-card__title{font-weight:600;font-size:1.1rem;margin-bottom:.5rem}.torrent-card__tags,.torrent-card__uploader{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:.85rem;color:rgba(var(--text-color), 0.7)}.torrent-card__download-button{justify-self:flex-end;background-color:rgba(var(--text-color), 0.1);overflow:hidden}.torrent-card__download-button[data-collecting]::after{content:"";position:absolute;bottom:0;left:0;width:100%;transform:translateX(calc(-100% + var(--progress, 0%)));height:.3rem;background-color:rgba(var(--foreground-color), 1);z-index:1;transition:all .3s;border-radius:.5rem}.torrent-card__download-button .icon{margin-right:.5rem}.torrent-preview{display:grid;justify-content:center}.torrent-preview__info-section{display:flex;flex-direction:column;align-content:flex-start}.torrent-type-icon{display:flex;padding:1rem;border-radius:50%;align-items:center;justify-content:center;align-self:flex-start;aspect-ratio:1/1;flex-shrink:0;background-color:var(--accent-color)}.torrent-type-icon .icon{fill:#fff}#torrent_type_icon{align-self:center;justify-self:center;padding:2rem;margin:3rem 0 4rem 0;background-color:rgba(var(--text-color), 0.06)}#torrent_type_icon .icon{height:3rem;width:3rem;fill:rgba(var(--text-color), 0.3)}#torrent_tags,#torrent_uploader{display:flex;width:100%;font-size:.85rem;margin-bottom:.5rem;color:rgba(var(--text-color), 0.8)}#torrent_name{line-height:1.1;font-size:1.8rem;margin-bottom:2rem}#torrent_description{font-size:1rem;color:rgba(var(--text-color), 0.8)}#torrent_uploader{font-weight:500;margin:1.5rem 0 1rem 0;width:auto;border-radius:1.5rem;padding:.3rem .8rem;align-self:flex-start;background-color:rgba(var(--text-color), 0.1)}#torrent_download_button{position:relative;padding:1rem;margin-top:1.5rem;overflow:hidden}#torrent_download_button[data-collecting]::after{content:"";position:absolute;bottom:0;left:0;width:100%;transform:translateX(calc(-100% + var(--progress, 0%)));height:.3rem;background-color:rgba(var(--foreground-color), 1);z-index:1;transition:all .3s;border-radius:.5rem}#torrent_download_button .icon{margin-right:.5rem}#torrent_index_tx{padding:.4rem;font-size:.9rem;border-radius:.5rem;align-self:flex-start;border:solid var(--accent-color) thin}#torrent_index_tx .icon{margin-right:.5rem}#advance_search_section{align-items:flex-start;padding:1rem 0;margin-bottom:1rem}#filters_bar{padding:.5rem 0}sm-option{font-size:.9rem}#filter_popup{--width: min(32rem, 100%)}.option-selector{padding:1rem 0}.filter-option{display:inline-flex;margin:0 .5rem .8rem 0;-webkit-tap-highlight-color:rgba(0,0,0,0)}.filter-option input{display:none}.filter-option input:checked~.option-text{color:rgba(255,255,255,.9);background-color:var(--accent-color);border:solid var(--accent-color) thin}.filter-option .option-text{cursor:pointer;font-weight:500;font-size:.95rem;-webkit-user-select:none;-moz-user-select:none;user-select:none;border-radius:.3rem;padding:.3rem .6rem;transition:background-color .3s;color:rgba(var(--text-color), 0.8);border:solid rgba(var(--text-color), 0.2) thin}#filters_bar{display:grid;gap:1rem;margin-top:1rem;align-items:flex-start;grid-template-columns:minmax(0, 1fr) auto}.selected-filter{-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;display:inline-flex;align-items:center;padding:.4rem .5rem;margin:0 .5rem .8rem 0;border:solid rgba(var(--text-color), 0.2) thin;border-radius:.3rem}.selected-filter .icon{width:1.2rem}#page_selector sm-chip,#search_page_selector sm-chip{--border-radius: 0.3rem;--active-option-color: white;--active-option-backgroud-color: var(--accent-color)}#how_it_works{padding-bottom:8rem}#how_it_works .page__title{margin:6rem 0 1rem 0}.info-section{display:grid;gap:1.5rem;margin-top:3rem;align-items:center;grid-template-columns:1fr}.info__title{margin-bottom:1rem}#main_footer{padding:2rem 0;background-color:rgba(var(--text-color), 0.06)}@media only screen and (max-width: 640px){.torrent-card{grid-template-columns:1fr}.torrent-card__icon{margin:0}.torrent-card__title{font-size:.95rem}.torrent-card__tags,.torrent-card__uploader{font-size:.7rem}#torrent_tags{font-size:.8rem}#torrent_download_button{width:100%;justify-content:center}}@media only screen and (min-width: 640px){.popup__header{padding:1.5rem 1.5rem 0 .5rem}.auto-grid-2{grid-template-columns:1fr 1fr}.page-layout{grid-template-columns:1fr 90vw 1fr}#main_header{padding:1.5rem}.page__title{font-size:3rem}.torrent-card{padding:1.5rem}.torrent-preview{gap:3rem}#torrent_name{font-size:4rem;max-width:16ch}.info-section{grid-template-columns:1fr 1fr}.info-section:nth-of-type(even) .info__image{grid-column:2/3}.info-section:nth-of-type(even) .textual-info{grid-row:1/2;grid-column:1/2}}@media only screen and (min-width: 1280px){.page-layout{grid-template-columns:1fr 80vw 1fr}}@media(any-hover: hover){::-webkit-scrollbar{width:.5rem;height:.5rem}::-webkit-scrollbar-thumb{background:rgba(var(--text-color), 0.3);border-radius:1rem}::-webkit-scrollbar-thumb:hover{background:rgba(var(--text-color), 0.5)}.search-suggestion:hover{background-color:rgba(var(--text-color), 0.1)}} \ No newline at end of file diff --git a/css/main.scss b/css/main.scss index 57f296c..8b4bd11 100644 --- a/css/main.scss +++ b/css/main.scss @@ -167,7 +167,9 @@ button { } button:disabled { - opacity: 0.5; + cursor: not-allowed; + filter: saturate(0.5); + opacity: 0.8; } ul { list-style: none; @@ -522,44 +524,27 @@ ul { &__download-button { justify-self: flex-end; background-color: rgba(var(--text-color), 0.1); + overflow: hidden; + &[data-collecting] { + &::after { + content: ""; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + transform: translateX(calc(-100% + var(--progress, 0%))); + height: 0.3rem; + background-color: rgba(var(--foreground-color), 1); + z-index: 1; + transition: all 0.3s; + border-radius: 0.5rem; + } + } .icon { - height: 1.4rem; margin-right: 0.5rem; } } } -.progress-indicator { - position: relative; - justify-self: flex-end; - height: 2.3rem; - padding: 0 0.6rem; -} -.progress-percent { - font-size: 0.9rem; - font-weight: 500; - color: rgba(var(--text-color), 0.8); - width: 9ch; - text-align: right; -} -.progress-loader, -.placeholder-loader { - fill: none; - padding: 0.1rem; - stroke-width: 12; - overflow: visible; -} -.progress-loader { - stroke-dasharray: 201; - stroke-dashoffset: 201; - transform: rotate(-90deg); - stroke: var(--accent-color); - transition: stroke-dashoffset 0.3s; - z-index: 1; -} -.placeholder-loader { - position: absolute; - stroke: rgba(var(--text-color), 0.1); -} .torrent-preview { display: grid; justify-content: center; @@ -621,15 +606,26 @@ ul { align-self: flex-start; background-color: rgba(var(--text-color), 0.1); } -#download_container { - display: flex; - align-items: center; - height: 3rem; - margin-top: 2rem; -} #torrent_download_button { - width: auto; + position: relative; padding: 1rem; + margin-top: 1.5rem; + overflow: hidden; + &[data-collecting] { + &::after { + content: ""; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + transform: translateX(calc(-100% + var(--progress, 0%))); + height: 0.3rem; + background-color: rgba(var(--foreground-color), 1); + z-index: 1; + transition: all 0.3s; + border-radius: 0.5rem; + } + } .icon { margin-right: 0.5rem; } @@ -753,16 +749,11 @@ sm-option { &__uploader { font-size: 0.7rem; } - &__download-button, - .progress-indicator { - margin-top: 1rem; - } } #torrent_tags { font-size: 0.8rem; } - #torrent_download_button, - #loader_container { + #torrent_download_button { width: 100%; justify-content: center; } diff --git a/index.html b/index.html index a1ad9c3..21a7b5c 100644 --- a/index.html +++ b/index.html @@ -122,19 +122,10 @@ See the index entry in blockchain -
- -
-
+ @@ -321,11 +312,6 @@ @@ -406,47 +392,52 @@ if (lasttx === undefined) { lasttx = 0; } - var response = await getResponce(`api/addrs/${addr}/txs`); - var nRequired = response.totalItems - lasttx; - console.log(nRequired); - while (true && nRequired) { - var response = await getResponce(`api/addrs/${addr}/txs?from=0&to=${nRequired}`); - if (nRequired + lasttx != response.totalItems) { - nRequired = response.totalItems - lasttx; - continue; - } - var errorTxCount = 0; //Count of txs that didnot go into any blocks - response.items.reverse().forEach(function (tx) { - try { - if (!tx.blockhash) { //ignore error txs that did not go into any blocks - errorTxCount += 1; - return; - } - if (addr != tx.vin[0].addr) //ignore if the tx is not from kudos ID - return - var kudosData = JSON.parse(tx.floData).FLO_Kudos; - if (kudosData === undefined) - return; - storeTrustedIDs(kudosData).then(function (response) { - }).catch(function (error) { - }); - } catch (e) { - //console.log(e) + try { + var response = await getResponce(`api/addrs/${addr}/txs`); + var nRequired = response.totalItems - lasttx; + console.log(nRequired); + while (true && nRequired) { + var response = await getResponce(`api/addrs/${addr}/txs?from=0&to=${nRequired}`); + if (nRequired + lasttx != response.totalItems) { + nRequired = response.totalItems - lasttx; + continue; } - }); - var idb2 = indexedDB.open("FLO_Kudos"); - idb2.onerror = function (event) { - console.log("Error in opening IndexedDB!"); - }; - idb2.onsuccess = function (event) { - var dbt = event.target.result; - var obs = dbt.transaction('lastTx', "readwrite").objectStore('lastTx'); - obs.put(response.totalItems - errorTxCount, addr); - dbt.close(); - }; - break; + var errorTxCount = 0; //Count of txs that didnot go into any blocks + response.items.reverse().forEach(function (tx) { + try { + if (!tx.blockhash) { //ignore error txs that did not go into any blocks + errorTxCount += 1; + return; + } + if (addr != tx.vin[0].addr) //ignore if the tx is not from kudos ID + return + var kudosData = JSON.parse(tx.floData).FLO_Kudos; + if (kudosData === undefined) + return; + storeTrustedIDs(kudosData).then(function (response) { + }).catch(function (error) { + }); + } catch (e) { + //console.log(e) + } + }); + var idb2 = indexedDB.open("FLO_Kudos"); + idb2.onerror = function (event) { + console.log("Error in opening IndexedDB!"); + }; + idb2.onsuccess = function (event) { + var dbt = event.target.result; + var obs = dbt.transaction('lastTx', "readwrite").objectStore('lastTx'); + obs.put(response.totalItems - errorTxCount, addr); + dbt.close(); + }; + break; + } + resolve('retrieved data from API'); + } catch (e) { + notify("Error in retrieving data from API", 'error'); + console.error(e); } - resolve('retrived data from API'); }; db.close(); }; @@ -647,12 +638,12 @@ let percent = Math.round((i / N) * 100); console.log(torrentId) if (fromTorrentPage) { - getRef('loader_container').querySelector('.progress-loader').setAttribute('style', `stroke-dashoffset: ${201 - (2.01 * percent)}`) - getRef('loader_container').querySelector('.progress-percent').textContent = `${percent}% done` + getRef('torrent_download_button').style.setProperty('--progress', `${percent}%`) + getRef('torrent_download_button').textContent = `Collecting... ${percent}%` } else { - getRef(torrentId).querySelector('.progress-loader').setAttribute('style', `stroke-dashoffset: ${201 - (2.01 * percent)}`) - getRef(torrentId).querySelector('.progress-percent').textContent = `${percent}% done` + getRef(torrentId).querySelector('.torrent-card__download-button').style.setProperty('--progress', `${percent}%`) + getRef(torrentId).querySelector('.torrent-card__download-button').textContent = `Collecting... ${percent}%` } // console.log(i, N, percent, floData.next); if (!floData.next) @@ -672,33 +663,32 @@ } async function downloadTorrent(filename, txid, totalChunks, torrentId, fromTorrentPage = false) { console.log(txid); - const progressIndicator = create('div', { - className: 'progress-indicator flex align-center', - innerHTML: ` - - - 0% done - ` - }) if (fromTorrentPage) { - getRef('torrent_download_button').classList.add('hidden') - getRef('loader_container').append(progressIndicator) + getRef('torrent_download_button').setAttribute('data-collecting', '') + getRef('torrent_download_button').textContent = 'Collecting...' + getRef('torrent_download_button').disabled = true; } else { - getRef(torrentId).querySelector('.torrent-card__download-button').classList.add('hidden') - getRef(torrentId).append(progressIndicator) + getRef(torrentId).querySelector('.torrent-card__download-button').setAttribute('data-collecting', '') + getRef(torrentId).querySelector('.torrent-card__download-button').textContent = 'Collecting...' + getRef(torrentId).querySelector('.torrent-card__download-button').disabled = true; } getTorrentMetafromAPI(txid, 1, totalChunks, torrentId, fromTorrentPage).then(chunks => { let filedata = chunks.join(""); // console.log(filedata); download(filename, filedata); setTimeout(() => { - progressIndicator.remove() if (fromTorrentPage) { - getRef('torrent_download_button').classList.remove('hidden') + getRef('torrent_download_button').removeAttribute('data-collecting') + getRef('torrent_download_button').textContent = 'Get Torrent' + getRef('torrent_download_button').disabled = false; + getRef('torrent_download_button').style.removeProperty('--progress') } else { - getRef(torrentId).querySelector('.torrent-card__download-button').classList.remove('hidden') + getRef(torrentId).querySelector('.torrent-card__download-button').removeAttribute('data-collecting') + getRef(torrentId).querySelector('.torrent-card__download-button').textContent = 'Get Torrent'; + getRef(torrentId).querySelector('.torrent-card__download-button').disabled = false; + getRef(torrentId).querySelector('.torrent-card__download-button').style.removeProperty('--progress') } }, 300); }).catch(error => {