{"id":21840266,"url":"https://github.com/zapier/bemify-js","last_synced_at":"2025-04-14T10:51:26.588Z","repository":{"id":57189460,"uuid":"50802400","full_name":"zapier/bemify-js","owner":"zapier","description":":corn: Simple BEM prefixing of CSS classes","archived":false,"fork":false,"pushed_at":"2017-12-11T17:39:54.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":59,"default_branch":"master","last_synced_at":"2025-03-28T00:04:51.175Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zapier.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":"2016-02-01T00:04:29.000Z","updated_at":"2019-03-13T07:16:38.000Z","dependencies_parsed_at":"2022-09-15T06:21:58.305Z","dependency_job_id":null,"html_url":"https://github.com/zapier/bemify-js","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/zapier%2Fbemify-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fbemify-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fbemify-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fbemify-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zapier","download_url":"https://codeload.github.com/zapier/bemify-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248574906,"owners_count":21127088,"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-11-27T21:25:27.334Z","updated_at":"2025-04-14T10:51:26.569Z","avatar_url":"https://github.com/zapier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bemify-js\n\nSimple package to facilitate [BEM CSS class naming](http://getbem.com/)\nin JS with less verbosity.\n\n## Examples\n\n`bemify` takes a block string as its first argument which will prefix\nall modifier and element classes supplied within the second argument.\nNon-modifier/element classes remain unaffected.\n\n```js\n// Supply a string and all modifiers will be applied to the block.\nbemify('block', '--modifier-a --modifier-b');\n// returns 'block block--modifier-a block--modifier-b'\n\n// Supply a string with an element in it and all modifiers\n// will be applied to the element. Note that you can only\n// supply one element at a time; an element can't be two\n// elements at once. Whoa.\nbemify('block', '__element --modifier-a --modifier-b');\n// returns 'block__element block__element--modifier-a block__element--modifier-b'\n\n// Supply an array of classes and all the truthy ones\n// will be applied to the block.\nbemify('block', [\n  '--modifier-a',\n  '--modifier-b',\n]);\n// returns 'block block--modifier-a block--modifier-b'\n\n// Supply an object whose values indicate whether or not\n// the class should be applied.\nbemify('block', {\n  '--modifier-a': true,\n  '--modifier-b': false,\n  '--modifier-c': true,\n  'some-utility': true,\n  'some-other-utility': false,\n});\n// returns 'block block--modifier-a block--modifier-c some-utility'\n\n// `bemify` is curried, allowing you to easily apply classes\n// for the same block without duplication.\nconst bem = bemify('block');\nbem('--modifier-a --modifier-b');\n// returns 'block block--modifier-a block--modifier-b'\nbem('__element --modifier-a --modifier-b');\n// returns 'block__element block__element--modifier-a block__element--modifier-b'\n```\n\n`toModifiers` is exported as a utility function for your using pleasure. It transforms its passed arguments into modifier (`--`) versions, returning an array of those modifiers. It accepts the same possible argument types as `bemify`'s second argument, ie strings, arrays, objects, or a combination. Useful for when you don't want to pepper `--` throughout your code.\n\n```js\n// Supply a space separated string and it'll be split.\ntoModifiers('a b c');\n// returns ['--a', '--b', '--c']\n\n// Supply an array of strings and they'll be `map`ped into modifiers.\ntoModifiers(['a', 'b', 'c']);\n// returns ['--a', '--b', '--c']\n\n// Supply an object whose values indicate whether or not\n// the modifiers should be used.\ntoModifiers({ a: true, b: true, c: true, d: false });\n// returns ['--a', '--b', '--c']\n```\n\nCheck out the tests for complete examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapier%2Fbemify-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzapier%2Fbemify-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapier%2Fbemify-js/lists"}