{"id":20315345,"url":"https://github.com/henrylin03/language-picker","last_synced_at":"2026-04-20T04:02:35.346Z","repository":{"id":241428863,"uuid":"806322864","full_name":"henrylin03/language-picker","owner":"henrylin03","description":"Language picker UI component written in vanilla JS","archived":false,"fork":false,"pushed_at":"2024-06-03T01:42:24.000Z","size":110,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T04:34:45.074Z","etag":null,"topics":["dropdown-menu","language-picker","odin-project","ui","ui-components"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/henrylin03.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2024-05-27T00:58:34.000Z","updated_at":"2024-06-03T01:42:24.000Z","dependencies_parsed_at":"2024-06-03T01:30:24.033Z","dependency_job_id":null,"html_url":"https://github.com/henrylin03/language-picker","commit_stats":null,"previous_names":["henrylin03/language-picker","henrylin03/dropdown"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrylin03%2Flanguage-picker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrylin03%2Flanguage-picker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrylin03%2Flanguage-picker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrylin03%2Flanguage-picker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henrylin03","download_url":"https://codeload.github.com/henrylin03/language-picker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241818872,"owners_count":20025210,"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":["dropdown-menu","language-picker","odin-project","ui","ui-components"],"created_at":"2024-11-14T18:18:51.429Z","updated_at":"2026-04-20T04:02:30.324Z","avatar_url":"https://github.com/henrylin03.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @henrylin03/language-picker\n\nLightweight language picker UI component, written in vanilla JavaScript (JS).\n\nThis package was developed and published as an exercise for [The Odin Project](https://www.theodinproject.com/lessons/node-path-javascript-dynamic-user-interface-interactions).\n\n## Installation\n\nInstall the package using npm:\n\n```bash\nnpm install @henrylin03/language-picker\n```\n\n## Usage\n\nIn your JS file, import the `createLanguagePicker` function to create a dropdown of languages\n\n```js\nimport createLanguagePicker from \"@henrylin03/language-picker\";\n```\n\n### Syntax\n\n```js\ncreateLanguagePicker( obj )\n```\n\n#### Parameters\n\n`obj` is a JS object that contains several parameters required to generate your language picker. The following are its keys:\n\n* **`containerElementCSSSelector`** (string): CSS selector of the container (parent) element where the language picker will be appended as a child.\n\n  * If not provided, the language picker will be appended to the `\u003cbody\u003e` of the document\n\n* **`languages`** (array): array of language strings to display in the dropdown. The first language in the array will be the initial selected language, and displayed on the button that triggers the dropdown.\n\n  * If not provided, the only language will be \"English\"\n\n* **`expandEvent`** (string): specifies the type of user interaction that will expand the language picker.\n\n  * **Valid values**: `\"hover\"`, `\"click\"`\n  * If not provided, the dropdown will be expanded on a click event\n\n### Example\n\n#### HTML\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n  \u003ctitle\u003eDEMO\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003csection id=\"hover-dropdown\"\u003e\n    \u003ch2\u003eHover dropdown\u003c/h2\u003e\n  \u003c/section\u003e\n  \u003csection id=\"click-dropdown\"\u003e\n    \u003ch2\u003eClick dropdown\u003c/h2\u003e\n  \u003c/section\u003e\n  \n  \u003cscript type=\"module\"\u003e\n    import createDropdown from '@henrylin03/ui-dropdown';\n\n    const LANGUAGES = [\"English\", \"简体中文\", \"繁體中文\"];\n\n    const clickDropdownOptions = {\n      containerElementCSSSelector: \"#click-dropdown\",\n      expandEvent: \"click\",\n      languages: LANGUAGES,\n    };\n    const hoverDropdownOptions = {\n      containerElementCSSSelector: \"#hover-dropdown\",\n      expandEvent: \"hover\",\n      languages: LANGUAGES,\n    };\n\n    createDropdown(clickDropdownOptions);\n    createDropdown(hoverDropdownOptions);\n  \u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### Initial state\n\n![Example dropdowns not expanded](./docs/not-expanded.png)\n\n#### Expanded\n\n![Example dropdowns expanded](./docs/expanded.png)\n\n## Contributing\n\nContributions are welcome! Please feel free to open an issue and/or submit a pull request on [GitHub](https://github.com/henrylin03/language-picker).\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Author\n\nHenry Lin: \u003chttps://henrylin.io\u003e\n\n## Links\n\n* [GitHub repository](https://github.com/henrylin03/language-picker)\n* [Issues](https://github.com/henrylin03/language-picker/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrylin03%2Flanguage-picker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenrylin03%2Flanguage-picker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrylin03%2Flanguage-picker/lists"}