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

docs(ShadowContainer): Adding note for shadows order #741

Merged
merged 5 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/assets/green-shadow-cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/assets/red-shadow-cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions doc/controls/ShadowContainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,85 @@ For more info on how `inset` works in CSS for `box-shadow` follow https://develo
> [!IMPORTANT]
> Be careful not to confuse the `Shadow` property with the `Shadows` property. The singular `Shadow` property comes from `UIElement`. To add shadows to the `ShadowContainer`, use only the `Shadows` property.

### Shadow Order
When adding shadows to the `ShadowContainer`, keep in mind that the order in which you place them matters, as shadows can overlap each other, affecting the final result. Shadows implemented last may overlap shadows added previously. See the examples below:

The following example has a red shadow and a green shadow, respectively. See that the green shadow overlaps the red shadow, since the green one was added last:

```xml
xmlns:utu="using:Uno.Toolkit.UI"
...

<Page.Resources>
<utu:ShadowCollection x:Key="InnerShadows">
<utu:Shadow BlurRadius="30"
OffsetX="50"
OffsetY="50"
Opacity="1"
Spread="-5"
Color="Red"
IsInner="True" />
<utu:Shadow BlurRadius="30"
OffsetX="-50"
OffsetY="-50"
Opacity="1"
Spread="-5"
Color="Green"
IsInner="True" />
</utu:ShadowCollection>
</Page.Resources>

<StackPanel>
<utu:ShadowContainer Shadows="{StaticResource InnerShadows}">
<Grid Height="100"
Width="100"
Background="LightGray"
CornerRadius="50" />
</utu:ShadowContainer>
</StackPanel>
```
Result:

![Green shadow covers red](../assets/green-shadow-cover.png)

Now, let's change the shadow order and place the red shadow in the end. See that the red shadow, now, overlaps the green one:
eriklimakc marked this conversation as resolved.
Show resolved Hide resolved

```xml
xmlns:utu="using:Uno.Toolkit.UI"
...

<Page.Resources>
<utu:ShadowCollection x:Key="InnerShadows">
<utu:Shadow BlurRadius="30"
OffsetX="-50"
OffsetY="-50"
Opacity="1"
Spread="-5"
Color="Green"
IsInner="True" />
<utu:Shadow BlurRadius="30"
OffsetX="50"
OffsetY="50"
Opacity="1"
Spread="-5"
Color="Red"
IsInner="True" />
</utu:ShadowCollection>
</Page.Resources>

<StackPanel>
<utu:ShadowContainer Shadows="{StaticResource InnerShadows}">
<Grid Height="100"
Width="100"
Background="LightGray"
CornerRadius="50" />
</utu:ShadowContainer>
</StackPanel>
```
Result:

![Red shadow covers green](../assets/red-shadow-cover.png)

## Usage

See how to add shadows to your controls with the following code and the result.
Expand Down
Loading