Skip to content

Commit

Permalink
chore: updated shadcn tabs for showcase
Browse files Browse the repository at this point in the history
  • Loading branch information
pimenovoleg committed Jan 5, 2025
1 parent 6889f40 commit 6187ae7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import { ShTabsModule } from '@radix-ng/shadcn/tabs';
ShButtonDirective
],
template: `
<div class="w-[350px]" shTabs shDefaultValue="account">
<div class="grid w-full grid-cols-2" shTabsList>
<sh-tabs class="w-[350px]" shDefaultValue="account">
<sh-tabs-list class="grid w-full grid-cols-2">
<button shTabsTrigger shValue="account">Account</button>
<button shTabsTrigger shValue="password">Password</button>
</div>
</sh-tabs-list>
<div shTabsContent shValue="account">
<sh-tabs-content shValue="account">
<shCard class="block">
<shCardHeader>
<shCardTitle>Account</shCardTitle>
Expand All @@ -55,9 +55,9 @@ import { ShTabsModule } from '@radix-ng/shadcn/tabs';
<button shButton>Save changes</button>
</shCardFooter>
</shCard>
</div>
</sh-tabs-content>
<div shTabsContent shValue="password">
<sh-tabs-content shValue="password">
<shCard class="block">
<shCardHeader>
<shCardTitle>Password</shCardTitle>
Expand All @@ -79,8 +79,8 @@ import { ShTabsModule } from '@radix-ng/shadcn/tabs';
<button shButton>Save password</button>
</shCardFooter>
</shCard>
</div>
</div>
</sh-tabs-content>
</sh-tabs>
`
})
export class TabsExampleComponent {}
4 changes: 2 additions & 2 deletions packages/shadcn/tabs/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import {
ShTabsContentDirective,
ShTabsContentComponent,
ShTabsDirective,
ShTabsListDirective,
ShTabsTriggerDirective
Expand All @@ -10,7 +10,7 @@ export * from './src/tabs.directive';

const tabsImports = [
ShTabsDirective,
ShTabsContentDirective,
ShTabsContentComponent,
ShTabsTriggerDirective,
ShTabsListDirective
];
Expand Down
27 changes: 14 additions & 13 deletions packages/shadcn/tabs/src/tabs.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, Directive, Input, input } from '@angular/core';
import { Component, computed, Directive, Input, input } from '@angular/core';
import {
RdxTabsContentDirective,
RdxTabsListDirective,
Expand All @@ -10,7 +10,7 @@ import { cva } from 'class-variance-authority';

// TabsPrimitive.Root
@Directive({
selector: '[shTabs]',
selector: 'sh-tabs,[shTabs]',
standalone: true,
hostDirectives: [{ directive: RdxTabsRootDirective, inputs: ['defaultValue: shDefaultValue'] }]
})
Expand All @@ -23,7 +23,7 @@ const tabsListVariants = cva(
'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground'
);
@Directive({
selector: '[shTabsList]',
selector: 'sh-tabs-list,[shTabsList]',
standalone: true,
hostDirectives: [RdxTabsListDirective],
host: {
Expand Down Expand Up @@ -56,17 +56,18 @@ export class ShTabsTriggerDirective {
const tabsContentVariants = cva(
'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2'
);
@Directive({
selector: '[shTabsContent]',
standalone: true,
hostDirectives: [{ directive: RdxTabsContentDirective, inputs: ['value: shValue'] }],
host: {
'[class]': 'computedClass()'
}
@Component({
selector: 'sh-tabs-content,[shTabsContent]',
imports: [RdxTabsContentDirective],
template: `
<div [class]="computedClass()" [value]="shValue()" rdxTabsContent>
<ng-content />
</div>
`
})
export class ShTabsContentDirective {
export class ShTabsContentComponent {
readonly shValue = input.required<string>();

readonly class = input<string>();
protected computedClass = computed(() => cn(tabsContentVariants(), this.class()));
readonly classContent = input<string>();
protected computedClass = computed(() => cn(tabsContentVariants(), this.classContent()));
}

0 comments on commit 6187ae7

Please sign in to comment.