Comments (5)
I think having both has merits 👍 I think the operator internally would just use with_style
? I've also been thinking of having a way of defining "classes" or at least some sort of reusable style similar to JSS.
from kayak_ui.
with_style
works exactly as needed. Still new to kayak_ui so thanks for pointing out the functions 😃
There might be some cosmetic value in having the "+" operator to concatenate different styles, though. For instance, this code:
<Background styles={Some(container_style
.with_style(center_align)
.with_style(main_background_color)
.with_style(two_players)
)}>
</Backgroud>
would become:
<Background styles={Some(container_style + center_align + main_background_color + two_players)}>
</Backgroud>
Some food for thought, in case you want to copy/paste the with_style
method as the implementation for the Add<Style> operator.
from kayak_ui.
Interesting... Would you be willing to draft up a PR so we can take a look at it in real examples? It might be a nice QoL feature. Any thoughts on this @StarArawn?
One hesitation here is that it hides the ordering considerations (A + B ≠ B + A
) a bit more than with_style
already does.
from kayak_ui.
Add PR has been merged so I will be closing this. 👍
from kayak_ui.
Check out the methods defined on Style
here:
kayak_ui/kayak_core/src/styles/mod.rs
Lines 150 to 188 in 54c67ec
It sounds like you want to use apply
(or with_style
for builder-like syntax). If a style has any StyleProp::Unset
values, these methods will attempt to apply the value from the given style. Hopefully that helps! 😄
from kayak_ui.
Related Issues (20)
- Use Dashmap to replace `Rwlock<Hashmap>`
- UI materials have some usability friction when used to bevy shaders
- UI materials do not seem to respect z-ordering
- Quads with borders cannot have a transparent background HOT 1
- Using multiple shader materials causes them to render on eachother's elements
- Small text gets white boxes
- tree::should_remove_root test failed
- Make `Tree` have internal mutablity
- hello_world example is blank when copied into project HOT 3
- Input lag HOT 1
- Text Rendering Inverted HOT 2
- Is there a way to import Chinese fonts? HOT 1
- Add support for text outlines
- Dynamically rendering widgets inside the rsx! block ? HOT 1
- Consider removing the 'Styles' (KStyle) as an input, only leaving ComputedStyles
- I dont understand why widgets wrapped inside of a ContextProvider need to have a 'computed styles' HOT 1
- Consider removing 'computed styles' entirely from custom widgets
- Missing example: mouse cursor position to render position
- Can't query custom widget props HOT 1
- Font loading from subdirectories fails for nested .ttf files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kayak_ui.