Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use macros to generate bevy_ui layouts from CSS strings #8769

Open
ulvido opened this issue Jun 6, 2023 · 1 comment
Open

Use macros to generate bevy_ui layouts from CSS strings #8769

ulvido opened this issue Jun 6, 2023 · 1 comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Controversial There is active debate or serious implications around merging this PR

Comments

@ulvido
Copy link

ulvido commented Jun 6, 2023

What problem does this solve or what need does it fill?

I am new to rust and bevy. I came from node and web background and I can honestly say writing UI with the current version of bevy_ui is very hard. (0.10.1)

What solution would you like?

if it's mimicing exactly css flexbox is it posible to use valid css string?

example css_str:

.ComponentName {
    display: flex;
    flex-direction: column;
    justify-content: center;

    .ChildComponent1 {
        /* ... */
    }
}

if you impelement FromStr or macro or something...

commands.spawn(from_css_str!(css_str))

What alternative(s) have you considered?

as an example main_menu_style.css file in the assets/styles/ folder and asset_server.load(styles/main_menu_style.css) and use asset with a macro or etc.

Additional context

if bevy graphical ui happens some time in the future users will feel forced to use the graphical ui to create game ui becase of these too much verbosity. also considering gridbox is a thing.

@ulvido ulvido added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jun 6, 2023
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Controversial There is active debate or serious implications around merging this PR and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Jun 6, 2023
@alice-i-cecile
Copy link
Member

For the same sort of idea, see DioxusLabs/taffy#440 upstream.

Personally, I'm fairly strongly opposed to persistently coupling bevy_ui to CSS with macros like this on a first party level. I'd much rather see builder methods that actually play nice with Rust's tooling and can be extended to other layout paradigms like morphorm.

That said, belly attempts to do something quite similar using CSS-like macros, and may be to your taste!

P.S. css-grid support was added in #8026, and is coming in 0.11 :)

@alice-i-cecile alice-i-cecile changed the title bevy_iu css string parse Use macros to generate bevy_ui layouts from CSS strings Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

No branches or pull requests

2 participants