New layout and UX for trading view on mobile

This commit is contained in:
sairaj mote 2022-05-16 17:19:47 +05:30
parent e8943f73c0
commit 7f8334caa5
4 changed files with 168 additions and 56 deletions

View File

@ -682,9 +682,9 @@ sm-checkbox {
width: 100%; width: 100%;
justify-content: center; justify-content: center;
overflow-y: auto; overflow-y: auto;
padding: 0 1.5rem;
} }
#pages_container > * { #pages_container > * {
padding: 0 1.5rem;
min-width: min(26rem, 100%); min-width: min(26rem, 100%);
} }
@ -781,21 +781,12 @@ sm-checkbox {
} }
#asset_page { #asset_page {
position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
} }
#asset_page__nav {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 0;
}
#asset_page__nav .icon-only {
margin-left: -0.7rem;
}
#trade_form { #trade_form {
height: 100%; height: 100%;
} }
@ -1280,11 +1271,61 @@ sm-checkbox {
transform: translateY(50%) scale(1.2); transform: translateY(50%) scale(1.2);
} }
#asset_list_wrapper {
padding: 0 1.5rem;
}
.listed-asset { .listed-asset {
border-radius: 0; border-radius: 0;
border-bottom: solid thin rgba(var(--text-color), 0.1); border-bottom: solid thin rgba(var(--text-color), 0.1);
} }
#exchange {
margin: 0;
padding: 0;
}
#chart_header {
padding: 1rem 1.5rem 0.5rem 1.5rem;
margin-left: -0.7rem;
}
#trade_panel_backdrop {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 100%;
background-color: rgba(var(--text-color), 0.16);
-webkit-backdrop-filter: blur(0.5rem);
backdrop-filter: blur(0.5rem);
z-index: 3;
}
#show_trade_panel {
position: absolute;
border-radius: 2rem;
bottom: 0;
align-self: center;
margin-bottom: 1rem;
z-index: 5;
}
#trade_form {
position: fixed;
height: auto;
bottom: 0;
left: 0;
right: 0;
margin-top: auto;
width: auto;
z-index: 10;
padding: 1.5rem 1.5rem 0 1.5rem;
border-radius: 1rem 1rem 0 0;
background-color: rgba(var(--foreground-color), 1);
box-shadow: 0 -0.5rem 1rem rgba(0, 0, 0, 0.1);
}
#price_chart_container { #price_chart_container {
flex: 1; flex: 1;
} }
@ -1365,6 +1406,10 @@ sm-checkbox {
#pages_container { #pages_container {
grid-area: pages; grid-area: pages;
} }
#pages_container > * {
margin: 0 1.5rem;
padding: 2rem;
}
.is-signed-in #exchange { .is-signed-in #exchange {
display: flex; display: flex;
@ -1399,7 +1444,7 @@ sm-checkbox {
position: absolute; position: absolute;
width: 0.25rem; width: 0.25rem;
border-radius: 0 0.2rem 0.2rem 0; border-radius: 0 0.2rem 0.2rem 0;
height: 50%; height: 2rem;
background-color: var(--accent-color); background-color: var(--accent-color);
} }
} }
@ -1449,10 +1494,6 @@ sm-checkbox {
grid-template-columns: minmax(0, 1fr) 20rem; grid-template-columns: minmax(0, 1fr) 20rem;
} }
#asset_page__nav {
grid-column: 1/-1;
}
#portfolio { #portfolio {
gap: 1rem 2rem; gap: 1rem 2rem;
grid-template-columns: 20rem 24rem; grid-template-columns: 20rem 24rem;

File diff suppressed because one or more lines are too long

View File

@ -643,8 +643,8 @@ sm-checkbox {
width: 100%; width: 100%;
justify-content: center; justify-content: center;
overflow-y: auto; overflow-y: auto;
padding: 0 1.5rem;
& > * { & > * {
padding: 0 1.5rem;
min-width: min(26rem, 100%); min-width: min(26rem, 100%);
} }
} }
@ -738,19 +738,11 @@ sm-checkbox {
height: 100%; height: 100%;
} }
#asset_page { #asset_page {
position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
} }
#asset_page__nav {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 0;
.icon-only {
margin-left: -0.7rem;
}
}
#trade_form { #trade_form {
height: 100%; height: 100%;
&::part(form) { &::part(form) {
@ -765,7 +757,6 @@ sm-checkbox {
margin-top: auto; margin-top: auto;
} }
} }
#my_orders, #my_orders,
#market { #market {
width: min(46rem, 100%); width: min(46rem, 100%);
@ -1139,10 +1130,53 @@ sm-checkbox {
transform: translateY(50%) scale(1.2); transform: translateY(50%) scale(1.2);
} }
} }
#asset_list_wrapper {
padding: 0 1.5rem;
}
.listed-asset { .listed-asset {
border-radius: 0; border-radius: 0;
border-bottom: solid thin rgba(var(--text-color), 0.1); border-bottom: solid thin rgba(var(--text-color), 0.1);
} }
#exchange {
margin: 0;
padding: 0;
}
#chart_header {
padding: 1rem 1.5rem 0.5rem 1.5rem;
margin-left: -0.7rem;
}
#trade_panel_backdrop {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 100%;
background-color: rgba(var(--text-color), 0.16);
backdrop-filter: blur(0.5rem);
z-index: 3;
}
#show_trade_panel {
position: absolute;
border-radius: 2rem;
bottom: 0;
align-self: center;
margin-bottom: 1rem;
z-index: 5;
}
#trade_form {
position: fixed;
height: auto;
bottom: 0;
left: 0;
right: 0;
margin-top: auto;
width: auto;
z-index: 10;
padding: 1.5rem 1.5rem 0 1.5rem;
border-radius: 1rem 1rem 0 0;
background-color: rgba(var(--foreground-color), 1);
box-shadow: 0 -0.5rem 1rem rgba(0, 0, 0, 0.1);
}
#price_chart_container { #price_chart_container {
flex: 1; flex: 1;
} }
@ -1210,6 +1244,10 @@ sm-checkbox {
} }
#pages_container { #pages_container {
grid-area: pages; grid-area: pages;
& > * {
margin: 0 1.5rem;
padding: 2rem;
}
} }
.is-signed-in { .is-signed-in {
#exchange { #exchange {
@ -1241,7 +1279,7 @@ sm-checkbox {
position: absolute; position: absolute;
width: 0.25rem; width: 0.25rem;
border-radius: 0 0.2rem 0.2rem 0; border-radius: 0 0.2rem 0.2rem 0;
height: 50%; height: 2rem;
background-color: var(--accent-color); background-color: var(--accent-color);
} }
} }
@ -1292,9 +1330,6 @@ sm-checkbox {
gap: 1.5rem; gap: 1.5rem;
grid-template-columns: minmax(0, 1fr) 20rem; grid-template-columns: minmax(0, 1fr) 20rem;
} }
#asset_page__nav {
grid-column: 1/-1;
}
#portfolio { #portfolio {
gap: 1rem 2rem; gap: 1rem 2rem;
grid-template-columns: 20rem 24rem; grid-template-columns: 20rem 24rem;

View File

@ -120,22 +120,18 @@
<ul id="listed_assets" class="user-content hide"></ul> <ul id="listed_assets" class="user-content hide"></ul>
</div> </div>
<div id="asset_page" class="hide-on-mobile"> <div id="asset_page" class="hide-on-mobile">
<nav id="asset_page__nav" class="hide-on-desktop"> <div id="price_chart_container" class="flex direction-column gap-0-5">
<a href="#/exchange" class="button icon-only"> <div id="chart_header" class="flex align-center space-between">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" <div class="flex align-center">
width="24px" fill="#000000"> <a href="#/exchange" class="button icon-only hide-on-desktop flex align-center">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px"
viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" /> <path d="M0 0h24v24H0V0z" fill="none" />
<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /> <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
</svg> </svg>
</a> </a>
<strip-select id="trading_view_switcher">
<strip-option value="trade" selected>Trade</strip-option>
<strip-option value="chart">Chart</strip-option>
</strip-select>
</nav>
<div id="price_chart_container" class="flex direction-column gap-0-5 hide-on-mobile">
<div id="chart_header" class="flex align-center space-between">
<H4 id="chart_asset"></H4> <H4 id="chart_asset"></H4>
</div>
<strip-select id="price_duration_selector"> <strip-select id="price_duration_selector">
<strip-option value="hour" title="1 Hour price interval" selected>Hour <strip-option value="hour" title="1 Hour price interval" selected>Hour
</strip-option> </strip-option>
@ -146,7 +142,16 @@
<div id="price_history_chart"></div> <div id="price_history_chart"></div>
</div> </div>
</div> </div>
<sm-form id="trade_form"> <sm-form id="trade_form" class="hide-on-mobile">
<button class="popup__header__close hide-on-desktop" style="margin-right: auto;"
onclick="hideTradePanel()">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24"
height="24">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z" />
</svg>
</button>
<div class="flex space-between align-center"> <div class="flex space-between align-center">
<h4 id="traded_asset">Trade FLO</h4> <h4 id="traded_asset">Trade FLO</h4>
<strip-select id="trade_type_selector" class="tab"> <strip-select id="trade_type_selector" class="tab">
@ -194,6 +199,9 @@
</sm-button> </sm-button>
</div> </div>
</sm-form> </sm-form>
<div id="trade_panel_backdrop" onclick="hideTradePanel()" class="hide-on-mobile"></div>
<button id="show_trade_panel" class="button button--primary hide-on-desktop cta"
onclick="showTradePanel()">Buy / Sell</button>
</div> </div>
</section> </section>
</div> </div>
@ -1778,16 +1786,44 @@
} }
document.addEventListener('themechange', setChartTheme) document.addEventListener('themechange', setChartTheme)
function showTradePanel() {
getRef('trading_view_switcher').addEventListener('change', e => {
if (e.target.value === 'trade') {
getRef('price_chart_container').classList.add('hide-on-mobile')
getRef('trade_form').classList.remove('hide-on-mobile') getRef('trade_form').classList.remove('hide-on-mobile')
} else { getRef('trade_form').animate([
getRef('trade_form').classList.add('hide-on-mobile') { transform: 'translateY(100%)' },
getRef('price_chart_container').classList.remove('hide-on-mobile') { transform: 'translateY(0)' },
} ], {
duration: 150,
easing: 'ease'
}) })
getRef('trade_panel_backdrop').classList.remove('hide-on-mobile')
getRef('trade_panel_backdrop').animate([
{ opacity: 0 },
{ opacity: 1 },
], {
duration: 150,
easing: 'ease'
})
}
function hideTradePanel() {
getRef('trade_form').animate([
{ transform: 'translateY(0)' },
{ transform: 'translateY(100%)' },
], {
duration: 150,
easing: 'ease'
}).onfinish = () => {
getRef('trade_form').classList.add('hide-on-mobile')
}
getRef('trade_panel_backdrop').animate([
{ opacity: 1 },
{ opacity: 0 },
], {
duration: 150,
easing: 'ease'
}).onfinish = () => {
getRef('trade_panel_backdrop').classList.add('hide-on-mobile')
}
}
function updateTooltip(asset, tradeType) { function updateTooltip(asset, tradeType) {
getRef('quantity_selector').querySelectorAll('.button').forEach(button => { getRef('quantity_selector').querySelectorAll('.button').forEach(button => {