{"id":24511709,"url":"https://github.com/devnax/pretty-class","last_synced_at":"2025-05-12T22:16:03.114Z","repository":{"id":273114887,"uuid":"910764941","full_name":"devnax/pretty-class","owner":"devnax","description":"A utility for generating CSS class names with ease.","archived":false,"fork":false,"pushed_at":"2025-05-06T09:54:23.000Z","size":77,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T22:15:53.700Z","etag":null,"topics":["classnames","formatting","html","javascript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pretty-class","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devnax.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-01-01T10:57:46.000Z","updated_at":"2025-05-06T09:54:26.000Z","dependencies_parsed_at":"2025-01-18T19:32:53.455Z","dependency_job_id":"e7087f41-09cb-477b-81c3-5d1a85d2a64f","html_url":"https://github.com/devnax/pretty-class","commit_stats":null,"previous_names":["devnax/pretty-class"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnax%2Fpretty-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnax%2Fpretty-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnax%2Fpretty-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devnax%2Fpretty-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devnax","download_url":"https://codeload.github.com/devnax/pretty-class/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253831010,"owners_count":21971008,"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":["classnames","formatting","html","javascript"],"created_at":"2025-01-22T00:40:41.685Z","updated_at":"2025-05-12T22:16:03.060Z","avatar_url":"https://github.com/devnax.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pretty Class\n`pretty-class` is a lightweight utility package designed to simplify the process of generating dynamic class names in JavaScript and TypeScript applications. It provides a flexible and intuitive way to conditionally combine class names based on different input types.\n\n## Installation\nTo install `pretty-class`, use npm or yarn:\n\n```bash\nnpm install pretty-class\n```\n\nor\n\n```bash\nyarn add pretty-class\n```\n\n## Usage\n\n### Importing the Package\n\n```typescript\nimport prettyClass from 'pretty-class';\n```\n\n### Function Signature\n\n```typescript\nexport type prettyClassTypes = string | Record\u003cstring, boolean\u003e | prettyClassTypes[] | undefined | null | false;\nconst prettyClass: (...args: prettyClassTypes[]) =\u003e string;\n```\n\n### Parameters\n- `args`: A variable number of arguments of type `prettyClassTypes`. Each argument can be:\n  - A `string`: Adds the string directly to the class list.\n  - An `object` with keys as class names and values as boolean: Includes the key if the value is `true`.\n  - An `array`: Recursively processes the array elements.\n  - `undefined`, `null`, or `false`: Ignored in the output.\n\n### Returns\n- A `string` containing the concatenated class names.\n\n### Example Usage\n\n#### Basic String Input\n```typescript\nconst result = prettyClass('class1', 'class2');\nconsole.log(result); // Output: \"class1 class2\"\n```\n\n#### Conditional Classes\n```typescript\nconst result = prettyClass({ 'class1': true, 'class2': false, 'class3': true });\nconsole.log(result); // Output: \"class1 class3\"\n```\n\n#### Nested Arrays\n```typescript\nconst result = prettyClass(['class1', { 'class2': true }, ['class3', { 'class4': false }]]);\nconsole.log(result); // Output: \"class1 class2 class3\"\n```\n\n#### Mixed Inputs\n```typescript\nconst result = prettyClass('class1', { 'class2': true }, ['class3', null, false]);\nconsole.log(result); // Output: \"class1 class2 class3\"\n```\n\n## Benefits\n- **Lightweight**: Minimal code footprint.\n- **Flexible**: Supports various input types.\n- **Recursive**: Handles nested arrays gracefully.\n- **Typed**: Fully typed for TypeScript users.\n\n## License\n`pretty-class` is licensed under the MIT License. See the LICENSE file for more details.\n\n---\n\nFor contributions, issues, or feature requests, visit the [GitHub repository](#).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevnax%2Fpretty-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevnax%2Fpretty-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevnax%2Fpretty-class/lists"}