Skip to content

Commit

Permalink
init ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Bereket Engida committed May 19, 2023
1 parent 096b3bd commit e18ebcd
Show file tree
Hide file tree
Showing 26 changed files with 1,850 additions and 151 deletions.
4 changes: 3 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"linked": [],
"access": "public",
"baseBranch": "main",
"ignore": [],
"ignore": [
"examples/nextjs"
],
"changelog": "@changesets/cli/changelog"
}
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const config = {
"**/node_modules/**",
".eslintrc.cjs",
"**/config.*",
"tailwind.config.js",
"postcss.config.js"
],
};

Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"clsx"
]
}
10 changes: 9 additions & 1 deletion examples/nextjs/app/api/loglib/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { Next13 } from "@loglib/next"
import { prismaAdapter } from "@loglib/prisma-adapter"
import { PrismaClient } from "@prisma/client"

export const POST = Next13

const db = new PrismaClient()
const POST = Next13({
adapter: prismaAdapter(db),
disableLocation: true
})
export { POST }
116 changes: 3 additions & 113 deletions examples/nextjs/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,113 +1,3 @@
:root {
--max-width: 1100px;
--border-radius: 12px;
--font-mono: ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono",
"Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro",
"Fira Mono", "Droid Sans Mono", "Courier New", monospace;

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

--primary-glow: conic-gradient(
from 180deg at 50% 50%,
#16abff33 0deg,
#0885ff33 55deg,
#54d6ff33 120deg,
#0071ff33 160deg,
transparent 360deg
);
--secondary-glow: radial-gradient(
rgba(255, 255, 255, 1),
rgba(255, 255, 255, 0)
);

--tile-start-rgb: 239, 245, 249;
--tile-end-rgb: 228, 232, 233;
--tile-border: conic-gradient(
#00000080,
#00000040,
#00000030,
#00000020,
#00000010,
#00000010,
#00000080
);

--callout-rgb: 238, 240, 241;
--callout-border-rgb: 172, 175, 176;
--card-rgb: 180, 185, 188;
--card-border-rgb: 131, 134, 135;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;

--primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0));
--secondary-glow: linear-gradient(
to bottom right,
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0),
rgba(1, 65, 255, 0.3)
);

--tile-start-rgb: 2, 13, 46;
--tile-end-rgb: 2, 5, 19;
--tile-border: conic-gradient(
#ffffff80,
#ffffff40,
#ffffff30,
#ffffff20,
#ffffff10,
#ffffff10,
#ffffff80
);

--callout-rgb: 20, 20, 20;
--callout-border-rgb: 108, 108, 108;
--card-rgb: 100, 100, 100;
--card-border-rgb: 200, 200, 200;
}
}

* {
box-sizing: border-box;
padding: 0;
margin: 0;
}

html,
body {
max-width: 100vw;
min-height: 100vh;
overflow-x: hidden;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8;
}

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

a {
color: inherit;
text-decoration: none;
}

@media (prefers-color-scheme: dark) {
html {
color-scheme: dark;
}
}
@tailwind base;
@tailwind components;
@tailwind utilities;
3 changes: 2 additions & 1 deletion examples/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "./globals.css";
import { Inter } from "next/font/google";
import LogLib from "@loglib/tracker/react"
import LogLib from "@loglib/tracker/react";


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

Expand Down
16 changes: 5 additions & 11 deletions examples/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
"use client"
import Link from "next/link";
import { getDashboard } from "@loglib/ui"
import "@loglib/ui/dist/index.css"


export default function HomePage() {
return <div>
<Link href="/example">
example
</Link>
<button>
click me
</button>
</div>;
}

export default getDashboard()
6 changes: 5 additions & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@loglib/next": "0.0.2",
"@loglib/prisma-adapter": "0.0.2",
"@loglib/tracker": "0.0.2",
"@loglib/ui": "workspace:*",
"@prisma/client": "^4.14.0",
"@types/node": "^18.15.13",
"@types/react": "^18.2.0",
Expand All @@ -24,6 +25,9 @@
"devDependencies": {
"@prisma-enums/eslint-plugin": "^0.2.0",
"@prisma-enums/generator": "^0.2.0",
"prisma": "^4.14.0"
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"prisma": "^4.14.0",
"tailwindcss": "^3.3.2"
}
}
6 changes: 6 additions & 0 deletions examples/nextjs/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
11 changes: 11 additions & 0 deletions examples/nextjs/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {},
},
plugins: [],
}

Binary file modified packages/adapter-prisma/prisma/dev.db
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/adapter-prisma/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,5 @@ export const prismaAdapter = (db: PrismaClient): Adapter => {
await db.$disconnect()
}
}
}
}

2 changes: 1 addition & 1 deletion packages/core/src/router/routes/session/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const sessionPost: ApiPostHandler<SessionPostInput> = async (req, options
const ipAddress = options.environment === "test" ? "155.252.206.205" : getIpAddress(req) as string
if (!await isLocalhost(ipAddress)) {
const location = !options.disableLocation ? options.getLocation ? await options.getLocation().catch(() => null) : await getLocation(ipAddress, req).catch(() => null) : { city: null, country: null }
if (!location && !options.disableLocation) return { message: "Invalid location", code: 400 }
if (!location && !options.disableLocation) throw new GenericError("Error: Could not find MaxMind database in root folder. Please make sure the database is in the root folder or run loglib setup-geo. read more", { path: "/session" })
const { city, country } = location ? location : { city: null, country: null }
const adapter = options.adapter
const userAgent = req.headers['user-agent'] as string
Expand Down
6 changes: 4 additions & 2 deletions packages/framework-next/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const LogLib = (options: LogLibOptions) => {
}

const Next13 = (options: LogLibOptions) => {
return async (req: Request) => {
const POST = async (req: Request) => {
try {
const body = await req.json() as Record<string, string>
const header = Object.fromEntries(new Headers(req.headers))
Expand All @@ -32,10 +32,12 @@ const Next13 = (options: LogLibOptions) => {
query,
cookies: cookies()
}, options)
console.log(internalResponse)
return NextResponse.json({ message: internalResponse }, { status: 200 })
} catch (e) {
return NextResponse.json({ message: "bad request" }, { status: 400 })
return NextResponse.json({ message: e }, { status: 400 })
}
}
return POST
}
export { LogLib, Next13 };
56 changes: 56 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@loglib/ui",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"test": "vitest run",
"dev": "tsup --watch",
"build": "tsup",
"typecheck": "tsc --noEmit",
"lint": "eslint . --ext .ts"
},
"files": [
"dist",
"package.json",
"LICENSE",
"README.md"
],
"keywords": [],
"author": "",
"license": "ISC",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./dist/index.css": "./dist/index.css"
},
"devDependencies": {
"@types/react": "^18.2.0",
"next": "^13.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"peerDependencies": {
"next": "^13.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"dependencies": {
"@radix-ui/react-avatar": "^1.0.2",
"add": "^2.0.6",
"autoprefixer": "^10.4.14",
"avatar": "^0.1.0",
"class-variance-authority": "^0.6.0",
"clsx": "^1.2.1",
"lucide-react": "^0.220.0",
"pnpx": "^0.0.1",
"recharts": "^2.6.2",
"shadcn-ui": "^0.1.3",
"tailwind-merge": "^1.12.0",
"tailwindcss": "^3.3.2",
"tailwindcss-animate": "^1.0.5"
}
}
3 changes: 3 additions & 0 deletions packages/ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: [require('tailwindcss')(), require('autoprefixer')()],
}
4 changes: 4 additions & 0 deletions packages/ui/src/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import url('https://fonts.cdnfonts.com/css/neue-haas-grotesk-display-pro');
@tailwind base;
@tailwind components;
@tailwind utilities;
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './react'
50 changes: 50 additions & 0 deletions packages/ui/src/react/components/ui/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use client"

import * as React from "react"
import * as AvatarPrimitive from "@radix-ui/react-avatar"

import { cn } from "@/src/react/lib/utils"

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
className
)}
{...props}
/>
))
Avatar.displayName = AvatarPrimitive.Root.displayName

const AvatarImage = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
className={cn("aspect-square h-full w-full", className)}
{...props}
/>
))
AvatarImage.displayName = AvatarPrimitive.Image.displayName

const AvatarFallback = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
"flex h-full w-full items-center justify-center rounded-full bg-muted",
className
)}
{...props}
/>
))
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName

export { Avatar, AvatarImage, AvatarFallback }
Loading

0 comments on commit e18ebcd

Please sign in to comment.