Compare commits

...

1 Commits

Author SHA1 Message Date
Luccas Mateus de Medeiros Gomes
23fd9524e3 [simple-example][m] - make it prettier 2023-04-27 08:29:06 -03:00
6 changed files with 225 additions and 131 deletions

View File

@ -0,0 +1,16 @@
export default function Footer() {
return (
<footer className="bg-white">
<div className="mx-auto max-w-7xl overflow-hidden px-6 py-8 sm:py-12 lg:px-8">
<div className="mt-10 flex justify-center space-x-10">
<span className="text-gray-400 hover:text-gray-500 flex gap-4 items-center">
<span className="mt-2">Powered by</span>
<a href="https://datopian.com">
<img src="/logo.png" className="w-32 h-10" />
</a>
</span>
</div>
</div>
</footer>
);
}

View File

@ -0,0 +1,31 @@
export default function NavBar() {
return (
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div className="flex h-16 justify-between">
<div className="flex">
<div className="flex flex-shrink-0 items-center">
<img
className="block h-8 w-auto lg:hidden"
src="/logo.png"
alt="Your Company"
/>
<img
className="hidden h-8 w-auto lg:block mt-4"
src="/logo.png"
alt="Your Company"
/>
</div>
<div className="hidden sm:ml-6 sm:flex sm:space-x-8">
{/* Current: "border-indigo-500 text-gray-900", Default: "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700" */}
<a
href="/"
className="inline-flex items-center border-b-2 border-indigo-500 px-1 pt-1 text-sm font-medium text-gray-900"
>
Home
</a>
</div>
</div>
</div>
</div>
);
}

View File

@ -9,21 +9,30 @@ import { getProject, GithubProject } from '../../../lib/octokit';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm'; import remarkGfm from 'remark-gfm';
import Link from 'next/link'; import Link from 'next/link';
import Footer from '../../../components/Footer';
import NavBar from '../../../components/NavBar';
export default function ProjectPage({ project }) { export default function ProjectPage({ project }) {
return ( return (
<> <>
<NextSeo title={`PortalJS - @${project.repo_config.owner}/${project.repo_config.repo}${project.base_path !== '/' ? '/' + project.base_path : ''}`} /> <NextSeo
<main className="prose mx-auto my-8"> title={`PortalJS - @${project.repo_config.owner}/${
<Link href='/'>Back to homepage</Link> project.repo_config.repo
}${project.base_path !== '/' ? '/' + project.base_path : ''}`}
/>
<NavBar />
<main className="mx-auto my-8 max-w-7xl sm:px-6 lg:px-8 px-4">
<div className="prose">
<h1 className="mb-0">Data</h1> <h1 className="mb-0">Data</h1>
<div className="inline-block min-w-full py-2 align-middle"> </div>
<div className="inline-block min-w-full py-4 align-middle">
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg">
<table className="min-w-full divide-y divide-gray-300"> <table className="min-w-full divide-y divide-gray-300">
<thead> <thead className="bg-gray-50">
<tr> <tr>
<th <th
scope="col" scope="col"
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900" className="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6"
> >
Name Name
</th> </th>
@ -33,38 +42,53 @@ export default function ProjectPage({ project }) {
> >
Size Size
</th> </th>
<th
scope="col"
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
>
Download
</th>
</tr> </tr>
</thead> </thead>
<tbody className="divide-y divide-gray-200"> <tbody className="divide-y divide-gray-200 bg-white">
{project.files.map((file) => ( {project.files.map((file) => (
<tr key={file.download_url}> <tr key={file.download_url}>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> <td className="py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
<a href={file.download_url}>{file.name}</a> {file.name}
</td> </td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> <td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
{file.size} Bytes {file.size} Bytes
</td> </td>
<td className="px-3 py-4 text-sm text-gray-500">
<a
className="rounded-md bg-indigo-600 no-underline px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
href={file.download_url}
>
Download file
</a>
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<div className="prose py-4 max-w-7xl">
<h1>Readme</h1> <h1>Readme</h1>
<ReactMarkdown remarkPlugins={[remarkGfm]}> <ReactMarkdown remarkPlugins={[remarkGfm]}>
{project.readmeContent} {project.readmeContent}
</ReactMarkdown> </ReactMarkdown>
</div>
</main> </main>
<Footer />
</> </>
); );
} }
// Generates `/posts/1` and `/posts/2` // Generates `/posts/1` and `/posts/2`
export async function getStaticPaths() { export async function getStaticPaths() {
const jsonDirectory = path.join( const jsonDirectory = path.join(process.cwd(), 'datasets.json');
process.cwd(),
'datasets.json'
);
const repos = await fs.readFile(jsonDirectory, 'utf8'); const repos = await fs.readFile(jsonDirectory, 'utf8');
return { return {
@ -88,10 +112,7 @@ export async function getStaticPaths() {
} }
export async function getStaticProps({ params }) { export async function getStaticProps({ params }) {
const jsonDirectory = path.join( const jsonDirectory = path.join(process.cwd(), 'datasets.json');
process.cwd(),
'datasets.json'
);
const reposFile = await fs.readFile(jsonDirectory, 'utf8'); const reposFile = await fs.readFile(jsonDirectory, 'utf8');
const repos: GithubProject[] = JSON.parse(reposFile); const repos: GithubProject[] = JSON.parse(reposFile);
const repo = repos.find((_repo) => { const repo = repos.find((_repo) => {

View File

@ -2,17 +2,16 @@ import { promises as fs } from 'fs';
import path from 'path'; import path from 'path';
import { getProject } from '../lib/octokit'; import { getProject } from '../lib/octokit';
import getConfig from 'next/config'; import getConfig from 'next/config';
import NavBar from '../components/NavBar';
import Footer from '../components/Footer';
export async function getStaticProps() { export async function getStaticProps() {
const jsonDirectory = path.join( const jsonDirectory = path.join(process.cwd(), '/datasets.json');
process.cwd(),
'/datasets.json'
);
const repos = await fs.readFile(jsonDirectory, 'utf8'); const repos = await fs.readFile(jsonDirectory, 'utf8');
const github_pat = getConfig().serverRuntimeConfig.github_pat; const github_pat = getConfig().serverRuntimeConfig.github_pat;
const projects = await Promise.all( const projects = await Promise.all(
(JSON.parse(repos)).map(async (repo) => { JSON.parse(repos).map(async (repo) => {
const project = await getProject(repo, github_pat); const project = await getProject(repo, github_pat);
return { ...project, repo_config: repo }; return { ...project, repo_config: repo };
}) })
@ -29,30 +28,36 @@ const formatter = new Intl.DateTimeFormat('en-US', {
month: 'long', month: 'long',
day: 'numeric', day: 'numeric',
hour: 'numeric', hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZone: 'UTC', timeZone: 'UTC',
}); });
export function Datasets({ projects }) { export default function Datasets({ projects }) {
return ( return (
<div className="bg-white"> <>
<div className="mx-auto max-w-7xl px-6 py-16 sm:py-24 lg:px-8"> <NavBar />
<h2 className="text-2xl font-bold leading-10 tracking-tight"> <div className="px-4 sm:px-6 lg:px-8 py-16 max-w-7xl mx-auto">
My Datasets <div className="sm:flex sm:items-center">
</h2> <div className="sm:flex-auto">
<p className="mt-6 max-w-2xl text-base leading-7 text-gray-600"> <h1 className="text-xl font-semibold leading-6 text-indigo-600">
Here is a list of all my datasets for easy access and sharing Datasets
</h1>
<p className="mt-2 text-sm text-gray-700 py-8">
Here is a list of all my datasets for easy access and sharing all
stored on multiple github accounts and repos and joined together
here
</p> </p>
<div className="mt-20"> </div>
</div>
<div className="mt-8 flow-root">
<div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> <div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8"> <div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8">
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg">
<table className="min-w-full divide-y divide-gray-300"> <table className="min-w-full divide-y divide-gray-300">
<thead> <thead className="bg-gray-50">
<tr> <tr>
<th <th
scope="col" scope="col"
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900" className="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6"
> >
Name Name
</th> </th>
@ -76,17 +81,22 @@ export function Datasets({ projects }) {
</th> </th>
<th <th
scope="col" scope="col"
className="relative py-3.5 pl-3 pr-4 sm:pr-0" className="relative py-3.5 pl-3 pr-4 sm:pr-6"
></th> >
<span className="sr-only">More info</span>
</th>
</tr> </tr>
</thead> </thead>
<tbody className="divide-y divide-gray-200"> <tbody className="divide-y divide-gray-200 bg-white">
{projects.map((project) => ( {projects.map((project) => (
<tr key={project.id}> <tr key={project.id}>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> <td className="py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
{project.repo_config.name {project.repo_config.name
? project.repo_config.name ? project.repo_config.name
: project.full_name + (project.base_path === '/' ? '' : '/' + project.base_path)} : project.full_name +
(project.base_path === '/'
? ''
: '/' + project.base_path)}
</td> </td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> <td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
<a href={project.html_url}>{project.full_name}</a> <a href={project.html_url}>{project.full_name}</a>
@ -99,11 +109,25 @@ export function Datasets({ projects }) {
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> <td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
{formatter.format(new Date(project.last_updated))} {formatter.format(new Date(project.last_updated))}
</td> </td>
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-0"> <td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
<a <a
href={`/@${project.repo_config.owner}/${project.repo_config.repo}/${project.base_path === '/' ? '' : project.base_path}`} href={`/@${project.repo_config.owner}/${
project.repo_config.repo
}/${
project.base_path === '/' ? '' : project.base_path
}`}
className="text-indigo-600 hover:text-indigo-900"
> >
More info More info
<span className="sr-only">
on,
{project.repo_config.name
? project.repo_config.name
: project.full_name +
(project.base_path === '/'
? ''
: '/' + project.base_path)}
</span>
</a> </a>
</td> </td>
</tr> </tr>
@ -115,7 +139,7 @@ export function Datasets({ projects }) {
</div> </div>
</div> </div>
</div> </div>
<Footer />
</>
); );
} }
export default Datasets;

View File

@ -1,6 +1,11 @@
@tailwind base; @tailwind base;
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;
.prose {
--tw-prose-headings: #4F46E5 !important;
}
html { html {
-webkit-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
@ -62,9 +67,6 @@ pre {
box-shadow: 0 0 #0000, 0 0 #0000, 0 10px 15px -3px rgba(0, 0, 0, 0.1), box-shadow: 0 0 #0000, 0 0 #0000, 0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05); 0 4px 6px -2px rgba(0, 0, 0, 0.05);
} }
.rounded {
border-radius: 1.5rem;
}
.wrapper { .wrapper {
width: 100%; width: 100%;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB