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

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ storybook-static
public/storybook
.artifacts
.vercel
repo-metadata.json

View File

@ -1,6 +1,10 @@
const path = require('path')
const createFields = require('./gatsby/createFields')
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 }) => {
createFields(node, actions, getNode)

View File

@ -11,12 +11,13 @@
"jest": "NODE_ENV=test jest -c tests/unit/jest.config.js",
"test": "npm run lint && npm run jest",
"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",
"type-check": "tsc --noEmit",
"analyze": "npm run build && source-map-explorer 'public/*.js'",
"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": {
"@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 {
margin-bottom: calc(var(--spacer) * 2);
font-size: var(--font-size-base);
font-size: var(--font-size-small);
line-height: 2;
}
.stats > div > div {
display: inline-block;
}
.stats > div strong {
font-size: var(--font-size-base) !important;
}
.total {
color: var(--color-secondary) !important;
font-size: var(--font-size-small) !important;
}

View File

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

View File

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