Feature and UX improvements

Added -
Landing, sign in and sign up pages
This commit is contained in:
sairaj mote 2021-12-22 19:47:34 +05:30
parent ae4e6116d5
commit 18d9de223f
5 changed files with 396 additions and 85 deletions

View File

@ -3591,12 +3591,14 @@ textField.innerHTML = `
.editable{
border-bottom: 0.15rem solid rgba(var(--text-color), 0.6);
}
.icon-container{
.edit-button{
display: grid;
position: relative;
margin-left: 0.5rem;
background-color: transparent;
border: none;
}
:host([disabled]) .icon-container{
:host([disabled]) .edit-button{
display: none;
}
.icon{
@ -3607,15 +3609,15 @@ textField.innerHTML = `
fill: rgba(var(--text-color), 1);
}
.hide{
display: none;
visibility: hidden;
}
</style>
<div class="text-field">
<div class="text" part="text"></div>
<div tabindex="0" class="icon-container">
<svg class="edit-button icon" title="edit" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
<svg class="save-button icon hide" title="Save" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>
</div>
<button class="edit-button">
<svg class="icon" title="edit" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
<svg class="icon hide" title="Save" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>
</button>
</div>
`
@ -3630,13 +3632,13 @@ customElements.define('text-field', class extends HTMLElement {
this.textContainer = this.textField.children[0]
this.iconsContainer = this.textField.children[1]
this.editButton = this.textField.querySelector('.edit-button')
this.saveButton = this.textField.querySelector('.save-button')
this.isTextEditable = false
this.isDisabled = false
this.fireEvent = this.fireEvent.bind(this)
this.setEditable = this.setEditable.bind(this)
this.setNonEditable = this.setNonEditable.bind(this)
this.toggleEditable = this.toggleEditable.bind(this)
this.revert = this.revert.bind(this)
}
@ -3675,12 +3677,12 @@ customElements.define('text-field', class extends HTMLElement {
this.textContainer.classList.add('editable')
this.textContainer.focus()
document.execCommand('selectAll', false, null);
this.editButton.animate(this.rotateOut, this.animOptions).onfinish = () => {
this.editButton.classList.add('hide')
this.editButton.children[0].animate(this.rotateOut, this.animOptions).onfinish = () => {
this.editButton.children[0].classList.add('hide')
}
setTimeout(() => {
this.saveButton.classList.remove('hide')
this.saveButton.animate(this.rotateIn, this.animOptions)
this.editButton.children[1].classList.remove('hide')
this.editButton.children[1].animate(this.rotateIn, this.animOptions)
}, 100);
this.isTextEditable = true
}
@ -3696,15 +3698,21 @@ customElements.define('text-field', class extends HTMLElement {
} else {
this.value = this.text
}
this.saveButton.animate(this.rotateOut, this.animOptions).onfinish = () => {
this.saveButton.classList.add('hide')
this.editButton.children[1].animate(this.rotateOut, this.animOptions).onfinish = () => {
this.editButton.children[1].classList.add('hide')
}
setTimeout(() => {
this.editButton.classList.remove('hide')
this.editButton.animate(this.rotateIn, this.animOptions)
this.editButton.children[0].classList.remove('hide')
this.editButton.children[0].animate(this.rotateIn, this.animOptions)
}, 100);
this.isTextEditable = false
}
toggleEditable() {
if (this.isTextEditable)
this.setNonEditable()
else
this.setEditable()
}
revert() {
if (this.textContainer.isContentEditable) {
@ -3752,22 +3760,19 @@ customElements.define('text-field', class extends HTMLElement {
if (!this.isDisabled) {
this.iconsContainer.classList.remove('hide')
this.textContainer.addEventListener('dblclick', this.setEditable)
this.editButton.addEventListener('click', this.setEditable)
this.saveButton.addEventListener('click', this.setNonEditable)
this.editButton.addEventListener('click', this.toggleEditable)
}
}
attributeChangedCallback(name, oldValue, newValue) {
if (name === 'disabled') {
if (this.hasAttribute('disabled')) {
this.textContainer.removeEventListener('dblclick', this.setEditable)
this.editButton.removeEventListener('click', this.setEditable)
this.saveButton.removeEventListener('click', this.setNonEditable)
this.editButton.removeEventListener('click', this.toggleEditable)
this.revert()
}
else {
this.textContainer.addEventListener('dblclick', this.setEditable)
this.editButton.addEventListener('click', this.setEditable)
this.saveButton.addEventListener('click', this.setNonEditable)
this.editButton.addEventListener('click', this.toggleEditable)
}
} else if (name === 'value') {
this.text = newValue
@ -3776,8 +3781,7 @@ customElements.define('text-field', class extends HTMLElement {
}
disconnectedCallback() {
this.textContainer.removeEventListener('dblclick', this.setEditable)
this.editButton.removeEventListener('click', this.setEditable)
this.saveButton.removeEventListener('click', this.setNonEditable)
this.editButton.removeEventListener('click', this.toggleEditable)
}
})
const smMenu = document.createElement('template')

View File

@ -493,6 +493,11 @@ menu-option {
font-size: 0.9rem;
}
sm-copy {
font-size: 0.9rem;
--button-border-radius: 0.2rem;
}
.warning {
background-color: khaki;
color: rgba(0, 0, 0, 0.7);
@ -501,6 +506,10 @@ menu-option {
line-height: 1.5;
}
.page {
height: 100%;
}
.page-layout,
#preview_page {
display: grid;
@ -511,6 +520,65 @@ menu-option {
grid-column: 2/3;
}
#landing {
grid-template-rows: auto 1fr;
}
#landing header {
padding: 1.5rem 0;
}
#landing > section {
-webkit-box-align: start;
-ms-flex-align: start;
align-items: flex-start;
margin-top: 6rem;
height: 100%;
text-align: center;
}
#sign_in,
#sign_up {
grid-template-rows: auto 1fr;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#sign_in section,
#sign_up section {
margin-top: -6rem;
justify-self: center;
width: min(24rem, 100%);
}
#sign_in sm-form,
#sign_up sm-form {
margin: 2rem 0;
}
#sign_in header,
#sign_up header {
padding: 1.5rem 0;
}
#sign_up .h2 {
margin-bottom: 0.5rem;
}
#sign_up .card {
margin: 1.5rem 0;
}
#sign_up h5 {
font-weight: 500;
color: rgba(var(--text-color), 0.8);
}
#sign_up .warning {
margin-top: 2rem;
}
#loading {
place-content: center;
text-align: center;
}
#loading sm-spinner {
margin-bottom: 1.5rem;
}
#main_header {
position: sticky;
top: 0;
@ -823,10 +891,11 @@ menu-option {
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
position: absolute;
z-index: 1;
position: fixed;
z-index: 10;
left: 0;
top: 0;
right: 0;
bottom: 0;
-webkit-transition: -webkit-transform 0.1s;
transition: -webkit-transform 0.1s;
transition: transform 0.1s;
@ -1084,7 +1153,7 @@ menu-option {
}
.page-layout {
grid-template-columns: 1.5rem minmax(0, 1fr) 1.5rem;
grid-template-columns: 1fr 90vw 1fr;
}
.hide-on-desktop {
@ -1151,6 +1220,15 @@ menu-option {
right: 0;
bottom: 100%;
}
#text_toolbar {
position: absolute;
z-index: 1;
left: 0;
top: 0;
right: auto;
bottom: auto;
}
}
@media (any-hover: hover) {
::-webkit-scrollbar {

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -428,6 +428,10 @@ sm-menu {
menu-option {
font-size: 0.9rem;
}
sm-copy {
font-size: 0.9rem;
--button-border-radius: 0.2rem;
}
.warning {
background-color: khaki;
color: rgba(0, 0, 0, 0.7);
@ -435,6 +439,9 @@ menu-option {
border-radius: 0.5rem;
line-height: 1.5;
}
.page{
height: 100%;
}
.page-layout,
#preview_page {
display: grid;
@ -443,6 +450,57 @@ menu-option {
grid-column: 2/3;
}
}
#landing {
grid-template-rows: auto 1fr;
header {
padding: 1.5rem 0;
}
& > section {
align-items: flex-start;
margin-top: 6rem;
height: 100%;
text-align: center;
}
}
#sign_in,
#sign_up {
grid-template-rows: auto 1fr;
align-items: center;
section{
margin-top: -6rem;
justify-self: center;
width: min(24rem, 100%);
}
sm-form {
margin: 2rem 0;
}
header {
padding: 1.5rem 0;
}
}
#sign_up {
.h2 {
margin-bottom: 0.5rem;
}
.card {
margin: 1.5rem 0;
}
h5 {
font-weight: 500;
color: rgba(var(--text-color), 0.8);
}
.warning {
margin-top: 2rem;
}
}
#loading {
place-content: center;
text-align: center;
sm-spinner {
margin-bottom: 1.5rem;
}
}
#main_header {
position: sticky;
@ -712,10 +770,11 @@ menu-option {
}
#text_toolbar {
user-select: none;
position: absolute;
z-index: 1;
position: fixed;
z-index: 10;
left: 0;
top: 0;
right: 0;
bottom: 0;
transition: transform 0.1s;
background-color: var(--foreground-color);
border: solid thin rgba(var(--text-color), 0.2);
@ -944,7 +1003,7 @@ menu-option {
--width: 24rem;
}
.page-layout {
grid-template-columns: 1.5rem minmax(0, 1fr) 1.5rem;
grid-template-columns: 1fr 90vw 1fr;
}
.hide-on-desktop {
display: none;
@ -1002,6 +1061,14 @@ menu-option {
right: 0;
bottom: 100%;
}
#text_toolbar {
position: absolute;
z-index: 1;
left: 0;
top: 0;
right: auto;
bottom: auto;
}
}
@media (any-hover: hover) {
::-webkit-scrollbar {

View File

@ -59,7 +59,94 @@
<sm-button variant="no-outline" class="submit-btn">OK</sm-button>
</div>
</sm-popup>
<article id="main_page" class="grid page">
<article id="landing" class="page page-layout hide-completely">
<header class="flex space-between">
<div class="logo">
<svg class="main-logo" viewBox="0 0 27.25 32">
<title>RanchiMall</title>
<path
d="M27.14,30.86c-.74-2.48-3-4.36-8.25-6.94a20,20,0,0,1-4.2-2.49,6,6,0,0,1-1.25-1.67,4,4,0,0,1,0-2.26c.37-1.08.79-1.57,3.89-4.55a11.66,11.66,0,0,0,3.34-4.67,6.54,6.54,0,0,0,.05-2.82C20,3.6,18.58,2,16.16.49c-.89-.56-1.29-.64-1.3-.24a3,3,0,0,1-.3.72l-.3.55L13.42.94C13,.62,12.4.26,12.19.15c-.4-.2-.73-.18-.72.05a9.39,9.39,0,0,1-.61,1.33s-.14,0-.27-.13C8.76.09,8-.27,8,.23A11.73,11.73,0,0,1,6.76,2.6C4.81,5.87,2.83,7.49.77,7.49c-.89,0-.88,0-.61,1,.22.85.33.92,1.09.69A5.29,5.29,0,0,0,3,8.33c.23-.17.45-.29.49-.26a2,2,0,0,1,.22.63A1.31,1.31,0,0,0,4,9.34a5.62,5.62,0,0,0,2.27-.87L7,8l.13.55c.19.74.32.82,1,.65a7.06,7.06,0,0,0,3.46-2.47l.6-.71-.06.64c-.17,1.63-1.3,3.42-3.39,5.42L6.73,14c-3.21,3.06-3,5.59.6,8a46.77,46.77,0,0,0,4.6,2.41c.28.13,1,.52,1.59.87,3.31,2,4.95,3.92,4.95,5.93a2.49,2.49,0,0,0,.07.77h0c.09.09,0,.1.9-.14a2.61,2.61,0,0,0,.83-.32,3.69,3.69,0,0,0-.55-1.83A11.14,11.14,0,0,0,17,26.81a35.7,35.7,0,0,0-5.1-2.91C9.37,22.64,8.38,22,7.52,21.17a3.53,3.53,0,0,1-1.18-2.48c0-1.38.71-2.58,2.5-4.23,2.84-2.6,3.92-3.91,4.67-5.65a3.64,3.64,0,0,0,.42-2A3.37,3.37,0,0,0,13.61,5l-.32-.74.29-.48c.17-.27.37-.63.46-.8l.15-.3.44.64a5.92,5.92,0,0,1,1,2.81,5.86,5.86,0,0,1-.42,1.94c0,.12-.12.3-.15.4a9.49,9.49,0,0,1-.67,1.1,28,28,0,0,1-4,4.29C8.62,15.49,8.05,16.44,8,17.78a3.28,3.28,0,0,0,1.11,2.76c.95,1,2.07,1.74,5.25,3.32,3.64,1.82,5.22,2.9,6.41,4.38A4.78,4.78,0,0,1,21.94,31a3.21,3.21,0,0,0,.14.92,1.06,1.06,0,0,0,.43-.05l.83-.22.46-.12-.06-.46c-.21-1.53-1.62-3.25-3.94-4.8a37.57,37.57,0,0,0-5.22-2.82A13.36,13.36,0,0,1,11,21.19a3.36,3.36,0,0,1-.8-4.19c.41-.85.83-1.31,3.77-4.15,2.39-2.31,3.43-4.13,3.43-6a5.85,5.85,0,0,0-2.08-4.29c-.23-.21-.44-.43-.65-.65A2.5,2.5,0,0,1,15.27.69a10.6,10.6,0,0,1,2.91,2.78A4.16,4.16,0,0,1,19,6.16a4.91,4.91,0,0,1-.87,3c-.71,1.22-1.26,1.82-4.27,4.67a9.47,9.47,0,0,0-2.07,2.6,2.76,2.76,0,0,0-.33,1.54,2.76,2.76,0,0,0,.29,1.47c.57,1.21,2.23,2.55,4.65,3.73a32.41,32.41,0,0,1,5.82,3.24c2.16,1.6,3.2,3.16,3.2,4.8a1.94,1.94,0,0,0,.09.76,4.54,4.54,0,0,0,1.66-.4C27.29,31.42,27.29,31.37,27.14,30.86ZM6.1,7h0a3.77,3.77,0,0,1-1.46.45L4,7.51l.68-.83a25.09,25.09,0,0,0,3-4.82A12,12,0,0,1,8.28.76c.11-.12.77.32,1.53,1l.63.58-.57.84A10.34,10.34,0,0,1,6.1,7Zm5.71-1.78A9.77,9.77,0,0,1,9.24,7.18h0a5.25,5.25,0,0,1-1.17.28l-.58,0,.65-.78a21.29,21.29,0,0,0,2.1-3.12c.22-.41.42-.76.44-.79s.5.43.9,1.24L12,5ZM13.41,3a2.84,2.84,0,0,1-.45.64,11,11,0,0,1-.9-.91l-.84-.9.19-.45c.34-.79.39-.8,1-.31A9.4,9.4,0,0,1,13.8,2.33q-.18.34-.39.69Z" />
</svg>
<div class="grid">
<h4>RanchiMall CC</h4>
</div>
</div>
<div class="flex gap-0-5">
<a href="#/sign_up" class="button">Sign up</a>
<a href="#/sign_in" class="button button--primary">Sign in</a>
</div>
</header>
<section class="grid justify-center">
<div class="grid gap-0-5">
<h1 class="h1">Create. Collaborate. <br>Publish.</h1>
<p>Write content with collaboration </p>
</div>
</section>
</article>
<article id="sign_in" class="page page-layout hide-completely">
<header>
<div class="logo">
<svg class="main-logo" viewBox="0 0 27.25 32">
<title>RanchiMall</title>
<path
d="M27.14,30.86c-.74-2.48-3-4.36-8.25-6.94a20,20,0,0,1-4.2-2.49,6,6,0,0,1-1.25-1.67,4,4,0,0,1,0-2.26c.37-1.08.79-1.57,3.89-4.55a11.66,11.66,0,0,0,3.34-4.67,6.54,6.54,0,0,0,.05-2.82C20,3.6,18.58,2,16.16.49c-.89-.56-1.29-.64-1.3-.24a3,3,0,0,1-.3.72l-.3.55L13.42.94C13,.62,12.4.26,12.19.15c-.4-.2-.73-.18-.72.05a9.39,9.39,0,0,1-.61,1.33s-.14,0-.27-.13C8.76.09,8-.27,8,.23A11.73,11.73,0,0,1,6.76,2.6C4.81,5.87,2.83,7.49.77,7.49c-.89,0-.88,0-.61,1,.22.85.33.92,1.09.69A5.29,5.29,0,0,0,3,8.33c.23-.17.45-.29.49-.26a2,2,0,0,1,.22.63A1.31,1.31,0,0,0,4,9.34a5.62,5.62,0,0,0,2.27-.87L7,8l.13.55c.19.74.32.82,1,.65a7.06,7.06,0,0,0,3.46-2.47l.6-.71-.06.64c-.17,1.63-1.3,3.42-3.39,5.42L6.73,14c-3.21,3.06-3,5.59.6,8a46.77,46.77,0,0,0,4.6,2.41c.28.13,1,.52,1.59.87,3.31,2,4.95,3.92,4.95,5.93a2.49,2.49,0,0,0,.07.77h0c.09.09,0,.1.9-.14a2.61,2.61,0,0,0,.83-.32,3.69,3.69,0,0,0-.55-1.83A11.14,11.14,0,0,0,17,26.81a35.7,35.7,0,0,0-5.1-2.91C9.37,22.64,8.38,22,7.52,21.17a3.53,3.53,0,0,1-1.18-2.48c0-1.38.71-2.58,2.5-4.23,2.84-2.6,3.92-3.91,4.67-5.65a3.64,3.64,0,0,0,.42-2A3.37,3.37,0,0,0,13.61,5l-.32-.74.29-.48c.17-.27.37-.63.46-.8l.15-.3.44.64a5.92,5.92,0,0,1,1,2.81,5.86,5.86,0,0,1-.42,1.94c0,.12-.12.3-.15.4a9.49,9.49,0,0,1-.67,1.1,28,28,0,0,1-4,4.29C8.62,15.49,8.05,16.44,8,17.78a3.28,3.28,0,0,0,1.11,2.76c.95,1,2.07,1.74,5.25,3.32,3.64,1.82,5.22,2.9,6.41,4.38A4.78,4.78,0,0,1,21.94,31a3.21,3.21,0,0,0,.14.92,1.06,1.06,0,0,0,.43-.05l.83-.22.46-.12-.06-.46c-.21-1.53-1.62-3.25-3.94-4.8a37.57,37.57,0,0,0-5.22-2.82A13.36,13.36,0,0,1,11,21.19a3.36,3.36,0,0,1-.8-4.19c.41-.85.83-1.31,3.77-4.15,2.39-2.31,3.43-4.13,3.43-6a5.85,5.85,0,0,0-2.08-4.29c-.23-.21-.44-.43-.65-.65A2.5,2.5,0,0,1,15.27.69a10.6,10.6,0,0,1,2.91,2.78A4.16,4.16,0,0,1,19,6.16a4.91,4.91,0,0,1-.87,3c-.71,1.22-1.26,1.82-4.27,4.67a9.47,9.47,0,0,0-2.07,2.6,2.76,2.76,0,0,0-.33,1.54,2.76,2.76,0,0,0,.29,1.47c.57,1.21,2.23,2.55,4.65,3.73a32.41,32.41,0,0,1,5.82,3.24c2.16,1.6,3.2,3.16,3.2,4.8a1.94,1.94,0,0,0,.09.76,4.54,4.54,0,0,0,1.66-.4C27.29,31.42,27.29,31.37,27.14,30.86ZM6.1,7h0a3.77,3.77,0,0,1-1.46.45L4,7.51l.68-.83a25.09,25.09,0,0,0,3-4.82A12,12,0,0,1,8.28.76c.11-.12.77.32,1.53,1l.63.58-.57.84A10.34,10.34,0,0,1,6.1,7Zm5.71-1.78A9.77,9.77,0,0,1,9.24,7.18h0a5.25,5.25,0,0,1-1.17.28l-.58,0,.65-.78a21.29,21.29,0,0,0,2.1-3.12c.22-.41.42-.76.44-.79s.5.43.9,1.24L12,5ZM13.41,3a2.84,2.84,0,0,1-.45.64,11,11,0,0,1-.9-.91l-.84-.9.19-.45c.34-.79.39-.8,1-.31A9.4,9.4,0,0,1,13.8,2.33q-.18.34-.39.69Z" />
</svg>
<div class="grid">
<h4>RanchiMall CC</h4>
</div>
</div>
</header>
<section>
<h1 class="h2">Sign In</h1>
<p>Welcome back, glad to see you again</p>
<sm-form>
<sm-input id="private_key_field" type="password" placeholder="FLO private key"
error-text="Private key is invalid" data-private-key required></sm-input>
<sm-button id="sign_in_button" variant="primary" disabled>Sign In</sm-button>
</sm-form>
<p>
New here? <a href="#/sign_up">get your FLO login credentials</a>
</p>
</section>
</article>
<article id="sign_up" class="page page-layout hide-completely">
<header>
<div class="logo">
<svg class="main-logo" viewBox="0 0 27.25 32">
<title>RanchiMall</title>
<path
d="M27.14,30.86c-.74-2.48-3-4.36-8.25-6.94a20,20,0,0,1-4.2-2.49,6,6,0,0,1-1.25-1.67,4,4,0,0,1,0-2.26c.37-1.08.79-1.57,3.89-4.55a11.66,11.66,0,0,0,3.34-4.67,6.54,6.54,0,0,0,.05-2.82C20,3.6,18.58,2,16.16.49c-.89-.56-1.29-.64-1.3-.24a3,3,0,0,1-.3.72l-.3.55L13.42.94C13,.62,12.4.26,12.19.15c-.4-.2-.73-.18-.72.05a9.39,9.39,0,0,1-.61,1.33s-.14,0-.27-.13C8.76.09,8-.27,8,.23A11.73,11.73,0,0,1,6.76,2.6C4.81,5.87,2.83,7.49.77,7.49c-.89,0-.88,0-.61,1,.22.85.33.92,1.09.69A5.29,5.29,0,0,0,3,8.33c.23-.17.45-.29.49-.26a2,2,0,0,1,.22.63A1.31,1.31,0,0,0,4,9.34a5.62,5.62,0,0,0,2.27-.87L7,8l.13.55c.19.74.32.82,1,.65a7.06,7.06,0,0,0,3.46-2.47l.6-.71-.06.64c-.17,1.63-1.3,3.42-3.39,5.42L6.73,14c-3.21,3.06-3,5.59.6,8a46.77,46.77,0,0,0,4.6,2.41c.28.13,1,.52,1.59.87,3.31,2,4.95,3.92,4.95,5.93a2.49,2.49,0,0,0,.07.77h0c.09.09,0,.1.9-.14a2.61,2.61,0,0,0,.83-.32,3.69,3.69,0,0,0-.55-1.83A11.14,11.14,0,0,0,17,26.81a35.7,35.7,0,0,0-5.1-2.91C9.37,22.64,8.38,22,7.52,21.17a3.53,3.53,0,0,1-1.18-2.48c0-1.38.71-2.58,2.5-4.23,2.84-2.6,3.92-3.91,4.67-5.65a3.64,3.64,0,0,0,.42-2A3.37,3.37,0,0,0,13.61,5l-.32-.74.29-.48c.17-.27.37-.63.46-.8l.15-.3.44.64a5.92,5.92,0,0,1,1,2.81,5.86,5.86,0,0,1-.42,1.94c0,.12-.12.3-.15.4a9.49,9.49,0,0,1-.67,1.1,28,28,0,0,1-4,4.29C8.62,15.49,8.05,16.44,8,17.78a3.28,3.28,0,0,0,1.11,2.76c.95,1,2.07,1.74,5.25,3.32,3.64,1.82,5.22,2.9,6.41,4.38A4.78,4.78,0,0,1,21.94,31a3.21,3.21,0,0,0,.14.92,1.06,1.06,0,0,0,.43-.05l.83-.22.46-.12-.06-.46c-.21-1.53-1.62-3.25-3.94-4.8a37.57,37.57,0,0,0-5.22-2.82A13.36,13.36,0,0,1,11,21.19a3.36,3.36,0,0,1-.8-4.19c.41-.85.83-1.31,3.77-4.15,2.39-2.31,3.43-4.13,3.43-6a5.85,5.85,0,0,0-2.08-4.29c-.23-.21-.44-.43-.65-.65A2.5,2.5,0,0,1,15.27.69a10.6,10.6,0,0,1,2.91,2.78A4.16,4.16,0,0,1,19,6.16a4.91,4.91,0,0,1-.87,3c-.71,1.22-1.26,1.82-4.27,4.67a9.47,9.47,0,0,0-2.07,2.6,2.76,2.76,0,0,0-.33,1.54,2.76,2.76,0,0,0,.29,1.47c.57,1.21,2.23,2.55,4.65,3.73a32.41,32.41,0,0,1,5.82,3.24c2.16,1.6,3.2,3.16,3.2,4.8a1.94,1.94,0,0,0,.09.76,4.54,4.54,0,0,0,1.66-.4C27.29,31.42,27.29,31.37,27.14,30.86ZM6.1,7h0a3.77,3.77,0,0,1-1.46.45L4,7.51l.68-.83a25.09,25.09,0,0,0,3-4.82A12,12,0,0,1,8.28.76c.11-.12.77.32,1.53,1l.63.58-.57.84A10.34,10.34,0,0,1,6.1,7Zm5.71-1.78A9.77,9.77,0,0,1,9.24,7.18h0a5.25,5.25,0,0,1-1.17.28l-.58,0,.65-.78a21.29,21.29,0,0,0,2.1-3.12c.22-.41.42-.76.44-.79s.5.43.9,1.24L12,5ZM13.41,3a2.84,2.84,0,0,1-.45.64,11,11,0,0,1-.9-.91l-.84-.9.19-.45c.34-.79.39-.8,1-.31A9.4,9.4,0,0,1,13.8,2.33q-.18.34-.39.69Z" />
</svg>
<div class="grid">
<h4>RanchiMall CC</h4>
</div>
</div>
</header>
<section class="grid">
<h1 class="h2">FLO credentials</h1>
<p>Get your FLO credentials to use RanchiMall CC and all RanchiMall FLO apps. </p>
<div class="grid gap-1-5 card">
<div class="grid gap-0-5">
<h5>FLO ID</h5>
<sm-copy id="generated_flo_id"></sm-copy>
</div>
<div class="grid gap-0-5">
<h5>Private key</h5>
<sm-copy id="generated_private_key"></sm-copy>
</div>
</div>
<sm-button id="sign_up_button" variant="primary">Sign in with these credentials</sm-button>
<strong class="warning">
Keep your private key secure and don't share with anyone.
Once lost there is no way to recover private key.
</strong>
</section>
</article>
<article id="loading" class="page page-layout">
<sm-spinner></sm-spinner>
<h4>Loading RanchiMall CC</h4>
</article>
<article id="main_page" class="grid page hide-completely">
<header id="main_header">
<div class="logo">
<svg class="main-logo" viewBox="0 0 27.25 32">
@ -482,6 +569,27 @@
<sm-button variant="primary" onclick="publishArticle()">Request publishing</sm-button>
</sm-form>
</sm-popup>
<sm-popup id="user_popup">
<header slot="header" class="popup__header">
<div class="flex align-center">
<button class="popup__header__close" onclick="hidePopup()">
<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="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
</svg>
</button>
</div>
</header>
<section class="grid gap-1-5">
<div class="grid gap-0-5">
<h5>My FLO ID</h5>
<sm-copy id="user_flo_id"></sm-copy>
</div>
<sm-button class="danger" onclick="signOut()">Sign out</sm-button>
</section>
</sm-popup>
<template id="contributor_template">
<div class="contributor grid">
<svg class="icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
@ -818,7 +926,7 @@
if (typeof myFloID === "undefined") {
pageId = 'landing'
} else {
pageId = 'home'
pageId = 'main_page'
}
} else {
if (targetPage.includes('/')) {
@ -837,6 +945,7 @@
pageId = targetPage
}
}
if (typeof myFloID === "undefined" && !(['sign_up', 'sign_in', 'loading', 'landing'].includes(pageId))) return
if (searchParams) {
const urlSearchParams = new URLSearchParams('?' + searchParams);
params = Object.fromEntries(urlSearchParams.entries());
@ -850,6 +959,21 @@
])
}
switch (pageId) {
case 'landing':
targetPage = 'landing'
break;
case 'sign_in':
setTimeout(() => {
getRef('private_key_field').focusIn()
}, 0);
targetPage = 'sign_in'
break;
case 'sign_up':
const { floID, privKey } = floCrypto.generateNewID()
getRef('generated_flo_id').value = floID
getRef('generated_private_key').value = privKey
targetPage = 'sign_up'
break;
case 'home':
case 'main_page':
if (!floGlobals.currentArticle.id || params.articleID !== pagesData.params.articleID) {
@ -869,7 +993,6 @@
targetPage = 'preview_page'
break
}
document.querySelectorAll('.page').forEach(page => page.classList.add('hide-completely'))
getRef(targetPage).classList.remove('hide-completely')
if (pagesData.lastPage !== pageId) {
@ -1132,13 +1255,11 @@
const contentArea = contentCard.querySelector('.content__area')
const uid = contentCard.dataset.uid
const isUniqueEntry = contentArea.dataset.type === 'origin'
contentArea.querySelectorAll('[style=""]').forEach((el) => {
el.removeAttribute('style')
})
const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v));
if (clean === '' || clean === '<p><br></p>') {
if (contentArea.textContent.trim() === '') {
contentCard.querySelector('.submit-entry').classList.add('hide-completely')
} else {
const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'] })
.replace(/b>/gi, 'strong>').replace(/i>/gi, 'em>')
const hash = Crypto.SHA256(clean)
let previousHash
if (!isUniqueEntry) {
@ -1167,16 +1288,13 @@
const isUniqueEntry = contentArea.dataset.type === 'origin'
const parentSection = contentCard.closest('.article-section')
const sectionID = parentSection.dataset.sectionId
contentArea.querySelectorAll('[style=""]').forEach((el) => {
el.removeAttribute('style')
})
const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'));
const clean = DOMPurify.sanitize(contentArea.innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'] })
.replace(/b>/gi, 'strong>').replace(/i>/gi, 'em>')
if (clean === '') return
const hash = Crypto.SHA256(clean)
let previousVersion, previousHash
if (!isUniqueEntry) {
({ data: previousVersion, hash: previousHash = '' } = getIterationDetails(uid))
({ data: previousVersion, hash: previousHash = '', contributors } = getIterationDetails(uid))
} else {
previousHash = ''
}
@ -1233,6 +1351,15 @@
parentSection.append(newCard)
}
} else {
let noOfContributors = 0
for (const contributor in contributors) {
noOfContributors++
if (noOfContributors === 2)
break
}
if (noOfContributors < 2) {
contentCard.querySelector('.content__author').textContent = `2 Contributors`
}
floGlobals.currentArticle.uniqueEntries[entry.origin].iterations.push(iterationData)
}
})
@ -1268,7 +1395,7 @@
const sectionID = target.parentNode.dataset.sectionId
if (floGlobals.currentArticle.sections[sectionID].expanded) {
target.textContent = `See ${floGlobals.currentArticle.sections[sectionID].uniqueEntries.length - maxCardsPerSection} more`;
[...target.parentNode.nextElementSibling.children].slice(maxCardsPerSection + 1).forEach(card => {
[...target.parentNode.nextElementSibling.children].slice(3).forEach(card => {
card.querySelector('sm-checkbox').checked = false
card.remove()
})
@ -1307,7 +1434,8 @@
selectedContent.delete(contentID)
} else {
const sectionID = contentCard.closest('.article-section').dataset.sectionId
const content = DOMPurify.sanitize(contentCard.querySelector('.content__area').innerHTML)
const content = DOMPurify.sanitize(contentCard.querySelector('.content__area').innerHTML.split('\n').map(v => v.trim()).filter(v => v).join('\n'), { FORBID_ATTR: ['style'] })
.replace(/b>/gi, 'strong>').replace(/i>/gi, 'em>')
selectedContent.set(contentID, { content, sectionID })
}
const animOptions = {
@ -1462,14 +1590,14 @@
const headHTML = createElement('div')
headHTML.append(headTemplate)
const finalMarkup = `
<!DOCTYPE html>
<html lang="en">
<head>${headHTML.innerHTML}<\/head>
<body data-theme="light" ${bodyAttributes}>
${bodyHTML.innerHTML}
${extraScripts}
<\/body>
<\/html>
<!DOCTYPE html>
<html lang="en">
<head>${headHTML.innerHTML}<\/head>
<body data-theme="light" ${bodyAttributes}>
${bodyHTML.innerHTML}
${extraScripts}
<\/body>
<\/html>
`
downloadHTML(finalMarkup, { title: articleTitle })
}
@ -1478,7 +1606,7 @@
}
function sharePreview() {
if (isSubAdmin) {
if (floGlobals.appObjects[pagesData.params.articleID].preview.uid) {
if (floGlobals.appObjects[pagesData.params.articleID].preview) {
floGlobals.appObjects[pagesData.params.articleID].preview.content = DOMPurify.sanitize(getRef('preview__body').innerHTML)
} else {
floGlobals.appObjects[pagesData.params.articleID].preview = {
@ -1651,23 +1779,24 @@
}
})
})
let isMobile = false
const mobileQuery = window.matchMedia('(max-width: 40rem)')
function handleMobileChange(e) {
if (e.matches) {
// Mobile view
console.log('Media Query Matched!')
isMobile = true
document.querySelectorAll('.article-section').forEach(section => {
sectionMutationObserver.observe(section, { childList: true })
})
} else {
// Desktop view
isMobile = false
sectionMutationObserver.disconnect()
sectionIntersectionObserver.disconnect()
}
}
mobileQuery.addListener(handleMobileChange)
// handleMobileChange(mobileQuery)
handleMobileChange(mobileQuery)
const render = {
article(id) {
floGlobals.currentArticle.id = id
@ -1792,7 +1921,7 @@
textContent: `See ${floGlobals.currentArticle.sections[sectionID].uniqueEntries.length - maxCardsPerSection} more`
}))
}
if (window.innerWidth < 640)
if (isMobile)
sectionMutationObserver.observe(section.querySelector('.article-section'), { childList: true })
section.querySelector('.article-section').append(frag)
headingIntersectionObserver.observe(section.children[1])
@ -2144,15 +2273,21 @@
function manageFormattingOptions() {
const selection = window.getSelection();
if (selection.isCollapsed && selection.focusNode.textContent.trim() !== '') {
if (selection.isCollapsed) {
getRef('text_toolbar').classList.add('hide-completely')
document.querySelectorAll('.formatting-button').forEach(elem => elem.classList.remove('active'))
} else {
getRef('create_link_href').value = ''
const pos = selection.isCollapsed ? selection.anchorNode.getBoundingClientRect() : selection.getRangeAt(0).getBoundingClientRect()
getRef('text_toolbar').style.transform = `translate(${pos.left}px, calc(${pos.bottom + window.pageYOffset}px + 1rem))`
getRef('text_toolbar').classList.remove('hide-completely')
getRef('text_toolbar').style.transform = `translate(${pos.left}px, calc(${pos.bottom + window.pageYOffset}px + 0.3rem))`
if (isMobile) {
getRef('text_toolbar').classList.remove('hide-completely')
getRef('text_toolbar').style.transform = `none`
} else {
const pos = selection.getRangeAt(0).getBoundingClientRect()
const leftOffset = pos.left + 200 < window.innerWidth ? pos.left : pos.left - 220 + window.innerWidth - pos.left
getRef('text_toolbar').style.transform = `translate(${leftOffset}px, calc(${pos.bottom + window.pageYOffset}px + 1rem))`
getRef('text_toolbar').classList.remove('hide-completely')
getRef('text_toolbar').style.transform = `translate(${leftOffset}px, calc(${pos.bottom + window.pageYOffset}px + 0.3rem))`
}
getRef('formatting_options').classList.remove('hide-completely')
getRef('link_panel').classList.add('hide-completely')
}
@ -2180,10 +2315,10 @@
function saveSelection() {
if (window.getSelection) {
sel = window.getSelection();
const sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
var ranges = [];
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
const ranges = [];
for (let i = 0, len = sel.rangeCount; i < len; ++i) {
ranges.push(sel.getRangeAt(i));
}
return ranges;
@ -2196,9 +2331,9 @@
function restoreSelection(savedSel) {
if (savedSel) {
if (window.getSelection) {
sel = window.getSelection();
const sel = window.getSelection();
sel.removeAllRanges();
for (var i = 0, len = savedSel.length; i < len; ++i) {
for (let i = 0, len = savedSel.length; i < len; ++i) {
sel.addRange(savedSel[i]);
}
} else if (document.selection && savedSel.select) {
@ -2369,19 +2504,49 @@
function insertBlockquote() {
insertNode(createQuote())
}
function getSignedIn() {
return new Promise((resolve, reject) => {
if (window.location.hash.includes('sign_in') || window.location.hash.includes('sign_up')) {
showPage(window.location.hash)
} else {
showPage('landing')
}
getRef('sign_in_button').onclick = () => {
resolve(getRef('private_key_field').value.trim())
getRef('private_key_field').value = ''
showPage('loading')
}
getRef('sign_up_button').onclick = () => {
resolve(getRef('generated_private_key').value.trim())
getRef('generated_private_key').value = ''
showPage('loading')
}
})
}
function signOut() {
getConfirmation('Sign out?', 'You are about to sign out of the app, continue?', 'Stay', 'Leave')
.then(async (res) => {
if (res) {
await floDapps.clearCredentials()
location.reload()
}
})
}
</script>
<script id="onLoadStartUp">
let isSubAdmin = false
let maxCardsPerSection = isSubAdmin ? 3 : 2
let maxCardsPerSection
function onLoadStartUp() {
//floDapps.addStartUpFunction('Sample', Promised Function)
//floDapps.setAppObjectStores({sampleObs1:{}, sampleObs2:{options{autoIncrement:true, keyPath:'SampleKey'}, Indexes:{sampleIndex:{}}}})
//floDapps.setCustomPrivKeyInput( () => { FUNCTION BODY *must resolve private key* } )
floDapps.setCustomPrivKeyInput(getSignedIn)
floDapps.launchStartUp().then(async result => {
getRef('user_flo_id').value = myFloID
isSubAdmin = floGlobals.subAdmins.includes(myFloID)
maxCardsPerSection = isSubAdmin ? 3 : 2
if (isSubAdmin) {
document.querySelectorAll('.admin-option').forEach(elem => elem.classList.remove('hide-completely'))
} else {
@ -2409,11 +2574,11 @@
`}
</sm-button>
`
if (window.location.hash.includes('sign_in') || window.location.hash.includes('sign_up')) {
history.replaceState(null, null, ' ')
}
showPage(window.location.hash, { firstLoad: true })
console.log(result)
// alert(`Welcome FLO_ID: ${ myFloID }`)
//App functions....
}).catch(error => console.error(error))
}
</script>
@ -9320,7 +9485,6 @@
}
})();
</script>
<script id="floCrypto" version="2.0.1">
/* FLO Crypto Operators*/
const floCrypto = {
@ -11937,6 +12101,11 @@
color: var(--accent-color);
}
sm-copy {
font-size: 0.9rem;
--button-border-radius: 0.5rem;
}
.flex {
display: -webkit-box;
display: -ms-flexbox;
@ -12372,13 +12541,6 @@
</button>
</header>
<article class="page-layout">
<!-- <picture class="hero-image full-bleed">
<source
srcset="https://www.europeanscientist.com/wp-content/uploads/thumbs/111-27-38qkzhwijiszfu016l71fk.jpg"
media="(min-width: 800px)">
<img loading="lazy" src="https://www.europeanscientist.com/wp-content/uploads/thumbs/111-27-38qkzhwijiszfu016l71fk.jpg"
alt="" />
</picture> -->
<section class="hero-section">
<h1 id="exported_title"></h1>
<div class="flex align-center">