{"id":16005855,"url":"https://github.com/sparten11740/classes","last_synced_at":"2025-03-17T19:32:14.873Z","repository":{"id":153164800,"uuid":"628383604","full_name":"sparten11740/classes","owner":"sparten11740","description":"Dependency-free rust macro that simplifies the process of building class strings for DOM elements for usage in frameworks like Dioxus","archived":false,"fork":false,"pushed_at":"2023-04-23T06:16:33.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T03:26:56.261Z","etag":null,"topics":["classnames","dioxus","dom","helper","macro","rust","web"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/classes","language":"Rust","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/sparten11740.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}},"created_at":"2023-04-15T19:22:33.000Z","updated_at":"2024-08-26T02:48:50.000Z","dependencies_parsed_at":"2023-07-11T06:45:15.831Z","dependency_job_id":null,"html_url":"https://github.com/sparten11740/classes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparten11740%2Fclasses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparten11740%2Fclasses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparten11740%2Fclasses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparten11740%2Fclasses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparten11740","download_url":"https://codeload.github.com/sparten11740/classes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878478,"owners_count":20362433,"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","dioxus","dom","helper","macro","rust","web"],"created_at":"2024-10-08T11:22:07.096Z","updated_at":"2025-03-17T19:32:14.866Z","avatar_url":"https://github.com/sparten11740.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/sparten11740/classes/actions/workflows/ci.yml/badge.svg)](https://github.com/sparten11740/classes/actions/workflows/ci.yml)\n# classes\n\n`classes` is a lightweight and dependency-free macro that simplifies the process of building class strings for DOM\nelements. It accepts a variable number of arguments and combines them into a single class string.\nThis macro is designed after the popular `classnames` npm package, which is commonly used in React and other frameworks.\n\n## Usage\n\nYou can supply string types or types that can be transformed into a string to the macro:\n\n- `Option\u003cString\u003e` / `Option\u003c\u0026str\u003e` will use the inner value if the option is `Some`, and ignore the option if\n  it's `None`\n- `String` / `\u0026str` will be applied as is\n- The special syntax `string_expr =\u003e bool_expr` will use the `string_expr` when `bool_expr` evaluates to true\n\nUsing the Classes macro can simplify your code by reducing the boilerplate needed to build class strings.\n\n### Example\n\n```rust\nuse classes::classes;\n\nfn main() {\n    let optional = Some(\"lumos\");\n    let is_night = true;\n\n    let class = classes![\"hogwarts\", optional, \"hogwarts--at-night\" =\u003e is_night, \"wingardium-leviosa\" =\u003e false];\n\n    println!(\"{class}\"); // =\u003e 'hogwarts lumos hogwarts--at-night'\n}\n\n```\n\n### Dioxus Example\n\n```rust\nuse classes::classes;\n\npub fn Button\u003c'a\u003e(cx: Scope\u003c'a, ButtonProps\u003c'a\u003e\u003e) -\u003e Element {\n    let class = classes![\"button\", \"button--disabled\" =\u003e cx.props.disabled, cx.props.class];\n\n    cx.render(rsx! {\n      button { class }\n    })\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparten11740%2Fclasses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparten11740%2Fclasses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparten11740%2Fclasses/lists"}