Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
maxaleks committed Sep 2, 2024
0 parents commit dabb489
Show file tree
Hide file tree
Showing 20 changed files with 27,534 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

> **_NOTE:_** If you are using Next 13 be sure to look at the examples in `examples/nextjs-page-router`
> which have been written with Next.js 13 specifically in mind.
Examples can be seen on the following paths

- http://localhost:3000/ - the shows the use of \<ClientOnly \/\> to import and used the Widget in the App Router
- http://localhost:3000/pages-example - the shows the use of \<ClientOnly \/\> to import and used the Widget in the Pages Router
- http://localhost:3000/dynamic-import - the shows the use of `next/dynamic` API to import and use the Widget


## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Binary file added app/favicon.ico
Binary file not shown.
32 changes: 32 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 245, 251, 255;
--background-end-rgb: 190, 221, 243;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 245, 251, 255;
--background-end-rgb: 190, 221, 243;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
rgb(var(--background-start-rgb)),
rgb(var(--background-end-rgb))
);
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}
22 changes: 22 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';

const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
);
}
29 changes: 29 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Link from 'next/link';
import Image from 'next/image';

import { Widget } from '@/components/Widget';

export default function Page() {
return (
<main className="flex min-h-screen flex-col items-center justify-center p-24">
<div className="z-10 items-center justify-between font-mono text-sm">
<div className="mb-6 flex justify-center">
<Image src="/logo.svg" alt="Swapscout Logo" width={172} height={30} />
</div>
<div className="shadow-custom rounded-[16px] overflow-hidden">
{/* <QueryClientProvider client={queryClient}>
<WalletProvider>
<Widget/>
</WalletProvider>
</QueryClientProvider> */}
{/* <LiFiWidget integrator="blockscout" config={widgetConfig} /> */}
<Widget />
</div>
<div className="mt-8 flex justify-center space-x-8">
<Link href="https://blockscout.com" className="text-gray-500 hover:text-gray-600">Blockscout</Link>
<Link href="#" className="text-gray-500 hover:text-gray-600">Documentation</Link>
</div>
</div>
</main>
);
}
15 changes: 15 additions & 0 deletions components/ClientOnly.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { type PropsWithChildren } from 'react';
import { useHydrated } from '../hooks/useHydrated';

interface ClientOnlyProps extends PropsWithChildren {
fallback?: React.ReactNode;
}

/**
* Render the children only after the JS has loaded client-side. Use an optional
* fallback component if the JS is not yet loaded.
*/
export function ClientOnly({ children, fallback = null }: ClientOnlyProps) {
const hydrated = useHydrated();
return hydrated ? children : fallback;
}
37 changes: 37 additions & 0 deletions components/Widget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use client';

import type { WidgetConfig } from '@lifi/widget';
import { LiFiWidget, WidgetSkeleton } from '@lifi/widget';
import { ClientOnly } from './ClientOnly';

export function Widget() {
const config = {
fee: 0.00075, // 0.075%
variant: 'compact',
subvariant: 'default',
appearance: 'light',
theme: {
palette: {
primary: { main: '#2B6CB0' },
secondary: { main: '#2B6CB0' },
},
typography: { fontFamily: 'Inter, sans-serif' },
container: {
boxShadow: '0px 8px 32px rgba(0, 0, 0, 0.08)',
borderRadius: '16px',
},
shape: {
borderRadius: 24,
borderRadiusSecondary: 8,
},
},
} as Partial<WidgetConfig>;

return (
<main>
<ClientOnly fallback={<WidgetSkeleton config={config} />}>
<LiFiWidget config={config} integrator="blockscout" />
</ClientOnly>
</main>
);
}
20 changes: 20 additions & 0 deletions hooks/useHydrated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useSyncExternalStore } from 'react';

function subscribe() {
return () => {};
}

/**
* Return a boolean indicating if the JS has been hydrated already.
* When doing Server-Side Rendering, the result will always be false.
* When doing Client-Side Rendering, the result will always be false on the
* first render and true from then on. Even if a new component renders it will
* always start with true.
*/
export function useHydrated() {
return useSyncExternalStore(
subscribe,
() => true,
() => false,
);
}
12 changes: 12 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
config.resolve.fallback = { fs: false, net: false, tls: false };
config.externals.push('pino-pretty', 'lokijs', 'encoding');
return config;
},
reactStrictMode: true,
swcMinify: true,
};

module.exports = nextConfig;
Loading

0 comments on commit dabb489

Please sign in to comment.