1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

More footer data (#224)

* output total datatoken liquidity in footer stats

* add build id to footer

* write out repo metadata before build

* build tweaks

* add title

* refactor
This commit is contained in:
Matthias Kretschmann 2020-11-09 14:31:04 +01:00 committed by GitHub
parent ad28f866e9
commit b3510230e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 84 additions and 10 deletions

3
.gitignore vendored
View File

@ -10,4 +10,5 @@ public
storybook-static storybook-static
public/storybook public/storybook
.artifacts .artifacts
.vercel .vercel
repo-metadata.json

View File

@ -1,6 +1,10 @@
const path = require('path') const path = require('path')
const createFields = require('./gatsby/createFields') const createFields = require('./gatsby/createFields')
const createMarkdownPages = require('./gatsby/createMarkdownPages') const createMarkdownPages = require('./gatsby/createMarkdownPages')
const execSync = require('child_process').execSync
// Write out repo metadata
execSync(`node ./scripts/write-repo-metadata > repo-metadata.json`)
exports.onCreateNode = ({ node, actions, getNode }) => { exports.onCreateNode = ({ node, actions, getNode }) => {
createFields(node, actions, getNode) createFields(node, actions, getNode)

View File

@ -11,12 +11,13 @@
"jest": "NODE_ENV=test jest -c tests/unit/jest.config.js", "jest": "NODE_ENV=test jest -c tests/unit/jest.config.js",
"test": "npm run lint && npm run jest", "test": "npm run lint && npm run jest",
"test:watch": "npm run lint && npm run jest -- --watch", "test:watch": "npm run lint && npm run jest -- --watch",
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx . && npm run type-check", "lint": "npm run write:repoMetadata && eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx . && npm run type-check",
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json}' --write", "format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json}' --write",
"type-check": "tsc --noEmit", "type-check": "tsc --noEmit",
"analyze": "npm run build && source-map-explorer 'public/*.js'", "analyze": "npm run build && source-map-explorer 'public/*.js'",
"storybook": "start-storybook -p 4000 -c .storybook", "storybook": "start-storybook -p 4000 -c .storybook",
"storybook:build": "build-storybook -c .storybook -o public/storybook" "storybook:build": "build-storybook -c .storybook -o public/storybook",
"write:repoMetadata": "node ./scripts/write-repo-metadata > repo-metadata.json"
}, },
"dependencies": { "dependencies": {
"@coingecko/cryptoformat": "^0.4.2", "@coingecko/cryptoformat": "^0.4.2",

View File

@ -0,0 +1,23 @@
#!/usr/bin/env node
'use strict'
const execSync = require('child_process').execSync
//
// VERCEL_GITHUB_COMMIT_REF & VERCEL_GITHUB_COMMIT_SHA need to be added with empty
// values in Vercel environment variables, making them available to builds.
// https://vercel.com/docs/build-step#system-environment-variables
//
process.stdout.write(
JSON.stringify(
{
version: require('../package.json').version,
branch: process.env.VERCEL_GITHUB_COMMIT_REF || 'dev',
commit:
process.env.VERCEL_GITHUB_COMMIT_SHA ||
execSync(`git rev-parse HEAD`).toString().trim()
},
null,
' '
)
)

View File

@ -0,0 +1,6 @@
.buildId {
display: inline-block;
font-size: var(--font-size-mini);
margin-bottom: var(--spacer);
font-family: var(--font-family-monospace);
}

View File

@ -0,0 +1,23 @@
import React, { ReactElement } from 'react'
import repoMetadata from '../../../repo-metadata.json'
import styles from './BuildId.module.css'
export default function BuildId(): ReactElement {
const commitBranch = repoMetadata.branch
const commitId = repoMetadata.commit
const isMainBranch = commitBranch === 'main'
return (
<a
className={styles.buildId}
href={`https://github.com/oceanprotocol/market/tree/${
isMainBranch ? commitId : commitBranch
}`}
target="_blank"
rel="noreferrer"
title="Build ID referring to the linked commit hash."
>
{isMainBranch ? commitId.substring(0, 7) : commitBranch}
</a>
)
}

View File

@ -1,16 +1,14 @@
.stats { .stats {
margin-bottom: calc(var(--spacer) * 2); margin-bottom: calc(var(--spacer) * 2);
font-size: var(--font-size-base); font-size: var(--font-size-small);
line-height: 2;
} }
.stats > div > div { .stats > div > div {
display: inline-block; display: inline-block;
} }
.stats > div strong {
font-size: var(--font-size-base) !important;
}
.total { .total {
color: var(--color-secondary) !important; color: var(--color-secondary) !important;
font-size: var(--font-size-small) !important;
} }

View File

@ -57,8 +57,8 @@ export default function MarketStats(): ReactElement {
return ( return (
<div className={styles.stats} ref={ref}> <div className={styles.stats} ref={ref}>
Total of <strong>{stats?.datasets.total}</strong> data sets & datatokens Total of <strong>{stats?.datasets.total}</strong> data sets & unique
published by <strong>{stats?.owners}</strong> accounts. datatokens published by <strong>{stats?.owners}</strong> accounts.
<br /> <br />
<PriceUnit <PriceUnit
price={`${stats?.ocean}`} price={`${stats?.ocean}`}
@ -66,6 +66,13 @@ export default function MarketStats(): ReactElement {
className={styles.total} className={styles.total}
conversion conversion
/>{' '} />{' '}
and{' '}
<PriceUnit
price={`${stats?.datatoken}`}
symbol="datatokens"
small
className={styles.total}
/>{' '}
in <strong>{stats?.datasets.pools}</strong> data set pools. in <strong>{stats?.datasets.pools}</strong> data set pools.
<br /> <br />
<strong>{stats?.datasets.none}</strong> data sets have no price set yet. <strong>{stats?.datasets.none}</strong> data sets have no price set yet.

View File

@ -14,3 +14,12 @@
.content p { .content p {
display: inline; display: inline;
} }
.content a {
color: inherit;
}
.content a:hover,
.content a:focus {
color: var(--color-primary);
}

View File

@ -4,6 +4,7 @@ import Markdown from '../atoms/Markdown'
import { useSiteMetadata } from '../../hooks/useSiteMetadata' import { useSiteMetadata } from '../../hooks/useSiteMetadata'
import { Link } from 'gatsby' import { Link } from 'gatsby'
import MarketStats from '../molecules/MarketStats' import MarketStats from '../molecules/MarketStats'
import BuildId from '../atoms/BuildId'
export default function Footer(): ReactElement { export default function Footer(): ReactElement {
const { copyright } = useSiteMetadata() const { copyright } = useSiteMetadata()
@ -12,6 +13,7 @@ export default function Footer(): ReactElement {
return ( return (
<footer className={styles.footer}> <footer className={styles.footer}>
<div className={styles.content}> <div className={styles.content}>
<BuildId />
<MarketStats />© {year} <Markdown text={copyright} /> {' '} <MarketStats />© {year} <Markdown text={copyright} /> {' '}
<Link to="/terms">Terms</Link> <Link to="/terms">Terms</Link>
{' — '} {' — '}