Skip to content

Commit

Permalink
Add tailwind example
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Jun 26, 2024
1 parent f2e1080 commit 3c0ba4a
Show file tree
Hide file tree
Showing 17 changed files with 546 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/tailwind/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions examples/tailwind/.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
81 changes: 81 additions & 0 deletions examples/tailwind/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# tailwind

## 0.1.11

### Patch Changes

- Updated dependencies
- [email protected]

## 0.1.10

### Patch Changes

- Updated dependencies
- [email protected]

## 0.1.9

### Patch Changes

- Updated dependencies
- [email protected]

## 0.1.8

### Patch Changes

- Updated dependencies [9f30638]
- Updated dependencies [9f30638]
- [email protected]

## 0.1.7

### Patch Changes

- Updated dependencies
- [email protected]

## 0.1.6

### Patch Changes

- Updated dependencies
- [email protected]

## 0.1.5

### Patch Changes

- Updated dependencies
- [email protected]

## 0.1.4

### Patch Changes

- Updated dependencies [6de3493]
- [email protected]

## 0.1.3

### Patch Changes

- Updated dependencies
- Updated dependencies [6f17cce]
- [email protected]

## 0.1.2

### Patch Changes

- Add resolvedTheme and resolvedColorScheme to useTheme state.
- Updated dependencies
- [email protected]

## 0.1.1

### Patch Changes

- Updated dependencies
- [email protected]
36 changes: 36 additions & 0 deletions examples/tailwind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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).

## 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.
23 changes: 23 additions & 0 deletions examples/tailwind/app/_components/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
interface CardProps {
href: string;
title: string;
text: string;
}

export default function Card({ href, title, text }: CardProps) {
return (
<a
href={href}
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer">
<h2 className={`mb-3 text-2xl font-semibold`}>
{title + " "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>{text}</p>
</a>
);
}
Binary file added examples/tailwind/app/favicon.ico
Binary file not shown.
23 changes: 23 additions & 0 deletions examples/tailwind/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@import "nextjs-themes/styles.css";

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

.dark,
.cs-dark {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb));
}
24 changes: 24 additions & 0 deletions examples/tailwind/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import { ThemeSwitcher } from "nextjs-themes";
import { NextJsSSGThemeSwitcher } from "nextjs-themes/server";

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

export const metadata: Metadata = {
title: "Tailwind CSS Example",
description: "Generated by Mayank <https://github.com/mayank1513>",
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body className={inter.className}>
<NextJsSSGThemeSwitcher />
<ThemeSwitcher />
{children}
</body>
</html>
);
}
71 changes: 71 additions & 0 deletions examples/tailwind/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { StarMe } from "@mayank1513/fork-me";
import Image from "next/image";
import { ColorSwitch } from "nextjs-themes";
import Card from "./_components/card";

export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
nextjs-themes Tailwind CSS example
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer">
<a href="https://mayank-chaudhari.vercel.app" rel="noopener noreferrer" target="_blank">
By Mayank
</a>
</a>
</div>
</div>

<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>

<ColorSwitch />

<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<Card
href="https://react18-tools.github.io/nextjs-themes/"
title="Docs"
text="Find in-depth information about nextjs-themes features and API."
/>
<Card
href="https://github.com/react18-tools/nextjs-themes"
title="Examples"
text="Learn through more examples on official GitHub repo."
/>
<StarMe
gitHubUrl="https://github.com/react18-tools/nextjs-themes"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30">
<h2 className={`mb-3 text-2xl font-semibold`}>
Star Me{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Explore and star official <code>nextjs-themes</code> repo.
</p>
</StarMe>
<Card
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
title="Deploy"
text="Instantly deploy your Next.js site to a shareable URL with Vercel."
/>
</div>
</main>
);
}
4 changes: 4 additions & 0 deletions examples/tailwind/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = nextConfig
30 changes: 30 additions & 0 deletions examples/tailwind/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@example/tailwind",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@mayank1513/fork-me": "^2.1.2",
"next": "14.2.4",
"nextjs-themes": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^20.14.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"autoprefixer": "^10.4.19",
"eslint": "^9.5.0",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"typescript": "^5.4.5"
}
}
6 changes: 6 additions & 0 deletions examples/tailwind/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 1 addition & 0 deletions examples/tailwind/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/tailwind/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions examples/tailwind/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Config } from "tailwindcss";

const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic": "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
darkMode: "class",
};
export default config;
13 changes: 13 additions & 0 deletions examples/tailwind/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"exclude": ["node_modules"],
"extends": "@repo/typescript-config/nextjs.json",
"compilerOptions": {
"outDir": "dist",
"plugins": [
{
"name": "next"
}
]
},
"include": ["src", "next.config.js", "next-env.d.ts", ".next/types/**/*.ts"]
}
Loading

0 comments on commit 3c0ba4a

Please sign in to comment.