Skip to content

Commit

Permalink
feat: add label component
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-ub committed Jul 24, 2024
1 parent e904cb3 commit be466fe
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
28 changes: 28 additions & 0 deletions apps/www/src/registry/default/ui/label.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { computed, Directive, input } from "@angular/core";

import { RdxLabelRootDirective } from "@radix-ng/primitives/label";
import { cva } from "class-variance-authority";

import { cn } from "@/lib/utils";

const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
);

@Directive({
selector: "[ubLabel]",
standalone: true,
hostDirectives: [
{
directive: RdxLabelRootDirective,
inputs: ["htmlFor"],
},
],
host: {
"[class]": "computedClass()",
},
})
export class UbLabelDirective {
readonly class = input<string>("");
protected computedClass = computed(() => cn(labelVariants(), this.class()));
}
28 changes: 28 additions & 0 deletions apps/www/src/registry/new-york/ui/label.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { computed, Directive, input } from "@angular/core";

import { RdxLabelRootDirective } from "@radix-ng/primitives/label";
import { cva } from "class-variance-authority";

import { cn } from "@/lib/utils";

const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
);

@Directive({
selector: "[ubLabel]",
standalone: true,
hostDirectives: [
{
directive: RdxLabelRootDirective,
inputs: ["htmlFor"],
},
],
host: {
"[class]": "computedClass()",
},
})
export class UbLabelDirective {
readonly class = input<string>("");
protected computedClass = computed(() => cn(labelVariants(), this.class()));
}
6 changes: 6 additions & 0 deletions apps/www/src/registry/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export const ui: Registry = [
type: "components:ui",
files: ["ui/card.directive.ts"],
},
{
name: "label",
type: "components:ui",
dependencies: ["@radix-ng/primitives"],
files: ["ui/label.directive.ts"],
},
{
name: "separator",
type: "components:ui",
Expand Down

0 comments on commit be466fe

Please sign in to comment.