{"id":23860181,"url":"https://github.com/dekirisu/mevy","last_synced_at":"2025-04-06T07:09:43.416Z","repository":{"id":270678551,"uuid":"910779230","full_name":"dekirisu/mevy","owner":"dekirisu","description":"Bevy macros - e.g. CSS-like syntax for bevy_ui \u0026 simple child spawning","archived":false,"fork":false,"pushed_at":"2025-03-10T00:09:26.000Z","size":117,"stargazers_count":70,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T06:04:30.770Z","etag":null,"topics":["bevy","bevy-engine","bevy-ui"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dekirisu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2025-01-01T11:58:31.000Z","updated_at":"2025-03-28T09:45:25.000Z","dependencies_parsed_at":"2025-01-09T11:24:26.133Z","dependency_job_id":null,"html_url":"https://github.com/dekirisu/mevy","commit_stats":null,"previous_names":["dekirisu/mevy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fmevy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fmevy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fmevy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekirisu%2Fmevy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dekirisu","download_url":"https://codeload.github.com/dekirisu/mevy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445667,"owners_count":20939958,"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":["bevy","bevy-engine","bevy-ui"],"created_at":"2025-01-03T04:24:01.094Z","updated_at":"2025-04-06T07:09:43.390Z","avatar_url":"https://github.com/dekirisu.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/user-attachments/assets/829a86b8-8dc4-4403-9da4-536daaefbd11\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/dekirisu/mevy\" style=\"position:relative\"\u003e\u003cimg src=\"https://img.shields.io/badge/github-dekirisu/mevy-ee6677\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/mevy\" style=\"position:relative\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/mevy\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://discord.gg/kevWvBuPFg\" style=\"position:relative\"\u003e\u003cimg src=\"https://img.shields.io/discord/515100001903312898\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/user-attachments/assets/891599e8-98a9-4d32-9f6e-6dfa76e51a31\"\u003e\n\u003c/p\n\nA **growing** set of **m**acros which add some witchcraft into b**evy**, currently available: 🪄\n- **Style Sheet Notation** for `bevy_ui` components (and your own) - `ui!(( width: 20px; ))`\n- **Simplified Notation** for `Color`, `Val` and `UiRect` - `code!{ let red = #ff0000; //..any code }`\n\n\u003e [!IMPORTANT]\n\u003e This crate is meant to provide macros only - no additional bevy plugins, resources, components or systems\n\n## Simpler Hierarchy Spawning\nSpawn children just by stating `[]` - the 'names' are just variables containing their `Entity`\n- those variables can be used anywhere in the macro - even 'before'\n- [read more](crates/ecs/README.md) or see [this example](examples/ecs_simple_spawn.rs).\n\n```rust\nspawn!{\n    // component/bundle;\n    // .method(..);\n    SpecificChild(optional_child_name);\n    [optional_child_name][\n        // component;\n        // .method(..);\n    ]\n}\n```\n\n## CSS-like notation for bevy_ui\nUsing `ui!((..))` (inner round braces) will return a tuple of **mentioned components** only.\n- read about **available fields**, custom fields \u0026 notation in [this readme](crates/ui/README.md)\n- see [this example](examples/ui_bundle.rs).\n```rust\nc.spawn(ui!((\n    size:          100px 100px;\n    border:        5px #ff0000;\n    box_shadow:    10% 10% 3px 8px #ffaa44;\n    background:    #ffffff;\n    border_radius: 6px;\n    neat_outline;\n)?));\n//^ optional ? (or any token): hovering shows the returned tuple (if LSP used)\n\n/// function as custom fields or p refabs\nfn neat_outline() -\u003e Outline {ui!((\n    outline: 3px 1px #00ff00;\n))}\n```\n\n## Code Replacement Macro\nUsing the `code!{}` macro simplifies constructing:\n- `Color` by writing `#rgb`/`#rgba`/`#rrggbb`/`#rrggbbaa`\n- `Val` by writing `0px`/`0%`/`0vw`/`0vh`/`0vmin`/`0vmax`/`@`(auto)\n- `UiRect` by writing `[\u003e0px]`/`[\u003e0px 0px]`/`[\u003e0px 0px 0px]`/`[\u003e0px 0px 0px 0px]` (css-like)\n\nSo you can do fun things like:\n```rust\nlet shadow = code!{BoxShadow{\n    // use #... is replaced with Color, meaning you can e.g. use methods \n    color: #FF1265.mix(\u0026#F93ECA,0.4).with_alpha(0.2),\n    x_offset: 100px,\n    y_offset: 50%,\n    spread_radius: 3.1vh,\n    blur_radius: 40.23vmax,\n}}};\nlet color = code!{#FF0000};\n// or multiple things in the macro\ncode!{\n    let color2 = #00FF00;\n    let color3 = #6600AA;\n}\nprintln!{\"{color2:?}\"}\n```\n\n## Version\nJust to mention the obvious:\n- Macros are token-based, meaning they aren't hard-bound to a specific bevy version\n- **However:** These are mainly designed for **bevy 0.15** and onwards\n- The closer your bevy version is to **0.15**, the more things will work\n\n## Design\nCrates are separated into:\n- `crate/*/syntax`: token handling, meant to be reusable\n- `crate/*`: actual macros, based on that 'syntax'\n\n\u003e [!NOTE]\n\u003e **Only relevant if you dig deeper into this crate:** The versions of those are not hard linked, since the macros can keep (or gain) features, even if the the syntax api has changed. So if one of those is `0.2.x` and the other `0.5.x` at some point, don't worry.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekirisu%2Fmevy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdekirisu%2Fmevy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekirisu%2Fmevy/lists"}