-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Night mode status in Card #6567
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @infinyte7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM I would have expected javascript to look whether the css class |
True - as I hit the approve button myself I also thought "can Javascript inspect the CSS classess? I think it can" which would make any consumers of this API more cross platform as we already have the CSS in sync between desktop and AnkiDroid, but likewise I have no problem with this, in general I think exposing any of the AbstractFlashcardViewer state to the WebView is fine, so javascript authors are on a level playing field with regard to constructing a viewing experience |
I have found one solution that may not need this. .card {
--text-color1: black;
}
.card.night_mode {
--text-color1: white;
}
.title {
color: var(--text-color1);
} Now turning on night mode automatically change the text color. But in my anki deck xiehanzi, the stroke color, outline color should be updated in JavaScript. So following are steps for that. .card {
--stroke-color: #555;
}
.card.night_mode {
--stroke-color: #fff;
}
.stroke {
color: var(--stroke-color);
} Now in JavaScript (Front/Back side of card) <!-- include this as empty -->
<div class = "stroke"></div>
<script>
var stroke_color = getComputedStyle(document.querySelector(".stroke")).color;
console.log(stroke_color);
</script> Above may be work on AnkiDesktop and AnkiMobile also. |
Pull Request template
Purpose / Description
While developing card we may need to know AnkiDroid night mode status so we can switch css class property according to night mode status.
Fixes
Fixes Link to the issues.
Approach
Return the value
isInNightMode()
How Has This Been Tested?
Tested on emulator
Learning (optional, can help others)
Checklist
Please, go through these checks before submitting the PR.
if
statements)