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

Show image description if present #2103

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cincodenada
Copy link

@cincodenada cincodenada commented Jan 17, 2022

Implements #2102. This is somewhat a proof-of-concept, it's a pretty basic implementation but it does the job!

I'm not actually sure it's worth using the lefthand button slot, it may make more sense to just have tapping on the description expand it instead - we could add something to indicate it was tappable? I'm not sure what that would be (Tusky has a little line in the top center and an outline indicating a "drawer" of sorts, for instance)

This also shows the first line of the image description by default, which takes up a little more vertical space, but I think it's worthwhile - making image descriptions more visible in general is a net good, I think. The button showing up also would indicate this, but for short descriptions the user wouldn't have to do anything.

I also considered making a three-state button, where it would start as hidden, and tapping would toggle through hidden->first line->full, but that seems not really an improvement over just hidden->full.

I made the max height of the expanded box shove the image out of the way and fill up to half the screen, and scroll after that. Another option would be to have it expand into an overlay over the image and take up as much height as it needs - if someone is reading the description, they're generally fine not looking at the image for a bit - but that was harder to implement, so I went with the easy way for the proof-of-concept.

Add a button to expand the image description if applicable
@cincodenada
Copy link
Author

Oh dang, the auto-deploy to preview is really slick! Many props to whoever got that set up!

One thing I remembered after checking out the preview: an awkward bit (that would be alleviated by having the text itself be the button) is that a button still shows up even if the text is only one line long, and clicking on it effectively does nothing. I don't know if there's a great way around this - can we determine at render time if the textbox is overflowing somehow? And even if we could, we'd have to re-check if the user zoomed or resized or what have you...seems maybe more complicated than it's worth.

Copy link
Owner

@nolanlawson nolanlawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting together this PR. I had some minor nitpicks.

Aside from that, I think the general idea is good – there's room on the left for the ℹ️ icon thanks to the pinch-zoom icon, so there's a pleasant symmetry by adding it. I also think it's a good idea to hide it when the description is missing.

As for the placement of the text itself, I would somewhat prefer for larger text center-positioned on top of the entire image. (Or maybe positioned over the bottom third, kind of like a film subtitle.) The current position seems a bit off to me.

Also I'm not sure if there's something wrong with how I'm using it, but it seems like the info toggle button doesn't actually work. The description seems always visible, whether the button is toggled or not.

Screenshot from 2022-01-17 09-25-25

Thanks again for your work on this!

<IconButton
className="media-control-button"
svgClassName="media-control-button-svg"
pressable={hasDescription}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pressable={hasDescription} is unnecessary; we're already in an if hasDescription block.

Suggested change
pressable={hasDescription}
pressable={true}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Yeah good catch - this is left over from an earlier iteration that didn't have the if blocks here.

<IconButton
className="media-control-button"
svgClassName="media-control-button-svg"
pressable={true}
pressable={canPinchZoom}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this can just be pressable={true}.

Suggested change
pressable={canPinchZoom}
pressable={true}

pressed={pinchZoomMode}
label="{intl.enterPinchZoom}"
pressedLabel="{intl.exitPinchZoom}"
href="#fa-search"
on:click="togglePinchZoomMode()"
ariaHidden={!canPinchZoom}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ariaHidden={!canPinchZoom}
ariaHidden={false}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can just leave ariaHidden off completely here, yeah?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

}),
computed: {
length: ({ mediaItems }) => mediaItems.length,
dots: ({ length }) => times(length, i => ({ i })),
canPinchZoom: ({ mediaItems }) => !mediaItems.some(media => ['video', 'audio'].includes(media.type)),
hasDescription: ({ mediaItem }) => mediaItem.description,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more clear that this is a boolean:

Suggested change
hasDescription: ({ mediaItem }) => mediaItem.description,
hasDescription: ({ mediaItem }) => !!mediaItem.description,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - I've come around to slightly prefer Boolean() in these situations, but I think either is fine if you have a style preference.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean() is fine too, yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants