{"id":13518222,"url":"https://github.com/fdaciuk/strclass","last_synced_at":"2025-03-17T00:32:24.425Z","repository":{"id":57371931,"uuid":"83376740","full_name":"fdaciuk/strclass","owner":"fdaciuk","description":"A ~200b library to apply CSS classes as strings from objects","archived":false,"fork":false,"pushed_at":"2017-03-05T15:29:33.000Z","size":101,"stargazers_count":83,"open_issues_count":2,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-13T13:30:08.647Z","etag":null,"topics":["classname","classnames","css","hacktoberfest","react","reactjs","strclass"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/strclass","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/fdaciuk.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}},"created_at":"2017-02-28T01:49:00.000Z","updated_at":"2024-09-18T11:01:45.000Z","dependencies_parsed_at":"2022-09-07T18:10:24.288Z","dependency_job_id":null,"html_url":"https://github.com/fdaciuk/strclass","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdaciuk%2Fstrclass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdaciuk%2Fstrclass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdaciuk%2Fstrclass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdaciuk%2Fstrclass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fdaciuk","download_url":"https://codeload.github.com/fdaciuk/strclass/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221669347,"owners_count":16860855,"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":["classname","classnames","css","hacktoberfest","react","reactjs","strclass"],"created_at":"2024-08-01T05:01:42.299Z","updated_at":"2024-10-27T11:35:26.062Z","avatar_url":"https://github.com/fdaciuk.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# strclass\n\n\u003e A tiny library to apply CSS classes as strings from objects\n\n[![Build Status][travis-image]][travis-url]\n[![Coveralls Coverage Status][coverage-image]][coverage-url]\n\n## Installation\n\n```\nyarn add strclass\n```\n\n## Usage\n\n`strclass` is an _Universal Module_, and can be used as a global,\nwith AMD, CommonJS or ES Module.\n\n**Signature:**\n\n```\nstrclass({ className: booleanConditionToShowThisClass }, [defaultClass1, defaultclass2, ..., defaultclassN])\n```\n\n**Usage:**\n\n```js\nimport strclass from 'strclass'\n\nconsole.log(strclass({ highlighted: true }))\n// 'highlighted'\n\nconsole.log(strclass({ '-active': true }, 'button'))\n// 'button -active'\n\nconsole.log(strclass({ '-active': true }, 'button', 'button-default'))\n// 'button button-default -active'\n\nconsole.log(strclass({ active: false }))\n// ''\n```\n\nYou can use with React, VanillaJS or any other lib/framework:\n\n```js\nconst Button = ({ active, children }) =\u003e (\n  \u003cbutton className={strclass({ active }, 'button')}\u003e\n    {children}\n  \u003c/button\u003e\n)\n\n\u003cButton active\u003eClick!\u003c/Button\u003e\n// will render: \u003cbutton class=\"button active\"\u003eClick!\u003c/button\u003e\n\n\u003cButton active={false}\u003eClick!\u003c/Button\u003e\n// will render: \u003cbutton class=\"button\"\u003eClick!\u003c/button\u003e\n```\n\nIf you are using _CSS Modules_, or need to pass the class as a dynamic value, just do:\n\n```js\nconst ac = 'active'\nconsole.log(strclass({ [ac]: true })) // 'active'\n```\n\n## Differences from [`classnames module`](https://github.com/JedWatson/classnames)\n\n**Size**\n\n`strclass` has ~200bytes gzipped.\n\n**Signature**\n\nWith `classnames`, you can pass any argument as `String`, `Object` or `Array`.\nOtherwise, `strclass` has a signature that should be respected: `Object` as a first argument, with the conditionals,\nand any other argument should be a `String`.\n\nIf you don't need conditionals, you don't need `strclass`. Just use `strings`.\n\nThat's it =)\n\n## License\n\n[MIT](license-url) \u0026copy; Fernando Daciuk\n\n[travis-image]: https://img.shields.io/travis/fdaciuk/strclass.svg?style=flat-square\n[travis-url]: https://travis-ci.org/fdaciuk/strclass\n[coverage-image]: https://img.shields.io/coveralls/fdaciuk/strclass/master.svg?style=flat-square\n[coverage-url]: https://coveralls.io/r/fdaciuk/strclass?branch=master\n[license-url]: https://github.com/fdaciuk/licenses/blob/master/MIT-LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdaciuk%2Fstrclass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdaciuk%2Fstrclass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdaciuk%2Fstrclass/lists"}