Skip to content

Commit

Permalink
fix: accordion trigger is now a directive (#64)
Browse files Browse the repository at this point in the history
* fix: accordion is now a directive
* fix: moving with tab changes the activeitem of the keymanager
* fix(accordion): accordion.component change to directive
The accordion does not neet to be a component
* fix(accordion): accordion.item change to directive
* refactor(accordion): change transition to grid fr transition
* docs(accordion): adjust examples to directives
* docs: adjust to directives
* fix: remove console logs
* test(accordion): adjust e2e tests to directives
* fix(icon): make icon take host classes into account
* feat(accordion): iterate on benni's accordion changes
* fix: prevents keys on all accordion triggers
* fix: typo
* test: add test for brn-accordion-directive
Co-authored-by: robingotz <[email protected]>

BREAKING CHANGE: accordion trigger is now a directive & accordion icon is replaced with hlm-icon + directive
  • Loading branch information
elite-benni authored Dec 2, 2023
1 parent 0af36ab commit 4138dec
Show file tree
Hide file tree
Showing 23 changed files with 654 additions and 511 deletions.
Original file line number Diff line number Diff line change
@@ -1,157 +1,146 @@
import { Component } from '@angular/core';
import {
BrnAccordionComponent,
BrnAccordionContentComponent,
BrnAccordionItemComponent,
BrnAccordionTriggerComponent,
BrnAccordionDirective,
BrnAccordionItemDirective,
BrnAccordionTriggerDirective,
} from '@spartan-ng/ui-accordion-brain';
import {
HlmAccordionContentDirective,
HlmAccordionDirective,
HlmAccordionIconComponent,
HlmAccordionIconDirective,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
} from '@spartan-ng/ui-accordion-helm';
import { HlmIconComponent } from '@spartan-ng/ui-icon-helm';

@Component({
selector: 'spartan-accordion-preview',
standalone: true,
imports: [
BrnAccordionComponent,
BrnAccordionDirective,
BrnAccordionContentComponent,
BrnAccordionItemComponent,
BrnAccordionTriggerComponent,
BrnAccordionItemDirective,
BrnAccordionTriggerDirective,
HlmAccordionDirective,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
HlmAccordionContentDirective,
HlmAccordionIconComponent,
HlmAccordionIconDirective,
HlmIconComponent,
],
template: `
<brn-accordion hlm>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<span>Is it accessible?</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<div hlmAccordion>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
Is it accessible?
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>Yes. It adheres to the WAI-ARIA design pattern.</brn-accordion-content>
</brn-accordion-item>
</div>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<span>Is it styled</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
Is it styled?
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
Yes. It comes with default styles that match the other components' aesthetics.
</brn-accordion-content>
</brn-accordion-item>
</div>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<span>Is it animated?</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
Is it animated?
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
Yes. It's animated by default, but you can disable it if you prefer.
</brn-accordion-content>
</brn-accordion-item>
</brn-accordion>
</div>
</div>
`,
})
export class AccordionPreviewComponent {}

export const codeString = `
import { Component } from '@angular/core';
export const codeImports = `
import {
BrnAccordionComponent,
BrnAccordionContentComponent,
BrnAccordionItemComponent,
BrnAccordionTriggerComponent,
BrnAccordionDirective,
BrnAccordionItemDirective,
BrnAccordionTriggerDirective,
} from '@spartan-ng/ui-accordion-brain';
import {
HlmAccordionContentDirective,
HlmAccordionDirective,
HlmAccordionIconComponent,
HlmAccordionIconDirective,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
} from '@spartan-ng/ui-accordion-helm';
import { HlmIconComponent } from '@spartan-ng/ui-icon-helm';
`;

@Component({
selector: 'spartan-accordion-preview',
standalone: true,
imports: [
BrnAccordionComponent,
BrnAccordionContentComponent,
BrnAccordionItemComponent,
BrnAccordionTriggerComponent,
HlmAccordionDirective,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
HlmAccordionContentDirective,
HlmAccordionIconComponent,
],
template: \`
<brn-accordion hlm>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<span>Is it accessible?</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<brn-accordion-content hlm> Yes. It adheres to the WAI-ARIA design pattern.</brn-accordion-content>
</brn-accordion-item>
export const codeString =
"import { Component } from '@angular/core';" +
codeImports +
`
@Component({
selector: 'spartan-accordion-preview',
standalone: true,
imports: [
BrnAccordionDirective,
BrnAccordionContentComponent,
BrnAccordionItemDirective,
BrnAccordionTriggerDirective,
HlmAccordionDirective,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
HlmAccordionContentDirective,
HlmAccordionIconDirective,
HlmIconComponent,
],
template: \`
<div hlmAccordion>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
Is it accessible?
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>Yes. It adheres to the WAI-ARIA design pattern.</brn-accordion-content>
</div>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<span>Is it styled</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<brn-accordion-content hlm>
Yes. It comes with default styles that match the other components' aesthetics.
</brn-accordion-content>
</brn-accordion-item>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
Is it styled?
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
Yes. It comes with default styles that match the other components' aesthetics.
</brn-accordion-content>
</div>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<span>Is it animated?</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<brn-accordion-content hlm>
Yes. It's animated by default, but you can disable it if you prefer.
</brn-accordion-content>
</brn-accordion-item>
</brn-accordion>
\`,
<div hlmAccordionItem>
<button hlmAccordionTrigger>
Is it animated?
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
Yes. It's animated by default, but you can disable it if you prefer.
</brn-accordion-content>
</div>
</div>
\`,
})
export class AccordionPreviewComponent {}
`;

export const codeImports = `
import {
BrnAccordionComponent,
BrnAccordionContentComponent,
BrnAccordionItemComponent,
BrnAccordionTriggerComponent,
} from '@spartan-ng/ui-accordion-brain';
import {
HlmAccordionContentDirective,
HlmAccordionDirective,
HlmAccordionIconComponent,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
} from '@spartan-ng/ui-accordion-helm';
`;
export class AccordionPreviewComponent {}`;

export const codeSkeleton = `
<brn-accordion hlm>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<span>Is it accessible?</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<brn-accordion-content hlm>
Yes. It adheres to the WAI-ARIA design pattern.
</brn-accordion-content>
</brn-accordion-item>
</brn-accordion>
<div hlmAccordion>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
Is it accessible?
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>Yes. It adheres to the WAI-ARIA design pattern.</brn-accordion-content>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { RouterLink } from '@angular/router';
import { provideIcons } from '@ng-icons/core';
import { radixChevronRight } from '@ng-icons/radix-icons';
import {
BrnAccordionComponent,
BrnAccordionContentComponent,
BrnAccordionItemComponent,
BrnAccordionTriggerComponent,
BrnAccordionDirective,
BrnAccordionItemDirective,
BrnAccordionTriggerDirective,
} from '@spartan-ng/ui-accordion-brain';
import {
HlmAccordionContentDirective,
HlmAccordionDirective,
HlmAccordionIconComponent,
HlmAccordionIconDirective,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
} from '@spartan-ng/ui-accordion-helm';
Expand Down Expand Up @@ -46,13 +46,13 @@ export const routeMeta: RouteMeta = {
SectionIntroComponent,
SectionSubHeadingComponent,
PageNavComponent,
BrnAccordionComponent,
BrnAccordionDirective,
BrnAccordionContentComponent,
BrnAccordionItemComponent,
BrnAccordionTriggerComponent,
BrnAccordionItemDirective,
BrnAccordionTriggerDirective,
HlmAccordionContentDirective,
HlmAccordionDirective,
HlmAccordionIconComponent,
HlmAccordionIconDirective,
HlmAccordionItemDirective,
HlmAccordionTriggerDirective,
RouterLink,
Expand Down Expand Up @@ -126,47 +126,45 @@ export const routeMeta: RouteMeta = {
</a>
</div>
<spartan-section-sub-heading id="faq">FAQ</spartan-section-sub-heading>
<brn-accordion hlm>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<div hlmAccordion>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
<span>What is spartan/stack</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
It is a collection of full-stack technologies that power end-to-end type-safe Angular development.
</brn-accordion-content>
</brn-accordion-item>
</div>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
<span>What is spartan/ui</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
A collection of Angular UI primitives that are both beautiful and accessible.
</brn-accordion-content>
</brn-accordion-item>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
</div>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
<span>What is spartan/ui/brain</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
A collection of unstyled UI primitives that provide accessibility out of the box.
</brn-accordion-content>
</brn-accordion-item>
<brn-accordion-item hlm>
<brn-accordion-trigger hlm>
</div>
<div hlmAccordionItem>
<button hlmAccordionTrigger>
<span>What is spartan/ui/helm</span>
<hlm-accordion-icon />
</brn-accordion-trigger>
<hlm-icon hlmAccIcon />
</button>
<brn-accordion-content hlm>
Directives, sometimes additional components, that give spartan/brain a shadcn look.
</brn-accordion-content>
</brn-accordion-item>
</brn-accordion>
</div>
</div>
<spartan-page-bottom-nav>
<spartan-page-bottom-nav-link href="cli" label="CLI" />
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/app/shared/layout/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SideNavComponent } from '~/app/shared/layout/side-nav/side-nav.componen
template: `
<spartan-side-nav />
<main class="sticky top-0 overflow-hidden py-6 lg:gap-10 lg:py-8 xl:grid xl:grid-cols-[minmax(0,1fr)_280px]">
<div>
<div class="px-2">
<spartan-breadcrumbs />
<router-outlet />
</div>
Expand Down
Loading

0 comments on commit 4138dec

Please sign in to comment.