diff --git a/docs/css/main.css b/docs/css/main.css index 1e51547..a00cdce 100644 --- a/docs/css/main.css +++ b/docs/css/main.css @@ -71,21 +71,8 @@ a:focus-visible { box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; } -a.button { - display: flex; - align-items: center; - padding: 0.4rem 0.6rem; - border-radius: 0.3rem; - font-size: 0.9rem; - font-weight: 500; - color: var(--accent-color); -} - -fieldset { - border: none; -} - -button { +button, +.button { -webkit-user-select: none; -moz-user-select: none; user-select: none; @@ -97,39 +84,63 @@ button { color: inherit; -webkit-tap-highlight-color: transparent; align-items: center; - font-size: 0.9rem; + font-size: inherit; font-weight: 500; white-space: nowrap; padding: 0.8rem; border-radius: 0.3rem; justify-content: center; + flex-shrink: 0; } -button:focus-visible { +button:focus-visible, +.button:focus-visible { outline: var(--accent-color) solid medium; } -button:not(:disabled) { +button:not(:disabled), +.button:not(:disabled) { cursor: pointer; } .button { - color: var(--accent-color); - background-color: rgba(var(--text-color), 0.06); -} -.button--primary, .button--danger { - color: rgba(var(--background-color), 1) !important; -} -.button--primary .icon, .button--danger .icon { - fill: rgba(var(--background-color), 1); + background-color: rgba(var(--text-color), 0.02); + border: solid thin rgba(var(--text-color), 0.06); } .button--primary { + color: rgba(var(--background-color), 1); background-color: var(--accent-color); } +.button--primary .icon { + fill: rgba(var(--background-color), 1); +} +.button--colored { + color: var(--accent-color); +} +.button--colored .icon { + fill: var(--accent-color); +} .button--danger { - background-color: var(--danger-color); + background-color: rgba(255, 115, 115, 0.062745098); + color: var(--danger-color); +} +.button--danger .icon { + fill: var(--danger-color); } .button--small { padding: 0.4rem 0.6rem; } +.button--outlined { + border: solid rgba(var(--text-color), 0.3) 0.1rem; + background-color: rgba(var(--foreground-color), 1); +} +.button--transparent { + background-color: transparent; +} + +button:disabled { + opacity: 0.4; + cursor: not-allowed; + filter: saturate(0); +} .cta { text-transform: uppercase; @@ -496,32 +507,32 @@ details[open] summary .icon { transform: rotate(180deg); } -strip-select { +sm-chips { --gap: 0; background-color: rgba(var(--text-color), 0.06); border-radius: 0.2rem; } -strip-option { - font-weight: 500; +sm-chip { + position: relative; font-size: 0.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; - --border-radius: 0; - --active-option-color: rgba(var(--background-color), 1); - --active-option-background-color: var(--accent-color); + font-weight: 500; } -strip-option:first-of-type { - --border-radius: 0.2rem 0 0 0.2rem; +sm-chip[selected] { + --background: var(--accent-color); + color: rgba(var(--background-color), 1); } -strip-option:last-of-type { - --border-radius: 0 0.2rem 0.2rem 0; +sm-chip:first-of-type { + --border-radius: 0.3rem 0 0 0.3rem; } - -sm-select, -sm-option { - font-size: 0.9rem; +sm-chip:last-of-type { + --border-radius: 0 0.3rem 0.3rem 0; } sm-checkbox { diff --git a/docs/css/main.min.css b/docs/css/main.min.css index cb51504..2b934d8 100644 --- a/docs/css/main.min.css +++ b/docs/css/main.min.css @@ -1 +1 @@ -*{padding:0;margin:0;box-sizing:border-box;font-family:"Roboto",sans-serif}:root{font-size:clamp(1rem,1.2vmax,1.2rem)}html,body{height:100%;scroll-behavior:smooth}body{--accent-color: #516beb;--text-color: 20, 20, 20;--foreground-color: 252, 253, 255;--background-color: 241, 243, 248;--danger-color: rgb(255, 75, 75);--green: #1cad59;--yellow: #bd7200;scrollbar-width:thin;scrollbar-gutter:stable;color:rgba(var(--text-color), 1);background-color:rgba(var(--background-color), 1);transition:background-color .3s}body[data-theme=dark]{--accent-color: #a4b3ff;--text-color: 220, 220, 220;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--danger-color: rgb(255, 106, 106);--green: #00e676;--yellow: #ffeb3b}body[data-theme=dark] sm-popup::part(popup){background-color:rgba(var(--foreground-color), 1)}p,strong{font-size:.9rem;max-width:70ch;line-height:1.7;color:rgba(var(--text-color), 0.8)}p:not(:last-of-type),strong:not(:last-of-type){margin-bottom:1.5rem}a:where([class]){color:inherit;text-decoration:none}a:where([class]):focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}a{text-decoration:none;color:var(--accent-color)}a:focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}a.button{display:flex;align-items:center;padding:.4rem .6rem;border-radius:.3rem;font-size:.9rem;font-weight:500;color:var(--accent-color)}fieldset{border:none}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;color:inherit;-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:.3rem;justify-content:center}button:focus-visible{outline:var(--accent-color) solid medium}button:not(:disabled){cursor:pointer}.button{color:var(--accent-color);background-color:rgba(var(--text-color), 0.06)}.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{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}a:-webkit-any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}a:-moz-any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}a:any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}input{accent-color:var(--accent-color)}sm-input{font-size:.9rem;--border-radius: 0.3rem}sm-button{text-transform:uppercase;letter-spacing:.02em;font-weight:700;font-size:.9rem;--padding: 0.7rem 1rem}sm-button[variant=primary] .icon{fill:rgba(var(--background-color), 1)}sm-button[disabled] .icon{fill:rgba(var(--text-color), 0.6)}sm-button.danger{--background: var(--danger-color);color:rgba(var(--background-color), 1)}sm-form{--gap: 1rem}sm-copy{font-size:.9rem}ul{list-style:none}.hide{display:none !important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.wrap-around{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.sticky{position:-webkit-sticky;position:sticky;top:0;z-index:1}.full-bleed{grid-column:1/4}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.flex{display:flex}.flex-1{flex:1}.flex-wrap{flex-wrap:wrap}.flex-direction-column{flex-direction:column}.grid{display:grid}.grid-3{grid-template-columns:1fr auto auto}.flow-column{grid-auto-flow:column}.gap-0-3{gap:.3rem}.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}.justify-self-end{justify-self:end}.space-between{justify-content:space-between}.w-100{width:100%}.interact{position:relative;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.ripple{height:8rem;width:8rem;position:absolute;border-radius:50%;transform:scale(0);background:radial-gradient(circle, rgba(var(--text-color), 0.3) 0%, rgba(0, 0, 0, 0) 50%);pointer-events:none}.icon{width:1.2rem;height:1.2rem;fill:rgba(var(--text-color), 0.8)}.margin-right-0-5{margin-right:.5rem}.margin-left-0-5{margin-left:.5rem}.icon-only{padding:.5rem;aspect-ratio:1/1;background-color:rgba(0,0,0,0)}.icon-button{padding:.6rem;border-radius:.8rem;background-color:var(--accent-color--light);height:-webkit-max-content;height:-moz-max-content;height:max-content}.icon-button .icon{fill:var(--accent-color)}.empty-state{display:grid;text-align:center;justify-items:center;width:100%;max-width:none;padding:1.5rem}.empty-state__icon{height:3rem;width:3rem;padding:.6rem;border-radius:1rem;background-color:rgba(var(--text-color), 0.06);margin-bottom:1rem}.observe-empty-state:empty{display:none !important}.observe-empty-state:not(:empty)+.empty-state{display:none !important}#confirmation_popup,#prompt_popup{flex-direction:column}#confirmation_popup h4,#prompt_popup h4{font-weight:500;margin-bottom:.5rem}#confirmation_popup sm-button,#prompt_popup sm-button{margin:0}#confirmation_popup .flex,#prompt_popup .flex{padding:0;margin-top:1rem}#confirmation_popup .flex sm-button:first-of-type,#prompt_popup .flex sm-button:first-of-type{margin-right:.6rem;margin-left:auto}#prompt_message{margin-bottom:1.5rem}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem;align-items:center;justify-items:flex-start}.popup__header__close{padding:.5rem;margin-left:-0.5rem}#main_page{padding:1.5rem}#main_page>section:nth-of-type(1){align-content:flex-start}.logo{display:grid;align-items:center;grid-template-columns:auto 1fr;gap:0 .3rem;margin-right:auto}.logo h4{text-transform:capitalize;font-weight:600}.logo .main-logo{height:1.4rem;width:1.4rem;fill:rgba(var(--text-color), 1);stroke:none}details:not(:last-of-type){border-bottom:thin solid rgba(var(--text-color), 0.3)}details summary{display:flex;justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;padding:1rem 0}details .icon{flex-shrink:0}details[open]{padding-bottom:1rem}details[open] summary .icon{transform:rotate(180deg)}strip-select{--gap: 0;background-color:rgba(var(--text-color), 0.06);border-radius:.2rem}strip-option{font-weight:500;font-size:.9rem;-webkit-user-select:none;-moz-user-select:none;user-select:none;--border-radius: 0;--active-option-color: rgba(var(--background-color), 1);--active-option-background-color: var(--accent-color)}strip-option:first-of-type{--border-radius: 0.2rem 0 0 0.2rem}strip-option:last-of-type{--border-radius: 0 0.2rem 0.2rem 0}sm-select,sm-option{font-size:.9rem}sm-checkbox{--height: 1rem;--width: 1rem;-webkit-tap-highlight-color:rgba(0,0,0,0)}.warning{background-color:khaki;color:rgba(0,0,0,.7);padding:1rem;border-radius:.5rem;line-height:1.5}.tip{border-radius:1.5rem;background-color:rgba(var(--text-color), 0.06);padding:.3rem .8rem;font-size:.85rem}.tip .icon{fill:var(--accent-color);flex-shrink:0}.tooltip{display:flex;position:relative;z-index:8;cursor:pointer}.tooltip .banner{position:absolute;right:0;top:100%;width:min(20rem,100vw - 1rem);display:none;font-size:.9rem;background-color:rgba(var(--foreground-color), 1);padding:1rem;border-radius:.5rem;box-shadow:0 .2rem .5rem rgba(0,0,0,.1);border:solid thin rgba(var(--text-color), 0.2)}.tooltip:hover .banner{display:block}.page-layout{display:grid;grid-template-columns:1.5rem minmax(0, 1fr) 1.5rem}.page-layout>*{grid-column:2/3}.page{height:100%}.mobile-page{align-items:flex-start}#landing{grid-template-rows:auto 1fr}#landing header{padding:1.5rem 0}#landing>.grid{align-content:flex-start;text-align:center;gap:1rem}#sign_up{grid-template-rows:auto 1fr;align-items:center}#sign_up section{margin-top:-6rem;justify-self:center;width:min(24rem,100%)}#sign_up header{padding:1.5rem 0}#sign_up .h2{margin-bottom:.5rem}#sign_up h5{font-weight:500;color:rgba(var(--text-color), 0.8)}#sign_up .warning{margin-top:2rem}.multi-state-button{display:grid;text-align:center;align-items:center}.multi-state-button>*{grid-area:1/1/2/2}.multi-state-button button{z-index:1}#home{height:100%;display:flex;flex-direction:column;align-items:flex-start;align-content:flex-start}#login_form{width:min(24rem,100%);margin:0 auto}#login_form__priv_key{margin-top:1rem}#main_header{display:flex;flex-wrap:wrap;gap:1rem;padding:1rem 1.5rem;width:100%;align-items:center}#user_popup_button{background-color:rgba(var(--text-color), 0.06);border-radius:2rem;font-size:.8rem}#main_navbar{width:100%}.main_navbar__item{display:flex;flex-direction:column;align-items:center;flex:1;padding:.5rem 0}.main_navbar__item .item__title,.main_navbar__item .icon{transition:transform .3s cubic-bezier(0.175, 0.885, 0.32, 1.275),opacity .3s}.main_navbar__item .item__title{color:rgba(var(--text-color), 0.8);font-size:.8rem;font-weight:500}.main_navbar__item .icon{height:1.2rem;margin-bottom:.3rem}.main_navbar__item--active .item__title{color:var(--accent-color)}.main_navbar__item--active .icon{fill:var(--accent-color)}#pages_container{display:flex;flex:1;width:100%;height:100%;justify-content:center;overflow-y:auto}#pages_container>*{padding:0 1.5rem;min-width:min(26rem,100%)}.listed-asset{position:relative;gap:.5rem;padding:1rem 0;border-radius:.5rem;font-weight:400;transition:background-color .3s;-webkit-user-select:none;-moz-user-select:none;user-select:none;color:inherit;grid-template-columns:auto 1fr auto auto;grid-template-areas:"icon name rate right-arrow" "icon name countdown right-arrow"}.listed-asset__icon{grid-area:icon;padding:.5rem;border-radius:1rem;display:flex;background-color:var(--accent-color)}.listed-asset__icon .icon{height:1.2rem;width:1.2rem;fill:rgba(var(--background-color), 1)}.listed-asset__name{grid-area:name;margin-left:.3rem}.listed-asset__rate{grid-area:rate}.listed-asset__countdown{display:flex;align-items:center;grid-area:countdown;justify-self:flex-end;font-size:.8rem;color:var(--accent-color)}.listed-asset__countdown .icon{margin-left:.3rem;overflow:visible;stroke-width:3;fill:none}.listed-asset__countdown .icon .path-a{stroke:var(--accent-color);stroke-dashoffset:var(--path-length, 0);stroke-dasharray:63}.listed-asset__countdown .icon .path-b{stroke:rgba(var(--text-color), 0.2)}.listed-asset__right-arrow{grid-area:right-arrow;background-color:rgba(var(--text-color), 0.1);border-radius:1rem;padding:.1rem;margin-left:.3rem}.quantity-selector .button{flex:1;padding:.5rem .6rem;margin-left:.5rem}#quantity_selector_tip::first-letter{text-transform:uppercase}#quantity_type,#portfolio_quantity_type{font-size:.8rem;padding-right:.5rem;border-right:thin solid rgba(var(--text-color), 0.3);margin-right:auto;color:rgba(var(--text-color), 0.8);line-height:1.5;font-weight:500;min-width:8ch}#exchange_wrapper{display:flex;flex-direction:column;height:100%}#asset_page{position:relative;display:flex;flex-direction:column;height:100%;align-items:flex-start}#asset_page_wrapper{display:flex;flex-direction:column;height:100%;width:100%}#trade_form{height:100%}#trade_form::part(form){display:flex;flex-direction:column;gap:0}#trade_form>*{margin-bottom:1rem}#trade_form>:last-child{margin-top:auto}#my_orders,#market{width:min(46rem,100%);height:-webkit-max-content;height:-moz-max-content;height:max-content}#my_orders{grid-template-rows:auto 1fr}.orders_section__header{min-height:2.8rem;position:-webkit-sticky;position:sticky;top:0;background-color:rgba(var(--background-color), 1);z-index:2;transition:background-color .3s}.list__item{padding:.5rem 0;display:grid}.order-card{position:relative;outline:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;align-items:center;gap:.5rem;grid-template-columns:-webkit-min-content 1fr auto;grid-template-columns:min-content 1fr auto;border-radius:.5rem;grid-template-areas:"checkbox quantity quantity time" "checkbox price amount cancel"}.order-card>.grid:nth-of-type(2){grid-area:price}.order-card>.grid:nth-of-type(3){grid-area:amount}.order-card__type{font-size:.9rem;font-weight:500;margin-bottom:.3rem}.order-card[data-type=buy] .order-card__type{color:var(--green)}.order-card[data-type=sell] .order-card__type{color:var(--danger-color)}.order-card--selected{background-color:rgba(var(--text-color), 0.08)}.order-card--selected .cancel-order{visibility:hidden;pointer-events:none}.order-card sm-checkbox{grid-area:checkbox;cursor:pointer;margin-right:.5rem}.order-card__quantity,.order-card__price{font-size:.9rem;color:rgba(var(--text-color), 0.9)}.order-card__time{grid-area:time;font-size:.8rem;color:rgba(var(--text-color), 0.8)}.order-card .cancel-order{grid-area:cancel;color:var(--danger-color)}.order-card .cancel-order .icon{fill:var(--danger-color)}.cancel-order{align-items:center;padding:.4rem .6rem}.cancel-order span{margin-left:.3rem}.completed-trade,.transaction-card,.live-order{gap:0 1rem}.completed-trade__type,.transaction-card__type,.live-order__type{font-size:.9rem;font-weight:500;margin-bottom:.3rem}.completed-trade[data-type=Bought] .completed-trade__type,.completed-trade--buy .completed-trade__type,.completed-trade[data-type=Bought] .transaction-card__type,.completed-trade--buy .transaction-card__type,.completed-trade[data-type=Bought] .live-order__type,.completed-trade--buy .live-order__type,.transaction-card[data-type=Bought] .completed-trade__type,.transaction-card--buy .completed-trade__type,.transaction-card[data-type=Bought] .transaction-card__type,.transaction-card--buy .transaction-card__type,.transaction-card[data-type=Bought] .live-order__type,.transaction-card--buy .live-order__type,.live-order[data-type=Bought] .completed-trade__type,.live-order--buy .completed-trade__type,.live-order[data-type=Bought] .transaction-card__type,.live-order--buy .transaction-card__type,.live-order[data-type=Bought] .live-order__type,.live-order--buy .live-order__type{color:var(--green)}.completed-trade[data-type=Sold] .completed-trade__type,.completed-trade--sell .completed-trade__type,.completed-trade[data-type=Sold] .transaction-card__type,.completed-trade--sell .transaction-card__type,.completed-trade[data-type=Sold] .live-order__type,.completed-trade--sell .live-order__type,.transaction-card[data-type=Sold] .completed-trade__type,.transaction-card--sell .completed-trade__type,.transaction-card[data-type=Sold] .transaction-card__type,.transaction-card--sell .transaction-card__type,.transaction-card[data-type=Sold] .live-order__type,.transaction-card--sell .live-order__type,.live-order[data-type=Sold] .completed-trade__type,.live-order--sell .completed-trade__type,.live-order[data-type=Sold] .transaction-card__type,.live-order--sell .transaction-card__type,.live-order[data-type=Sold] .live-order__type,.live-order--sell .live-order__type{color:var(--danger-color)}.completed-trade__total,.transaction-card__total,.live-order__total{font-weight:700;font-size:.9rem;color:rgba(var(--text-color), 0.8)}.completed-trade__quantity,.completed-trade__price,.transaction-card__quantity,.transaction-card__price,.live-order__quantity,.live-order__price{font-size:.9rem;color:rgba(var(--text-color), 0.9)}.completed-trade__time,.transaction-card__time,.live-order__time{font-size:.8rem;color:rgba(var(--text-color), 0.8)}.completed-trade .more-info,.transaction-card .more-info,.live-order .more-info{flex-shrink:0;padding:.3rem}.transaction-card{content-visibility:auto;contain-intrinsic-size:2.5rem;grid-template-columns:repeat(3, 1fr) 2rem}.completed-trade{display:grid;gap:.5rem;grid-template-columns:1fr 1fr;background-color:rgba(var(--text-color), 0.03);border-radius:.5rem;padding:1rem;margin-bottom:.5rem}#market_asset_rates{display:grid;gap:.5rem}#market_asset_rates .listed-asset{padding:1rem;background-color:rgba(var(--text-color), 0.03)}#market_orders_wrapper .list__header{font-size:.8rem;font-weight:500}#market_orders_wrapper .list__header div{padding:.5rem 0}#market_orders_wrapper .list__header{margin-bottom:.5rem;grid-template-columns:repeat(3, 1fr) 2rem}.live-order{display:grid;gap:1rem;padding:1rem;border-radius:.5rem;background-color:rgba(var(--text-color), 0.03)}.live-order:not(:last-of-type){margin-bottom:.5rem}.live-order[data-type=buy]{background-color:rgba(0,250,154,.062745098)}.live-order[data-type=sell]{background-color:rgba(226,19,81,.062745098)}#portfolio{display:grid;gap:1.5rem;grid-template-columns:minmax(0, 1fr);align-content:flex-start;width:min(32rem,100%)}.label{font-size:.8rem;color:rgba(var(--text-color), 0.8);margin-bottom:.2rem}#my_assets{gap:.5rem;margin-top:.5rem;padding-bottom:1.5rem;border:none}.balance-card{display:grid;align-items:center;gap:0 .5rem;padding:1rem;padding-left:.6rem;border-radius:.3rem;color:inherit;background-color:rgba(var(--text-color), 0.03)}.balance-card.is-locked{grid-template-columns:auto 1fr auto}.balance-card.is-locked .balance-card__icon{grid-row:span 2}.balance-card.is-locked .balance-card__right-arrow{grid-area:1/3/3/4}.balance-card.is-locked .balance-card__amount-wrapper{grid-area:2/2/3/3}.balance-card:not(.is-locked){grid-template-columns:auto 1fr auto auto}.balance-card:not(.is-locked) .balance-card__right-arrow{grid-area:1/4/2/5}.balance-card__icon{display:flex;align-content:center;justify-content:center;margin:0 .5rem;border-radius:.8rem;align-self:flex-start;background-color:var(--accent-color--light)}.balance-card__icon .icon{height:1.3rem;width:1.3rem;fill:var(--accent-color)}.balance-card__token{font-size:.9rem;font-weight:500}.balance-card__amount-wrapper{margin-top:.5rem;grid-column:3/-1;gap:.3rem 1rem;grid-template-columns:1fr 1fr}.balance-card__amount-wrapper>:nth-child(even){text-align:right}.balance-card__right-arrow{background-color:rgba(var(--text-color), 0.1);border-radius:1rem;padding:.1rem;fill:var(--accent-color)}#history{padding-top:0 !important;width:min(36rem,100%)}#history .sticky{margin-left:-0.7rem;padding:1rem 0;background-color:rgba(var(--background-color), 1)}#exchange_history{margin-top:.5rem}.history-entry{display:grid;grid-template-columns:auto 1fr auto;gap:.5rem 1rem;align-items:center;margin-bottom:2rem}.history-entry[data-status=SUCCESS] .history-entry__status .icon{fill:var(--green)}.history-entry[data-status=PENDING] .history-entry__status .icon,.history-entry[data-status=WAITING_CONFIRMATION] .history-entry__status .icon{fill:var(--yellow)}.history-entry__status{display:flex;align-items:center;justify-content:center;grid-row:1/3;width:2.5rem;height:2.5rem;background-color:rgba(var(--text-color), 0.03);border-radius:2rem}.history-entry__token-action{font-weight:500}.history-entry__amount{font-weight:500;text-align:right}.history-entry[data-type=deposit] .history-entry__amount:not(:empty){color:var(--green)}.history-entry[data-type=deposit] .history-entry__amount:not(:empty)::before{content:"+ "}.history-entry[data-type=withdraw] .history-entry__amount:not(:empty)::before{content:"- "}.history-entry__time{font-size:.8rem;color:rgba(var(--text-color), 0.8)}.history-entry__txid{font-weight:500;font-size:.9rem;text-align:right}#portfolio_asset_page .sticky{margin-top:-1.5rem;margin-left:-0.7rem;padding:1rem 0;background-color:rgba(var(--background-color), 1)}#portfolio_asset__history{margin-top:1rem}#portfolio_cards_wrapper{display:grid;gap:.5rem;grid-template-columns:repeat(auto-fit, minmax(12rem, 1fr))}.personal-asset-balance{align-content:flex-start;padding:1rem;border-radius:.5rem;color:rgba(0,0,0,.8);width:100%}.personal-asset-balance:not(:last-of-type){margin-right:.5rem}.personal-asset-balance:nth-of-type(1){background:url("bg-art2.svg") no-repeat bottom right,#c2ffd7;background-size:contain}.personal-asset-balance:nth-of-type(1) .icon{background-color:rgba(102,255,156,.5)}.personal-asset-balance:nth-of-type(1) .button{border:solid thin rgba(102,255,156,.5)}.personal-asset-balance:nth-of-type(2){background:url("back.svg") no-repeat top right,#fcffa8;background-size:contain}.personal-asset-balance:nth-of-type(2) .icon{background-color:rgba(255,234,0,.5)}.personal-asset-balance>.flex{margin-bottom:.3rem}.personal-asset-balance>.flex .icon{height:2rem;width:2rem;padding:.4rem;border-radius:.3rem;fill:rgba(0,0,0,.8);margin-right:.5rem}.personal-asset-balance .button{display:flex;align-items:center;margin-top:.5rem;padding-right:.8rem;justify-self:flex-start;border-radius:1rem;background-color:rgba(var(--foreground-color), 1);color:rgba(var(--text-color), 1);transition:box-shadow .3s}.personal-asset-balance .button .icon{height:1rem;background-color:rgba(0,0,0,0);margin-right:.3rem}.personal-asset-balance .button:hover{box-shadow:0 .3rem .5rem rgba(0,0,0,.16)}#personal_rupee_balance span:first-of-type,#personal_flo_balance span:first-of-type{font-size:1.5rem}#personal_rupee_balance span:last-of-type,#personal_flo_balance span:last-of-type{font-size:.9rem}#portfolio_result{justify-content:center;text-align:center}#portfolio_result__icon{display:flex;padding:1rem;border-radius:50%;background-color:rgba(var(--text-color), 0.06);justify-self:center;-webkit-animation:pop-up .3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);animation:pop-up .3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275)}#portfolio_result__icon .icon{height:2rem;width:2rem}.icon--success{fill:var(--green)}.icon--failure,.icon--error{fill:var(--danger-color)}@-webkit-keyframes pop-up{from{transform:translateY(3rem) scale(0.5);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}@keyframes pop-up{from{transform:translateY(3rem) scale(0.5);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}#portfolio_result__cta{padding:1.5rem 1rem;border-radius:.5rem;background-color:rgba(var(--text-color), 0.06)}.stateful-button-wrapper{display:flex;position:relative;justify-content:center;align-items:center}.stateful-button-wrapper sm-button,.stateful-button-wrapper slide-button{width:100%;z-index:1;transition:-webkit-clip-path .3s;transition:clip-path .3s;transition:clip-path .3s, -webkit-clip-path .3s;-webkit-clip-path:circle(100%);clip-path:circle(100%)}.stateful-button-wrapper sm-button.clip,.stateful-button-wrapper slide-button.clip{pointer-events:none;-webkit-clip-path:circle(0);clip-path:circle(0)}.stateful-button-wrapper sm-spinner{position:absolute}.stateful-result{overflow:hidden;position:absolute;display:flex;justify-content:center;align-items:center;height:100%;width:100%;left:0}.stateful-result>*{position:absolute}.stateful-result--success .result__background{background-color:var(--green)}.stateful-result--failure .result__background{background-color:var(--danger-color)}.stateful-result .icon-wrapper{-webkit-animation:pop .4s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);animation:pop .4s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275)}.stateful-result .icon{height:1.5rem;width:1.5rem;fill:rgba(var(--background-color), 1)}.stateful-result span{font-weight:500;color:rgba(var(--background-color), 1)}.stateful-result .result__background{-webkit-animation:ripple-reveal 1s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);animation:ripple-reveal 1s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275)}.result__background{border-radius:.3rem;height:100%;width:100%;-webkit-clip-path:circle(10%);clip-path:circle(10%)}@-webkit-keyframes pop{from{opacity:0;transform:translateY(2rem)}to{opacity:1;transform:translateY(0)}}@keyframes pop{from{opacity:0;transform:translateY(2rem)}to{opacity:1;transform:translateY(0)}}@-webkit-keyframes ripple-reveal{to{-webkit-clip-path:circle(100%);clip-path:circle(100%)}}@keyframes ripple-reveal{to{-webkit-clip-path:circle(100%);clip-path:circle(100%)}}#help{width:min(60ch,100%);margin-bottom:3rem;align-content:flex-start}#help ul{list-style:initial;display:grid;gap:1rem}#help ul li{margin-left:1rem;padding-left:.5rem;font-size:.9rem}@media screen and (max-width: 40rem)and (any-hover: none){.cancel-order span{display:none !important}}@media screen and (max-width: 40rem){sm-button{--padding: 0.9rem 1.6rem}.empty-state{align-self:center}#user_popup_button{width:100%}.main_navbar__item--active .item__title{transform:translateY(100%);opacity:0}.main_navbar__item--active .icon{transform:translateY(50%) scale(1.2)}#asset_list_wrapper{padding:0 1.5rem}.listed-asset{border-radius:0;border-bottom:solid thin rgba(var(--text-color), 0.1)}#exchange{margin:0;padding:0}#login_form{padding:0 1.5rem}#asset_page__header{display:flex;padding:1rem 1.5rem .5rem .8rem}#chart_header{padding:0 1.5rem .5rem 1.5rem}#trade_form{padding:0 1.5rem}#price_chart_container{flex:1}#asset_page__footer button{display:flex;flex-direction:column;align-items:center;flex:1;padding:.5rem 0;color:rgba(var(--text-color), 0.8);font-size:.8rem;font-weight:500}#asset_page__footer button .icon{height:1.2rem;margin-bottom:.3rem;margin-right:.3rem}#asset_page__footer button.active{color:var(--accent-color)}#asset_page__footer button.active .icon{fill:var(--accent-color)}.hide-on-mobile{display:none !important}}@media screen and (min-width: 40rem){sm-popup{--width: 24rem}.popup__header{grid-column:1/-1;padding:1rem 1.5rem 0 1.5rem}#confirmation_popup{--width: 24rem}.page-layout{grid-template-columns:1fr 90vw 1fr}.mobile-page{align-self:flex-start;padding:2rem;border-radius:.5rem;background-color:rgba(var(--foreground-color), 1)}.hide-on-desktop{display:none !important}#home{display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto 1fr;grid-template-areas:"header header" "nav pages"}#main_header{grid-area:header}#user_popup_button{justify-self:flex-end}#main_navbar{grid-area:nav;flex-direction:column;height:100%;padding-left:.5rem}.main_navbar__item{padding:1.5rem 2rem 1.5rem 1rem;width:100%;flex:0;flex-direction:row;border-radius:.5rem;transition:background-color .3s}.main_navbar__item .icon{margin-bottom:0;margin-right:.5rem}.main_navbar__item .item__title{font-size:.9rem}.main_navbar__item--active{background-color:rgba(var(--text-color), 0.06)}#pages_container{grid-area:pages}#pages_container>*{margin:0 1.5rem;padding:2rem}.is-signed-in #exchange{display:flex;width:100%}.is-signed-in #exchange_wrapper{display:grid;width:100%;height:100%;gap:1.5rem;grid-template-columns:17rem minmax(0, 1fr);align-items:flex-start}#price_history_chart{height:20rem}#asset_list_wrapper{grid-row:1/3}.listed-asset{padding:1rem}.listed-asset--active{opacity:1;background-color:rgba(var(--text-color), 0.06)}.listed-asset--active::before{content:"";position:absolute;width:.25rem;border-radius:0 .2rem .2rem 0;height:2rem;background-color:var(--accent-color)}.order-card{grid-template-columns:auto 1fr 1fr 1fr auto;grid-template-areas:"checkbox quantity price amount time cancel"}.orders_section__header{background-color:rgba(var(--foreground-color), 1)}#history .sticky,#portfolio_asset_page .sticky{background-color:rgba(var(--foreground-color), 1)}}@media screen and (max-width: 80rem)and (min-width: 40rem){.main_navbar__item{padding:1.5rem 1rem}.main_navbar__item .icon{margin-right:0}.main_navbar__item .item__title{display:none !important}}@media screen and (min-width: 52rem){body:not(.is-signed-in) #market{gap:2rem;width:100%;grid-template-columns:18rem 1fr}.completed-trade{grid-template-columns:1fr 1fr 1fr 8rem;grid-template-areas:"quantity price amount info"}.completed-trade .quantity-block{grid-area:quantity}.completed-trade .price-block{grid-area:price}.completed-trade .amount-block{grid-area:amount}.completed-trade .info-block{grid-area:info}}@media screen and (min-width: 64rem){#home{grid-template-columns:auto 1fr}#asset_page_wrapper{display:grid;gap:1.5rem;grid-template-columns:minmax(0, 1fr) 20rem}}@media screen and (min-width: 72rem){.page-layout{grid-template-columns:1fr 80vw 1fr}}@media screen and (min-width: 120rem){.page-layout{grid-template-columns:1fr 70vw 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)}.order-card .cancel-order{justify-self:flex-end;overflow:hidden}.order-card .cancel-order .icon,.order-card .cancel-order span{transition:opacity .3s,transform .3s}.order-card .cancel-order .icon{transform:translateX(100%)}.order-card .cancel-order span{transform:translateX(100%);opacity:0}.order-card:hover .cancel-order .icon,.order-card:focus-within .cancel-order .icon{opacity:1}.order-card .cancel-order:hover .icon,.order-card .cancel-order:hover span{opacity:1;transform:translateX(0)}} \ No newline at end of file +*{padding:0;margin:0;box-sizing:border-box;font-family:"Roboto",sans-serif}:root{font-size:clamp(1rem,1.2vmax,1.2rem)}html,body{height:100%;scroll-behavior:smooth}body{--accent-color: #516beb;--text-color: 20, 20, 20;--foreground-color: 252, 253, 255;--background-color: 241, 243, 248;--danger-color: rgb(255, 75, 75);--green: #1cad59;--yellow: #bd7200;scrollbar-width:thin;scrollbar-gutter:stable;color:rgba(var(--text-color), 1);background-color:rgba(var(--background-color), 1);transition:background-color .3s}body[data-theme=dark]{--accent-color: #a4b3ff;--text-color: 220, 220, 220;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--danger-color: rgb(255, 106, 106);--green: #00e676;--yellow: #ffeb3b}body[data-theme=dark] sm-popup::part(popup){background-color:rgba(var(--foreground-color), 1)}p,strong{font-size:.9rem;max-width:70ch;line-height:1.7;color:rgba(var(--text-color), 0.8)}p:not(:last-of-type),strong:not(:last-of-type){margin-bottom:1.5rem}a:where([class]){color:inherit;text-decoration:none}a:where([class]):focus-visible{box-shadow:0 0 0 .1rem rgba(var(--text-color), 1) inset}a{text-decoration:none;color:var(--accent-color)}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;color:inherit;-webkit-tap-highlight-color:rgba(0,0,0,0);align-items:center;font-size:inherit;font-weight:500;white-space:nowrap;padding:.8rem;border-radius:.3rem;justify-content:center;flex-shrink:0}button:focus-visible,.button:focus-visible{outline:var(--accent-color) solid medium}button:not(:disabled),.button:not(:disabled){cursor:pointer}.button{background-color:rgba(var(--text-color), 0.02);border:solid thin rgba(var(--text-color), 0.06)}.button--primary{color:rgba(var(--background-color), 1);background-color:var(--accent-color)}.button--primary .icon{fill:rgba(var(--background-color), 1)}.button--colored{color:var(--accent-color)}.button--colored .icon{fill:var(--accent-color)}.button--danger{background-color:rgba(255,115,115,.062745098);color:var(--danger-color)}.button--danger .icon{fill:var(--danger-color)}.button--small{padding:.4rem .6rem}.button--outlined{border:solid rgba(var(--text-color), 0.3) .1rem;background-color:rgba(var(--foreground-color), 1)}.button--transparent{background-color:rgba(0,0,0,0)}button:disabled{opacity:.4;cursor:not-allowed;filter:saturate(0)}.cta{text-transform:uppercase;font-size:.8rem;font-weight:700;letter-spacing:.05em;padding:.8rem 1rem}a:-webkit-any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}a:-moz-any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}a:any-link:focus-visible{outline:rgba(var(--text-color), 1) .1rem solid}input{accent-color:var(--accent-color)}sm-input{font-size:.9rem;--border-radius: 0.3rem}sm-button{text-transform:uppercase;letter-spacing:.02em;font-weight:700;font-size:.9rem;--padding: 0.7rem 1rem}sm-button[variant=primary] .icon{fill:rgba(var(--background-color), 1)}sm-button[disabled] .icon{fill:rgba(var(--text-color), 0.6)}sm-button.danger{--background: var(--danger-color);color:rgba(var(--background-color), 1)}sm-form{--gap: 1rem}sm-copy{font-size:.9rem}ul{list-style:none}.hide{display:none !important}.overflow-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.wrap-around{overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.sticky{position:-webkit-sticky;position:sticky;top:0;z-index:1}.full-bleed{grid-column:1/4}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.flex{display:flex}.flex-1{flex:1}.flex-wrap{flex-wrap:wrap}.flex-direction-column{flex-direction:column}.grid{display:grid}.grid-3{grid-template-columns:1fr auto auto}.flow-column{grid-auto-flow:column}.gap-0-3{gap:.3rem}.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}.justify-self-end{justify-self:end}.space-between{justify-content:space-between}.w-100{width:100%}.interact{position:relative;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.ripple{height:8rem;width:8rem;position:absolute;border-radius:50%;transform:scale(0);background:radial-gradient(circle, rgba(var(--text-color), 0.3) 0%, rgba(0, 0, 0, 0) 50%);pointer-events:none}.icon{width:1.2rem;height:1.2rem;fill:rgba(var(--text-color), 0.8)}.margin-right-0-5{margin-right:.5rem}.margin-left-0-5{margin-left:.5rem}.icon-only{padding:.5rem;aspect-ratio:1/1;background-color:rgba(0,0,0,0)}.icon-button{padding:.6rem;border-radius:.8rem;background-color:var(--accent-color--light);height:-webkit-max-content;height:-moz-max-content;height:max-content}.icon-button .icon{fill:var(--accent-color)}.empty-state{display:grid;text-align:center;justify-items:center;width:100%;max-width:none;padding:1.5rem}.empty-state__icon{height:3rem;width:3rem;padding:.6rem;border-radius:1rem;background-color:rgba(var(--text-color), 0.06);margin-bottom:1rem}.observe-empty-state:empty{display:none !important}.observe-empty-state:not(:empty)+.empty-state{display:none !important}#confirmation_popup,#prompt_popup{flex-direction:column}#confirmation_popup h4,#prompt_popup h4{font-weight:500;margin-bottom:.5rem}#confirmation_popup sm-button,#prompt_popup sm-button{margin:0}#confirmation_popup .flex,#prompt_popup .flex{padding:0;margin-top:1rem}#confirmation_popup .flex sm-button:first-of-type,#prompt_popup .flex sm-button:first-of-type{margin-right:.6rem;margin-left:auto}#prompt_message{margin-bottom:1.5rem}.popup__header{display:grid;gap:.5rem;width:100%;padding:0 1.5rem;align-items:center;justify-items:flex-start}.popup__header__close{padding:.5rem;margin-left:-0.5rem}#main_page{padding:1.5rem}#main_page>section:nth-of-type(1){align-content:flex-start}.logo{display:grid;align-items:center;grid-template-columns:auto 1fr;gap:0 .3rem;margin-right:auto}.logo h4{text-transform:capitalize;font-weight:600}.logo .main-logo{height:1.4rem;width:1.4rem;fill:rgba(var(--text-color), 1);stroke:none}details:not(:last-of-type){border-bottom:thin solid rgba(var(--text-color), 0.3)}details summary{display:flex;justify-content:space-between;-webkit-user-select:none;-moz-user-select:none;user-select:none;cursor:pointer;padding:1rem 0}details .icon{flex-shrink:0}details[open]{padding-bottom:1rem}details[open] summary .icon{transform:rotate(180deg)}sm-chips{--gap: 0;background-color:rgba(var(--text-color), 0.06);border-radius:.2rem}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(--background-color), 1)}sm-chip:first-of-type{--border-radius: 0.3rem 0 0 0.3rem}sm-chip:last-of-type{--border-radius: 0 0.3rem 0.3rem 0}sm-checkbox{--height: 1rem;--width: 1rem;-webkit-tap-highlight-color:rgba(0,0,0,0)}.warning{background-color:khaki;color:rgba(0,0,0,.7);padding:1rem;border-radius:.5rem;line-height:1.5}.tip{border-radius:1.5rem;background-color:rgba(var(--text-color), 0.06);padding:.3rem .8rem;font-size:.85rem}.tip .icon{fill:var(--accent-color);flex-shrink:0}.tooltip{display:flex;position:relative;z-index:8;cursor:pointer}.tooltip .banner{position:absolute;right:0;top:100%;width:min(20rem,100vw - 1rem);display:none;font-size:.9rem;background-color:rgba(var(--foreground-color), 1);padding:1rem;border-radius:.5rem;box-shadow:0 .2rem .5rem rgba(0,0,0,.1);border:solid thin rgba(var(--text-color), 0.2)}.tooltip:hover .banner{display:block}.page-layout{display:grid;grid-template-columns:1.5rem minmax(0, 1fr) 1.5rem}.page-layout>*{grid-column:2/3}.page{height:100%}.mobile-page{align-items:flex-start}#landing{grid-template-rows:auto 1fr}#landing header{padding:1.5rem 0}#landing>.grid{align-content:flex-start;text-align:center;gap:1rem}#sign_up{grid-template-rows:auto 1fr;align-items:center}#sign_up section{margin-top:-6rem;justify-self:center;width:min(24rem,100%)}#sign_up header{padding:1.5rem 0}#sign_up .h2{margin-bottom:.5rem}#sign_up h5{font-weight:500;color:rgba(var(--text-color), 0.8)}#sign_up .warning{margin-top:2rem}.multi-state-button{display:grid;text-align:center;align-items:center}.multi-state-button>*{grid-area:1/1/2/2}.multi-state-button button{z-index:1}#home{height:100%;display:flex;flex-direction:column;align-items:flex-start;align-content:flex-start}#login_form{width:min(24rem,100%);margin:0 auto}#login_form__priv_key{margin-top:1rem}#main_header{display:flex;flex-wrap:wrap;gap:1rem;padding:1rem 1.5rem;width:100%;align-items:center}#user_popup_button{background-color:rgba(var(--text-color), 0.06);border-radius:2rem;font-size:.8rem}#main_navbar{width:100%}.main_navbar__item{display:flex;flex-direction:column;align-items:center;flex:1;padding:.5rem 0}.main_navbar__item .item__title,.main_navbar__item .icon{transition:transform .3s cubic-bezier(0.175, 0.885, 0.32, 1.275),opacity .3s}.main_navbar__item .item__title{color:rgba(var(--text-color), 0.8);font-size:.8rem;font-weight:500}.main_navbar__item .icon{height:1.2rem;margin-bottom:.3rem}.main_navbar__item--active .item__title{color:var(--accent-color)}.main_navbar__item--active .icon{fill:var(--accent-color)}#pages_container{display:flex;flex:1;width:100%;height:100%;justify-content:center;overflow-y:auto}#pages_container>*{padding:0 1.5rem;min-width:min(26rem,100%)}.listed-asset{position:relative;gap:.5rem;padding:1rem 0;border-radius:.5rem;font-weight:400;transition:background-color .3s;-webkit-user-select:none;-moz-user-select:none;user-select:none;color:inherit;grid-template-columns:auto 1fr auto auto;grid-template-areas:"icon name rate right-arrow" "icon name countdown right-arrow"}.listed-asset__icon{grid-area:icon;padding:.5rem;border-radius:1rem;display:flex;background-color:var(--accent-color)}.listed-asset__icon .icon{height:1.2rem;width:1.2rem;fill:rgba(var(--background-color), 1)}.listed-asset__name{grid-area:name;margin-left:.3rem}.listed-asset__rate{grid-area:rate}.listed-asset__countdown{display:flex;align-items:center;grid-area:countdown;justify-self:flex-end;font-size:.8rem;color:var(--accent-color)}.listed-asset__countdown .icon{margin-left:.3rem;overflow:visible;stroke-width:3;fill:none}.listed-asset__countdown .icon .path-a{stroke:var(--accent-color);stroke-dashoffset:var(--path-length, 0);stroke-dasharray:63}.listed-asset__countdown .icon .path-b{stroke:rgba(var(--text-color), 0.2)}.listed-asset__right-arrow{grid-area:right-arrow;background-color:rgba(var(--text-color), 0.1);border-radius:1rem;padding:.1rem;margin-left:.3rem}.quantity-selector .button{flex:1;padding:.5rem .6rem;margin-left:.5rem}#quantity_selector_tip::first-letter{text-transform:uppercase}#quantity_type,#portfolio_quantity_type{font-size:.8rem;padding-right:.5rem;border-right:thin solid rgba(var(--text-color), 0.3);margin-right:auto;color:rgba(var(--text-color), 0.8);line-height:1.5;font-weight:500;min-width:8ch}#exchange_wrapper{display:flex;flex-direction:column;height:100%}#asset_page{position:relative;display:flex;flex-direction:column;height:100%;align-items:flex-start}#asset_page_wrapper{display:flex;flex-direction:column;height:100%;width:100%}#trade_form{height:100%}#trade_form::part(form){display:flex;flex-direction:column;gap:0}#trade_form>*{margin-bottom:1rem}#trade_form>:last-child{margin-top:auto}#my_orders,#market{width:min(46rem,100%);height:-webkit-max-content;height:-moz-max-content;height:max-content}#my_orders{grid-template-rows:auto 1fr}.orders_section__header{min-height:2.8rem;position:-webkit-sticky;position:sticky;top:0;background-color:rgba(var(--background-color), 1);z-index:2;transition:background-color .3s}.list__item{padding:.5rem 0;display:grid}.order-card{position:relative;outline:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;align-items:center;gap:.5rem;grid-template-columns:-webkit-min-content 1fr auto;grid-template-columns:min-content 1fr auto;border-radius:.5rem;grid-template-areas:"checkbox quantity quantity time" "checkbox price amount cancel"}.order-card>.grid:nth-of-type(2){grid-area:price}.order-card>.grid:nth-of-type(3){grid-area:amount}.order-card__type{font-size:.9rem;font-weight:500;margin-bottom:.3rem}.order-card[data-type=buy] .order-card__type{color:var(--green)}.order-card[data-type=sell] .order-card__type{color:var(--danger-color)}.order-card--selected{background-color:rgba(var(--text-color), 0.08)}.order-card--selected .cancel-order{visibility:hidden;pointer-events:none}.order-card sm-checkbox{grid-area:checkbox;cursor:pointer;margin-right:.5rem}.order-card__quantity,.order-card__price{font-size:.9rem;color:rgba(var(--text-color), 0.9)}.order-card__time{grid-area:time;font-size:.8rem;color:rgba(var(--text-color), 0.8)}.order-card .cancel-order{grid-area:cancel;color:var(--danger-color)}.order-card .cancel-order .icon{fill:var(--danger-color)}.cancel-order{align-items:center;padding:.4rem .6rem}.cancel-order span{margin-left:.3rem}.completed-trade,.transaction-card,.live-order{gap:0 1rem}.completed-trade__type,.transaction-card__type,.live-order__type{font-size:.9rem;font-weight:500;margin-bottom:.3rem}.completed-trade[data-type=Bought] .completed-trade__type,.completed-trade--buy .completed-trade__type,.completed-trade[data-type=Bought] .transaction-card__type,.completed-trade--buy .transaction-card__type,.completed-trade[data-type=Bought] .live-order__type,.completed-trade--buy .live-order__type,.transaction-card[data-type=Bought] .completed-trade__type,.transaction-card--buy .completed-trade__type,.transaction-card[data-type=Bought] .transaction-card__type,.transaction-card--buy .transaction-card__type,.transaction-card[data-type=Bought] .live-order__type,.transaction-card--buy .live-order__type,.live-order[data-type=Bought] .completed-trade__type,.live-order--buy .completed-trade__type,.live-order[data-type=Bought] .transaction-card__type,.live-order--buy .transaction-card__type,.live-order[data-type=Bought] .live-order__type,.live-order--buy .live-order__type{color:var(--green)}.completed-trade[data-type=Sold] .completed-trade__type,.completed-trade--sell .completed-trade__type,.completed-trade[data-type=Sold] .transaction-card__type,.completed-trade--sell .transaction-card__type,.completed-trade[data-type=Sold] .live-order__type,.completed-trade--sell .live-order__type,.transaction-card[data-type=Sold] .completed-trade__type,.transaction-card--sell .completed-trade__type,.transaction-card[data-type=Sold] .transaction-card__type,.transaction-card--sell .transaction-card__type,.transaction-card[data-type=Sold] .live-order__type,.transaction-card--sell .live-order__type,.live-order[data-type=Sold] .completed-trade__type,.live-order--sell .completed-trade__type,.live-order[data-type=Sold] .transaction-card__type,.live-order--sell .transaction-card__type,.live-order[data-type=Sold] .live-order__type,.live-order--sell .live-order__type{color:var(--danger-color)}.completed-trade__total,.transaction-card__total,.live-order__total{font-weight:700;font-size:.9rem;color:rgba(var(--text-color), 0.8)}.completed-trade__quantity,.completed-trade__price,.transaction-card__quantity,.transaction-card__price,.live-order__quantity,.live-order__price{font-size:.9rem;color:rgba(var(--text-color), 0.9)}.completed-trade__time,.transaction-card__time,.live-order__time{font-size:.8rem;color:rgba(var(--text-color), 0.8)}.completed-trade .more-info,.transaction-card .more-info,.live-order .more-info{flex-shrink:0;padding:.3rem}.transaction-card{content-visibility:auto;contain-intrinsic-size:2.5rem;grid-template-columns:repeat(3, 1fr) 2rem}.completed-trade{display:grid;gap:.5rem;grid-template-columns:1fr 1fr;background-color:rgba(var(--text-color), 0.03);border-radius:.5rem;padding:1rem;margin-bottom:.5rem}#market_asset_rates{display:grid;gap:.5rem}#market_asset_rates .listed-asset{padding:1rem;background-color:rgba(var(--text-color), 0.03)}#market_orders_wrapper .list__header{font-size:.8rem;font-weight:500}#market_orders_wrapper .list__header div{padding:.5rem 0}#market_orders_wrapper .list__header{margin-bottom:.5rem;grid-template-columns:repeat(3, 1fr) 2rem}.live-order{display:grid;gap:1rem;padding:1rem;border-radius:.5rem;background-color:rgba(var(--text-color), 0.03)}.live-order:not(:last-of-type){margin-bottom:.5rem}.live-order[data-type=buy]{background-color:rgba(0,250,154,.062745098)}.live-order[data-type=sell]{background-color:rgba(226,19,81,.062745098)}#portfolio{display:grid;gap:1.5rem;grid-template-columns:minmax(0, 1fr);align-content:flex-start;width:min(32rem,100%)}.label{font-size:.8rem;color:rgba(var(--text-color), 0.8);margin-bottom:.2rem}#my_assets{gap:.5rem;margin-top:.5rem;padding-bottom:1.5rem;border:none}.balance-card{display:grid;align-items:center;gap:0 .5rem;padding:1rem;padding-left:.6rem;border-radius:.3rem;color:inherit;background-color:rgba(var(--text-color), 0.03)}.balance-card.is-locked{grid-template-columns:auto 1fr auto}.balance-card.is-locked .balance-card__icon{grid-row:span 2}.balance-card.is-locked .balance-card__right-arrow{grid-area:1/3/3/4}.balance-card.is-locked .balance-card__amount-wrapper{grid-area:2/2/3/3}.balance-card:not(.is-locked){grid-template-columns:auto 1fr auto auto}.balance-card:not(.is-locked) .balance-card__right-arrow{grid-area:1/4/2/5}.balance-card__icon{display:flex;align-content:center;justify-content:center;margin:0 .5rem;border-radius:.8rem;align-self:flex-start;background-color:var(--accent-color--light)}.balance-card__icon .icon{height:1.3rem;width:1.3rem;fill:var(--accent-color)}.balance-card__token{font-size:.9rem;font-weight:500}.balance-card__amount-wrapper{margin-top:.5rem;grid-column:3/-1;gap:.3rem 1rem;grid-template-columns:1fr 1fr}.balance-card__amount-wrapper>:nth-child(even){text-align:right}.balance-card__right-arrow{background-color:rgba(var(--text-color), 0.1);border-radius:1rem;padding:.1rem;fill:var(--accent-color)}#history{padding-top:0 !important;width:min(36rem,100%)}#history .sticky{margin-left:-0.7rem;padding:1rem 0;background-color:rgba(var(--background-color), 1)}#exchange_history{margin-top:.5rem}.history-entry{display:grid;grid-template-columns:auto 1fr auto;gap:.5rem 1rem;align-items:center;margin-bottom:2rem}.history-entry[data-status=SUCCESS] .history-entry__status .icon{fill:var(--green)}.history-entry[data-status=PENDING] .history-entry__status .icon,.history-entry[data-status=WAITING_CONFIRMATION] .history-entry__status .icon{fill:var(--yellow)}.history-entry__status{display:flex;align-items:center;justify-content:center;grid-row:1/3;width:2.5rem;height:2.5rem;background-color:rgba(var(--text-color), 0.03);border-radius:2rem}.history-entry__token-action{font-weight:500}.history-entry__amount{font-weight:500;text-align:right}.history-entry[data-type=deposit] .history-entry__amount:not(:empty){color:var(--green)}.history-entry[data-type=deposit] .history-entry__amount:not(:empty)::before{content:"+ "}.history-entry[data-type=withdraw] .history-entry__amount:not(:empty)::before{content:"- "}.history-entry__time{font-size:.8rem;color:rgba(var(--text-color), 0.8)}.history-entry__txid{font-weight:500;font-size:.9rem;text-align:right}#portfolio_asset_page .sticky{margin-top:-1.5rem;margin-left:-0.7rem;padding:1rem 0;background-color:rgba(var(--background-color), 1)}#portfolio_asset__history{margin-top:1rem}#portfolio_cards_wrapper{display:grid;gap:.5rem;grid-template-columns:repeat(auto-fit, minmax(12rem, 1fr))}.personal-asset-balance{align-content:flex-start;padding:1rem;border-radius:.5rem;color:rgba(0,0,0,.8);width:100%}.personal-asset-balance:not(:last-of-type){margin-right:.5rem}.personal-asset-balance:nth-of-type(1){background:url("bg-art2.svg") no-repeat bottom right,#c2ffd7;background-size:contain}.personal-asset-balance:nth-of-type(1) .icon{background-color:rgba(102,255,156,.5)}.personal-asset-balance:nth-of-type(1) .button{border:solid thin rgba(102,255,156,.5)}.personal-asset-balance:nth-of-type(2){background:url("back.svg") no-repeat top right,#fcffa8;background-size:contain}.personal-asset-balance:nth-of-type(2) .icon{background-color:rgba(255,234,0,.5)}.personal-asset-balance>.flex{margin-bottom:.3rem}.personal-asset-balance>.flex .icon{height:2rem;width:2rem;padding:.4rem;border-radius:.3rem;fill:rgba(0,0,0,.8);margin-right:.5rem}.personal-asset-balance .button{display:flex;align-items:center;margin-top:.5rem;padding-right:.8rem;justify-self:flex-start;border-radius:1rem;background-color:rgba(var(--foreground-color), 1);color:rgba(var(--text-color), 1);transition:box-shadow .3s}.personal-asset-balance .button .icon{height:1rem;background-color:rgba(0,0,0,0);margin-right:.3rem}.personal-asset-balance .button:hover{box-shadow:0 .3rem .5rem rgba(0,0,0,.16)}#personal_rupee_balance span:first-of-type,#personal_flo_balance span:first-of-type{font-size:1.5rem}#personal_rupee_balance span:last-of-type,#personal_flo_balance span:last-of-type{font-size:.9rem}#portfolio_result{justify-content:center;text-align:center}#portfolio_result__icon{display:flex;padding:1rem;border-radius:50%;background-color:rgba(var(--text-color), 0.06);justify-self:center;-webkit-animation:pop-up .3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);animation:pop-up .3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275)}#portfolio_result__icon .icon{height:2rem;width:2rem}.icon--success{fill:var(--green)}.icon--failure,.icon--error{fill:var(--danger-color)}@-webkit-keyframes pop-up{from{transform:translateY(3rem) scale(0.5);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}@keyframes pop-up{from{transform:translateY(3rem) scale(0.5);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}#portfolio_result__cta{padding:1.5rem 1rem;border-radius:.5rem;background-color:rgba(var(--text-color), 0.06)}.stateful-button-wrapper{display:flex;position:relative;justify-content:center;align-items:center}.stateful-button-wrapper sm-button,.stateful-button-wrapper slide-button{width:100%;z-index:1;transition:-webkit-clip-path .3s;transition:clip-path .3s;transition:clip-path .3s, -webkit-clip-path .3s;-webkit-clip-path:circle(100%);clip-path:circle(100%)}.stateful-button-wrapper sm-button.clip,.stateful-button-wrapper slide-button.clip{pointer-events:none;-webkit-clip-path:circle(0);clip-path:circle(0)}.stateful-button-wrapper sm-spinner{position:absolute}.stateful-result{overflow:hidden;position:absolute;display:flex;justify-content:center;align-items:center;height:100%;width:100%;left:0}.stateful-result>*{position:absolute}.stateful-result--success .result__background{background-color:var(--green)}.stateful-result--failure .result__background{background-color:var(--danger-color)}.stateful-result .icon-wrapper{-webkit-animation:pop .4s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);animation:pop .4s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275)}.stateful-result .icon{height:1.5rem;width:1.5rem;fill:rgba(var(--background-color), 1)}.stateful-result span{font-weight:500;color:rgba(var(--background-color), 1)}.stateful-result .result__background{-webkit-animation:ripple-reveal 1s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);animation:ripple-reveal 1s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275)}.result__background{border-radius:.3rem;height:100%;width:100%;-webkit-clip-path:circle(10%);clip-path:circle(10%)}@-webkit-keyframes pop{from{opacity:0;transform:translateY(2rem)}to{opacity:1;transform:translateY(0)}}@keyframes pop{from{opacity:0;transform:translateY(2rem)}to{opacity:1;transform:translateY(0)}}@-webkit-keyframes ripple-reveal{to{-webkit-clip-path:circle(100%);clip-path:circle(100%)}}@keyframes ripple-reveal{to{-webkit-clip-path:circle(100%);clip-path:circle(100%)}}#help{width:min(60ch,100%);margin-bottom:3rem;align-content:flex-start}#help ul{list-style:initial;display:grid;gap:1rem}#help ul li{margin-left:1rem;padding-left:.5rem;font-size:.9rem}@media screen and (max-width: 40rem)and (any-hover: none){.cancel-order span{display:none !important}}@media screen and (max-width: 40rem){sm-button{--padding: 0.9rem 1.6rem}.empty-state{align-self:center}#user_popup_button{width:100%}.main_navbar__item--active .item__title{transform:translateY(100%);opacity:0}.main_navbar__item--active .icon{transform:translateY(50%) scale(1.2)}#asset_list_wrapper{padding:0 1.5rem}.listed-asset{border-radius:0;border-bottom:solid thin rgba(var(--text-color), 0.1)}#exchange{margin:0;padding:0}#login_form{padding:0 1.5rem}#asset_page__header{display:flex;padding:1rem 1.5rem .5rem .8rem}#chart_header{padding:0 1.5rem .5rem 1.5rem}#trade_form{padding:0 1.5rem}#price_chart_container{flex:1}#asset_page__footer button{display:flex;flex-direction:column;align-items:center;flex:1;padding:.5rem 0;color:rgba(var(--text-color), 0.8);font-size:.8rem;font-weight:500}#asset_page__footer button .icon{height:1.2rem;margin-bottom:.3rem;margin-right:.3rem}#asset_page__footer button.active{color:var(--accent-color)}#asset_page__footer button.active .icon{fill:var(--accent-color)}.hide-on-mobile{display:none !important}}@media screen and (min-width: 40rem){sm-popup{--width: 24rem}.popup__header{grid-column:1/-1;padding:1rem 1.5rem 0 1.5rem}#confirmation_popup{--width: 24rem}.page-layout{grid-template-columns:1fr 90vw 1fr}.mobile-page{align-self:flex-start;padding:2rem;border-radius:.5rem;background-color:rgba(var(--foreground-color), 1)}.hide-on-desktop{display:none !important}#home{display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto 1fr;grid-template-areas:"header header" "nav pages"}#main_header{grid-area:header}#user_popup_button{justify-self:flex-end}#main_navbar{grid-area:nav;flex-direction:column;height:100%;padding-left:.5rem}.main_navbar__item{padding:1.5rem 2rem 1.5rem 1rem;width:100%;flex:0;flex-direction:row;border-radius:.5rem;transition:background-color .3s}.main_navbar__item .icon{margin-bottom:0;margin-right:.5rem}.main_navbar__item .item__title{font-size:.9rem}.main_navbar__item--active{background-color:rgba(var(--text-color), 0.06)}#pages_container{grid-area:pages}#pages_container>*{margin:0 1.5rem;padding:2rem}.is-signed-in #exchange{display:flex;width:100%}.is-signed-in #exchange_wrapper{display:grid;width:100%;height:100%;gap:1.5rem;grid-template-columns:17rem minmax(0, 1fr);align-items:flex-start}#price_history_chart{height:20rem}#asset_list_wrapper{grid-row:1/3}.listed-asset{padding:1rem}.listed-asset--active{opacity:1;background-color:rgba(var(--text-color), 0.06)}.listed-asset--active::before{content:"";position:absolute;width:.25rem;border-radius:0 .2rem .2rem 0;height:2rem;background-color:var(--accent-color)}.order-card{grid-template-columns:auto 1fr 1fr 1fr auto;grid-template-areas:"checkbox quantity price amount time cancel"}.orders_section__header{background-color:rgba(var(--foreground-color), 1)}#history .sticky,#portfolio_asset_page .sticky{background-color:rgba(var(--foreground-color), 1)}}@media screen and (max-width: 80rem)and (min-width: 40rem){.main_navbar__item{padding:1.5rem 1rem}.main_navbar__item .icon{margin-right:0}.main_navbar__item .item__title{display:none !important}}@media screen and (min-width: 52rem){body:not(.is-signed-in) #market{gap:2rem;width:100%;grid-template-columns:18rem 1fr}.completed-trade{grid-template-columns:1fr 1fr 1fr 8rem;grid-template-areas:"quantity price amount info"}.completed-trade .quantity-block{grid-area:quantity}.completed-trade .price-block{grid-area:price}.completed-trade .amount-block{grid-area:amount}.completed-trade .info-block{grid-area:info}}@media screen and (min-width: 64rem){#home{grid-template-columns:auto 1fr}#asset_page_wrapper{display:grid;gap:1.5rem;grid-template-columns:minmax(0, 1fr) 20rem}}@media screen and (min-width: 72rem){.page-layout{grid-template-columns:1fr 80vw 1fr}}@media screen and (min-width: 120rem){.page-layout{grid-template-columns:1fr 70vw 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)}.order-card .cancel-order{justify-self:flex-end;overflow:hidden}.order-card .cancel-order .icon,.order-card .cancel-order span{transition:opacity .3s,transform .3s}.order-card .cancel-order .icon{transform:translateX(100%)}.order-card .cancel-order span{transform:translateX(100%);opacity:0}.order-card:hover .cancel-order .icon,.order-card:focus-within .cancel-order .icon{opacity:1}.order-card .cancel-order:hover .icon,.order-card .cancel-order:hover span{opacity:1;transform:translateX(0)}} \ No newline at end of file diff --git a/docs/css/main.scss b/docs/css/main.scss index 3145908..8e7a6be 100644 --- a/docs/css/main.scss +++ b/docs/css/main.scss @@ -71,19 +71,8 @@ a { box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset; } } -a.button { - display: flex; - align-items: center; - padding: 0.4rem 0.6rem; - border-radius: 0.3rem; - font-size: 0.9rem; - font-weight: 500; - color: var(--accent-color); -} -fieldset { - border: none; -} -button { +button, +.button { user-select: none; position: relative; display: inline-flex; @@ -93,39 +82,65 @@ button { color: inherit; -webkit-tap-highlight-color: transparent; align-items: center; - font-size: 0.9rem; + font-size: inherit; font-weight: 500; white-space: nowrap; padding: 0.8rem; border-radius: 0.3rem; justify-content: center; + flex-shrink: 0; &:focus-visible { outline: var(--accent-color) solid medium; } + &:not(:disabled) { cursor: pointer; } } + .button { - color: var(--accent-color); - background-color: rgba(var(--text-color), 0.06); - &--primary, - &--danger { - color: rgba(var(--background-color), 1) !important; + background-color: rgba(var(--text-color), 0.02); + border: solid thin rgba(var(--text-color), 0.06); + &--primary { + color: rgba(var(--background-color), 1); + background-color: var(--accent-color); + .icon { fill: rgba(var(--background-color), 1); } } - &--primary { - background-color: var(--accent-color); + &--colored { + color: var(--accent-color); + .icon { + fill: var(--accent-color); + } } &--danger { - background-color: var(--danger-color); + background-color: #ff737310; + color: var(--danger-color); + .icon { + fill: var(--danger-color); + } } + &--small { padding: 0.4rem 0.6rem; } + + &--outlined { + border: solid rgba(var(--text-color), 0.3) 0.1rem; + background-color: rgba(var(--foreground-color), 1); + } + &--transparent { + background-color: transparent; + } } +button:disabled { + opacity: 0.4; + cursor: not-allowed; + filter: saturate(0); +} + .cta { text-transform: uppercase; font-size: 0.8rem; @@ -471,29 +486,31 @@ details { } } } -strip-select { +sm-chips { --gap: 0; background-color: rgba(var(--text-color), 0.06); border-radius: 0.2rem; } -strip-option { - font-weight: 500; + +sm-chip { + position: relative; font-size: 0.9rem; + --border-radius: 0.5rem; + --padding: 0.5rem 0.8rem; + --background: rgba(var(--text-color), 0.06); user-select: none; - --border-radius: 0; - --active-option-color: rgba(var(--background-color), 1); - --active-option-background-color: var(--accent-color); + font-weight: 500; + &[selected] { + --background: var(--accent-color); + color: rgba(var(--background-color), 1); + } &:first-of-type { - --border-radius: 0.2rem 0 0 0.2rem; + --border-radius: 0.3rem 0 0 0.3rem; } &:last-of-type { - --border-radius: 0 0.2rem 0.2rem 0; + --border-radius: 0 0.3rem 0.3rem 0; } } -sm-select, -sm-option { - font-size: 0.9rem; -} sm-checkbox { --height: 1rem; --width: 1rem; diff --git a/docs/index.html b/docs/index.html index 3720cdc..5e4db2f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -37,9 +37,9 @@

-
- Cancel - OK +
+ +
@@ -47,9 +47,9 @@

-
- Cancel - OK +
+ +
@@ -60,7 +60,7 @@

RanchiMall Exchange

Getting everything ready

- Reset +
@@ -102,13 +102,13 @@
- Log in +

Don't have FLO credentials?

- Generate FLO credentials +
- Reset +
@@ -135,11 +135,11 @@

- - Hour - - Day - + + Hour + + Day +
@@ -148,10 +148,10 @@

Trade FLO

- - Buy - Sell - + + Buy + Sell +
- BUY FLO - +
@@ -235,10 +235,10 @@

My orders

- - Live - Trades - + + Live + Trades +
- - Live - Trades - + + Live + Trades +
@@ -331,10 +331,10 @@
- - Exchange - On-chain - + + Exchange + On-chain +
@@ -772,9 +772,9 @@ private key.

- Add password + - Log out +
@@ -837,7 +837,7 @@ error-text="Invalid private key" data-private-key="" animate>
- +
@@ -1103,25 +1103,16 @@ const relativeTime = new RelativeTime('en', { style: 'short' }); //Checks for internet connection status - if (!navigator.onLine) { - notify( - "There seems to be a problem connecting to the internet. Please check your internet connection.", - "error", - { pinned: true } - ); - } - window.addEventListener("offline", () => { - notify( - "There seems to be a problem connecting to the internet. Please check your internet connection.", - "error", - { pinned: true } - ); + if (!navigator.onLine) + floGlobals.connectionErrorNotification = notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error') + window.addEventListener('offline', () => { + floGlobals.connectionErrorNotification = notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error') + }) + window.addEventListener('online', () => { + getRef('notification_drawer').remove(floGlobals.connectionErrorNotification) + notify('We are back online.', 'success') location.reload() - }); - window.addEventListener("online", () => { - getRef("notification_drawer").clearAll(); - notify("We are back online.", "success"); - }); + }) // Use instead of document.getElementById function getRef(elementId) { @@ -1187,72 +1178,82 @@ return Array.from(document.querySelectorAll(selector)); } - let zIndex = 10 + let zIndex = 50 // function required for popups or modals to appear function openPopup(popupId, pinned) { zIndex++ getRef(popupId).setAttribute('style', `z-index: ${zIndex}`) - getRef(popupId).show({ pinned }) - return getRef(popupId); + return getRef(popupId).show({ pinned }) } // hides the popup or modal - function closePopup() { + function closePopup(options = {}) { if (popupStack.peek() === undefined) return; - popupStack.peek().popup.hide() + popupStack.peek().popup.hide(options) } // displays a popup for asking permission. Use this instead of JS confirm const getConfirmation = (title, options = {}) => { return new Promise(resolve => { - const { message, cancelText = 'Cancel', confirmText = 'OK' } = options - openPopup('confirmation_popup', true) - getRef('confirm_title').textContent = title; - getRef('confirm_message').textContent = message; - let cancelButton = getRef('confirmation_popup').children[2].children[0], - submitButton = getRef('confirmation_popup').children[2].children[1] - submitButton.textContent = confirmText + const { message = '', cancelText = 'Cancel', confirmText = 'OK', danger = false } = options + getRef('confirm_title').innerText = title; + getRef('confirm_message').innerText = message; + const cancelButton = getRef('confirmation_popup').querySelector('.cancel-button'); + const confirmButton = getRef('confirmation_popup').querySelector('.confirm-button') + confirmButton.textContent = confirmText cancelButton.textContent = cancelText - submitButton.onclick = () => { - closePopup() - resolve(true); + if (danger) + confirmButton.classList.add('button--danger') + else + confirmButton.classList.remove('button--danger') + const { opened, closed } = openPopup('confirmation_popup') + confirmButton.onclick = () => { + closePopup({ payload: true }) } cancelButton.onclick = () => { closePopup() - resolve(false); } + closed.then((payload) => { + confirmButton.onclick = null + cancelButton.onclick = null + if (payload) + resolve(true) + else + resolve(false) + }) }) } - // displays a popup for asking user input. Use this instead of JS prompt function getPromptInput(title, message = '', options = {}) { - const { isPassword = true, cancelText = 'Cancel', confirmText = 'OK' } = options - openPopup('prompt_popup', true) - getRef('prompt_title').textContent = title; - getRef('prompt_message').textContent = message; - let buttons = getRef('prompt_popup').querySelectorAll("sm-button"); - if (isPassword) + let { placeholder = '', isPassword = false, cancelText = 'Cancel', confirmText = 'OK' } = options + getRef('prompt_title').innerText = title; + getRef('prompt_message').innerText = message; + const cancelButton = getRef('prompt_popup').querySelector('.cancel-button'); + const confirmButton = getRef('prompt_popup').querySelector('.confirm-button') + if (isPassword) { + placeholder = 'Password' getRef('prompt_input').setAttribute("type", "password") + } + getRef('prompt_input').setAttribute("placeholder", placeholder) getRef('prompt_input').focusIn() - buttons[0].textContent = cancelText; - buttons[1].textContent = confirmText; + cancelButton.textContent = cancelText; + confirmButton.textContent = confirmText; + openPopup('prompt_popup', true) return new Promise((resolve, reject) => { - buttons[0].onclick = () => { + cancelButton.addEventListener('click', () => { closePopup() - return (null); - } - buttons[1].onclick = () => { - const value = getRef('prompt_input').value; + return null + }, { once: true }) + confirmButton.addEventListener('click', () => { closePopup() - resolve(value) - } + resolve(getRef('prompt_input').value) + }, { once: true }) }) } //Function for displaying toast notifications. pass in error for mode param if you want to show an error. function notify(message, mode, options = {}) { - const { pinned = false, sound = false } = options let icon switch (mode) { case 'success': @@ -1260,14 +1261,14 @@ break; case 'error': icon = `` + options.pinned = true break; } - getRef("notification_drawer").push(message, { pinned, icon }); if (mode === 'error') { console.error(message) } + return getRef("notification_drawer").push(message, { icon, ...options }); } - function getFormattedTime(time, format) { try { let [day, month, date, year] = new Date(time).toString().split(' '), @@ -1312,8 +1313,8 @@ notify('copied', 'success') }) document.addEventListener("pointerdown", (e) => { - if (e.target.closest("button:not([disabled]), sm-button:not([disabled]), .interact")) { - createRipple(e, e.target.closest("button, sm-button, .interact")); + if (e.target.closest("button:not([disabled]), .interact")) { + createRipple(e, e.target.closest("button, .interact")); } }); document.querySelectorAll('.popup__header__close, .close-popup-on-click').forEach(elem => { diff --git a/docs/scripts/components.js b/docs/scripts/components.js index 38f50d2..41e0714 100644 --- a/docs/scripts/components.js +++ b/docs/scripts/components.js @@ -1,2233 +1,14 @@ /*jshint esversion: 6 */ -const smButton = document.createElement('template') -smButton.innerHTML = ` - -
- -
`; -customElements.define('sm-button', - class extends HTMLElement { - constructor() { - super(); - this.attachShadow({ - mode: 'open' - }).append(smButton.content.cloneNode(true)); - } - static get observedAttributes() { - return ['disabled']; - } - - get disabled() { - return this.hasAttribute('disabled'); - } - - set disabled(value) { - if (value) { - this.setAttribute('disabled', ''); - } else { - this.removeAttribute('disabled'); - } - } - focusIn() { - this.focus(); - } - - handleKeyDown(e) { - if (!this.hasAttribute('disabled') && (e.key === 'Enter' || e.key === ' ')) { - e.preventDefault(); - this.click(); - } - } - - connectedCallback() { - if (!this.hasAttribute('disabled')) { - this.setAttribute('tabindex', '0'); - } - this.setAttribute('role', 'button'); - this.addEventListener('keydown', this.handleKeyDown); - } - attributeChangedCallback(name) { - if (name === 'disabled') { - if (this.hasAttribute('disabled')) { - this.removeAttribute('tabindex'); - } else { - this.setAttribute('tabindex', '0'); - } - this.setAttribute('aria-disabled', this.hasAttribute('disabled')); - } - } - }) -const smForm = document.createElement('template'); -smForm.innerHTML = ` - -
- -
- `; - -customElements.define('sm-form', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smForm.content.cloneNode(true)) - - this.form = this.shadowRoot.querySelector('form'); - this.formElements - this.requiredElements - this.submitButton - this.resetButton - this.allRequiredValid = false; - - this.debounce = this.debounce.bind(this) - this._checkValidity = this._checkValidity.bind(this) - this.handleKeydown = this.handleKeydown.bind(this) - this.reset = this.reset.bind(this) - this.elementsChanged = this.elementsChanged.bind(this) - } - debounce(callback, wait) { - let timeoutId = null; - return (...args) => { - window.clearTimeout(timeoutId); - timeoutId = window.setTimeout(() => { - callback.apply(null, args); - }, wait); - }; - } - _checkValidity() { - this.allRequiredValid = this.requiredElements.every(elem => elem.isValid) - if (!this.submitButton) return; - if (this.allRequiredValid) { - this.submitButton.disabled = false; - } - else { - this.submitButton.disabled = true; - } - } - handleKeydown(e) { - if (e.key === 'Enter' && !e.target.tagName.includes('TEXTAREA')) { - if (this.allRequiredValid) { - if (this.submitButton) { - this.submitButton.click() - } - this.dispatchEvent(new CustomEvent('submit', { - bubbles: true, - composed: true, - })) - } - else { - this.requiredElements.find(elem => !elem.isValid).vibrate() - } - } - } - reset() { - this.formElements.forEach(elem => elem.reset()) - } - elementsChanged() { - this.formElements = [...this.querySelectorAll('sm-input, sm-textarea, sm-checkbox, tags-input, file-input, sm-switch, sm-radio')] - this.requiredElements = this.formElements.filter(elem => elem.hasAttribute('required')); - this.submitButton = this.querySelector('[variant="primary"], [type="submit"]'); - this.resetButton = this.querySelector('[type="reset"]'); - if (this.resetButton) { - this.resetButton.addEventListener('click', this.reset); - } - this._checkValidity() - } - connectedCallback() { - const slot = this.shadowRoot.querySelector('slot') - slot.addEventListener('slotchange', this.elementsChanged) - this.addEventListener('input', this.debounce(this._checkValidity, 100)); - this.addEventListener('keydown', this.debounce(this.handleKeydown, 100)); - } - disconnectedCallback() { - this.removeEventListener('input', this.debounce(this._checkValidity, 100)); - this.removeEventListener('keydown', this.debounce(this.handleKeydown, 100)); - } -}) - -const smInput = document.createElement('template') -smInput.innerHTML = ` - -
- - -
- `; -customElements.define('sm-input', - class extends HTMLElement { - - constructor() { - super(); - this.attachShadow({ - mode: 'open' - }).append(smInput.content.cloneNode(true)); - - this.inputParent = this.shadowRoot.querySelector('.input'); - this.input = this.shadowRoot.querySelector('input'); - this.clearBtn = this.shadowRoot.querySelector('.clear'); - this.label = this.shadowRoot.querySelector('.label'); - this.feedbackText = this.shadowRoot.querySelector('.feedback-text'); - this.outerContainer = this.shadowRoot.querySelector('.outer-container'); - this._helperText = ''; - this._errorText = ''; - this.isRequired = false; - this.validationFunction = undefined; - this.reflectedAttributes = ['value', 'required', 'disabled', 'type', 'inputmode', 'readonly', 'min', 'max', 'pattern', 'minlength', 'maxlength', 'step']; - - this.reset = this.reset.bind(this); - this.clear = this.clear.bind(this); - this.focusIn = this.focusIn.bind(this); - this.focusOut = this.focusOut.bind(this); - this.fireEvent = this.fireEvent.bind(this); - this.checkInput = this.checkInput.bind(this); - this.vibrate = this.vibrate.bind(this); - } - - static get observedAttributes() { - return ['value', 'placeholder', 'required', 'disabled', 'type', 'inputmode', 'readonly', 'min', 'max', 'pattern', 'minlength', 'maxlength', 'step', 'helper-text', 'error-text', 'hiderequired']; - } - - get value() { - return this.input.value; - } - - set value(val) { - this.input.value = val; - this.checkInput(); - this.fireEvent(); - } - - get placeholder() { - return this.getAttribute('placeholder'); - } - - set placeholder(val) { - this.setAttribute('placeholder', val); - } - - get type() { - return this.getAttribute('type'); - } - - set type(val) { - this.setAttribute('type', val); - } - - get validity() { - return this.input.validity; - } - - get disabled() { - return this.hasAttribute('disabled'); - } - set disabled(value) { - if (value) - this.inputParent.classList.add('disabled'); - else - this.inputParent.classList.remove('disabled'); - } - get readOnly() { - return this.hasAttribute('readonly'); - } - set readOnly(value) { - if (value) { - this.setAttribute('readonly', ''); - } else { - this.removeAttribute('readonly'); - } - } - set customValidation(val) { - this.validationFunction = val; - } - set errorText(val) { - this._errorText = val; - } - set helperText(val) { - this._helperText = val; - } - get isValid() { - if (this.input.value !== '') { - const _isValid = this.input.checkValidity(); - let _customValid = true; - if (this.validationFunction) { - _customValid = Boolean(this.validationFunction(this.input.value)); - } - if (_isValid && _customValid) { - this.feedbackText.classList.remove('error'); - this.feedbackText.classList.add('success'); - this.feedbackText.textContent = ''; - } else { - if (this._errorText) { - this.feedbackText.classList.add('error'); - this.feedbackText.classList.remove('success'); - this.feedbackText.innerHTML = ` - - ${this._errorText} - `; - } - } - return (_isValid && _customValid); - } - } - reset() { - this.value = ''; - } - clear() { - this.value = ''; - this.input.focus(); - } - - focusIn() { - this.input.focus(); - } - - focusOut() { - this.input.blur(); - } - - fireEvent() { - let event = new Event('input', { - bubbles: true, - cancelable: true, - composed: true - }); - this.dispatchEvent(event); - } - - checkInput(e) { - if (!this.hasAttribute('readonly')) { - if (this.input.value.trim() !== '') { - this.clearBtn.classList.remove('hide'); - } else { - this.clearBtn.classList.add('hide'); - } - } - if (!this.hasAttribute('placeholder') || this.getAttribute('placeholder').trim() === '') return; - if (this.input.value !== '') { - if (this.animate) - this.inputParent.classList.add('animate-placeholder'); - else - this.label.classList.add('hide'); - } else { - if (this.animate) - this.inputParent.classList.remove('animate-placeholder'); - else - this.label.classList.remove('hide'); - this.feedbackText.textContent = ''; - } - } - vibrate() { - this.outerContainer.animate([ - { transform: 'translateX(-1rem)' }, - { transform: 'translateX(1rem)' }, - { transform: 'translateX(-0.5rem)' }, - { transform: 'translateX(0.5rem)' }, - { transform: 'translateX(0)' }, - ], { - duration: 300, - easing: 'ease' - }); - } - - - connectedCallback() { - this.animate = this.hasAttribute('animate'); - this.setAttribute('role', 'textbox'); - this.input.addEventListener('input', this.checkInput); - this.clearBtn.addEventListener('click', this.clear); - } - - attributeChangedCallback(name, oldValue, newValue) { - if (oldValue !== newValue) { - if (this.reflectedAttributes.includes(name)) { - if (this.hasAttribute(name)) { - this.input.setAttribute(name, this.getAttribute(name) ? this.getAttribute(name) : ''); - } - else { - this.input.removeAttribute(name); - } - } - if (name === 'placeholder') { - this.label.textContent = newValue; - this.setAttribute('aria-label', newValue); - } - else if (this.hasAttribute('value')) { - this.checkInput(); - } - else if (name === 'type') { - if (this.hasAttribute('type') && this.getAttribute('type') === 'number') { - this.input.setAttribute('inputmode', 'decimal'); - } - } - else if (name === 'helper-text') { - this._helperText = this.getAttribute('helper-text'); - } - else if (name === 'error-text') { - this._errorText = this.getAttribute('error-text'); - } - else if (name === 'required') { - this.isRequired = this.hasAttribute('required'); - if (this.isRequired) { - this.setAttribute('aria-required', 'true'); - } - else { - this.setAttribute('aria-required', 'false'); - } - } - else if (name === 'readonly') { - if (this.hasAttribute('readonly')) { - this.inputParent.classList.add('readonly'); - } else { - this.inputParent.classList.remove('readonly'); - } - } - else if (name === 'disabled') { - if (this.hasAttribute('disabled')) { - this.inputParent.classList.add('disabled'); - } - else { - this.inputParent.classList.remove('disabled'); - } - } - } - } - disconnectedCallback() { - this.input.removeEventListener('input', this.checkInput); - this.clearBtn.removeEventListener('click', this.clear); - } - }) - -const smNotifications = document.createElement('template') -smNotifications.innerHTML = ` - -
- `; -customElements.define('sm-notifications', class extends HTMLElement { - constructor() { - super(); - this.shadow = this.attachShadow({ - mode: 'open' - }).append(smNotifications.content.cloneNode(true)) - - this.notificationPanel = this.shadowRoot.querySelector('.notification-panel') - this.animationOptions = { - duration: 300, - fill: "forwards", - easing: "cubic-bezier(0.175, 0.885, 0.32, 1.275)" - } - - this.push = this.push.bind(this) - this.createNotification = this.createNotification.bind(this) - this.removeNotification = this.removeNotification.bind(this) - this.clearAll = this.clearAll.bind(this) - this.handlePointerMove = this.handlePointerMove.bind(this) - - - this.startX = 0; - this.currentX = 0; - this.endX = 0; - this.swipeDistance = 0; - this.swipeDirection = ''; - this.swipeThreshold = 0; - this.startTime = 0; - this.swipeTime = 0; - this.swipeTimeThreshold = 200; - this.currentTarget = null; - - this.mediaQuery = window.matchMedia('(min-width: 640px)') - this.handleOrientationChange = this.handleOrientationChange.bind(this) - this.isLandscape = false - } - - randString(length) { - let result = ''; - const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - for (let i = 0; i < length; i++) - result += characters.charAt(Math.floor(Math.random() * characters.length)); - return result; - } - - createNotification(message, options = {}) { - const { pinned = false, icon = '', action } = options; - const notification = document.createElement('output') - notification.id = this.randString(8) - notification.classList.add('notification'); - let composition = ``; - composition += ` -
${icon}
-

${message}

- `; - if (action) { - composition += ` - - ` - } - if (pinned) { - notification.classList.add('pinned'); - composition += ` - - `; - } - notification.innerHTML = composition; - return notification; - } - - push(message, options = {}) { - const notification = this.createNotification(message, options); - if (this.isLandscape) - this.notificationPanel.append(notification); - else - this.notificationPanel.prepend(notification); - this.notificationPanel.animate( - [ - { - transform: `translateY(${this.isLandscape ? '' : '-'}${notification.clientHeight}px)`, - }, - { - transform: `none`, - }, - ], this.animationOptions - ) - notification.animate([ - { - transform: `translateY(-1rem)`, - opacity: '0' - }, - { - transform: `none`, - opacity: '1' - }, - ], this.animationOptions).onfinish = (e) => { - e.target.commitStyles() - e.target.cancel() - } - if (notification.querySelector('.action')) - notification.querySelector('.action').addEventListener('click', options.action.callback) - return notification.id; - } - - removeNotification(notification, direction = 'left') { - const sign = direction === 'left' ? '-' : '+'; - notification.animate([ - { - transform: this.currentX ? `translateX(${this.currentX}px)` : `none`, - opacity: '1' - }, - { - transform: `translateX(calc(${sign}${Math.abs(this.currentX)}px ${sign} 1rem))`, - opacity: '0' - } - ], this.animationOptions).onfinish = () => { - notification.remove(); - }; - } - - clearAll() { - Array.from(this.notificationPanel.children).forEach(child => { - this.removeNotification(child); - }); - } - - handlePointerMove(e) { - this.currentX = e.clientX - this.startX; - this.currentTarget.style.transform = `translateX(${this.currentX}px)`; - } - - handleOrientationChange(e) { - this.isLandscape = e.matches - if (e.matches) { - // landscape - - } else { - // portrait - } - } - connectedCallback() { - - this.handleOrientationChange(this.mediaQuery); - - this.mediaQuery.addEventListener('change', this.handleOrientationChange); - this.notificationPanel.addEventListener('pointerdown', e => { - if (e.target.closest('.notification')) { - this.swipeThreshold = this.clientWidth / 2; - this.currentTarget = e.target.closest('.notification'); - this.currentTarget.setPointerCapture(e.pointerId); - this.startTime = Date.now(); - this.startX = e.clientX; - this.startY = e.clientY; - this.notificationPanel.addEventListener('pointermove', this.handlePointerMove); - } - }); - this.notificationPanel.addEventListener('pointerup', e => { - this.endX = e.clientX; - this.endY = e.clientY; - this.swipeDistance = Math.abs(this.endX - this.startX); - this.swipeTime = Date.now() - this.startTime; - if (this.endX > this.startX) { - this.swipeDirection = 'right'; - } else { - this.swipeDirection = 'left'; - } - if (this.swipeTime < this.swipeTimeThreshold) { - if (this.swipeDistance > 50) - this.removeNotification(this.currentTarget, this.swipeDirection); - } else { - if (this.swipeDistance > this.swipeThreshold) { - this.removeNotification(this.currentTarget, this.swipeDirection); - } else { - this.currentTarget.animate([ - { - transform: `translateX(${this.currentX}px)`, - }, - { - transform: `none`, - }, - ], this.animationOptions).onfinish = (e) => { - e.target.commitStyles() - e.target.cancel() - } - } - } - this.notificationPanel.removeEventListener('pointermove', this.handlePointerMove) - this.notificationPanel.releasePointerCapture(e.pointerId); - this.currentX = 0; - }); - this.notificationPanel.addEventListener('click', e => { - if (e.target.closest('.close')) { - this.removeNotification(e.target.closest('.notification')); - } - }); - - const observer = new MutationObserver(mutationList => { - mutationList.forEach(mutation => { - if (mutation.type === 'childList') { - if (mutation.addedNodes.length && !mutation.addedNodes[0].classList.contains('pinned')) { - setTimeout(() => { - this.removeNotification(mutation.addedNodes[0]); - }, 5000); - } - } - }); - }); - observer.observe(this.notificationPanel, { - childList: true, - }); - } - disconnectedCallback() { - mediaQueryList.removeEventListener('change', handleOrientationChange); - } -}); - -class Stack { - constructor() { - this.items = []; - } - push(element) { - this.items.push(element); - } - pop() { - if (this.items.length == 0) - return "Underflow"; - return this.items.pop(); - } - peek() { - return this.items[this.items.length - 1]; - } -} -const popupStack = new Stack(); - -const smPopup = document.createElement('template'); -smPopup.innerHTML = ` - - -`; -customElements.define('sm-popup', class extends HTMLElement { - constructor() { - super(); - this.attachShadow({ - mode: 'open' - }).append(smPopup.content.cloneNode(true)); - - this.allowClosing = false; - this.isOpen = false; - this.pinned = false; - this.offset = 0; - this.touchStartY = 0; - this.touchEndY = 0; - this.touchStartTime = 0; - this.touchEndTime = 0; - this.touchEndAnimation = undefined; - this.focusable - this.autoFocus - this.mutationObserver - - this.popupContainer = this.shadowRoot.querySelector('.popup-container'); - this.backdrop = this.shadowRoot.querySelector('.background'); - this.dialogBox = this.shadowRoot.querySelector('.popup'); - this.popupBodySlot = this.shadowRoot.querySelector('.popup-body slot'); - this.popupHeader = this.shadowRoot.querySelector('.popup-top'); - - this.resumeScrolling = this.resumeScrolling.bind(this); - this.setStateOpen = this.setStateOpen.bind(this); - this.show = this.show.bind(this); - this.hide = this.hide.bind(this); - this.handleTouchStart = this.handleTouchStart.bind(this); - this.handleTouchMove = this.handleTouchMove.bind(this); - this.handleTouchEnd = this.handleTouchEnd.bind(this); - this.detectFocus = this.detectFocus.bind(this); - } - - static get observedAttributes() { - return ['open']; - } - - get open() { - return this.isOpen; - } - - animateTo(element, keyframes, options) { - const anime = element.animate(keyframes, { ...options, fill: 'both' }) - anime.finished.then(() => { - anime.commitStyles() - anime.cancel() - }) - return anime - } - - resumeScrolling() { - const scrollY = document.body.style.top; - window.scrollTo(0, parseInt(scrollY || '0') * -1); - document.body.style.overflow = ''; - document.body.style.top = 'initial'; - } - - setStateOpen() { - if (!this.isOpen || this.offset) { - const animOptions = { - duration: 300, - easing: 'ease' - } - const initialAnimation = (window.innerWidth > 640) ? 'scale(1.1)' : `translateY(${this.offset ? `${this.offset}px` : '100%'})` - this.animateTo(this.dialogBox, [ - { - opacity: this.offset ? 1 : 0, - transform: initialAnimation - }, - { - opacity: 1, - transform: 'none' - }, - ], animOptions) - - } - } - - show(options = {}) { - const { pinned = false } = options; - if (!this.isOpen) { - const animOptions = { - duration: 300, - easing: 'ease' - } - popupStack.push({ - popup: this, - permission: pinned - }); - if (popupStack.items.length > 1) { - this.animateTo(popupStack.items[popupStack.items.length - 2].popup.shadowRoot.querySelector('.popup'), [ - { transform: 'none' }, - { transform: (window.innerWidth > 640) ? 'scale(0.95)' : 'translateY(-1.5rem)' }, - ], animOptions) - } - this.popupContainer.classList.remove('hide'); - if (!this.offset) - this.backdrop.animate([ - { opacity: 0 }, - { opacity: 1 }, - ], animOptions) - this.setStateOpen() - this.dispatchEvent( - new CustomEvent("popupopened", { - bubbles: true, - detail: { - popup: this, - } - }) - ); - this.pinned = pinned; - this.isOpen = true; - document.body.style.overflow = 'hidden'; - document.body.style.top = `-${window.scrollY}px`; - const elementToFocus = this.autoFocus || this.focusable[0]; - elementToFocus.tagName.includes('SM-') ? elementToFocus.focusIn() : elementToFocus.focus(); - if (!this.hasAttribute('open')) - this.setAttribute('open', ''); - } - } - hide() { - const animOptions = { - duration: 150, - easing: 'ease' - } - this.backdrop.animate([ - { opacity: 1 }, - { opacity: 0 } - ], animOptions) - this.animateTo(this.dialogBox, [ - { - opacity: 1, - transform: (window.innerWidth > 640) ? 'none' : `translateY(${this.offset ? `${this.offset}px` : '0'})` - }, - { - opacity: 0, - transform: (window.innerWidth > 640) ? 'scale(1.1)' : 'translateY(100%)' - }, - ], animOptions).finished - .finally(() => { - this.popupContainer.classList.add('hide'); - this.dialogBox.style = '' - this.removeAttribute('open'); - - if (this.forms.length) { - this.forms.forEach(form => form.reset()); - } - this.dispatchEvent( - new CustomEvent("popupclosed", { - bubbles: true, - detail: { - popup: this, - } - }) - ); - this.isOpen = false; - }) - popupStack.pop(); - if (popupStack.items.length) { - this.animateTo(popupStack.items[popupStack.items.length - 1].popup.shadowRoot.querySelector('.popup'), [ - { transform: (window.innerWidth > 640) ? 'scale(0.95)' : 'translateY(-1.5rem)' }, - { transform: 'none' }, - ], animOptions) - - } else { - this.resumeScrolling(); - } - } - - handleTouchStart(e) { - this.offset = 0 - this.popupHeader.addEventListener('touchmove', this.handleTouchMove, { passive: true }); - this.popupHeader.addEventListener('touchend', this.handleTouchEnd, { passive: true }); - this.touchStartY = e.changedTouches[0].clientY; - this.touchStartTime = e.timeStamp; - } - - handleTouchMove(e) { - if (this.touchStartY < e.changedTouches[0].clientY) { - this.offset = e.changedTouches[0].clientY - this.touchStartY; - this.touchEndAnimation = window.requestAnimationFrame(() => { - this.dialogBox.style.transform = `translateY(${this.offset}px)`; - }); - } - } - - handleTouchEnd(e) { - this.touchEndTime = e.timeStamp; - cancelAnimationFrame(this.touchEndAnimation); - this.touchEndY = e.changedTouches[0].clientY; - this.threshold = this.dialogBox.getBoundingClientRect().height * 0.3; - if (this.touchEndTime - this.touchStartTime > 200) { - if (this.touchEndY - this.touchStartY > this.threshold) { - if (this.pinned) { - this.setStateOpen(); - return; - } else - this.hide(); - } else { - this.setStateOpen(); - } - } else { - if (this.touchEndY > this.touchStartY) - if (this.pinned) { - this.setStateOpen(); - return; - } - else - this.hide(); - } - this.popupHeader.removeEventListener('touchmove', this.handleTouchMove, { passive: true }); - this.popupHeader.removeEventListener('touchend', this.handleTouchEnd, { passive: true }); - } - - - detectFocus(e) { - if (e.key === 'Tab') { - const lastElement = this.focusable[this.focusable.length - 1]; - const firstElement = this.focusable[0]; - if (e.shiftKey && document.activeElement === firstElement) { - e.preventDefault(); - lastElement.tagName.includes('SM-') ? lastElement.focusIn() : lastElement.focus(); - } else if (!e.shiftKey && document.activeElement === lastElement) { - e.preventDefault(); - firstElement.tagName.includes('SM-') ? firstElement.focusIn() : firstElement.focus(); - } - } - } - - updateFocusableList() { - this.focusable = this.querySelectorAll('sm-button:not([disabled]), button:not([disabled]), [href], sm-input, input:not([readonly]), sm-select, select, sm-checkbox, sm-textarea, textarea, [tabindex]:not([tabindex="-1"])') - this.autoFocus = this.querySelector('[autofocus]') - } - - connectedCallback() { - this.popupBodySlot.addEventListener('slotchange', () => { - this.forms = this.querySelectorAll('sm-form'); - this.updateFocusableList() - }); - this.popupContainer.addEventListener('mousedown', e => { - if (e.target === this.popupContainer && !this.pinned) { - if (this.pinned) { - this.setStateOpen(); - } else - this.hide(); - } - }); - - const resizeObserver = new ResizeObserver(entries => { - for (let entry of entries) { - if (entry.contentBoxSize) { - // Firefox implements `contentBoxSize` as a single content rect, rather than an array - const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize; - this.threshold = contentBoxSize.blockSize.height * 0.3; - } else { - this.threshold = entry.contentRect.height * 0.3; - } - } - }); - resizeObserver.observe(this); - - this.mutationObserver = new MutationObserver(entries => { - this.updateFocusableList() - }) - this.mutationObserver.observe(this, { attributes: true, childList: true, subtree: true }) - - this.addEventListener('keydown', this.detectFocus); - this.popupHeader.addEventListener('touchstart', this.handleTouchStart, { passive: true }); - } - disconnectedCallback() { - this.removeEventListener('keydown', this.detectFocus); - resizeObserver.unobserve(); - this.mutationObserver.disconnect() - this.popupHeader.removeEventListener('touchstart', this.handleTouchStart, { passive: true }); - } - attributeChangedCallback(name) { - if (name === 'open') { - if (this.hasAttribute('open')) { - this.show(); - } - } - } -}); -const spinner = document.createElement('template'); -spinner.innerHTML = ` - - - -`; -class SpinnerLoader extends HTMLElement { - constructor() { - super(); - this.attachShadow({ - mode: 'open' - }).append(spinner.content.cloneNode(true)); - } -} -window.customElements.define('sm-spinner', SpinnerLoader); - -const themeToggle = document.createElement('template'); -themeToggle.innerHTML = ` - - -`; - -class ThemeToggle extends HTMLElement { - constructor() { - super(); - - this.attachShadow({ - mode: 'open' - }).append(themeToggle.content.cloneNode(true)); - - this.isChecked = false; - this.hasTheme = 'light'; - - this.toggleState = this.toggleState.bind(this); - this.fireEvent = this.fireEvent.bind(this); - this.handleThemeChange = this.handleThemeChange.bind(this); - } - static get observedAttributes() { - return ['checked']; - } - get theme() { - return this.hasTheme; - } - - daylight() { - this.hasTheme = 'light'; - document.body.dataset.theme = 'light'; - this.setAttribute('aria-checked', 'false'); - } - - nightlight() { - this.hasTheme = 'dark'; - document.body.dataset.theme = 'dark'; - this.setAttribute('aria-checked', 'true'); - } - - toggleState() { - this.toggleAttribute('checked'); - this.fireEvent(); - } - handleKeyDown(e) { - if (e.code === 'Space') { - this.toggleState(); - } - } - handleThemeChange(e) { - if (e.detail.theme !== this.hasTheme) { - if (e.detail.theme === 'dark') { - this.setAttribute('checked', ''); - } - else { - this.removeAttribute('checked'); - } - } - } - - fireEvent() { - this.dispatchEvent( - new CustomEvent('themechange', { - bubbles: true, - composed: true, - detail: { - theme: this.hasTheme - } - }) - ); - } - - connectedCallback() { - this.setAttribute('role', 'switch'); - this.setAttribute('aria-label', 'theme toggle'); - if (localStorage.getItem(`${window.location.hostname}-theme`) === "dark") { - this.nightlight(); - this.setAttribute('checked', ''); - } else if (localStorage.getItem(`${window.location.hostname}-theme`) === "light") { - this.daylight(); - this.removeAttribute('checked'); - } - else { - if (window.matchMedia(`(prefers-color-scheme: dark)`).matches) { - this.nightlight(); - this.setAttribute('checked', ''); - } else { - this.daylight(); - this.removeAttribute('checked'); - } - } - this.addEventListener("click", this.toggleState); - this.addEventListener("keydown", this.handleKeyDown); - document.addEventListener('themechange', this.handleThemeChange); - } - - disconnectedCallback() { - this.removeEventListener("click", this.toggleState); - this.removeEventListener("keydown", this.handleKeyDown); - document.removeEventListener('themechange', this.handleThemeChange); - } - - attributeChangedCallback(name, oldVal, newVal) { - if (name === 'checked') { - if (this.hasAttribute('checked')) { - this.nightlight(); - localStorage.setItem(`${window.location.hostname}-theme`, "dark"); - } else { - this.daylight(); - localStorage.setItem(`${window.location.hostname}-theme`, "light"); - } - } - } -} - -window.customElements.define('theme-toggle', ThemeToggle); - -const smCopy = document.createElement('template'); -smCopy.innerHTML = ` - -
-

- -
-`; -customElements.define('sm-copy', - class extends HTMLElement { - constructor() { - super(); - this.attachShadow({ - mode: 'open' - }).append(smCopy.content.cloneNode(true)); - - this.copyContent = this.shadowRoot.querySelector('.copy-content'); - this.copyButton = this.shadowRoot.querySelector('.copy-button'); - - this.copy = this.copy.bind(this); - } - static get observedAttributes() { - return ['value']; - } - set value(val) { - this.setAttribute('value', val); - } - get value() { - return this.getAttribute('value'); - } - fireEvent() { - this.dispatchEvent( - new CustomEvent('copy', { - composed: true, - bubbles: true, - cancelable: true, - }) - ); - } - copy() { - navigator.clipboard.writeText(this.copyContent.textContent) - .then(res => this.fireEvent()) - .catch(err => console.error(err)); - } - connectedCallback() { - this.copyButton.addEventListener('click', this.copy); - } - attributeChangedCallback(name, oldValue, newValue) { - if (name === 'value') { - this.copyContent.textContent = newValue; - } - } - disconnectedCallback() { - this.copyButton.removeEventListener('click', this.copy); - } - }); -const stripSelect = document.createElement('template'); -stripSelect.innerHTML = ` - -
-
- -
- -
- -
-
- - `; -customElements.define('strip-select', class extends HTMLElement { - constructor() { - super(); - this.attachShadow({ - mode: 'open' - }).append(stripSelect.content.cloneNode(true)); - this.stripSelect = this.shadowRoot.querySelector('.strip-select'); - this.slottedOptions = undefined; - this._value = undefined; - this.scrollDistance = 0; - - this.scrollLeft = this.scrollLeft.bind(this); - this.scrollRight = this.scrollRight.bind(this); - this.fireEvent = this.fireEvent.bind(this); - } - get value() { - return this._value; - } - scrollLeft() { - this.stripSelect.scrollBy({ - left: -this.scrollDistance, - behavior: 'smooth' - }); - } - - scrollRight() { - this.stripSelect.scrollBy({ - left: this.scrollDistance, - behavior: 'smooth' - }); - } - fireEvent() { - this.dispatchEvent( - new CustomEvent("change", { - bubbles: true, - composed: true, - detail: { - value: this._value - } - }) - ); - } - connectedCallback() { - this.setAttribute('role', 'listbox'); - - const slot = this.shadowRoot.querySelector('slot'); - const coverLeft = this.shadowRoot.querySelector('.cover--left'); - const coverRight = this.shadowRoot.querySelector('.cover--right'); - const navButtonLeft = this.shadowRoot.querySelector('.nav-button--left'); - const navButtonRight = this.shadowRoot.querySelector('.nav-button--right'); - slot.addEventListener('slotchange', e => { - const assignedElements = slot.assignedElements(); - assignedElements.forEach(elem => { - if (elem.hasAttribute('selected')) { - elem.setAttribute('active', ''); - this._value = elem.value; - } - }); - if (!this.hasAttribute('multiline')) { - if (assignedElements.length > 0) { - firstOptionObserver.observe(slot.assignedElements()[0]); - lastOptionObserver.observe(slot.assignedElements()[slot.assignedElements().length - 1]); - } - else { - navButtonLeft.classList.add('hide'); - navButtonRight.classList.add('hide'); - coverLeft.classList.add('hide'); - coverRight.classList.add('hide'); - firstOptionObserver.disconnect(); - lastOptionObserver.disconnect(); - } - } - }); - const resObs = new ResizeObserver(entries => { - entries.forEach(entry => { - if (entry.contentBoxSize) { - // Firefox implements `contentBoxSize` as a single content rect, rather than an array - const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize; - - this.scrollDistance = contentBoxSize.inlineSize * 0.6; - } else { - this.scrollDistance = entry.contentRect.width * 0.6; - } - }); - }); - resObs.observe(this); - this.stripSelect.addEventListener('option-clicked', e => { - if (this._value !== e.target.value) { - this._value = e.target.value; - slot.assignedElements().forEach(elem => elem.removeAttribute('active')); - e.target.setAttribute('active', ''); - e.target.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" }); - this.fireEvent(); - } - }); - const firstOptionObserver = new IntersectionObserver(entries => { - entries.forEach(entry => { - if (entry.isIntersecting) { - navButtonLeft.classList.add('hide'); - coverLeft.classList.add('hide'); - } - else { - navButtonLeft.classList.remove('hide'); - coverLeft.classList.remove('hide'); - } - }); - }, - { - threshold: 0.9, - root: this - }); - const lastOptionObserver = new IntersectionObserver(entries => { - entries.forEach(entry => { - if (entry.isIntersecting) { - navButtonRight.classList.add('hide'); - coverRight.classList.add('hide'); - } - else { - navButtonRight.classList.remove('hide'); - coverRight.classList.remove('hide'); - } - }); - }, - { - threshold: 0.9, - root: this - }); - navButtonLeft.addEventListener('click', this.scrollLeft); - navButtonRight.addEventListener('click', this.scrollRight); - } - disconnectedCallback() { - navButtonLeft.removeEventListener('click', this.scrollLeft); - navButtonRight.removeEventListener('click', this.scrollRight); - } -}); - -//Strip option -const stripOption = document.createElement('template'); -stripOption.innerHTML = ` - - - `; -customElements.define('strip-option', class extends HTMLElement { - constructor() { - super(); - this.attachShadow({ - mode: 'open' - }).append(stripOption.content.cloneNode(true)); - this._value = undefined; - this.radioButton = this.shadowRoot.querySelector('input'); - - this.fireEvent = this.fireEvent.bind(this); - this.handleKeyDown = this.handleKeyDown.bind(this); - } - get value() { - return this._value; - } - fireEvent() { - this.dispatchEvent( - new CustomEvent("option-clicked", { - bubbles: true, - composed: true, - detail: { - value: this._value - } - }) - ); - } - handleKeyDown(e) { - if (e.key === 'Enter' || e.key === 'Space') { - this.fireEvent(); - } - } - connectedCallback() { - this.setAttribute('role', 'option'); - this.setAttribute('tabindex', '0'); - this._value = this.getAttribute('value'); - this.addEventListener('click', this.fireEvent); - this.addEventListener('keydown', this.handleKeyDown); - } - disconnectedCallback() { - this.removeEventListener('click', this.fireEvent); - this.removeEventListener('keydown', this.handleKeyDown); - } -}); +// Components downloaded: checkbox,chips,copy,form,input,notifications,popup,spinner,theme-toggle +const smCheckbox = document.createElement("template"); smCheckbox.innerHTML = '
', customElements.define("sm-checkbox", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smCheckbox.content.cloneNode(!0)), this.defaultState, this.checkbox = this.shadowRoot.querySelector(".checkbox"), this.reset = this.reset.bind(this), this.dispatch = this.dispatch.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleClick = this.handleClick.bind(this) } static get observedAttributes() { return ["value", "disabled", "checked"] } get disabled() { return this.hasAttribute("disabled") } set disabled(e) { e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled") } get checked() { return this.hasAttribute("checked") } set checked(e) { e ? this.setAttribute("checked", "") : this.removeAttribute("checked") } set value(e) { this.setAttribute("value", e) } get value() { return this.getAttribute("value") } focusIn() { this.focus() } reset() { this.value = this.defaultState } dispatch() { this.dispatchEvent(new CustomEvent("change", { bubbles: !0, composed: !0 })) } handleKeyDown(e) { " " === e.key && (e.preventDefault(), this.toggleAttribute("checked")) } handleClick(e) { this.toggleAttribute("checked") } connectedCallback() { this.hasAttribute("disabled") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "checkbox"), this.defaultState = this.hasAttribute("checked"), this.hasAttribute("checked") || this.setAttribute("aria-checked", "false"), this.addEventListener("keydown", this.handleKeyDown), this.addEventListener("click", this.handleClick) } attributeChangedCallback(e, t, n) { t !== n && ("checked" === e ? (this.setAttribute("aria-checked", this.hasAttribute("checked")), this.dispatch()) : "disabled" === e && (this.hasAttribute("disabled") ? this.removeAttribute("tabindex") : this.setAttribute("tabindex", "0"))) } disconnectedCallback() { this.removeEventListener("keydown", this.handleKeyDown), this.removeEventListener("change", this.handleClick) } }); +const smChips = document.createElement("template"); smChips.innerHTML = '
', customElements.define("sm-chips", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smChips.content.cloneNode(!0)), this.chipsWrapper = this.shadowRoot.querySelector(".sm-chips"), this.coverLeft = this.shadowRoot.querySelector(".cover--left"), this.coverRight = this.shadowRoot.querySelector(".cover--right"), this.navButtonLeft = this.shadowRoot.querySelector(".nav-button--left"), this.navButtonRight = this.shadowRoot.querySelector(".nav-button--right"), this.slottedOptions = void 0, this._value = void 0, this.scrollDistance = 0, this.assignedElements = [], this.scrollLeft = this.scrollLeft.bind(this), this.scrollRight = this.scrollRight.bind(this), this.fireEvent = this.fireEvent.bind(this), this.setSelectedOption = this.setSelectedOption.bind(this) } get value() { return this._value } set value(t) { this.setSelectedOption(t) } scrollLeft() { this.chipsWrapper.scrollBy({ left: -this.scrollDistance, behavior: "smooth" }) } scrollRight() { this.chipsWrapper.scrollBy({ left: this.scrollDistance, behavior: "smooth" }) } setSelectedOption(t) { this._value !== t && (this._value = t, this.assignedElements.forEach(e => { e.value == t ? (e.setAttribute("selected", ""), e.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" })) : e.removeAttribute("selected") })) } fireEvent() { this.dispatchEvent(new CustomEvent("change", { bubbles: !0, composed: !0, detail: { value: this._value } })) } connectedCallback() { this.setAttribute("role", "listbox"); const t = this.shadowRoot.querySelector("slot"); t.addEventListener("slotchange", e => { clearTimeout(this.slotChangeTimeout), this.slotChangeTimeout = setTimeout(() => { n.disconnect(), i.disconnect(), this.assignedElements = t.assignedElements(), this.assignedElements.forEach(t => { t.hasAttribute("selected") && (this._value = t.value) }), this.hasAttribute("multiline") || (this.assignedElements.length > 0 ? (n.observe(this.assignedElements[0]), i.observe(this.assignedElements[this.assignedElements.length - 1])) : (this.navButtonLeft.classList.add("hide"), this.navButtonRight.classList.add("hide"), this.coverLeft.classList.add("hide"), this.coverRight.classList.add("hide"), n.disconnect(), i.disconnect())) }, 100) }); const e = new ResizeObserver(t => { t.forEach(t => { if (t.contentBoxSize) { const e = Array.isArray(t.contentBoxSize) ? t.contentBoxSize[0] : t.contentBoxSize; this.scrollDistance = .6 * e.inlineSize } else this.scrollDistance = .6 * t.contentRect.width }) }); e.observe(this), this.chipsWrapper.addEventListener("option-clicked", t => { this._value !== t.target.value && (this.setSelectedOption(t.target.value), this.fireEvent()) }); const n = new IntersectionObserver(t => { t.forEach(t => { t.isIntersecting ? (this.navButtonLeft.classList.add("hide"), this.coverLeft.classList.add("hide")) : (this.navButtonLeft.classList.remove("hide"), this.coverLeft.classList.remove("hide")) }) }, { threshold: .9, root: this }), i = new IntersectionObserver(t => { t.forEach(t => { t.isIntersecting ? (this.navButtonRight.classList.add("hide"), this.coverRight.classList.add("hide")) : (this.navButtonRight.classList.remove("hide"), this.coverRight.classList.remove("hide")) }) }, { threshold: .9, root: this }); this.navButtonLeft.addEventListener("click", this.scrollLeft), this.navButtonRight.addEventListener("click", this.scrollRight) } disconnectedCallback() { this.navButtonLeft.removeEventListener("click", this.scrollLeft), this.navButtonRight.removeEventListener("click", this.scrollRight) } }); const smChip = document.createElement("template"); smChip.innerHTML = ' ', customElements.define("sm-chip", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smChip.content.cloneNode(!0)), this._value = void 0, this.radioButton = this.shadowRoot.querySelector("input"), this.fireEvent = this.fireEvent.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this) } get value() { return this._value } fireEvent() { this.dispatchEvent(new CustomEvent("option-clicked", { bubbles: !0, composed: !0, detail: { value: this._value } })) } handleKeyDown(t) { "Enter" !== t.key && "Space" !== t.key || this.fireEvent() } connectedCallback() { this.setAttribute("role", "option"), this.setAttribute("tabindex", "0"), this._value = this.getAttribute("value"), this.addEventListener("click", this.fireEvent), this.addEventListener("keydown", this.handleKeyDown) } disconnectedCallback() { this.removeEventListener("click", this.fireEvent), this.removeEventListener("keydown", this.handleKeyDown) } }); +const smCopy = document.createElement("template"); smCopy.innerHTML = '

', customElements.define("sm-copy", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smCopy.content.cloneNode(!0)), this.copyContent = this.shadowRoot.querySelector(".copy-content"), this.copyButton = this.shadowRoot.querySelector(".copy-button"), this.copy = this.copy.bind(this) } static get observedAttributes() { return ["value"] } set value(t) { this.setAttribute("value", t) } get value() { return this.getAttribute("value") } fireEvent() { this.dispatchEvent(new CustomEvent("copy", { composed: !0, bubbles: !0, cancelable: !0 })) } copy() { navigator.clipboard.writeText(this.copyContent.textContent).then(t => this.fireEvent()).catch(t => console.error(t)) } connectedCallback() { this.copyButton.addEventListener("click", this.copy) } attributeChangedCallback(t, n, o) { "value" === t && (this.copyContent.textContent = o) } disconnectedCallback() { this.copyButton.removeEventListener("click", this.copy) } }); +const smForm = document.createElement("template"); smForm.innerHTML = `
`, customElements.define("sm-form", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smForm.content.cloneNode(!0)), this.form = this.shadowRoot.querySelector("form"), this.invalidFields = !1, this.skipSubmit = !1, this.isFormValid = !1, this.supportedElements = new Set(["INPUT", "SM-INPUT", "SM-TEXTAREA", "SM-CHECKBOX", "TAGS-INPUT", "FILE-INPUT", "SM-SWITCH", "SM-RADIO"]), this.debounce = this.debounce.bind(this), this._checkValidity = this._checkValidity.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.reset = this.reset.bind(this), this.elementsChanged = this.elementsChanged.bind(this) } static get observedAttributes() { return ["skip-submit"] } get validity() { return this.isFormValid } debounce(t, e) { let i = null; return (...s) => { window.clearTimeout(i), i = window.setTimeout(() => { t.apply(null, s) }, e) } } _checkValidity() { this.submitButton && (this.invalidFields = this._requiredElements.filter(([t, e]) => e ? !t.isValid : !t.checkValidity()), this.isFormValid = 0 === this.invalidFields.length, this.skipSubmit || (this.submitButton.disabled = !this.isFormValid), this.isFormValid ? this.dispatchEvent(new CustomEvent("valid", { bubbles: !0, composed: !0 })) : this.dispatchEvent(new CustomEvent("invalid", { bubbles: !0, composed: !0 }))) } handleKeydown(t) { if ("Enter" === t.key && t.target.tagName.includes("INPUT")) { if (this.invalidFields.length) for (let [e, i] of this._requiredElements) { let s = i ? !e.isValid : !e.checkValidity(); if (s) { (e?.shadowRoot?.lastElementChild || e).animate([{ transform: "translateX(-1rem)" }, { transform: "translateX(1rem)" }, { transform: "translateX(-0.5rem)" }, { transform: "translateX(0.5rem)" }, { transform: "translateX(0)" },], { duration: 300, easing: "ease" }), i ? e.focusIn() : e.focus(); break } } else this.submitButton && this.submitButton.click(), this.dispatchEvent(new CustomEvent("submit", { bubbles: !0, composed: !0 })) } } reset() { this.formElements.forEach(([t, e]) => { e ? t.reset() : t.value = "" }) } elementsChanged() { this.formElements = [...this.querySelectorAll("input, sm-input, sm-textarea, sm-checkbox, tags-input, file-input, sm-switch, sm-radio")].map(t => [t, t.tagName.includes("-")]), this._requiredElements = this.formElements.filter(([t]) => t.hasAttribute("required")), this.submitButton = this.querySelector('[variant="primary"], [type="submit"]'), this.resetButton = this.querySelector('[type="reset"]'), this.resetButton && this.resetButton.addEventListener("click", this.reset), this._checkValidity() } connectedCallback() { let t = this.debounce(this.elementsChanged, 100); this.shadowRoot.querySelector("slot").addEventListener("slotchange", t), this.addEventListener("input", this.debounce(this._checkValidity, 100)), this.addEventListener("keydown", this.debounce(this.handleKeydown, 100)), this.mutationObserver = new MutationObserver(e => { e.forEach(e => { ("childList" === e.type && [...e.addedNodes].some(t => this.supportedElements.has(t.tagName)) || [...e.removedNodes].some(t => this.supportedElements.has(t.tagName))) && t() }) }), this.mutationObserver.observe(this, { childList: !0, subtree: !0 }) } attributeChangedCallback(t, e, i) { "skip-submit" === t && (this.skipSubmit = null !== i) } disconnectedCallback() { this.removeEventListener("input", this.debounce(this._checkValidity, 100)), this.removeEventListener("keydown", this.debounce(this.handleKeydown, 100)), this.mutationObserver.disconnect() } }); +const smInput = document.createElement("template"); smInput.innerHTML = '
', customElements.define("sm-input", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smInput.content.cloneNode(!0)), this.inputParent = this.shadowRoot.querySelector(".input"), this.input = this.shadowRoot.querySelector("input"), this.clearBtn = this.shadowRoot.querySelector(".clear"), this.label = this.shadowRoot.querySelector(".label"), this.feedbackText = this.shadowRoot.querySelector(".feedback-text"), this.outerContainer = this.shadowRoot.querySelector(".outer-container"), this.optionList = this.shadowRoot.querySelector(".datalist"), this._helperText = "", this._errorText = "", this.isRequired = !1, this.datalist = [], this.validationFunction = void 0, this.reflectedAttributes = ["value", "required", "disabled", "type", "inputmode", "readonly", "min", "max", "pattern", "minlength", "maxlength", "step", "list", "autocomplete"], this.reset = this.reset.bind(this), this.clear = this.clear.bind(this), this.focusIn = this.focusIn.bind(this), this.focusOut = this.focusOut.bind(this), this.fireEvent = this.fireEvent.bind(this), this.checkInput = this.checkInput.bind(this), this.allowOnlyNum = this.allowOnlyNum.bind(this), this.handleOptionClick = this.handleOptionClick.bind(this), this.handleInputNavigation = this.handleInputNavigation.bind(this), this.handleDatalistNavigation = this.handleDatalistNavigation.bind(this), this.handleFocus = this.handleFocus.bind(this), this.handleBlur = this.handleBlur.bind(this) } static get observedAttributes() { return ["value", "placeholder", "required", "disabled", "type", "inputmode", "readonly", "min", "max", "pattern", "minlength", "maxlength", "step", "helper-text", "error-text", "list"] } get value() { return this.input.value } set value(t) { t !== this.input.value && (this.input.value = t, this.checkInput()) } get placeholder() { return this.getAttribute("placeholder") } set placeholder(t) { this.setAttribute("placeholder", t) } get type() { return this.getAttribute("type") } set type(t) { this.setAttribute("type", t) } get validity() { return this.input.validity } get disabled() { return this.hasAttribute("disabled") } set disabled(t) { t ? this.inputParent.classList.add("disabled") : this.inputParent.classList.remove("disabled") } get readOnly() { return this.hasAttribute("readonly") } set readOnly(t) { t ? this.setAttribute("readonly", "") : this.removeAttribute("readonly") } set customValidation(t) { this.validationFunction = t } set errorText(t) { this._errorText = t } set helperText(t) { this._helperText = t } get isValid() { if ("" !== this.input.value) { const t = this.input.checkValidity(); let e = !0; return this.validationFunction && (e = Boolean(this.validationFunction(this.input.value))), t && e ? (this.feedbackText.classList.remove("error"), this.feedbackText.classList.add("success"), this.feedbackText.textContent = "") : this._errorText && (this.feedbackText.classList.add("error"), this.feedbackText.classList.remove("success"), this.feedbackText.innerHTML = ` ${this._errorText}`), t && e } } reset() { this.value = "" } clear() { this.value = "", this.input.focus(), this.fireEvent() } focusIn() { this.input.focus() } focusOut() { this.input.blur() } fireEvent() { let t = new Event("input", { bubbles: !0, cancelable: !0, composed: !0 }); this.dispatchEvent(t) } searchDatalist(t) { const e = this.datalist.filter(e => e.toLowerCase().includes(t.toLowerCase())); if (e.sort((e, n) => { const i = e.toLowerCase().indexOf(t.toLowerCase()), s = n.toLowerCase().indexOf(t.toLowerCase()); return i - s }), e.length) { if (this.optionList.children.length > e.length) { const t = this.optionList.children.length - e.length; for (let e = 0; e < t; e++)this.optionList.removeChild(this.optionList.lastChild) } e.forEach((t, e) => { if (this.optionList.children[e]) this.optionList.children[e].textContent = t; else { const e = document.createElement("li"); e.textContent = t, e.classList.add("datalist-item"), e.setAttribute("tabindex", "0"), this.optionList.appendChild(e) } }), this.optionList.classList.remove("hidden") } else this.optionList.classList.add("hidden") } checkInput(t) { this.hasAttribute("readonly") || ("" !== this.input.value ? this.clearBtn.classList.remove("hidden") : this.clearBtn.classList.add("hidden")), this.hasAttribute("placeholder") && "" !== this.getAttribute("placeholder").trim() && ("" !== this.input.value ? (this.animate ? this.inputParent.classList.add("animate-placeholder") : this.label.classList.add("hidden"), this.datalist.length && (this.searchTimeout && clearTimeout(this.searchTimeout), this.searchTimeout = setTimeout(() => { this.searchDatalist(this.input.value.trim()) }, 100))) : (this.animate ? this.inputParent.classList.remove("animate-placeholder") : this.label.classList.remove("hidden"), this.feedbackText.textContent = "", this.datalist.length && (this.optionList.innerHTML = "", this.optionList.classList.add("hidden")))) } allowOnlyNum(t) { 1 === t.key.length && (("." !== t.key || !t.target.value.includes(".") && 0 !== t.target.value.length) && ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."].includes(t.key) || t.preventDefault()) } handleOptionClick(t) { this.input.value = t.target.textContent, this.optionList.classList.add("hidden"), this.input.focus() } handleInputNavigation(t) { "ArrowDown" === t.key ? (t.preventDefault(), this.optionList.children.length && this.optionList.children[0].focus()) : "ArrowUp" === t.key && (t.preventDefault(), this.optionList.children.length && this.optionList.children[this.optionList.children.length - 1].focus()) } handleDatalistNavigation(t) { "ArrowUp" === t.key ? (t.preventDefault(), this.shadowRoot.activeElement.previousElementSibling ? this.shadowRoot.activeElement.previousElementSibling.focus() : this.input.focus()) : "ArrowDown" === t.key ? (t.preventDefault(), this.shadowRoot.activeElement.nextElementSibling ? this.shadowRoot.activeElement.nextElementSibling.focus() : this.input.focus()) : "Enter" !== t.key && " " !== t.key || (t.preventDefault(), this.input.value = t.target.textContent, this.optionList.classList.add("hidden"), this.input.focus()) } handleFocus(t) { this.datalist.length && this.searchDatalist(this.input.value.trim()) } handleBlur(t) { this.datalist.length && this.optionList.classList.add("hidden") } connectedCallback() { this.animate = this.hasAttribute("animate"), this.setAttribute("role", "textbox"), this.input.addEventListener("input", this.checkInput), this.clearBtn.addEventListener("click", this.clear), this.datalist.length && (this.optionList.addEventListener("click", this.handleOptionClick), this.input.addEventListener("keydown", this.handleInputNavigation), this.optionList.addEventListener("keydown", this.handleDatalistNavigation)), this.input.addEventListener("focusin", this.handleFocus), this.addEventListener("focusout", this.handleBlur) } attributeChangedCallback(t, e, n) { e !== n && (this.reflectedAttributes.includes(t) && (this.hasAttribute(t) ? this.input.setAttribute(t, this.getAttribute(t) ? this.getAttribute(t) : "") : this.input.removeAttribute(t)), "placeholder" === t ? (this.label.textContent = n, this.setAttribute("aria-label", n)) : this.hasAttribute("value") ? this.checkInput() : "type" === t ? this.hasAttribute("type") && "number" === this.getAttribute("type") ? (this.input.setAttribute("inputmode", "decimal"), this.input.addEventListener("keydown", this.allowOnlyNum)) : this.input.removeEventListener("keydown", this.allowOnlyNum) : "helper-text" === t ? this._helperText = this.getAttribute("helper-text") : "error-text" === t ? this._errorText = this.getAttribute("error-text") : "required" === t ? (this.isRequired = this.hasAttribute("required"), this.isRequired ? this.setAttribute("aria-required", "true") : this.setAttribute("aria-required", "false")) : "readonly" === t ? this.hasAttribute("readonly") ? this.inputParent.classList.add("readonly") : this.inputParent.classList.remove("readonly") : "disabled" === t ? this.hasAttribute("disabled") ? this.inputParent.classList.add("disabled") : this.inputParent.classList.remove("disabled") : "list" === t && this.hasAttribute("list") && "" !== this.getAttribute("list").trim() && (this.datalist = this.getAttribute("list").split(","))) } disconnectedCallback() { this.input.removeEventListener("input", this.checkInput), this.clearBtn.removeEventListener("click", this.clear), this.input.removeEventListener("keydown", this.allowOnlyNum), this.optionList.removeEventListener("click", this.handleOptionClick), this.input.removeEventListener("keydown", this.handleInputNavigation), this.optionList.removeEventListener("keydown", this.handleDatalistNavigation), this.input.removeEventListener("focusin", this.handleFocus), this.removeEventListener("focusout", this.handleBlur) } }); +const smNotifications = document.createElement("template"); smNotifications.innerHTML = '
', customElements.define("sm-notifications", class extends HTMLElement { constructor() { super(), this.shadow = this.attachShadow({ mode: "open" }).append(smNotifications.content.cloneNode(!0)), this.notificationPanel = this.shadowRoot.querySelector(".notification-panel"), this.animationOptions = { duration: 300, fill: "forwards", easing: "cubic-bezier(0.175, 0.885, 0.32, 1.275)" }, this.push = this.push.bind(this), this.createNotification = this.createNotification.bind(this), this.removeNotification = this.removeNotification.bind(this), this.clearAll = this.clearAll.bind(this), this.remove = this.remove.bind(this), this.handlePointerMove = this.handlePointerMove.bind(this), this.startX = 0, this.currentX = 0, this.endX = 0, this.swipeDistance = 0, this.swipeDirection = "", this.swipeThreshold = 0, this.startTime = 0, this.swipeTime = 0, this.swipeTimeThreshold = 200, this.currentTarget = null, this.mediaQuery = window.matchMedia("(min-width: 640px)"), this.handleOrientationChange = this.handleOrientationChange.bind(this), this.isLandscape = !1 } randString(n) { let t = ""; const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; for (let e = 0; e < n; e++)t += i.charAt(Math.floor(Math.random() * i.length)); return t } createNotification(n, t = {}) { const { pinned: i = !1, icon: e = "", action: o } = t, r = document.createElement("div"); r.id = this.randString(8), r.classList.add("notification"); let a = ""; return a += `
${e}
${n} `, o && (a += ` `), i && (r.classList.add("pinned"), a += ' '), r.innerHTML = a, r } push(n, t = {}) { const i = this.createNotification(n, t); return this.isLandscape ? this.notificationPanel.append(i) : this.notificationPanel.prepend(i), this.notificationPanel.animate([{ transform: `translateY(${this.isLandscape ? "" : "-"}${i.clientHeight}px)` }, { transform: "none" }], this.animationOptions), i.animate([{ transform: "translateY(-1rem)", opacity: "0" }, { transform: "none", opacity: "1" }], this.animationOptions).onfinish = (n => { n.target.commitStyles(), n.target.cancel() }), i.querySelector(".action") && i.querySelector(".action").addEventListener("click", t.action.callback), i.id } removeNotification(n, t = "left") { if (!n) return; const i = "left" === t ? "-" : "+"; n.animate([{ transform: this.currentX ? `translateX(${this.currentX}px)` : "none", opacity: "1" }, { transform: `translateX(calc(${i}${Math.abs(this.currentX)}px ${i} 1rem))`, opacity: "0" }], this.animationOptions).onfinish = (() => { n.remove() }) } remove(n) { const t = this.notificationPanel.querySelector(`#${n}`); t && this.removeNotification(t) } clearAll() { Array.from(this.notificationPanel.children).forEach(n => { this.removeNotification(n) }) } handlePointerMove(n) { this.currentX = n.clientX - this.startX, this.currentTarget.style.transform = `translateX(${this.currentX}px)` } handleOrientationChange(n) { this.isLandscape = n.matches, n.matches } connectedCallback() { this.handleOrientationChange(this.mediaQuery), this.mediaQuery.addEventListener("change", this.handleOrientationChange), this.notificationPanel.addEventListener("pointerdown", n => { n.target.closest(".close") ? this.removeNotification(n.target.closest(".notification")) : n.target.closest(".notification") && (this.swipeThreshold = n.target.closest(".notification").getBoundingClientRect().width / 2, this.currentTarget = n.target.closest(".notification"), this.currentTarget.setPointerCapture(n.pointerId), this.startTime = Date.now(), this.startX = n.clientX, this.startY = n.clientY, this.notificationPanel.addEventListener("pointermove", this.handlePointerMove)) }), this.notificationPanel.addEventListener("pointerup", n => { this.endX = n.clientX, this.endY = n.clientY, this.swipeDistance = Math.abs(this.endX - this.startX), this.swipeTime = Date.now() - this.startTime, this.endX > this.startX ? this.swipeDirection = "right" : this.swipeDirection = "left", this.swipeTime < this.swipeTimeThreshold ? this.swipeDistance > 50 && this.removeNotification(this.currentTarget, this.swipeDirection) : this.swipeDistance > this.swipeThreshold ? this.removeNotification(this.currentTarget, this.swipeDirection) : this.currentTarget.animate([{ transform: `translateX(${this.currentX}px)` }, { transform: "none" }], this.animationOptions).onfinish = (n => { n.target.commitStyles(), n.target.cancel() }), this.notificationPanel.removeEventListener("pointermove", this.handlePointerMove), this.notificationPanel.releasePointerCapture(n.pointerId), this.currentX = 0 }); const n = new MutationObserver(n => { n.forEach(n => { "childList" === n.type && n.addedNodes.length && !n.addedNodes[0].classList.contains("pinned") && setTimeout(() => { this.removeNotification(n.addedNodes[0]) }, 5e3) }) }); n.observe(this.notificationPanel, { childList: !0 }) } disconnectedCallback() { mediaQueryList.removeEventListener("change", handleOrientationChange) } }); +class Stack { constructor() { this.items = [] } push(t) { this.items.push(t) } pop() { return 0 == this.items.length ? "Underflow" : this.items.pop() } peek() { return this.items[this.items.length - 1] } } const popupStack = new Stack, smPopup = document.createElement("template"); smPopup.innerHTML = ` `, customElements.define("sm-popup", class extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(smPopup.content.cloneNode(!0)), this.allowClosing = !1, this.isOpen = !1, this.offset = 0, this.touchStartY = 0, this.touchEndY = 0, this.touchStartTime = 0, this.touchEndTime = 0, this.touchEndAnimation = void 0, this.focusable, this.autoFocus, this.mutationObserver, this.popupContainer = this.shadowRoot.querySelector(".popup-container"), this.backdrop = this.shadowRoot.querySelector(".backdrop"), this.dialogBox = this.shadowRoot.querySelector(".popup"), this.popupBodySlot = this.shadowRoot.querySelector(".popup-body slot"), this.popupHeader = this.shadowRoot.querySelector(".popup-top"), this.resumeScrolling = this.resumeScrolling.bind(this), this.setStateOpen = this.setStateOpen.bind(this), this.show = this.show.bind(this), this.hide = this.hide.bind(this), this.handleTouchStart = this.handleTouchStart.bind(this), this.handleTouchMove = this.handleTouchMove.bind(this), this.handleTouchEnd = this.handleTouchEnd.bind(this), this.detectFocus = this.detectFocus.bind(this), this.handleSoftDismiss = this.handleSoftDismiss.bind(this) } static get observedAttributes() { return ["open"] } get open() { return this.isOpen } animateTo(t, e, i) { let s = t.animate(e, { ...i, fill: "both" }); return s.finished.then(() => { s.commitStyles(), s.cancel() }), s } resumeScrolling() { let t = document.body.style.top; window.scrollTo(0, -1 * parseInt(t || "0")), document.body.style.overflow = "", document.body.style.top = "initial" } setStateOpen() { if (!this.isOpen || this.offset) { let t = window.innerWidth > 640 ? "scale(1.1)" : `translateY(${this.offset ? `${this.offset}px` : "100%"})`; this.animateTo(this.dialogBox, [{ opacity: this.offset ? 1 : 0, transform: t }, { opacity: 1, transform: "none" },], { duration: 300, easing: "ease" }) } } show(t = {}) { let { pinned: e = !1, payload: i } = t; if (this.isOpen) return; let s = { duration: 300, easing: "ease" }; return this.payload = i, popupStack.push({ popup: this, permission: e }), popupStack.items.length > 1 && this.animateTo(popupStack.items[popupStack.items.length - 2].popup.shadowRoot.querySelector(".popup"), [{ transform: "none" }, { transform: window.innerWidth > 640 ? "scale(0.95)" : "translateY(-1.5rem)" },], s), this.popupContainer.classList.remove("hide"), this.offset || (this.backdrop.animate([{ opacity: 0 }, { opacity: 1 },], s).onfinish = () => { this.resolveOpen(this.payload) }, this.dispatchEvent(new CustomEvent("popupopened", { bubbles: !0, composed: !0, detail: { payload: this.payload } })), document.body.style.overflow = "hidden", document.body.style.top = `-${window.scrollY}px`), this.setStateOpen(), this.pinned = e, this.isOpen = !0, setTimeout(() => { let t = this.autoFocus || this.focusable?.[0] || this.dialogBox; t && (t.tagName.includes("-") ? t.focusIn() : t.focus()) }, 0), this.hasAttribute("open") || (this.setAttribute("open", ""), this.addEventListener("keydown", this.detectFocus), this.resizeObserver.observe(this), this.mutationObserver.observe(this, { attributes: !0, childList: !0, subtree: !0 }), this.popupHeader.addEventListener("touchstart", this.handleTouchStart, { passive: !0 }), this.backdrop.addEventListener("mousedown", this.handleSoftDismiss)), { opened: new Promise(t => { this.resolveOpen = t }), closed: new Promise(t => { this.resolveClose = t }) } } hide(t = {}) { let { payload: e } = t, i = { duration: 150, easing: "ease" }; this.backdrop.animate([{ opacity: 1 }, { opacity: 0 }], i), this.animateTo(this.dialogBox, [{ opacity: 1, transform: window.innerWidth > 640 ? "none" : `translateY(${this.offset ? `${this.offset}px` : "0"})` }, { opacity: 0, transform: window.innerWidth > 640 ? "scale(1.1)" : "translateY(100%)" },], i).finished.finally(() => { this.popupContainer.classList.add("hide"), this.dialogBox.style = "", this.removeAttribute("open"), this.forms.length && this.forms.forEach(t => t.reset()), this.dispatchEvent(new CustomEvent("popupclosed", { bubbles: !0, composed: !0, detail: { payload: e || this.payload } })), this.resolveClose(e || this.payload), this.isOpen = !1 }), popupStack.pop(), popupStack.items.length ? this.animateTo(popupStack.items[popupStack.items.length - 1].popup.shadowRoot.querySelector(".popup"), [{ transform: window.innerWidth > 640 ? "scale(0.95)" : "translateY(-1.5rem)" }, { transform: "none" },], i) : this.resumeScrolling(), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.removeEventListener("keydown", this.detectFocus), this.popupHeader.removeEventListener("touchstart", this.handleTouchStart, { passive: !0 }), this.backdrop.removeEventListener("mousedown", this.handleSoftDismiss) } handleTouchStart(t) { this.offset = 0, this.popupHeader.addEventListener("touchmove", this.handleTouchMove, { passive: !0 }), this.popupHeader.addEventListener("touchend", this.handleTouchEnd, { passive: !0 }), this.touchStartY = t.changedTouches[0].clientY, this.touchStartTime = t.timeStamp } handleTouchMove(t) { this.touchStartY < t.changedTouches[0].clientY && (this.offset = t.changedTouches[0].clientY - this.touchStartY, this.touchEndAnimation = window.requestAnimationFrame(() => { this.dialogBox.style.transform = `translateY(${this.offset}px)` })) } handleTouchEnd(t) { if (this.touchEndTime = t.timeStamp, cancelAnimationFrame(this.touchEndAnimation), this.touchEndY = t.changedTouches[0].clientY, this.threshold = .3 * this.dialogBox.getBoundingClientRect().height, this.touchEndTime - this.touchStartTime > 200) { if (this.touchEndY - this.touchStartY > this.threshold) { if (this.pinned) { this.setStateOpen(); return } this.hide() } else this.setStateOpen() } else if (this.touchEndY > this.touchStartY) { if (this.pinned) { this.setStateOpen(); return } this.hide() } this.popupHeader.removeEventListener("touchmove", this.handleTouchMove, { passive: !0 }), this.popupHeader.removeEventListener("touchend", this.handleTouchEnd, { passive: !0 }) } detectFocus(t) { if ("Tab" === t.key) { let e = this.focusable[this.focusable.length - 1], i = this.focusable[0]; t.shiftKey && document.activeElement === i ? (t.preventDefault(), e.tagName.includes("SM-") ? e.focusIn() : e.focus()) : t.shiftKey || document.activeElement !== e || (t.preventDefault(), i.tagName.includes("SM-") ? i.focusIn() : i.focus()) } } updateFocusableList() { this.focusable = this.querySelectorAll('sm-button:not([disabled]), button:not([disabled]), [href], sm-input, input:not([readonly]), sm-select, select, sm-checkbox, sm-textarea, textarea, [tabindex]:not([tabindex="-1"])'), this.autoFocus = this.querySelector("[autofocus]") } handleSoftDismiss() { this.pinned ? this.dialogBox.animate([{ transform: "translateX(-1rem)" }, { transform: "translateX(1rem)" }, { transform: "translateX(-0.5rem)" }, { transform: "translateX(0.5rem)" }, { transform: "translateX(0)" },], { duration: 300, easing: "ease" }) : this.hide() } debounce(t, e) { let i = null; return (...s) => { window.clearTimeout(i), i = window.setTimeout(() => { t.apply(null, s) }, e) } } connectedCallback() { this.popupBodySlot.addEventListener("slotchange", this.debounce(() => { this.forms = this.querySelectorAll("sm-form"), this.updateFocusableList() }, 0)), this.resizeObserver = new ResizeObserver(t => { for (let e of t) if (e.contentBoxSize) { let i = Array.isArray(e.contentBoxSize) ? e.contentBoxSize[0] : e.contentBoxSize; this.threshold = .3 * i.blockSize.height } else this.threshold = .3 * e.contentRect.height }), this.mutationObserver = new MutationObserver(t => { this.updateFocusableList() }) } disconnectedCallback() { this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.removeEventListener("keydown", this.detectFocus), this.popupHeader.removeEventListener("touchstart", this.handleTouchStart, { passive: !0 }), this.backdrop.removeEventListener("mousedown", this.handleSoftDismiss) } attributeChangedCallback(t) { "open" === t && this.hasAttribute("open") && this.show() } }); +const spinner = document.createElement("template"); spinner.innerHTML = ''; class SpinnerLoader extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(spinner.content.cloneNode(!0)) } } window.customElements.define("sm-spinner", SpinnerLoader); +const themeToggle = document.createElement("template"); themeToggle.innerHTML = ' '; class ThemeToggle extends HTMLElement { constructor() { super(), this.attachShadow({ mode: "open" }).append(themeToggle.content.cloneNode(!0)), this.isChecked = !1, this.hasTheme = "light", this.toggleState = this.toggleState.bind(this), this.fireEvent = this.fireEvent.bind(this), this.handleThemeChange = this.handleThemeChange.bind(this) } static get observedAttributes() { return ["checked"] } daylight() { this.hasTheme = "light", document.body.dataset.theme = "light", this.setAttribute("aria-checked", "false") } nightlight() { this.hasTheme = "dark", document.body.dataset.theme = "dark", this.setAttribute("aria-checked", "true") } toggleState() { this.toggleAttribute("checked"), this.fireEvent() } handleKeyDown(e) { " " === e.key && this.toggleState() } handleThemeChange(e) { e.detail.theme !== this.hasTheme && ("dark" === e.detail.theme ? this.setAttribute("checked", "") : this.removeAttribute("checked")) } fireEvent() { this.dispatchEvent(new CustomEvent("themechange", { bubbles: !0, composed: !0, detail: { theme: this.hasTheme } })) } connectedCallback() { this.setAttribute("role", "switch"), this.setAttribute("aria-label", "theme toggle"), "dark" === localStorage.getItem(`${window.location.hostname}-theme`) ? (this.nightlight(), this.setAttribute("checked", "")) : "light" === localStorage.getItem(`${window.location.hostname}-theme`) ? (this.daylight(), this.removeAttribute("checked")) : window.matchMedia("(prefers-color-scheme: dark)").matches ? (this.nightlight(), this.setAttribute("checked", "")) : (this.daylight(), this.removeAttribute("checked")), this.addEventListener("click", this.toggleState), this.addEventListener("keydown", this.handleKeyDown), document.addEventListener("themechange", this.handleThemeChange) } disconnectedCallback() { this.removeEventListener("click", this.toggleState), this.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("themechange", this.handleThemeChange) } attributeChangedCallback(e, t, n) { "checked" === e && (this.hasAttribute("checked") ? (this.nightlight(), localStorage.setItem(`${window.location.hostname}-theme`, "dark")) : (this.daylight(), localStorage.setItem(`${window.location.hostname}-theme`, "light"))) } } window.customElements.define("theme-toggle", ThemeToggle); const slideButton = document.createElement('template') slideButton.innerHTML = ` @@ -2374,612 +155,6 @@ class SlideButton extends HTMLElement { window.customElements.define('slide-button', SlideButton); -const smSelect = document.createElement('template') -smSelect.innerHTML = ` - -
-
-
- -
-
- -
-
`; -customElements.define('sm-select', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smSelect.content.cloneNode(true)) - - this.focusIn = this.focusIn.bind(this) - this.reset = this.reset.bind(this) - this.open = this.open.bind(this) - this.collapse = this.collapse.bind(this) - this.toggle = this.toggle.bind(this) - this.handleOptionsNavigation = this.handleOptionsNavigation.bind(this) - this.handleOptionSelection = this.handleOptionSelection.bind(this) - this.handleKeydown = this.handleKeydown.bind(this) - this.handleClickOutside = this.handleClickOutside.bind(this) - - this.availableOptions - this.previousOption - this.isOpen = false; - this.label = '' - this.slideDown = [{ - transform: `translateY(-0.5rem)`, - opacity: 0 - }, - { - transform: `translateY(0)`, - opacity: 1 - } - ] - this.slideUp = [{ - transform: `translateY(0)`, - opacity: 1 - }, - { - transform: `translateY(-0.5rem)`, - opacity: 0 - } - ] - this.animationOptions = { - duration: 300, - fill: "forwards", - easing: 'ease' - } - - this.optionList = this.shadowRoot.querySelector('.options') - this.chevron = this.shadowRoot.querySelector('.toggle') - this.selection = this.shadowRoot.querySelector('.selection') - this.selectedOptionText = this.shadowRoot.querySelector('.selected-option-text') - } - static get observedAttributes() { - return ['disabled', 'label'] - } - get value() { - return this.getAttribute('value') - } - set value(val) { - const selectedOption = this.availableOptions.find(option => option.getAttribute('value') === val) - if (selectedOption) { - this.setAttribute('value', val) - this.selectedOptionText.textContent = `${this.label}${selectedOption.textContent}`; - if (this.previousOption) { - this.previousOption.classList.remove('check-selected') - } - selectedOption.classList.add('check-selected') - this.previousOption = selectedOption - } else { - console.warn(`There is no option with ${val} as value`) - } - } - - reset(fire = true) { - if (this.availableOptions[0] && this.previousOption !== this.availableOptions[0]) { - const firstElement = this.availableOptions[0]; - if (this.previousOption) { - this.previousOption.classList.remove('check-selected') - } - firstElement.classList.add('check-selected') - this.value = firstElement.getAttribute('value') - this.selectedOptionText.textContent = `${this.label}${firstElement.textContent}` - this.previousOption = firstElement; - if (fire) { - this.fireEvent() - } - } - } - - focusIn() { - this.selection.focus() - } - - open() { - this.optionList.classList.remove('hide') - this.optionList.animate(this.slideDown, this.animationOptions) - this.chevron.classList.add('rotate') - this.isOpen = true - } - collapse() { - this.chevron.classList.remove('rotate') - this.optionList.animate(this.slideUp, this.animationOptions) - .onfinish = () => { - this.optionList.classList.add('hide') - this.isOpen = false - } - } - toggle() { - if (!this.isOpen && !this.hasAttribute('disabled')) { - this.open() - } else { - this.collapse() - } - } - - fireEvent() { - this.dispatchEvent(new CustomEvent('change', { - bubbles: true, - composed: true, - detail: { - value: this.value - } - })) - } - - handleOptionsNavigation(e) { - if (e.key === 'ArrowUp') { - e.preventDefault() - if (document.activeElement.previousElementSibling) { - document.activeElement.previousElementSibling.focus() - } else { - this.availableOptions[this.availableOptions.length - 1].focus() - } - } - else if (e.key === 'ArrowDown') { - e.preventDefault() - if (document.activeElement.nextElementSibling) { - document.activeElement.nextElementSibling.focus() - } else { - this.availableOptions[0].focus() - } - } - } - handleOptionSelection(e) { - if (this.previousOption !== document.activeElement) { - this.value = document.activeElement.getAttribute('value') - this.fireEvent() - } - } - handleClick(e) { - if (e.target === this) { - this.toggle() - } - else { - this.handleOptionSelection() - this.collapse() - } - } - handleKeydown(e) { - if (e.target === this) { - if (this.isOpen && e.key === 'ArrowDown') { - e.preventDefault() - this.availableOptions[0].focus() - this.handleOptionSelection(e) - } - else if (e.key === 'Enter' || e.key === ' ') { - e.preventDefault() - this.toggle() - } - } - else { - this.handleOptionsNavigation(e) - this.handleOptionSelection(e) - if (e.key === 'Enter' || e.key === ' ') { - e.preventDefault() - this.collapse() - } - } - } - handleClickOutside(e) { - if (this.isOpen && !this.contains(e.target)) { - this.collapse() - } - } - connectedCallback() { - this.setAttribute('role', 'listbox') - if (!this.hasAttribute('disabled')) { - this.selection.setAttribute('tabindex', '0') - } - let slot = this.shadowRoot.querySelector('slot') - slot.addEventListener('slotchange', e => { - this.availableOptions = slot.assignedElements() - this.reset(false) - }); - this.addEventListener('click', this.handleClick) - this.addEventListener('keydown', this.handleKeydown) - document.addEventListener('mousedown', this.handleClickOutside) - } - disconnectedCallback() { - this.removeEventListener('click', this.toggle) - this.removeEventListener('keydown', this.handleKeydown) - document.removeEventListener('mousedown', this.handleClickOutside) - } - attributeChangedCallback(name) { - if (name === "disabled") { - if (this.hasAttribute('disabled')) { - this.selection.removeAttribute('tabindex') - } else { - this.selection.setAttribute('tabindex', '0') - } - } else if (name === 'label') { - this.label = this.hasAttribute('label') ? `${this.getAttribute('label')} ` : '' - } - } -}) - -// option -const smOption = document.createElement('template') -smOption.innerHTML = ` - -
- - -
`; -customElements.define('sm-option', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smOption.content.cloneNode(true)) - } - - connectedCallback() { - this.setAttribute('role', 'option') - this.setAttribute('tabindex', '0') - } -}) - -const smCheckbox = document.createElement('template') -smCheckbox.innerHTML = ` - -` -customElements.define('sm-checkbox', class extends HTMLElement { - constructor() { - super() - this.attachShadow({ - mode: 'open' - }).append(smCheckbox.content.cloneNode(true)) - - this.checkbox = this.shadowRoot.querySelector('.checkbox'); - - this.reset = this.reset.bind(this) - this.dispatch = this.dispatch.bind(this) - this.handleKeyDown = this.handleKeyDown.bind(this) - this.handleClick = this.handleClick.bind(this) - } - - static get observedAttributes() { - return ['value', 'disabled', 'checked'] - } - - get disabled() { - return this.hasAttribute('disabled') - } - - set disabled(val) { - if (val) { - this.setAttribute('disabled', '') - } else { - this.removeAttribute('disabled') - } - } - - get checked() { - return this.hasAttribute('checked') - } - - set checked(value) { - if (value) { - this.setAttribute('checked', '') - } - else { - this.removeAttribute('checked') - } - } - - set value(val) { - this.setAttribute('value', val) - } - - get value() { - return this.getAttribute('value') - } - - reset() { - this.removeAttribute('checked') - } - - dispatch() { - this.dispatchEvent(new CustomEvent('change', { - bubbles: true, - composed: true - })) - } - handleKeyDown(e) { - if (e.code === "Space") { - e.preventDefault() - this.click() - } - } - handleClick(e) { - this.toggleAttribute('checked') - } - - connectedCallback() { - if (!this.hasAttribute('disabled')) { - this.setAttribute('tabindex', '0') - } - this.setAttribute('role', 'checkbox') - if (!this.hasAttribute('checked')) { - this.setAttribute('aria-checked', 'false') - } - this.addEventListener('keydown', this.handleKeyDown) - this.addEventListener('click', this.handleClick) - } - attributeChangedCallback(name, oldValue, newValue) { - if (oldValue !== newValue) { - if (name === 'checked') { - this.setAttribute('aria-checked', this.hasAttribute('checked')) - this.dispatch() - } - else if (name === 'disabled') { - if (this.hasAttribute('disabled')) { - this.removeAttribute('tabindex') - } - else { - this.setAttribute('tabindex', '0') - } - } - } - } - disconnectedCallback() { - this.removeEventListener('keydown', this.handleKeyDown) - this.removeEventListener('change', this.handleClick) - } -}) - const lineLoader = document.createElement('template'); lineLoader.innerHTML = `