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

Add box_shadow spread, h_offset, and v_offset #108

Merged
merged 2 commits into from
Sep 22, 2023
Merged

Conversation

maun
Copy link
Contributor

@maun maun commented Sep 22, 2023

Hi,

I added spread, h_offset, and v_offset to the box shadows. I tried to imitate the CSS property definition. inset is missing, as no clipping is done. Also only one box shadow style is supported, because I could not think of a good style API for multiple. If you got a good idea how to set multiple box shadows I can implement it. If you want me to, I could also try to add the inset.

Some screenshots:

Offsets

stack((empty().style(|s| {
    s.size_px(200.0, 100.0)
        .background(Color::CYAN)
        .box_shadow_h_offset(30.0)
        .box_shadow_v_offset(20.0)
}),))
.style(|s| s.size_pct(100.0, 100.0).justify_center().items_center())
offsets
stack((empty().style(|s| {
    s.size_px(200.0, 100.0)
        .background(Color::CYAN)
        .box_shadow_h_offset(30.0)
        .box_shadow_v_offset(20.0)
        .border_radius(16.0)
}),))
.style(|s| s.size_pct(100.0, 100.0).justify_center().items_center())
rounded-offset

Spread

stack((empty().style(|s| {
    s.size_px(200.0, 100.0)
        .background(Color::CYAN)
        .box_shadow_spread(20.0)
}),))
.style(|s| s.size_pct(100.0, 100.0).justify_center().items_center())
spread
stack((empty().style(|s| {
    s.size_px(200.0, 100.0)
        .background(Color::CYAN)
        .box_shadow_spread(20.0)
        .border_radius(16.0)
}),))
.style(|s| s.size_pct(100.0, 100.0).justify_center().items_center())
rounded-spread

Combined with blur

stack((empty().style(|s| {
    s.size_px(200.0, 100.0)
        .background(Color::CYAN)
        .box_shadow_spread(2.0)
        .box_shadow_h_offset(10.0)
        .box_shadow_v_offset(10.0)
        .box_shadow_blur(8.0)
        .box_shadow_color(Color::rgb(0.5, 0.5, 0.5))
        .border_radius(16.0)
}),))
.style(|s| s.size_pct(100.0, 100.0).justify_center().items_center())
combined

@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

Merging #108 (07ea953) into main (1b62ae9) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

@@           Coverage Diff            @@
##            main    #108      +/-   ##
========================================
- Coverage   3.74%   3.72%   -0.03%     
========================================
  Files         51      51              
  Lines       8564    8620      +56     
========================================
  Hits         321     321              
- Misses      8243    8299      +56     
Files Changed Coverage Δ
src/style.rs 22.54% <0.00%> (-1.77%) ⬇️
src/view.rs 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dzhou121
Copy link
Contributor

Excellent work! Thanks.

@dzhou121 dzhou121 merged commit 0d4eba4 into lapce:main Sep 22, 2023
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants