npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

raven-accordion

v0.0.2

Published

An Angular component for creating simple accordions.

Downloads

2

Readme

Raven Accordion

An Angular component for creating simple accordions.

Screenshot

Features

  • Option to expand multiple items simultaneously
  • Uses HTML <details> element for better accessibility
  • Customize color, padding, and borders with CSS custom properties

Installation

Install into your Angular project using NPM.

npm install raven-accordion --save

Import the AccordionModule into your module.

import { AccordionModule } from 'raven-accordion';

@NgModule({
  imports: [
    AccordionModule,
    // ...
  ],
  // ...
})
export class AppModule { }

Usage

Add a <raven-accordion> element to your template, and add <raven-accordion-item> elements for each item in the accordion. Then customize each item with a summary and content.

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <raven-accordion [allowMultiOpen]="false">
      <raven-accordion-item summary="Heading 1" [open]="true">Item 1</raven-accordion-item>
      <raven-accordion-item summary="Heading 2">Item 2</raven-accordion-item>
      <raven-accordion-item summary="Heading 3">Item 3</raven-accordion-item>
    </raven-accordion>
  `,
  styles: []
})
export class AppComponent { }

Accordion Options

| Option | Type | Description | Default Value | :--------------- | :-------------------- | :----------------------------------------------------------- | :------------ | allowMultiOpen | boolean | Whether to allow multiple items to be open at the same time. | false | openItemNotifier | Subject<number> | Should emit an index of an item to open (see FAQ). | undefined

Accordion Item Options

| Option | Type | Description | Default Value | :------------- | :------ | :----------------------------------------------------------- | :------------ | open | boolean | Whether default state of item is open. | false

Styling

CSS variables are used for styling. Example:

:root {
  --ra-summary-padding: 1.25rem;
  --ra-content-background: #cef;
}

Available CSS Variables

| Variable | Description | Default Value | :----------------------- | :------------------------------ | :------------- | --ra-summary-padding | Padding around the summaries. | .5rem 1rem | --ra-summary-border | Border around the summaries. | 1px solid #ddd | --ra-summary-font-size | Font size of the summaries. | 1.2rem | --ra-summary-font-weight | Font weight of the summaries. | 700 | --ra-summary-color | Text color of the summaries. | #000 | --ra-summary-background | Background of the summaries. | #eee | --ra-content-padding | Padding around item content. | 1rem | --ra-content-border | Border around item content. | 1px solid #ddd | --ra-content-font-size | Font size of item content. | 1rem | --ra-content-color | Text color of item content. | #000 | --ra-content-background | Background of item content. | #fff

FAQ

How do I open accordion items programmatically?

If you provide a Subject<number> to the openItemNotifier property of the RavenAccordion, you may emit a value that represents the index of the accordion item to open. Here's an example:

HTML Template

<raven-accordion [openItemNotifier]="itemOpened">
  <raven-accordion-item summary="Heading 1">Item 1</raven-accordion-item>
  <raven-accordion-item summary="Heading 2">Item 2</raven-accordion-item>
</raven-accordion>

<button type="button" (click)="openItem(0)">Open Item 1</button>
<button type="button" (click)="openItem(1)">Open Item 2</button>

TypeScript

export class AppComponent {
  itemOpened: Subject<number> = new Subject();

  openItem(index: number): void {
    this.itemOpened.next(index);
  }
}

Development

To contribute to the development of this component, clone its repository and run npm install. Then run ng serve -o to start a development server and to open a sample page in your browser.

License.

MIT license.