-
Notifications
You must be signed in to change notification settings - Fork 131
Daily #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daily #500
Changes from all commits
d706e9b
2264ed9
9339fa2
6b2a010
65450b1
7e1f5a0
011406b
5c414cb
7a56e79
637fd5b
5b5f4ab
00828d7
12aa781
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| "use client"; | ||
|
|
||
| import React, { useState } from "react"; | ||
| import { TagInput } from "@/components/tag"; | ||
| import { ComponentDemo } from "../component-demo"; | ||
|
|
||
| export default function TagsPage() { | ||
| const [tags, setTags] = useState<{ id: string; text: string }[]>([ | ||
| { id: "react", text: "react" }, | ||
| { id: "typescript", text: "typescript" }, | ||
| ]); | ||
| const [tagsWithAutocomplete, setTagsWithAutocomplete] = useState< | ||
| { id: string; text: string }[] | ||
| >([]); | ||
| const [emptyTags, setEmptyTags] = useState<{ id: string; text: string }[]>( | ||
| [] | ||
| ); | ||
| const [coloredTags, setColoredTags] = useState< | ||
| { id: string; text: string; color?: string }[] | ||
| >([{ id: "urgent", text: "urgent", color: "#ef4444" }]); | ||
|
|
||
| const autocompleteOptions = [ | ||
| { id: "apple", text: "apple" }, | ||
| { id: "banana", text: "banana" }, | ||
| { id: "cherry", text: "cherry" }, | ||
| { id: "date", text: "date" }, | ||
| { id: "elderberry", text: "elderberry" }, | ||
| { id: "fig", text: "fig" }, | ||
| { id: "grape", text: "grape" }, | ||
| { id: "honeydew", text: "honeydew" }, | ||
| { id: "kiwi", text: "kiwi" }, | ||
| { id: "lemon", text: "lemon" }, | ||
| { id: "mango", text: "mango" }, | ||
| { id: "orange", text: "orange" }, | ||
| { id: "papaya", text: "papaya" }, | ||
| { id: "raspberry", text: "raspberry" }, | ||
| { id: "strawberry", text: "strawberry" }, | ||
| ]; | ||
|
|
||
| const coloredAutocompleteOptions = [ | ||
| { id: "urgent", text: "urgent", color: "#ef4444" }, | ||
| { id: "review", text: "review", color: "#f59e0b" }, | ||
| { id: "planned", text: "planned", color: "#3b82f6" }, | ||
| { id: "done", text: "done", color: "#22c55e" }, | ||
| { id: "blocked", text: "blocked", color: "#a855f7" }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <main className="container max-w-screen-lg mx-auto py-10"> | ||
| <div className="space-y-8"> | ||
| <div> | ||
| <h1 className="text-3xl font-bold mb-2">Tag Input</h1> | ||
| <p className="text-gray-600"> | ||
| A flexible tag input component with autocomplete support for | ||
| managing multiple values. | ||
| </p> | ||
| </div> | ||
|
|
||
| <hr /> | ||
|
|
||
| <section className="space-y-4"> | ||
| <div> | ||
| <h2 className="text-xl font-semibold mb-1">Basic Usage</h2> | ||
| <p className="text-sm text-gray-600"> | ||
| Create and manage tags with keyboard support | ||
| </p> | ||
| </div> | ||
| <ComponentDemo | ||
| notes={ | ||
| <> | ||
| <strong>Tips:</strong> Type and press Enter to add tags. Click | ||
| on a tag to remove it. | ||
| </> | ||
| } | ||
| > | ||
| <TagInput | ||
| tags={tags} | ||
| setTags={setTags} | ||
| activeTagIndex={null} | ||
| setActiveTagIndex={() => {}} | ||
| /> | ||
|
Comment on lines
+76
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wire With 🛠️ Suggested wiring-import React, { useState } from "react";
+import React, { useState } from "react";
export default function TagsPage() {
+ const [basicActiveIndex, setBasicActiveIndex] = useState<number | null>(null);
+ const [autoActiveIndex, setAutoActiveIndex] = useState<number | null>(null);
+ const [colorActiveIndex, setColorActiveIndex] = useState<number | null>(null);
+ const [emptyActiveIndex, setEmptyActiveIndex] = useState<number | null>(null);
const [tags, setTags] = useState<{ id: string; text: string }[]>([
{ id: "react", text: "react" },
{ id: "typescript", text: "typescript" },
]);
...
<TagInput
tags={tags}
setTags={setTags}
- activeTagIndex={null}
- setActiveTagIndex={() => {}}
+ activeTagIndex={basicActiveIndex}
+ setActiveTagIndex={setBasicActiveIndex}
/>
...
<TagInput
tags={tagsWithAutocomplete}
setTags={setTagsWithAutocomplete}
enableAutocomplete
autocompleteOptions={autocompleteOptions}
- activeTagIndex={null}
- setActiveTagIndex={() => {}}
+ activeTagIndex={autoActiveIndex}
+ setActiveTagIndex={setAutoActiveIndex}
/>
...
<TagInput
tags={coloredTags}
setTags={setColoredTags}
enableAutocomplete
autocompleteOptions={coloredAutocompleteOptions}
- activeTagIndex={null}
- setActiveTagIndex={() => {}}
+ activeTagIndex={colorActiveIndex}
+ setActiveTagIndex={setColorActiveIndex}
/>
...
<TagInput
tags={emptyTags}
setTags={setEmptyTags}
- activeTagIndex={null}
- setActiveTagIndex={() => {}}
+ activeTagIndex={emptyActiveIndex}
+ setActiveTagIndex={setEmptyActiveIndex}
/>Also applies to: 102-109, 130-137, 151-156 🤖 Prompt for AI Agents |
||
| </ComponentDemo> | ||
| </section> | ||
|
|
||
| <hr /> | ||
|
|
||
| <section className="space-y-4"> | ||
| <div> | ||
| <h2 className="text-xl font-semibold mb-1">With Autocomplete</h2> | ||
| <p className="text-sm text-gray-600"> | ||
| Enable autocomplete suggestions for faster input | ||
| </p> | ||
| </div> | ||
| <ComponentDemo | ||
| notes={ | ||
| <> | ||
| <strong>Tips:</strong> Start typing to see autocomplete | ||
| suggestions. Select from the dropdown or create custom tags. | ||
| </> | ||
| } | ||
| > | ||
| <TagInput | ||
| tags={tagsWithAutocomplete} | ||
| setTags={setTagsWithAutocomplete} | ||
| enableAutocomplete | ||
| autocompleteOptions={autocompleteOptions} | ||
| activeTagIndex={null} | ||
| setActiveTagIndex={() => {}} | ||
| /> | ||
| </ComponentDemo> | ||
| </section> | ||
|
|
||
| <hr /> | ||
|
|
||
| <section className="space-y-4"> | ||
| <div> | ||
| <h2 className="text-xl font-semibold mb-1">With Colors</h2> | ||
| <p className="text-sm text-gray-600"> | ||
| Autocomplete and selected tags can be color-coded. | ||
| </p> | ||
| </div> | ||
| <ComponentDemo | ||
| notes={ | ||
| <> | ||
| <strong>Tips:</strong> Pick from the colored suggestions to see | ||
| the chips tinted, Notion-style. | ||
| </> | ||
| } | ||
| > | ||
| <TagInput | ||
| tags={coloredTags} | ||
| setTags={setColoredTags} | ||
| enableAutocomplete | ||
| autocompleteOptions={coloredAutocompleteOptions} | ||
| activeTagIndex={null} | ||
| setActiveTagIndex={() => {}} | ||
| /> | ||
| </ComponentDemo> | ||
| </section> | ||
|
|
||
| <hr /> | ||
|
|
||
| <section className="space-y-4"> | ||
| <div> | ||
| <h2 className="text-xl font-semibold mb-1">Empty State</h2> | ||
| <p className="text-sm text-gray-600"> | ||
| Tag input without any initial values | ||
| </p> | ||
| </div> | ||
| <ComponentDemo notes="Start typing to add your first tag."> | ||
| <TagInput | ||
| tags={emptyTags} | ||
| setTags={setEmptyTags} | ||
| activeTagIndex={null} | ||
| setActiveTagIndex={() => {}} | ||
| /> | ||
| </ComponentDemo> | ||
| </section> | ||
| </div> | ||
| </main> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.