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

ts-accordion

v1.0.2

Published

Package to render Accordion with dynamic data and styles.

Downloads

11

Readme

ts-accordion

Package to render Accordion with dynamic data and styles.

Installation

ts-accordion

ts-accordion is available as an npm package.

npm:

npm i ts-accordion

yarn:

yarn add ts-accordion

Getting started with ts-accordion

Example

import React, { useState } from "react";
import TsAccordion from "ts-accordion/dist/TsAccordion";
import img from "../src/user.png";
import img1 from "../src/AddEmployeeIcon.svg";

function App() {
  //Style Properties

  const bgColor1 = "#fff";

  const bgColor2 = "#FFEDE9";

  const menuColor = "#FF0000";

  const sectionStyles = {
    keyFontFamily: "Roboto",
    keyFontSize: "19px",
    valueFontFamily: "Times New Roman",
    valueFontSize: "15px",
    keyTextColor: "#000000",
    valueTextColor: "#0000FF",
    rowGap: 4,
    iconGap: 25,
  };

  // Data Properties

  const testData = [
    {
      section1: {
        first_name: "Syam",
        last_name: "Syam",
        role: "UI-Developer",
        empId: 101,
        email: "[email protected]",
        dateOfBirth: "25-08-1998",
        location: "Hyderabad",
      },
      section2: {
        ip_address: "26.16.10.231",
        dateOfBirth: "25-08-1998",
        location: "Hyderabad",
        jobType: "FTE",
        address:
          "P No: 0000, F No: Naya Apartment, KPHB, Hyderabad - 50000, Telangana, India ",
        department: "Developer",
        department1: "Developer",
      },
      section3: {
        maritalStatus: "Single",
        bloodGroup: "A+",
        dateOfJoining: "23-08-2021",
        reportingTo: "Vinod Gadde",
        generalLeaves: "15",
        privelegeLeaves: "08",
        personalEmail: "[email protected]",
        status: "active",
        department1: "Developer",
      },
      profileImage: {
        title: "Image",
        image: img,
      },
    },
    {
      section1: {
        first_name: "Nitesh",
        last_name: "Singh",
        role: "UI Developer",
        empId: 101,
        email: "[email protected]",
        dateOfBirth: "25-08-1998",
        location: "Hyderabad",
      },
      section2: {
        ip_address: "26.16.10.231",
        dateOfBirth: "25-08-1998",
        location: "Hyderabad",
        jobType: "FTE",
        address:
          "P No: XXXX, F No: Good Apartment, Madhapur, Hyderabad - 50001, Telangana, India ",
        department: "Developer",
      },
      section3: {
        maritalStatus: "Single",
        bloodGroup: "B+",
        dateOfJoining: "23-08-2021",
        reportingTo: "Santosh",
        generalLeaves: "15",
        privelegeLeaves: "08",
        personalEmail: "[email protected]",
        status: "inActive",
      },
      profileImage: {
        title: "Image",
        image: img1,
      },
    },
  ];

  const actions = [
    {
      actionId: "view",
      actionName: "View",
    },
    {
      actionId: "edit",
      actionName: "Edit",
    },
    {
      actionId: "deactivate",
      actionName: "Deactivate",
    },
  ];

  const handleActionClick = (event, row, id) => {
    event.preventDefault();
    event.stopPropagation();
    console.log("row", row);
    console.log("id", id);
  };

  const handleProfileImageClick = (event) => {
    event.preventDefault();
    event.stopPropagation();
    console.log(event);
  };

  return (
    <>
      <TsAccordion
        rowData={testData}
        actions={actions}
        handleActionClick={handleActionClick}
        handleProfileImageClick={handleProfileImageClick}
        bgColor1={bgColor1}
        bgColor2={bgColor2}
        menuColor={menuColor}
        sectionStyles={sectionStyles}
      />
    </>
  );
}

export default App;

rowData must be a list of Object in a array, where each object consists of: section1 (key value pairs) section2 (key value pairs) section3 (key value pairs) profileImage(title: title of image, image: variable path of image imported)

handleActionClick (handler function passed to handle onClick of each action) which returns row (row data clicked), event(onClick event details), id (actionId passed in actions array)

handleProfileImageClick (handler function passed to handle onclick of profile image in accordion)

actions is a array of objects consistes actionId and actionName. Which allows you to render Menu items in Accordion.

sectionStyles consists of style elements of section keyFontFamily (key font family) keyFontSize (key font size) valueFontFamily (value font family) valueFontSize (value font size) keyTextColor (key text color) valueTextColor (value text color) rowGap: (gap between each elements in sections) iconGap: (gap between elements in section and actions Icon)

Please refer above example to pass this style properties.

bgColor1 (background color for section1 of accordion)

bgColor2 (background color for section2 and section3 of accordion)

menuColor (actions icon color and menu items)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.