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

Visually truncate long bodies and quotes #2451

Merged
merged 1 commit into from
Oct 9, 2015
Merged

Conversation

JakeHartnell
Copy link
Contributor

  • Introduce collapsing bodies and quotes which expand when you click more.
  • This is done through the new excerpt directive which looks to see if text is overflowing its container and appends 'More' and 'Less' spans.
  • Watch annotation controller to see if an annotation is being edited so that excerpts can be applied to newly created and updated annotation.
  • Add event for threadToggleCollapse in the thread directive, and evaluate excerpts after thread expansion.
  • Implements @conordelahunty's design: https://hypothes-is.slack.com/files/conor/F09H4G4LC/pasted_image_at_2015_08_24_06_38_pm.png

It looks like this:
selection_121

@BigBlueHat
Copy link
Contributor

Needs angular wonk code review. 😉 I'm 👍 on this as it solves the > 2 year old #487 issue.

@conordelahunty could you take a look at this also? Cheers!

content: " ";
margin-left: -3em;
padding-right: 40px;
background: -webkit-gradient(linear, left top, right top, from(rgba(255, 255, 255, 0)), to(white), color-stop(50%, white));
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout!

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 16bc4b7 on hypothesis:visual-truncation into 59aeb92 on hypothesis:master.

@JakeHartnell JakeHartnell force-pushed the visual-truncation branch 2 times, most recently from 929ce15 to 10152be Compare September 8, 2015 19:56
@JakeHartnell JakeHartnell removed the WIP label Sep 8, 2015
@JakeHartnell
Copy link
Contributor Author

Ok, after much ado, I'm hoping this is good enough to be merged soon. 🙏

@@ -92,6 +92,7 @@ module.exports = angular.module('h', [

.directive('annotation', require('./directive/annotation'))
.directive('deepCount', require('./directive/deep-count'))
.directive('excerpt', require('./directive/excerpt'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Big 👍 to trying to keep this functionality as a separate directive.

@nickstenning
Copy link
Contributor

The styling/markup parts of this look absolutely fine to me. I'm a bit concerned about the business logic to do with vm.editing and thread collapse events making its way into the excerpt directive, so I'm going to try and put together a quick demo of how it might be possible to avoid that.

@nickstenning
Copy link
Contributor

Here's an example of what I mean. It's a bit rough around the edges but it shows how you might be able to keep the disable/enable state as a parameter to the excerpt directive rather than including logic about the rest of the application.

Hope that helps!

@tilgovi
Copy link
Contributor

tilgovi commented Sep 15, 2015

👍 @nickstenning, and I would only tweak it to prefer positive rather than negative conditionals as I think they're easier to parse: e.g. excerpt-if rather than excerpt-disable-if and default it to true so that it's an optional attribute.

@nickstenning
Copy link
Contributor

tweak it to prefer positive rather than negative conditionals

👍

@nickstenning
Copy link
Contributor

@JakeHartnell If you want to walk through the plunker I linked above at some point just let me know. I'm happy to help in any way I can to get this finished.

@landscape-bot
Copy link

Code Health
Repository health increased by 0.22% when pulling cb032fb on visual-truncation into 4a324db on master.

@JakeHartnell
Copy link
Contributor Author

@nickstenning this is great, and I understand why you like this approach. I'm having one problem that I had early on when I tried a similar approach that also used transclusion. The markdown converter also transcludes the annotation-body section and throws the following error:

"Error: [$compile:multidir] Multiple directives [excerpt, markdown] asking for template on: <section name="text" class="annotation-body" excerpt="" excerpt-if="!vm.editing" ng-model="vm.annotation.text" ng-readonly="!vm.editing" markdown="">

Any thoughts on that? I'll keep working on it, but I think if we can get past that we have a nice modular solution here. Thanks for the awesome comments and the plunker.

@tilgovi
Copy link
Contributor

tilgovi commented Sep 21, 2015

Unfortunately, the way around that is just another wrapping element so that
these directives don't conflict by being used on the same element.

On Mon, Sep 21, 2015, 14:44 Jake Hartnell [email protected] wrote:

@nickstenning https://github.com/nickstenning this is great, and I get
why you like this approach. I'm having one problem that I had early on when
I tried a similar approach that also used transclusion. The markdown
converter also transcludes the annotation-body section and throws the
following error:

"Error: [$compile:multidir] Multiple directives [excerpt, markdown] asking for template on:

Any thoughts on that? I'll keep working on it, but I think if we can get
past that we have a nice modular solution here. Thanks for the awesome
comments and the plunker.


Reply to this email directly or view it on GitHub
#2451 (comment).

@JakeHartnell
Copy link
Contributor Author

Unfortunately, the way around that is just another wrapping element so that these directives don't conflict by being used on the same element.

Cool, thanks.


scope:
enabled: '=excerptIf'
maxheight: '=maxheight'
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to go here, as far as I can tell. You can add some rules like .annotation-body .excerpt { max-height: 16.2em } to the CSS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Funny enough, that's what I was going to do, but worried it wouldn't be modular enough.

@nickstenning
Copy link
Contributor

Ok, looking a lot better. But checking it out there seem to be a few bugs -- excerpt controls seem to be displayed all the time for quotes, regardless of how long they are.

I've added a couple of comments inline, and I also would like to see the template moved into h/templates/client/ and added to h/templates/app.html along with all our other client templates.

@nickstenning
Copy link
Contributor

Okay, I've just force-pushed this branch. I've simplified the excerpt directive, translated it to JavaScript (although "translated" is probably a strong word in this case), and cleaned up the CSS.

@robertknight perhaps you could take a look at the general approach, and if you're happy I'll sort out the tests.

@nickstenning
Copy link
Contributor

Oh, and the whole thing is now behind a feature flag.

@ghost
Copy link

ghost commented Oct 8, 2015

Cool, I don't know if Jake got around to make the design changes or not yet but maybe Robert can pick this up if not.

@@ -0,0 +1,31 @@
@import "compass/css3/images";
@import "variables";
Copy link
Member

Choose a reason for hiding this comment

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

IIRC this will pull in a second copy of 'variables.scss' rather than require them once. I want to use a system in future where requiring in CSS works the same way as JS modules.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing that's not actually a problem because variables.scss is just variable definitions, but you're absolutely right -- it's not necessary. I'll remove it.

@robertknight
Copy link
Member

@nickstenning This looks good to me.
@conordelahunty - What are the design changes you wanted?

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling d15accf on hypothesis:visual-truncation into 81ca666 on hypothesis:master.

@nickstenning
Copy link
Contributor

Thanks for the review @robertknight. I'll fix up these things, write some tests, and then I reckon we can probably merge this and fix up the design in a separate PR, now that it's feature-flagged.

Introduces auto-truncation of long bodies and quotes which expand when
you click on a "More" link.

Feature flagged as 'truncate_annotations'.
@nickstenning
Copy link
Contributor

@robertknight Right, that's everything except the resize behaviour fixed. I reckon we can fix that another day. Let me know what you think.

@@ -5,6 +5,7 @@
@import 'mixins/responsive';
@import 'grid';
@import 'annotations';
@import 'excerpt';
Copy link
Member

Choose a reason for hiding this comment

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

This should go under 'components' in app.scss, assuming it isn't used by the help page.

robertknight added a commit that referenced this pull request Oct 9, 2015
Visually truncate long bodies and quotes
@robertknight robertknight merged commit 2fda6b8 into master Oct 9, 2015
@JakeHartnell
Copy link
Contributor Author

Thanks @robertknight and @nickstenning!

@nickstenning nickstenning deleted the visual-truncation branch October 16, 2015 13:45
@tilgovi
Copy link
Contributor

tilgovi commented Oct 30, 2015

This is also not enabled in production, it seems.

@dwhly
Copy link
Member

dwhly commented Oct 30, 2015

@conordelahunty is still working w/ the team to get his tweaks to the style implemented.

@JakeHartnell
Copy link
Contributor Author

@conordelahunty sorry I didn't get around to those, but it was good to see it on stage being used. Definitely thing we need to make the annotation bodies a bit bigger, as images are cut off.
annotationbodiesneedabiggermaxheight

@judell
Copy link
Contributor

judell commented Oct 30, 2015

It's also true that for a textual annotation, More may only reveal a few
characters.

On Thu, Oct 29, 2015 at 6:03 PM, Jake Hartnell [email protected]
wrote:

@conordelahunty https://github.com/conordelahunty sorry I didn't get
around to those, but it was good to see it on stage being used. Definitely
thing we need to make the annotation bodies a bit bigger, as images are cut
off.
[image: annotationbodiesneedabiggermaxheight]
https://cloud.githubusercontent.com/assets/521978/10836135/523488d8-7e67-11e5-9893-37e7687f1d17.jpg


Reply to this email directly or view it on GitHub
#2451 (comment).

@nickstenning nickstenning mentioned this pull request Feb 10, 2016
3 tasks
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.

8 participants