-
Notifications
You must be signed in to change notification settings - Fork 428
[dev-v5] Add mediaChanged, themeChanged, hidden-when and theme features #3956
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
Open
dvoituron
wants to merge
2
commits into
dev-v5
Choose a base branch
from
users/dvoituron/dev-v5/theme
base: dev-v5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+163
−18
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.9%
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[dev-v5] Add mediaChanged, themeChanged, hidden-when and theme features
body.mediaChanged
event to detect browser size changes in JavaScript.body.themeChanged
event to detect theme changes in JavaScript.scrollbar-color: var(--colorNeutralForeground4) var(--colorNeutralBackground2);
in the default styles to display a scrollbar adapted to the themehidden-when
attribute to hide any HTML elements when the screen size matches the specified breakpoints.hidden-when attribute
You can also use the HTML
hidden-when
attribute to hide any elements when the screen size matches the specified breakpoints.Example:
<div hidden-when="sm md">...</div>
will hide the element on small and medium devices.Only the values
xs sm, md, lg, xl, xxl
are supported, but you can combine them.body data-media
The
<body data-media>
attribute is used to specify the current media query state of the browser.This attribute is automatically updated to reflect the current screen size, each time the browser is resized.
For example, open the browser DevTools and resize the browser window.
You will see the
data-media
attribute change as you resize the window.Client side
A JavaScript
mediaChanged
event is triggered each time thedata-media
attribute changes.Blazor side
You can use the
FluentGrid.OnBreakpointEnter
event to handle media changes in Blazor.Light-Dark Themes
FluentUI provides a dark theme that can be applied to your application.
This theme is designed to provide a visually appealing and comfortable user experience in low-light environments.
You can easily switch between light and dark themes using the provided JavaScript functions:
Blazor.theme.setDarkTheme
andBlazor.theme.setLightTheme
.Example
body data-theme
The
<body data-theme>
attribute is used to specify the current theme of the application.When the dark theme is applied, this attribute will be set to
data-theme="dark"
.When the light theme is applied, this attribute will be missing.
For example, open the browser DevTools and switch between light and dark themes using the top-right button.
You will see the
data-theme
attribute change accordingly.Style
This attribute lets you easily apply specific CSS styles based on the current theme.
Client side
A JavaScript
themeChanged
event is triggered each time thedata-theme
attribute changes.