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

Reduced animations #1350

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/app/dev/DevToys.Api/Core/Theme/IThemeListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public interface IThemeListener
/// </summary>
bool UserIsCompactModePreference { get; }

/// <summary>
/// Gets a value indicating whether the app should use less animations.
/// </summary>
bool UseLessAnimations { get; }

/// <summary>
/// Raised when the theme has changed.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions src/app/dev/DevToys.Blazor/Assets/sass/_transitions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
animation-timing-function: ease-out;
}

// Use less animations
div[data-uselessanimations] {
.entrance-theme-transition {
animation-name: entrance-theme-transition-key-frames;
animation-duration: 0s;
animation-timing-function: linear;
}
}

@mixin transition($transition...) {
@if length($transition) == 0 {
$transition: all 0.2s ease-in-out !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,14 @@
opacity: 1;
}
}

// Use less animations
div[data-uselessanimations] {
.dialog {
animation: none;

&-overlay {
animation: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,14 @@ div[data-compactmode] {
}
}
}

// Use less animations
div[data-uselessanimations] {
.nav-bar-root {
nav {
&.transition {
@include transition( left 0s linear, width 0s linear, max-width 0s linear, box-shadow 0s linear);
}
}
}
}
3 changes: 2 additions & 1 deletion src/app/dev/DevToys.Blazor/Pages/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<div class="main-layout @(Class)"
data-theme="@ThemeName"
data-compactmode="@IsCompactMode"
data-usercompactmode="@UserIsCompactModePreference">
data-usercompactmode="@UserIsCompactModePreference"
data-uselessanimations="@UseLessAnimations">
@Body
</div>
5 changes: 5 additions & 0 deletions src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public partial class MainLayout : LayoutComponentBase
[Parameter]
public bool UserIsCompactModePreference { get; set; }

[Parameter]
public bool UseLessAnimations { get; set; }

[Parameter]
public string Class { get; set; } = default!;

Expand Down Expand Up @@ -104,6 +107,8 @@ private void ApplyTheme()
ThemeName = themeName;
IsCompactMode = _themeListener.IsCompactMode;
UserIsCompactModePreference = _themeListener.UserIsCompactModePreference;
UseLessAnimations = _themeListener.UseLessAnimations;

InvokeAsync(() =>
{
StateHasChanged();
Expand Down
10 changes: 10 additions & 0 deletions src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,13 @@ div[data-compactmode] {
padding: 8px 16px;
}
}

// Use less animations
div[data-uselessanimations] {
.hero {
&::before {
animation: none;
-webkit-animation: none;
}
}
}
2 changes: 1 addition & 1 deletion src/app/dev/DevToys.Blazor/wwwroot/css/devtoys.g.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public ThemeListener(ISettingsProvider settingsProvider)

public bool UserIsCompactModePreference => _settingsProvider.GetSetting(PredefinedSettings.CompactMode);

public bool UseLessAnimations => true;

public event EventHandler? ThemeChanged;

public void ApplyDesiredColorTheme()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public ThemeListener(ISettingsProvider settingsProvider)

public bool UserIsCompactModePreference => _settingsProvider.GetSetting(PredefinedSettings.CompactMode);

public bool UseLessAnimations => true;

public event EventHandler? ThemeChanged;

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public ThemeListener(ISettingsProvider settingsProvider)

public bool UserIsCompactModePreference => _settingsProvider.GetSetting(PredefinedSettings.CompactMode);

public bool UseLessAnimations => !SystemParameters.ClientAreaAnimation;

public event EventHandler? ThemeChanged;

public void ApplyDesiredColorTheme()
Expand Down
Loading