Collapsible changelog
Every version of Collapsible, newest first. Update with npx @ndop/cli update collapsible; it keeps your edits.
Preview an update
Paste your copy of the file to see what updating it to 1.0.0 would do.
1.0.0 Latest
Stable release; no code changes since 0.3.0.
0.3.0
The content slides open and closed, with tw-animate-css's collapsible animations, and takes a class input for extra classes. It clips its content only while it animates, so focus rings inside it still show. A page loads without animating content that starts open.
What ndop update does from 0.2.0
- Updates
{ui}/collapsible/collapsible.ts, keeping your edits. - Installs the
utilsitem.
import { Directive } from '@angular/core';
import { computed, Directive, input } from '@angular/core';
import {
NdCollapsible,
NdCollapsibleContent,
NdCollapsibleTrigger,
} from '@ndop/primitives/collapsible';
import { cn } from '@/lib/utils';
/**
* A collapsible (`@ndop/primitives/collapsible`): a trigger that shows and
* hides a section of content, which stays in the page. It has no styles of
* its own; style the trigger and content with other items, such as a ghost
* Button. `open` is two-way bindable.
* hides a section of content, which stays in the page and slides open and
* closed. Style the trigger with other items, such as a ghost Button.
* `open` is two-way bindable.
*
* @example
* ```html
// ⋯
export class CollapsibleTrigger {}
/**
* The content a collapsible shows and hides; hidden content leaves the
* accessibility tree and the tab order.
* The content a collapsible shows and hides, sliding open and closed;
* hidden content leaves the accessibility tree and the tab order. It clips
* its content only while it animates, so focus rings inside it show.
*
* @example
* ```html
// ⋯
@Directive({
selector: '[ndCollapsibleContent]',
hostDirectives: [NdCollapsibleContent],
host: { 'data-slot': 'collapsible-content' },
host: { 'data-slot': 'collapsible-content', '[class]': 'classes()' },
})
export class CollapsibleContent {}
export class CollapsibleContent {
/** Extra classes, merged last so they win. */
readonly class = input('');
protected readonly classes = computed(() =>
cn(
'data-animating:overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down',
// tw-animate-css's collapsible keyframes read this height.
'[--radix-collapsible-content-height:var(--nd-collapsible-content-height)]',
this.class(),
),
);
}0.2.0
Every part of the item is now its own directive without the Nd prefix, which is kept for the headless primitives. Renames NdCollapsible to Collapsible, NdCollapsibleTrigger to CollapsibleTrigger and NdCollapsibleContent to CollapsibleContent. Selectors and inputs are unchanged, and ndop update renames the imports and their uses in your code.
What ndop update does from 0.1.0
- Updates
{ui}/collapsible/collapsible.ts, keeping your edits. - Renames
NdCollapsibletoCollapsiblewhere your code imports it. - Renames
NdCollapsibleTriggertoCollapsibleTriggerwhere your code imports it. - Renames
NdCollapsibleContenttoCollapsibleContentwhere your code imports it.
import { Directive } from '@angular/core';
import {
NdCollapsible,
NdCollapsibleContent,
NdCollapsibleTrigger,
} from '@ndop/primitives/collapsible';
/**
* Collapsible (`@ndop/primitives/collapsible`): a trigger that shows and
* hides a section of content. It has no styles of its own; style the
* trigger and content with other items, such as a ghost Button. Import the
* parts from this file.
* A collapsible (`@ndop/primitives/collapsible`): a trigger that shows and
* hides a section of content, which stays in the page. It has no styles of
* its own; style the trigger and content with other items, such as a ghost
* Button. `open` is two-way bindable.
*
* @example
* ```html
* <div ndCollapsible [(open)]="open">
* <button ndCollapsibleTrigger ndButton variant="ghost">Show more</button>
* <button ndButton variant="ghost" ndCollapsibleTrigger>Show more</button>
* <div ndCollapsibleContent>…</div>
* </div>
* ```
*/
@Directive({
selector: '[ndCollapsible]',
hostDirectives: [
{
directive: NdCollapsible,
inputs: ['open', 'defaultOpen', 'disabled'],
outputs: ['openChange'],
},
],
host: { 'data-slot': 'collapsible' },
})
export class Collapsible {}
/**
* The button that shows and hides its collapsible's content, with
* `aria-expanded` and `aria-controls`.
*
* @packageDocumentation
* @example
* ```html
* <button ndButton variant="ghost" ndCollapsibleTrigger>Show more</button>
* ```
*/
export {
NdCollapsible,
NdCollapsibleContent,
NdCollapsibleTrigger,
} from '@ndop/primitives/collapsible';
@Directive({
selector: 'button[ndCollapsibleTrigger]',
hostDirectives: [NdCollapsibleTrigger],
host: { 'data-slot': 'collapsible-trigger' },
})
export class CollapsibleTrigger {}
/**
* The content a collapsible shows and hides; hidden content leaves the
* accessibility tree and the tab order.
*
* @example
* ```html
* <div ndCollapsibleContent>…</div>
* ```
*/
@Directive({
selector: '[ndCollapsibleContent]',
hostDirectives: [NdCollapsibleContent],
host: { 'data-slot': 'collapsible-content' },
})
export class CollapsibleContent {}0.1.0
First release.
What ndop update does
- Adds
{ui}/collapsible/collapsible.ts. - Installs
@ndop/primitives.