Skip to content

Commit

Permalink
feat: polishing some ui naming
Browse files Browse the repository at this point in the history
  • Loading branch information
mvriu5 committed Sep 6, 2024
1 parent 3ccfcac commit 0934960
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 75 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install griller
First, you need to wrap your application with the `Toaster` component. This component will manage the state and positioning of your toasts.

```jsx
import { Toaster } from "griller/toaster";
import Toaster from "griller";

export default function RootLayout({ children }: Readonly<{ children: ReactNode }>) {
return (
Expand All @@ -37,7 +37,7 @@ export default function RootLayout({ children }: Readonly<{ children: ReactNode
To create a toast, use the `useToast` hook in your component:

```jsx
import { Toast } from "griller/toast";
import {useToast} from "griller";

const { addToast } = useToast();

Expand Down Expand Up @@ -87,7 +87,7 @@ const { addToast } = useToast();
Griller allows for extensive customization through custom classnames:

- `titleClassname`
- `secondTitleClassname`
- `subtitleClassname`
- `iconClassname`
- `closeClassname`
- `closeDivClassname`
Expand Down
61 changes: 2 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "griller",
"license": "MIT",
"version": "1.0.22",
"version": "1.0.23",
"private": false,
"repository": {
"url": "https://github.com/mvriu5/griller"
Expand All @@ -20,20 +20,17 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@types/prismjs": "^1.26.4",
"clsx": "^2.1.1",
"framer-motion": "^11.3.19",
"lucide-react": "^0.416.0",
"next": "14.2.5",
"prismjs": "^1.29.0",
"react": "^18",
"react-dom": "^18",
"react-syntax-highlighter": "^15.5.0",
"react-textarea-autosize": "^8.5.3",
"tailwind-merge": "^2.4.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
"@storybook/addon-essentials": "^8.2.6",
"@storybook/addon-interactions": "^8.2.6",
"@storybook/addon-links": "^8.2.6",
Expand Down
2 changes: 1 addition & 1 deletion public/component-example.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Toast} from "griller/toast";
import {useToast} from "griller";

const { addToast } = useToast();

Expand Down
2 changes: 1 addition & 1 deletion public/layout-example.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Toaster} from "griller/toaster";
import Toaster from "griller";

export default function RootLayout({ children }: Readonly<{ children: ReactNode }>) {
return (
Expand Down
6 changes: 3 additions & 3 deletions src/app/lab/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function Home() {
const [icon, setIcon] = useState(false);

const generateCode = useCallback(() => {
return `addToast({\n title: "${title}",\n secondTitle: "${subtitle}",\n icon: ${icon ? "<ShieldAlert size={24} className={\"text-zinc-500\"}/>" : undefined},\n position: "${position}",\n duration: ${duration},\n theme: "${theme}",\n closeButton: ${closeButton},\n actionButton: ${actionButton}\n)};`;
return `addToast({\n title: "${title}",\n subtitle: "${subtitle}",\n icon: ${icon ? "<ShieldAlert size={24} className={\"text-zinc-500\"}/>" : undefined},\n position: "${position}",\n duration: ${duration},\n theme: "${theme}",\n closeButton: ${closeButton},\n actionButton: ${actionButton}\n)};`;
}, [actionButton, closeButton, duration, icon, position, subtitle, theme, title]);

const [code, setCode] = useState<string>(generateCode());
Expand Down Expand Up @@ -87,8 +87,8 @@ export default function Home() {
value={title}
onChange={(e) => setTitle(e.target.value)}
/>
<Input placeholder={"Second Title"}
label={"Second Title"}
<Input placeholder={"Subtitle"}
label={"Subtitle"}
preSelectedValue={"This is a Toast Component!"}
size={60}
value={subtitle}
Expand Down
7 changes: 3 additions & 4 deletions src/component/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {X} from "lucide-react";
import {AnimatePresence, motion} from "framer-motion";
import clsx, {ClassValue} from "clsx";
import {twMerge} from "tailwind-merge";
import {useToast} from "@griller/toaster";

export const cn = (...classes: ClassValue[]) => twMerge(clsx(classes));

Expand Down Expand Up @@ -52,7 +51,7 @@ interface ToastProps extends HTMLAttributes<HTMLDivElement> {

// custom classnames
titleClassname?: string;
secondTitleClassname?: string;
subtitleClassname?: string;
iconClassname?: string;
closeClassname?: string;
closeDivClassname?: string;
Expand All @@ -65,7 +64,7 @@ const Toast: React.FC<ToastProps & {
isPaused: boolean,
}> = ({
id, title, subtitle, icon, scale = 1, position = "br", closeButton, actionButton, onAction, actionButtonText,
duration = 3000, theme = "light", titleClassname, secondTitleClassname, closeClassname, closeDivClassname,
duration = 3000, theme = "light", titleClassname, subtitleClassname, closeClassname, closeDivClassname,
motionClassname, iconClassname, actionButtonClassname, className, removeToast, isPaused, ...props
}) => {

Expand Down Expand Up @@ -166,7 +165,7 @@ const Toast: React.FC<ToastProps & {
{title}
</span>
{subtitle && subtitle.trim() !== "" && (
<span className={cn("text-xs", theme === "light" ? "text-zinc-400" : "text-zinc-300", secondTitleClassname)}>
<span className={cn("text-xs", theme === "light" ? "text-zinc-400" : "text-zinc-300", subtitleClassname)}>
{subtitle}
</span>
)}
Expand Down

0 comments on commit 0934960

Please sign in to comment.