{"id":18031662,"url":"https://github.com/lukestorry/nested-accordion","last_synced_at":"2025-07-17T02:07:47.378Z","repository":{"id":57310067,"uuid":"232853124","full_name":"LukeStorry/nested-accordion","owner":"LukeStorry","description":"NPM package to generate a series of infinitely nested css accordions from a json datafile","archived":false,"fork":false,"pushed_at":"2023-07-18T20:33:37.000Z","size":803,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T02:18:32.940Z","etag":null,"topics":["css","html","js","json","visualisation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/nested-accordion","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LukeStorry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-09T16:26:45.000Z","updated_at":"2020-12-22T12:46:27.000Z","dependencies_parsed_at":"2024-12-18T01:43:44.190Z","dependency_job_id":"803a596a-62c4-4bdf-a058-3189d9581991","html_url":"https://github.com/LukeStorry/nested-accordion","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeStorry%2Fnested-accordion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeStorry%2Fnested-accordion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeStorry%2Fnested-accordion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeStorry%2Fnested-accordion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeStorry","download_url":"https://codeload.github.com/LukeStorry/nested-accordion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256072,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","html","js","json","visualisation"],"created_at":"2024-10-30T10:10:14.613Z","updated_at":"2025-04-04T21:43:26.277Z","avatar_url":"https://github.com/LukeStorry.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nested-accordion\n\n[![npm version](https://img.shields.io/npm/v/nested-accordion)](https://www.npmjs.com/nested-accordion)\n[![Build Status](https://img.shields.io/travis/lukestorry/nested-accordion/master.svg)](https://travis-ci.org/lukestorry/nested-accordion)\n[![Coverage Status](https://img.shields.io/codecov/c/github/lukestorry/nested-accordion/master.svg)](https://codecov.io/gh/lukestorry/nested-accordion/branch/master)\n[![install size](https://packagephobia.now.sh/badge?p=nested-accordion)](https://packagephobia.now.sh/result?p=nested-accordion)\n\nGenerates a series of nested accordions (using the details/summary elements) from a json datafile\n\n---\n\n## Install\n\n    $ yarn add nested-accordion\n\n---\n\n## Usage\n\n#### Import:\n```js\nconst nestedAccordion = require('nested-accordion');\n```\n\n#### `.create(data)` gives a html string with a nested-accordion div to be inserted in a website\n```js\nconst nestedAccordionDiv = nestedAccordion.create(data)\n```\n\n#### Data should be an array of SectionData\nTitle is required, optional text and children. \nIf both text and children are ommitted, that child accordion will be diabled\n\n```js\ntype SectionData = {\n  title: string;\n  text?: string;\n  children?: Array\u003cSectionData\u003e;\n};\n```\n\n#### `.styles()`` gives a string with the css you should add to your site\nOptional colour parameters default to grey boxes\n```js\nconst styles = nestedAccordion.styles(\n  activeColour: 'grey',\n  inactiveColor: 'lightgrey',\n  textColor: 'black')\nexport css = `\u003cstyle\u003e\\n${styles}\\n\u003c/style\u003e`\n```\n\n---\n\n## Example\n```js\n  const data = [\n    {\n      title: 'Grandparent 1',\n      text: 'Grandparent 1 description.',\n      children: [\n        {\n          title: 'Parent 1',\n        },\n        {\n          title: 'Parent 1',\n          children: [\n            {\n              title: 'First Child',\n              text: 'I am the first child',\n            },\n            {\n              title: 'Second Child',\n              text: 'I am the first child',\n            }\n          ]}\n      ]},\n      {\n      title: 'Grandparent 2',\n      text: 'Grandparent 2 description.',\n      children: [\n        {\n          title: 'Parent 3',\n          children: [\n            {\n              title: 'First Child',\n              text: 'I am the first child',\n            },\n            {\n              title: 'Second Child',\n              text: 'I am the first child',\n            }\n          ]}\n      ]}\n  ];\n\nconst css = `\u003cstyle\u003e${nestedAccordion.styles('cyan', 'lightcyan')}\u003c/style\u003e`\nconst div = nestedAccordion.create(data)\n```\nThen when the css string is put in the body of the page, and the div where you want the accordion to appear, to looks like:\n![demo gif](demo.gif)\n\n### Live usage\nThis can be used to visualise large mind-map style datasets, for example on [this site looking tinto university courses](https://marniewoodmeade.co.uk/authenticlearning/).\n\n---\n\n## Bugs or updates\n\nIf you want to use this accordion for you project, but it isn't quite working, let me know and I'll see what I can do!\n\nThis was originally made for a specific purpose (visualisation of a json dataset for an eleventy-genreated website), so may not work in all scenarios yet!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukestorry%2Fnested-accordion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukestorry%2Fnested-accordion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukestorry%2Fnested-accordion/lists"}