-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
17 changed files
with
290 additions
and
2 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
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,81 @@ | ||
--- | ||
title: Textarea | ||
description: Displays a form textarea or a component that looks like a textarea. | ||
component: true | ||
--- | ||
|
||
<ComponentPreview name="textarea-demo" description="A textarea" /> | ||
|
||
## Installation | ||
|
||
<Tabs defaultValue="cli"> | ||
|
||
<TabsList> | ||
<TabsTrigger value="cli">CLI</TabsTrigger> | ||
<TabsTrigger value="manual">Manual</TabsTrigger> | ||
</TabsList> | ||
<TabsContent value="cli"> | ||
|
||
```bash | ||
npx shadcn-ng@latest add textarea | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step>Copy and paste the following code into your project.</Step> | ||
|
||
<ComponentSource name="textarea" /> | ||
|
||
<Step>Update the import paths to match your project setup.</Step> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { UbTextareaDirective } from "@/components/ui/textarea" | ||
``` | ||
|
||
```html | ||
<textarea ubTextarea></textarea> | ||
``` | ||
|
||
## Examples | ||
|
||
### Default | ||
|
||
<ComponentPreview name="textarea-demo" description="A textarea" /> | ||
|
||
### Disabled | ||
|
||
<ComponentPreview name="textarea-disabled" description="A disabled textarea" /> | ||
|
||
### With Label | ||
|
||
<ComponentPreview | ||
name="textarea-with-label" | ||
className="[&_div.grid]:w-full" | ||
description="A textarea with a label" | ||
/> | ||
|
||
### With Text | ||
|
||
<ComponentPreview | ||
name="textarea-with-text" | ||
description="A textarea with text" | ||
/> | ||
|
||
### With Button | ||
|
||
<ComponentPreview | ||
name="textarea-with-button" | ||
description="A textarea with a button" | ||
/> |
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 @@ | ||
import { UbTextAreaDirective } from '@/registry/default/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-demo-default]', | ||
imports: [UbTextAreaDirective], | ||
template: `<textarea ubTextarea placeholder="Type your message here."></textarea>`, | ||
}) | ||
export default class TextAreaDemoDefault { } |
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 @@ | ||
import { UbTextAreaDirective } from '@/registry/default/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-disabled-default]', | ||
imports: [UbTextAreaDirective], | ||
template: `<textarea ubTextarea placeholder="Type your message here." disabled></textarea>`, | ||
}) | ||
export default class TextAreaDisabledDefault { } |
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,15 @@ | ||
import { UbButtonDirective } from '@/registry/default/ui/button' | ||
import { UbTextAreaDirective } from '@/registry/default/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-with-label-default]', | ||
imports: [UbTextAreaDirective, UbButtonDirective], | ||
template: ` | ||
<div class="grid w-full gap-2"> | ||
<textarea ubTextarea placeholder="Type your message here."></textarea> | ||
<button ubButton>Send message</button> | ||
</div>`, | ||
}) | ||
export default class TextAreaWithButtonDefault { } |
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,15 @@ | ||
import { UbLabelDirective } from '@/registry/default/ui/label' | ||
import { UbTextAreaDirective } from '@/registry/default/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-with-label-default]', | ||
imports: [UbTextAreaDirective, UbLabelDirective], | ||
template: ` | ||
<div class="grid w-full gap-1.5"> | ||
<label ubLabel for="message">Your message</label> | ||
<textarea ubTextarea placeholder="Type your message here." id="message"></textarea> | ||
</div>`, | ||
}) | ||
export default class TextAreaWithLabelDefault { } |
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,18 @@ | ||
import { UbLabelDirective } from '@/registry/default/ui/label' | ||
import { UbTextAreaDirective } from '@/registry/default/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-with-text-default]', | ||
imports: [UbTextAreaDirective, UbLabelDirective], | ||
template: ` | ||
<div class="grid w-full gap-1.5"> | ||
<label ubLabel for="message">Your message</label> | ||
<textarea ubTextarea placeholder="Type your message here." id="message"></textarea> | ||
<p class="text-sm text-muted-foreground"> | ||
Your message will be copied to the support team. | ||
</p> | ||
</div>`, | ||
}) | ||
export default class TextAreaWithTextDefault { } |
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,17 @@ | ||
import { cn } from '@/lib/utils' | ||
|
||
import { computed, Directive, input } from '@angular/core' | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[ubTextarea]', | ||
host: { | ||
'[class]': 'computedClass()', | ||
}, | ||
}) | ||
export class UbTextAreaDirective { | ||
class = input<string>() | ||
computedClass = computed(() => | ||
cn('flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', this.class()), | ||
) | ||
} |
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 @@ | ||
import { UbTextAreaDirective } from '@/registry/new-york/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-demo-new-york]', | ||
imports: [UbTextAreaDirective], | ||
template: `<textarea ubTextarea placeholder="Type your message here."></textarea>`, | ||
}) | ||
export default class TextAreaDemoNewYork { } |
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 @@ | ||
import { UbTextAreaDirective } from '@/registry/new-york/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-disabled-new-york]', | ||
imports: [UbTextAreaDirective], | ||
template: `<textarea ubTextarea placeholder="Type your message here." disabled></textarea>`, | ||
}) | ||
export default class TextAreaDisabledNewYork { } |
15 changes: 15 additions & 0 deletions
15
docs/src/registry/new-york/example/textarea-with-button.ts
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,15 @@ | ||
import { UbButtonDirective } from '@/registry/new-york/ui/button' | ||
import { UbTextAreaDirective } from '@/registry/new-york/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-with-label-new-york]', | ||
imports: [UbTextAreaDirective, UbButtonDirective], | ||
template: ` | ||
<div class="grid w-full gap-2"> | ||
<textarea ubTextarea placeholder="Type your message here."></textarea> | ||
<button ubButton>Send message</button> | ||
</div>`, | ||
}) | ||
export default class TextAreaWithButtonNewYork { } |
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,15 @@ | ||
import { UbLabelDirective } from '@/registry/new-york/ui/label' | ||
import { UbTextAreaDirective } from '@/registry/new-york/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-with-label-new-york]', | ||
imports: [UbTextAreaDirective, UbLabelDirective], | ||
template: ` | ||
<div class="grid w-full gap-1.5"> | ||
<label ubLabel for="message">Your message</label> | ||
<textarea ubTextarea placeholder="Type your message here." id="message"></textarea> | ||
</div>`, | ||
}) | ||
export default class TextAreaWithLabelNewYork { } |
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,18 @@ | ||
import { UbLabelDirective } from '@/registry/new-york/ui/label' | ||
import { UbTextAreaDirective } from '@/registry/new-york/ui/textarea' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[textarea-with-text-new-york]', | ||
imports: [UbTextAreaDirective, UbLabelDirective], | ||
template: ` | ||
<div class="grid w-full gap-1.5"> | ||
<label ubLabel for="message">Your message</label> | ||
<textarea ubTextarea placeholder="Type your message here." id="message"></textarea> | ||
<p class="text-sm text-muted-foreground"> | ||
Your message will be copied to the support team. | ||
</p> | ||
</div>`, | ||
}) | ||
export default class TextAreaWithTextNewYork { } |
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,17 @@ | ||
import { cn } from '@/lib/utils' | ||
|
||
import { computed, Directive, input } from '@angular/core' | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[ubTextarea]', | ||
host: { | ||
'[class]': 'computedClass()', | ||
}, | ||
}) | ||
export class UbTextAreaDirective { | ||
class = input<string>() | ||
computedClass = computed(() => | ||
cn('flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', this.class()), | ||
) | ||
} |
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