-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
506258e
commit bc428c2
Showing
14 changed files
with
359 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { Alert, AlertTitle, AlertDescription } from "@signozhq/alert"; | ||
|
||
const meta: Meta<typeof Alert> = { | ||
title: "Components/Alert", | ||
component: Alert, | ||
tags: ["autodocs"], | ||
argTypes: { | ||
variant: { | ||
control: "select", | ||
options: ["default", "destructive"], | ||
}, | ||
title: { | ||
control: "text", | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Alert>; | ||
|
||
const Template: Story = { | ||
render: ({ variant, title, children }) => ( | ||
<Alert variant={variant}> | ||
{title && <AlertTitle>{title}</AlertTitle>} | ||
<AlertDescription>{children}</AlertDescription> | ||
</Alert> | ||
), | ||
}; | ||
|
||
export const Default: Story = { | ||
...Template, | ||
args: { | ||
variant: "default", | ||
title: "Heads up!", | ||
children: | ||
"You can add components and dependencies to your app using the cli.", | ||
}, | ||
}; | ||
|
||
export const Destructive: Story = { | ||
...Template, | ||
args: { | ||
variant: "destructive", | ||
title: "Error", | ||
children: "Your session has expired. Please log in again.", | ||
}, | ||
}; | ||
|
||
export const TitleOnly: Story = { | ||
...Template, | ||
args: { | ||
title: "Note", | ||
children: null, | ||
}, | ||
}; | ||
|
||
export const DescriptionOnly: Story = { | ||
...Template, | ||
args: { | ||
title: "", | ||
children: "This is a description-only alert.", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
extends: ["@repo/eslint-config/react.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"style": "new-york", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "@signozhq/tailwind-config/tailwind.config.js", | ||
"css": "src/index.css", | ||
"baseColor": "zinc", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils", | ||
"ui": "src", | ||
"lib": "@/lib", | ||
"hooks": "@/hooks" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "@signozhq/alert", | ||
"version": "0.0.0", | ||
"sideEffects": false, | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/alert.d.ts", | ||
"import": "./dist/alert.js" | ||
} | ||
}, | ||
"main": "./dist/alert.js", | ||
"module": "./dist/alert.js", | ||
"types": "./dist/alert.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "vite build", | ||
"dev": "vite build --watch", | ||
"lint": "eslint . --max-warnings 0", | ||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" | ||
}, | ||
"devDependencies": { | ||
"@repo/eslint-config": "workspace:*", | ||
"@repo/typescript-config": "workspace:*", | ||
"@signozhq/tailwind-config": "workspace:*", | ||
"@types/node": "^22.5.5", | ||
"@types/react": "^18.2.61", | ||
"@types/react-dom": "^18.2.19", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"autoprefixer": "^10.4.20", | ||
"eslint": "^9.11.0", | ||
"postcss": "^8.4.47", | ||
"react-dom": "^18.2.0", | ||
"tailwindcss": "^3.4.12", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.0.0", | ||
"vite-plugin-lib-inject-css": "^2.1.1", | ||
"vite-plugin-dts": "^4.2.1" | ||
}, | ||
"dependencies": { | ||
"@radix-ui/react-icons": "^1.3.0", | ||
"@radix-ui/react-slot": "^1.1.0", | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.1", | ||
"lucide-react": "^0.445.0", | ||
"react": "^18.2.0", | ||
"tailwind-merge": "^2.5.2", | ||
"tailwindcss-animate": "^1.0.7" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"description": "Shadcn based alert component" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import "./index.css" | ||
import * as React from "react" | ||
import { cva, type VariantProps } from "class-variance-authority" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const alertVariants = cva( | ||
"relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", | ||
{ | ||
variants: { | ||
variant: { | ||
default: "bg-background text-foreground", | ||
destructive: | ||
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: "default", | ||
}, | ||
} | ||
) | ||
|
||
const Alert = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants> | ||
>(({ className, variant, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
role="alert" | ||
className={cn(alertVariants({ variant }), className)} | ||
{...props} | ||
/> | ||
)) | ||
Alert.displayName = "Alert" | ||
|
||
const AlertTitle = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLHeadingElement> | ||
>(({ className, ...props }, ref) => ( | ||
<h5 | ||
ref={ref} | ||
className={cn("mb-1 font-medium leading-none tracking-tight", className)} | ||
{...props} | ||
/> | ||
)) | ||
AlertTitle.displayName = "AlertTitle" | ||
|
||
const AlertDescription = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLParagraphElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("text-sm [&_p]:leading-relaxed", className)} | ||
{...props} | ||
/> | ||
)) | ||
AlertDescription.displayName = "AlertDescription" | ||
|
||
export { Alert, AlertTitle, AlertDescription } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { clsx, type ClassValue } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const sharedConfig = require("@signozhq/tailwind-config/tailwind.config.js"); | ||
|
||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
...sharedConfig, | ||
content: [...sharedConfig.content, "./src/**/*.{js,ts,jsx,tsx}"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
}, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "@repo/typescript-config/react-library.json", | ||
"include": ["src"], | ||
"exclude": ["dist", "build", "node_modules"], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import path from "path"; | ||
import { defineConfig } from "vite"; | ||
import dts from "vite-plugin-dts"; | ||
import react from "@vitejs/plugin-react"; | ||
import { resolve } from "path"; | ||
import { libInjectCss } from "vite-plugin-lib-inject-css"; | ||
|
||
export default defineConfig({ | ||
build: { | ||
lib: { | ||
entry: resolve(__dirname, "src/alert.tsx"), | ||
name: "Button", | ||
fileName: "alert", | ||
}, | ||
rollupOptions: { | ||
external: ["react"], | ||
output: { | ||
globals: { | ||
react: "React", | ||
}, | ||
}, | ||
treeshake: true, | ||
}, | ||
}, | ||
plugins: [dts(), react(), libInjectCss()], | ||
resolve: { | ||
alias: { | ||
"@": path.resolve(__dirname, "./src"), | ||
}, | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.