-
Notifications
You must be signed in to change notification settings - Fork 48
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
Mutual Checker: Icons in blog cards; icon tooltips #889
Mutual Checker: Icons in blog cards; icon tooltips #889
Conversation
Fix blog cards outside of posts, e.g. in the notification modal Fix icon color better
This reverts commit d18197e.
Figured out a way around this! We can prepend the icon to the parent of the parent of blogCardLink, I've tried this at several node levels and this prevents the link from overflowing to blank. blogCardLink.parentElement.parentElement.prepend(icon.cloneNode(true)); We would then have to change the display of the parent to flex and also set the height of the SVG. const styleElement = buildStyle(`
${keyToCss('popoverHolder')} ${keyToCss('blogCardBlogLink')} {
display: flex;
}
${keyToCss('popoverHolder')} ${keyToCss('blogCardBlogLink')} svg.xkit-mutual-icon {
height: 1.5em;
}
`); I've tried and verified that it produces this: There's probably a more graceful way to get the icon out of the link's parent's parent, but the proof-of-concept works! |
Hmm, it does indeed! Targeting the anchor element is probably the cleanest way to implement that, and allows for easily stealing the right color. pageModifications.register(`${keyToCss('blogCardBlogLink')} > a`, processBlogCardLinks); const clonedIcon = icon.cloneNode(true);
clonedIcon.setAttribute('fill', blogCardLink.style.color);
blogCardLink.before(clonedIcon); Edit: Ah, this breaks one day a year. |
Not if we curry const processBlogCardLinks = aprilFools => blogCardLinks =>
// other stuff
!aprilFools && clonedIcon.setAttribute('fill', blogCardLink.style.color); pageModifications.register(`${keyToCss('blogCardBlogLink')} > a`, processBlogCardLinks(aprilFools)); |
Generally in this codebase we just define preference variables in the module scope, relying on main() having been called and having set them before any other functions in the module, but that does work here too! |
Ah, then would setting |
Co-Authored-By: alleycatboy <[email protected]>
Co-Authored-By: April Sylph <[email protected]>
Note: a network request can be skipped the first time you mouse over a blog avatar that you do not follow by using the + import { blogData, timelineObject } from '../util/react_props.js';
const getIsFollowing = async (blogName, element) => {
- const { blog } = await timelineObject(element) ?? {};
+ const blog = await blogData(element) ?? (await timelineObject(element))?.blog;
if (following[blogName] === undefined) {
if (blogName === blog?.name) { This really isn't very many network requests IMO, so super minor.
|
This comment was marked as off-topic.
This comment was marked as off-topic.
wait no. the real problem is... that the SVG element... resizes incorrectly when a I hate this. |
There's something in the back of my mind about having encountered this before and maybe fixed it but I can't recall what the details were... and it's annoying to investigate because the element only appears on hover. Might be time to override removeChild to make it easier to examine again, sigh. |
It's pretty easy to inspect, actually. Just open up the debugger, have it focused so that F8 will pause execution, hover the thing, pause execution. On Firefox at least the inspector still works completely and changes to CSS are reflected visually. I have a fix almost ready to push, but now I'm trying to fix normal icons too... the alignment has been bothering me for forever, but if I do it too good it looks like part of the icon gets cut off, which I am trying to mitigate now. |
Actually nevermind, the in-post icons are fine actually. I thought I saw an elevated level perfection in the fixed blog card alignment, but it was illusory. |
Nevermind on that nevermind. I have seen a clean 18px square mutual icon and I like it a lot. |
Oh, fun, I figured out why when I tried that it never worked: I use the debugger popped out in another window, which of course prevents you from simultaneously focusing it and mousing over the page to make the popup appear. I solved this with a userscript, though I actually picked a hotkey combination that also does something on Tumblr, so maybe change it, hypothetical viewer who wants to use this: document.addEventListener('keydown', event => {
if (event.code === 'KeyP' && event.shiftKey) {
event.stopPropagation();
debugger;
}
}, { useCapture: true }); Anyway, I still find this method inconvenient, as you can't (or I haven't figured out how to) navigate to an element by right clicking it, and sure I've gotten pretty good at keyboard-navigating through the redpop DOM, but it seems silly to have to :D |
The element inspector also has a button that lets you pick an element to inspect via left-click. It's the one shaped like a pointer. |
Yeah, and it doesn't work when, oh no wait, yes it does 🤦 |
Me: "are you sure it doesn't look worse this way"
|
Co-authored-by: marcustyphoon <[email protected]>
Unfortunately because of the Also tested and still aligned at weird-but-not-crazy base font sizes (12px to 22px). |
Interesting, I'm not able to reproduce this! |
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.
Spoiler alert: I required a CSS wizard. |
resolved
Right now this doesn't completely work; I don't understand the CSS that's causing a specific friend's URL to vanish completely (presumably because it's long and has no hyphen) and I'm not making any progress. I require a CSS wizard.
Description
This adds mutual icons to the blog cards that appear when hovering over a blog avatar in most places, which I find really useful. For example, Mutual Checker only adds icons to the user who posted a post, not to users who contributed trail items; with this PR one can mouse over them to see if they're the person you're thinking of or not. (I would like to add an "is following you" icon type as well; implementing in #992)
This also adds on-hover tooltips to mutual icons; see #890.
Code changes performed to do this:
buildStyle
blogData
react-props-extracting utility function to get the target user blog data when possible in the resultinggetIsFollowing
functionicon
variable/element that gets cloned when needed with acreateIcon
function in order to implement icon tooltips and icon color varying in blog cardsTesting steps