{"id":14384587,"url":"https://github.com/18F/glossary","last_synced_at":"2025-08-23T17:32:52.773Z","repository":{"id":47466806,"uuid":"44635595","full_name":"18F/glossary","owner":"18F","description":"A glossary panel for your site to help readers understand jargon","archived":true,"fork":false,"pushed_at":"2021-08-30T17:56:28.000Z","size":682,"stargazers_count":47,"open_issues_count":11,"forks_count":26,"subscribers_count":112,"default_branch":"master","last_synced_at":"2024-12-12T00:52:04.230Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/18F.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-20T21:20:06.000Z","updated_at":"2024-01-07T05:22:45.000Z","dependencies_parsed_at":"2022-08-25T03:20:20.923Z","dependency_job_id":null,"html_url":"https://github.com/18F/glossary","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18F%2Fglossary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18F%2Fglossary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18F%2Fglossary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/18F%2Fglossary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/18F","download_url":"https://codeload.github.com/18F/glossary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230716567,"owners_count":18269790,"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":[],"created_at":"2024-08-28T18:01:29.624Z","updated_at":"2024-12-21T12:30:44.359Z","avatar_url":"https://github.com/18F.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Glossary panel\n\n[![CircleCI](https://circleci.com/gh/18F/glossary.svg?style=svg)](https://circleci.com/gh/18F/glossary)\n[![Test Coverage](https://img.shields.io/codecov/c/github/18F/glossary/master.svg)](https://codecov.io/github/18F/glossary)\n\n# About\nAdd a simple glossary panel to your site to help your users understand jargon-y terms. As seen on [FEC.gov](https://www.fec.gov) and DOI's [Natural Resources Revenue Data](https://revenuedata.doi.gov/).\n\nFor example:\n* https://www.fec.gov/data/ - click on the `Glossary` book icon in the header\n* https://www.fec.gov/help-candidates-and-committees/registering-candidate/ - click on `contributions`\n* https://revenuedata.doi.gov/ - click on `royalties`\n\n# Getting started\n\nTo run the example locally:\n\n```sh\nnpm install -g parcel-bundler\nnpm start\nopen http://localhost:1234\n```\n\nNote: if you are a contributor, please see [CONTRIBUTING for additional help](CONTRIBUTING.md).\n\n## Download\n### Via npm\n```\nnpm install glossary-panel\n```\n\n## Set up your HTML\nThe following is the bare minimum HTML needed in your document:\n\n```html\n\u003cbutton class=\"js-glossary-toggle\"\u003eGlossary\u003c/button\u003e\n\u003cdiv id=\"glossary\" aria-describedby=\"glossary-title\" aria-hidden=\"true\"\u003e\n  \u003cbutton title=\"Close glossary\" class=\"js-glossary-close\"\u003eHide glossary\u003c/button\u003e\n  \u003ch2 id=\"glossary-title\"\u003eGlossary\u003c/h2\u003e\n  \u003clabel for=\"glossary-search\"\u003eFilter glossary terms\u003c/label\u003e\n  \u003cinput id=\"glossary-search\" class=\"js-glossary-search\" type=\"search\" placeholder=\"e.g. Committee\"\u003e\n  \u003cul class=\"js-glossary-list\"\u003e\u003c/ul\u003e\n\u003c/div\u003e\n```\n\nIt includes a toggle button, a div for the glossary, a close button inside the glossary, a title, a search input and label, and a `\u003cul\u003e` for the terms.\n\nThen, to add glossary terms to the body of the page, add a `data-term` attribute to the terms. For example:\n\n```html\nA \u003cspan data-term=\"committee\"\u003ecommittee\u003c/span\u003e is a thing.\n```\n\nThe data attribute must match the text of the term in your JSON file exactly, but it is not case-sensitive.\n\n\n## Initialize\nIn whichever file you initialize your JavaScript components, initialize the glossary like so:\n\n```js\nvar Glossary = require('glossary-panel');\n\n// JSON file of terms and definitions\nvar terms = require('./terms');\n\n// Optional configuration objects\nvar selectors = { ... };\nvar classes = { ... };\n\nnew Glossary(terms, selectors, classes);\n```\n\n# Configuration\nThe constructor expects an array of objects (`terms`) that follows this pattern:\n\n```json\n[\n  {\n    \"term\": \"Glossary\",\n    \"definition\": \"A useful tool for finding the definitions of terms\"\n  }\n]\n```\n\nThe constructor also accepts an optional hash of `selectors` as its second parameter:\n\n- `glossaryID`: ID of the glossary panel that will be shown and hidden. _Default_: `#glossary`\n- `close`: ID or class of the close button inside the glossary panel. _Default_: `.js-glossary-close`\n- `listClass`: Class of the `\u003cul\u003e` that will be populated with terms. _Default_: `.js-glossary-list`\n- `searchClass`: Class of the `\u003cinput\u003e` that will be used to filter the list. _Default_: `.js-glossary-search`\n- `toggle`: ID or class of the element that will be used to open and close the glossary in the main body of the document. _Default_: `.js-glossary-toggle`\n\nAnd you can pass an optional hash of `classes` to be applied to to the DOM:\n\n- `definitionClass`: Single class applied to the `\u003cdiv\u003e` that contains the term's definition. _Default_: `glossary__definition`\n- `glossaryItemClass`: Single class applied to the `\u003cli\u003e` that contains the term and definition. _Default_: `glossary__item`\n- `highlightedTerm`: Single class applied to terms in the body when they are highlighted. _Default_: `term--higlight`\n- `termClass`: Single class applied to the `\u003cbutton\u003e` element that opens the definition. _Default_: `glossary__term`\n\n# Methods\n- `Glossary.show()`: Show the glossary\n- `Glossary.hide()`: Hide the glossary\n- `Glossary.toggle()`: Toggle the glossary open or closed\n- `Glossary.destroy()`: Completely remove the glossary from the DOM\n- `Glossary.findTerm(term)`: If the glossary is opens, filters the list down to the term called, expands the term, and highlights the associated term in the DOM\n\n# Styling\nTo style the glossary terms and definitions in the accordion list, either use the default classes or whichever ones you passed in. To change the style of the buttons when the accordion elements are expanded, you can select for `[aria-expanded=\"true\"]`.\n\nYou will need to add styles for `[aria-hidden=\"true\"]` in order to hide the glossary panel and the glossary definitions.\n\n# License\n## Public domain\n\nThis project is in the worldwide [public domain](LICENSE.md). As stated in [CONTRIBUTING](CONTRIBUTING.md):\n\n\u003e This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).\n\u003e\n\u003e All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F18F%2Fglossary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F18F%2Fglossary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F18F%2Fglossary/lists"}