645 lines
32 KiB
HTML
645 lines
32 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>RanchiMall Dapps</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link
|
|
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&display=swap"
|
|
rel="stylesheet">
|
|
<link rel="stylesheet" href="css/main.min.css">
|
|
</head>
|
|
|
|
<body class="hidden">
|
|
<sm-notifications id="notification_drawer"></sm-notifications>
|
|
<header id="main_header" class="flex align-center">
|
|
<a class="flex flex-items-center gap-0-3" href="#/home">
|
|
<svg id="main_logo" class="icon" 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">
|
|
</path>
|
|
</svg>
|
|
<h4>
|
|
RanchiMall Dapps
|
|
</h4>
|
|
</a>
|
|
<theme-toggle></theme-toggle>
|
|
</header>
|
|
<main id="page_container" class="grid"></main>
|
|
<script src="scripts/components.min.js"></script>
|
|
<script src="https://unpkg.com/uhtml@3.0.1/es.js"></script>
|
|
<script>
|
|
const { html, svg, render: renderElem } = uhtml;
|
|
const uiGlobals = {}
|
|
uiGlobals.connectionErrorNotification = []
|
|
//Checks for internet connection status
|
|
if (!navigator.onLine)
|
|
uiGlobals.connectionErrorNotification.push(notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error'))
|
|
window.addEventListener('offline', () => {
|
|
uiGlobals.connectionErrorNotification.push(notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error'))
|
|
})
|
|
window.addEventListener('online', () => {
|
|
uiGlobals.connectionErrorNotification.forEach(notification => {
|
|
getRef('notification_drawer').remove(notification)
|
|
})
|
|
notify('We are back online.', 'success')
|
|
})
|
|
// Use instead of document.getElementById
|
|
function getRef(elementId) {
|
|
return document.getElementById(elementId)
|
|
}
|
|
let zIndex = 50
|
|
// function required for popups or modals to appear
|
|
function openPopup(popupId, pinned) {
|
|
if (popupStack.peek() === undefined) {
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Escape') {
|
|
closePopup()
|
|
}
|
|
})
|
|
}
|
|
zIndex++
|
|
getRef(popupId).setAttribute('style', `z-index: ${zIndex}`)
|
|
return getRef(popupId).show({ pinned })
|
|
}
|
|
|
|
// hides the popup or modal
|
|
function closePopup(options = {}) {
|
|
if (popupStack.peek() === undefined)
|
|
return;
|
|
popupStack.peek().popup.hide(options)
|
|
}
|
|
|
|
document.addEventListener('popupopened', async e => {
|
|
switch (e.target.id) {
|
|
|
|
}
|
|
})
|
|
document.addEventListener('popupclosed', e => {
|
|
zIndex--
|
|
switch (e.target.id) {
|
|
}
|
|
})
|
|
//Function for displaying toast notifications. pass in error for mode param if you want to show an error.
|
|
function notify(message, mode, options = {}) {
|
|
let icon
|
|
switch (mode) {
|
|
case 'success':
|
|
icon = `<svg class="icon icon--success" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 15.172l9.192-9.193 1.415 1.414L10 18l-6.364-6.364 1.414-1.414z"/></svg>`
|
|
break;
|
|
case 'error':
|
|
icon = `<svg class="icon icon--error" 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 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>`
|
|
options.pinned = true
|
|
break;
|
|
}
|
|
if (mode === 'error') {
|
|
console.error(message)
|
|
}
|
|
return getRef("notification_drawer").push(message, { icon, ...options });
|
|
}
|
|
// displays a popup for asking permission. Use this instead of JS confirm
|
|
/**
|
|
@param {string} title - Title of the popup
|
|
@param {object} options - Options for the popup
|
|
@param {string} options.message - Message to be displayed in the popup
|
|
@param {string} options.cancelText - Text for the cancel button
|
|
@param {string} options.confirmText - Text for the confirm button
|
|
@param {boolean} options.danger - If true, confirm button will be red
|
|
*/
|
|
const getConfirmation = (title, options = {}) => {
|
|
return new Promise(resolve => {
|
|
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
|
|
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()
|
|
}
|
|
closed.then((payload) => {
|
|
confirmButton.onclick = null
|
|
cancelButton.onclick = null
|
|
if (payload)
|
|
resolve(true)
|
|
else
|
|
resolve(false)
|
|
})
|
|
})
|
|
}
|
|
function createRipple(event, target) {
|
|
const circle = document.createElement("span");
|
|
const diameter = Math.max(target.clientWidth, target.clientHeight);
|
|
const radius = diameter / 2;
|
|
const targetDimensions = target.getBoundingClientRect();
|
|
circle.style.width = circle.style.height = `${diameter}px`;
|
|
circle.style.left = `${event.clientX - (targetDimensions.left + radius)}px`;
|
|
circle.style.top = `${event.clientY - (targetDimensions.top + radius)}px`;
|
|
circle.classList.add("ripple");
|
|
const rippleAnimation = circle.animate(
|
|
[
|
|
{
|
|
opacity: 1,
|
|
transform: `scale(0)`
|
|
},
|
|
{
|
|
transform: "scale(4)",
|
|
opacity: 0,
|
|
},
|
|
],
|
|
{
|
|
duration: 600,
|
|
fill: "forwards",
|
|
easing: "ease-out",
|
|
}
|
|
);
|
|
target.append(circle);
|
|
rippleAnimation.onfinish = () => {
|
|
circle.remove();
|
|
};
|
|
}
|
|
function buttonLoader(id, show) {
|
|
const button = typeof id === 'string' ? document.getElementById(id) : id;
|
|
if (!button) return
|
|
if (!button.dataset.hasOwnProperty('wasDisabled'))
|
|
button.dataset.wasDisabled = button.disabled
|
|
const animOptions = {
|
|
duration: 200,
|
|
fill: 'forwards',
|
|
easing: 'ease'
|
|
}
|
|
if (show) {
|
|
button.disabled = true
|
|
button.parentNode.append(document.createElement('sm-spinner'))
|
|
button.animate([
|
|
{
|
|
clipPath: 'circle(100%)',
|
|
},
|
|
{
|
|
clipPath: 'circle(0)',
|
|
},
|
|
], animOptions)
|
|
} else {
|
|
button.disabled = button.dataset.wasDisabled === 'true';
|
|
button.animate([
|
|
{
|
|
clipPath: 'circle(0)',
|
|
},
|
|
{
|
|
clipPath: 'circle(100%)',
|
|
},
|
|
], animOptions).onfinish = (e) => {
|
|
button.removeAttribute('data-original-state')
|
|
}
|
|
const potentialTarget = button.parentNode.querySelector('sm-spinner')
|
|
if (potentialTarget) potentialTarget.remove();
|
|
}
|
|
}
|
|
class Router {
|
|
/**
|
|
* @constructor {object} options - options for the router
|
|
* @param {object} options.routes - routes for the router
|
|
* @param {object} options.state - initial state for the router
|
|
* @param {function} options.routingStart - function to be called before routing
|
|
* @param {function} options.routingEnd - function to be called after routing
|
|
*/
|
|
constructor(options = {}) {
|
|
const { routes = {}, state = {}, routingStart, routingEnd } = options
|
|
this.routes = routes
|
|
this.state = state
|
|
this.routingStart = routingStart
|
|
this.routingEnd = routingEnd
|
|
this.lastPage = null
|
|
window.addEventListener('hashchange', e => this.routeTo(window.location.hash))
|
|
}
|
|
/**
|
|
* @param {string} route - route to be added
|
|
* @param {function} callback - function to be called when route is matched
|
|
*/
|
|
addRoute(route, callback) {
|
|
this.routes[route] = callback
|
|
}
|
|
/**
|
|
* @param {string} route
|
|
*/
|
|
handleRouting = async (page) => {
|
|
if (this.routingStart) {
|
|
this.routingStart(this.state)
|
|
}
|
|
if (this.routes[page]) {
|
|
await this.routes[page](this.state)
|
|
this.lastPage = page
|
|
} else {
|
|
if (this.routes['404']) {
|
|
this.routes['404'](this.state);
|
|
} else {
|
|
console.error(`No route found for '${page}' and no '404' route is defined.`);
|
|
}
|
|
}
|
|
if (this.routingEnd) {
|
|
this.routingEnd(this.state)
|
|
}
|
|
}
|
|
async routeTo(destination) {
|
|
try {
|
|
let page
|
|
let wildcards = []
|
|
let params = {}
|
|
let [path, queryString] = destination.split('?');
|
|
if (path.includes('#'))
|
|
path = path.split('#')[1];
|
|
if (path.includes('/'))
|
|
[, page, ...wildcards] = path.split('/')
|
|
else
|
|
page = path
|
|
this.state = { page, wildcards, lastPage: this.lastPage, params }
|
|
if (queryString) {
|
|
params = new URLSearchParams(queryString)
|
|
this.state.params = Object.fromEntries(params)
|
|
}
|
|
if (document.startViewTransition) {
|
|
const viewTransition = document.startViewTransition(async () => {
|
|
await this.handleRouting(page)
|
|
})
|
|
this.state.viewTransition = viewTransition
|
|
} else {
|
|
// Fallback for browsers that don't support View transition API:
|
|
await this.handleRouting(page)
|
|
}
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<script>
|
|
const router = new Router({
|
|
routingStart(state) {
|
|
},
|
|
routingEnd(state) {
|
|
const { page } = state
|
|
if (!page)
|
|
page = 'home'
|
|
}
|
|
})
|
|
window.addEventListener('load', () => {
|
|
router.routeTo(location.hash)
|
|
document.body.classList.remove('hidden')
|
|
document.addEventListener('copy', () => {
|
|
notify('copied', 'success')
|
|
})
|
|
document.addEventListener("pointerdown", (e) => {
|
|
if (e.target.closest("button:not(:disabled), .interactive:not(:disabled)")) {
|
|
createRipple(e, e.target.closest("button, .interactive"));
|
|
}
|
|
});
|
|
})
|
|
router.addRoute('404', () => {
|
|
renderElem(getRef('page_container'), html`
|
|
<h1>Page not found</h1>
|
|
`)
|
|
})
|
|
const dappsList = [
|
|
{
|
|
name: 'Messenger',
|
|
description: 'Chat with your Bitcoin, Ethereum and FLO friends or use Bitcoin and FLO multisig.',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/messenger',
|
|
moreLink: '#/dapps/messenger',
|
|
tags: ['messenger', 'chat', 'bitcoin', 'ethereum', 'flo', 'multisig'],
|
|
category: 'social'
|
|
},
|
|
{
|
|
name: 'FLO Wallet',
|
|
description: 'A wallet for FLO',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/flowallet',
|
|
moreLink: '#/dapps/flo-wallet',
|
|
tags: ['flo', 'wallet'],
|
|
category: 'wallet'
|
|
},
|
|
{
|
|
name: 'FLO Scout',
|
|
description: 'Track FLO token transactions and utilize smart contracts.',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/floscout',
|
|
moreLink: '#/dapps/flo-scout',
|
|
tags: ['flo', 'scout', 'smart contracts'],
|
|
category: 'blockchain-explorer'
|
|
},
|
|
{
|
|
name: 'BTC Wallet',
|
|
description: 'Send and receive Bitcoin and track transactions.',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/btcwallet',
|
|
moreLink: '#/dapps/btc-wallet',
|
|
tags: ['bitcoin', 'wallet'],
|
|
category: 'wallet'
|
|
},
|
|
{
|
|
name: 'Taproot wallet',
|
|
description: 'A Bitcoin wallet with Taproot support.',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/taprootwallet',
|
|
moreLink: '#/dapps/taproot-wallet',
|
|
tags: ['bitcoin', 'wallet', 'taproot'],
|
|
category: 'wallet'
|
|
},
|
|
{
|
|
name: 'FLO Ethereum',
|
|
description: 'A Ethereum wallet that works with FLO',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/floethereum',
|
|
moreLink: '#/dapps/flo-ethereum',
|
|
tags: ['ethereum', 'wallet', 'flo'],
|
|
category: 'wallet'
|
|
},
|
|
{
|
|
name: 'KYC',
|
|
description: 'An app to verify your identity',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/kyc',
|
|
moreLink: '#/dapps/kyc',
|
|
tags: ['kyc', 'identity'],
|
|
category: 'identity'
|
|
},
|
|
{
|
|
name: 'BTC Mortgage',
|
|
description: 'Borrow or Lend USD against Bitcoin',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/btcmortgage',
|
|
moreLink: '#/dapps/btc-mortgage',
|
|
tags: ['bitcoin', 'mortgage', 'lend', 'borrow'],
|
|
category: 'finance'
|
|
},
|
|
{
|
|
name: 'FLOpay',
|
|
description: 'A rupee token payments app based on FLO',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/flopay',
|
|
moreLink: '#/dapps/flopay',
|
|
tags: ['flo', 'payments', 'rupee'],
|
|
category: 'wallet'
|
|
},
|
|
{
|
|
name: 'Content Collaboration',
|
|
description: 'A writing app that allows you to collaborate with others',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/cc',
|
|
moreLink: '#/dapps/content-collaboration',
|
|
tags: ['collaboration', 'writing', 'content'],
|
|
category: 'content'
|
|
},
|
|
{
|
|
name: 'RIBC',
|
|
description: 'RanchiMall Internship Blockchain Contract (RIBC) allows you hire and manage interns.',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/ribc',
|
|
moreLink: '#/dapps/ribc',
|
|
tags: ['internship', 'contract', 'ribc'],
|
|
category: 'management'
|
|
},
|
|
{
|
|
name: 'LogSheet',
|
|
description: 'Create and manage public and private log sheets',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/logsheet',
|
|
moreLink: '#/dapps/log-sheet',
|
|
tags: ['log', 'sheet', 'logsheets'],
|
|
category: 'content'
|
|
},
|
|
{
|
|
name: 'Exchange',
|
|
description: 'Trade FLO and FLO tokens with rupee tokens',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/exchangemarket',
|
|
moreLink: '#/dapps/exchange',
|
|
tags: ['exchange', 'trade', 'flo', 'rupee'],
|
|
category: 'finance'
|
|
},
|
|
{
|
|
name: 'RanchiMall Times',
|
|
description: 'A news app that showcases articles created with Content Collaboration app',
|
|
icon: ``,
|
|
appLink: 'https://ranchimall.github.io/rmtimes',
|
|
moreLink: '#/dapps/ranchimall-times',
|
|
tags: ['news', 'articles', 'content'],
|
|
category: 'content'
|
|
},
|
|
].sort((a, b) => a.name.localeCompare(b.name))
|
|
router.addRoute('home', renderHome)
|
|
router.addRoute('', renderHome)
|
|
function renderDappCard(dapp) {
|
|
const { name, description, icon, appLink, moreLink, tags, category } = dapp;
|
|
return html`
|
|
<li class="dapp-card">
|
|
<div class="flex space-between">
|
|
<div class="dapp-card__icon">
|
|
${icon}
|
|
</div>
|
|
<a class="dapp-card__category capitalize" href=${`#/home?category=${category}`}>
|
|
${category.replace('-', ' ')}
|
|
</a>
|
|
</div>
|
|
<div class="dapp-card__content grid gap-0-5">
|
|
<a class="flex align-center dapp-card__title__wrapper" href=${moreLink}>
|
|
<h3 class="dapp-card__title">${name}</h3>
|
|
<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="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"/></svg>
|
|
</a>
|
|
<p class="dapp-card__description">${description}</p>
|
|
</div>
|
|
<div class="flex gap-0-5 align-center flex-wrap">
|
|
<a href=${`https://github.com/ranchimall/${appLink.split('/').pop()}/archive/refs/heads/master.zip`} class="button dapp-card__link" title="Download dapp Zip">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"/></g></svg>
|
|
</a>
|
|
<a href=${appLink} class="button dapp-card__link dapp-card__link--primary" target="_blank">
|
|
Try it
|
|
<svg class="icon margin-left-0-5" 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> <path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path> </svg>
|
|
</a>
|
|
</div>
|
|
</li>
|
|
`
|
|
}
|
|
function renderHome(state) {
|
|
const { params: { category = 'all', query = '' }, page, viewTransition, lastPage } = state
|
|
getRef('page_container').dataset.page = 'home';
|
|
const renderedDappsList = filterDapps(query, category)
|
|
.map((dapp) => renderDappCard(dapp))
|
|
renderElem(getRef('page_container'), html`
|
|
<section id="hero_section">
|
|
<svg id="hero_section__svg" xmlns="http://www.w3.org/2000/svg" width="50" height="103" viewBox="0 0 50 103" fill="none"> <path d="M49.919 65.4057L12.7647 28.2514V102.56L49.919 65.4057Z" fill="#ABECDB"/> <path d="M49.919 49.0706L0.913757 0.0653687V98.0758L49.919 49.0706Z" fill="#CFF3EA"/> </svg>
|
|
<h1>
|
|
Discover the world of <br>
|
|
exciting new blockchain apps
|
|
</h1>
|
|
</section>
|
|
|
|
</ul>
|
|
<div class="flex align-center space-between gap-1 flex-wrap">
|
|
<h4>Our offerings</h4>
|
|
<sm-input id="dapp_search_input" type="search" placeholder="Search Dapps" oninput=${searchDapps} value=${query}>
|
|
<svg slot="icon" 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> <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"> </path> </svg>
|
|
</sm-input>
|
|
</div>
|
|
<sm-chips id="category_selector" onchange=${handleFilterCategory}>
|
|
${['all', 'blockchain-explorer', 'content', 'finance', 'identity', 'management', 'social', 'wallet'].map((value, index) => html`
|
|
<sm-chip value=${value} ?selected=${value === category}>${value.replace('-', ' ')}</sm-chip>
|
|
`)}
|
|
</sm-chips>
|
|
${renderedDappsList.length === 0 ? html`
|
|
<div class="text-center">
|
|
No dapps related to <strong>'${query}'</strong> ${category === 'all' ? '' : `in ${category.replace('-', ' ')}`} found.
|
|
</div>
|
|
` : html`
|
|
<ul id="dapp_list">${renderedDappsList}</ul>
|
|
`}
|
|
`)
|
|
if (!viewTransition || lastPage === page) return
|
|
viewTransition.ready.then(() => {
|
|
document.documentElement.animate(
|
|
[
|
|
{ transform: 'translateX(0)' },
|
|
{ transform: 'translateX(1rem)' },
|
|
],
|
|
{
|
|
duration: 300,
|
|
easing: 'ease',
|
|
pseudoElement: '::view-transition-old(root)',
|
|
}
|
|
);
|
|
document.documentElement.animate(
|
|
[
|
|
{ transform: 'translateX(-1rem)' },
|
|
{ transform: 'translateX(0)' },
|
|
],
|
|
{
|
|
duration: 300,
|
|
easing: 'ease',
|
|
pseudoElement: '::view-transition-new(root)',
|
|
}
|
|
);
|
|
})
|
|
}
|
|
function handleFilterCategory(e) {
|
|
const query = getRef('dapp_search_input')?.value.trim().toLowerCase() || '';
|
|
location.hash = `#/home?category=${e.target.value}${query ? `&query=${query}` : ''}`
|
|
}
|
|
function filterDapps(query = '', category = 'all') {
|
|
const filtered = dappsList.filter(dapp => {
|
|
if (category === 'all') {
|
|
return dapp.name.toLowerCase().includes(query) || dapp.description.toLowerCase().includes(query) || dapp.tags.some(tag => tag.includes(query))
|
|
} else {
|
|
return dapp.category.toLowerCase().includes(category) && (dapp.name.toLowerCase().includes(query) || dapp.description.toLowerCase().includes(query) || dapp.tags.some(tag => tag.includes(query)))
|
|
}
|
|
})
|
|
return filtered
|
|
}
|
|
function searchDapps(e) {
|
|
const query = e.target.value.trim().toLowerCase() || '';
|
|
const category = getRef('category_selector').value || 'all';
|
|
location.hash = `#/home?category=${category}&query=${query}`
|
|
}
|
|
const appHamburgerMenu = (activePage) => html`
|
|
<aside class="hamburger-menu-wrapper">
|
|
<nav id="dapps_menu" class="flex flex-direction-column gap-1 hamburger-menu">
|
|
<h4>Dapps</h4>
|
|
<ul class="flex flex-direction-column gap-0-3">
|
|
${dappsList.map(dapp => html`
|
|
<li>
|
|
<a class=${`hamburger-menu__item ${dapp.moreLink.includes(activePage) ? 'hamburger-menu__item--active' : ''}`} href=${dapp.moreLink}>${dapp.name}</a>
|
|
</li>
|
|
`)}
|
|
</ul>
|
|
</nav>
|
|
<div class="hamburger-menu__overlay" onclick=${closeHamburgerMenu}></div>
|
|
</aside>
|
|
`
|
|
function openHamburgerMenu() {
|
|
if (getRef('dapps_menu'))
|
|
getRef('dapps_menu').parentElement.classList.add('hamburger-menu--open')
|
|
}
|
|
function closeHamburgerMenu() {
|
|
if (getRef('dapps_menu'))
|
|
getRef('dapps_menu').parentElement.classList.remove('hamburger-menu--open')
|
|
}
|
|
router.addRoute('dapps', (state) => {
|
|
const { wildcards: [page], viewTransition } = state;
|
|
getRef('page_container').dataset.page = 'dapps';
|
|
const { name, description, icon, appLink, moreLink } = dappsList.find(dapp => dapp.moreLink.includes(page));
|
|
closeHamburgerMenu()
|
|
let dappPage = [
|
|
appHamburgerMenu(page),
|
|
html`
|
|
<section class="flex flex-direction-column gap-1-5">
|
|
<button id="hamburger_menu_trigger" class="margin-right-auto hide-on-large" onclick=${openHamburgerMenu}>
|
|
<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="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>
|
|
</button>
|
|
<div class="flex flex-direction-column gap-0-5">
|
|
<a href="#/home" class="flex align-center" style="margin-left: -0.3rem;">
|
|
<svg class="icon" style="fill: var(--accent-color)" 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="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"/></svg>
|
|
<span>Home</span>
|
|
</a>
|
|
<h1>${name}</h1>
|
|
</div>
|
|
<p>${description}</p>
|
|
<a href=${appLink} class="button dapp-card__link dapp-card__link--primary margin-right-auto" target="_blank">
|
|
Try it
|
|
<svg class="icon margin-left-0-5" 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> <path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path> </svg>
|
|
</a>
|
|
</section>
|
|
`
|
|
]
|
|
switch (page) {
|
|
case 'messenger':
|
|
dappPage.push(html`
|
|
`)
|
|
break;
|
|
case 'flo-wallet':
|
|
dappPage.push(html`
|
|
`)
|
|
break;
|
|
}
|
|
renderElem(getRef('page_container'), html`${dappPage}`)
|
|
if (!viewTransition) return
|
|
viewTransition.ready.then(() => {
|
|
document.documentElement.animate(
|
|
[
|
|
{ transform: 'translateX(0)' },
|
|
{ transform: 'translateX(-1rem)' },
|
|
],
|
|
{
|
|
duration: 300,
|
|
easing: 'ease',
|
|
pseudoElement: '::view-transition-old(root)',
|
|
}
|
|
);
|
|
document.documentElement.animate(
|
|
[
|
|
{ transform: 'translateX(1rem)' },
|
|
{ transform: 'translateX(0)' },
|
|
],
|
|
{
|
|
duration: 300,
|
|
easing: 'ease',
|
|
pseudoElement: '::view-transition-new(root)',
|
|
}
|
|
);
|
|
})
|
|
})
|
|
</script>
|
|
</body>
|
|
|
|
</html> |