Skip to content

remove diff signs - #254

Closed
jacobbearden wants to merge 1 commit into
refined-github:masterfrom
jacobbearden:remove-diff-signs
Closed

jacobbearden wants to merge 1 commit into
refined-github:masterfrom
jacobbearden:remove-diff-signs

Conversation

@jacobbearden

Copy link
Copy Markdown
Contributor

I feel like the red and green backgrounds on diffs are explanatory enough, and the +/- just make things messier.

Before

screenshot from 2016-06-22 23 48 35

After

screenshot from 2016-06-22 23 49 11

@jamestalmage

Copy link
Copy Markdown

👍 - This should make copy-pasting from diffs easier as well.

@hkdobrev

Copy link
Copy Markdown
Contributor

LGTM

I'd like to see if another collaborator would like the idea though.

@DrewML

DrewML commented Jun 23, 2016

Copy link
Copy Markdown
Contributor

I like this a lot. Should probably wait for @sindresorhus to 👍 though.

@SpaceK33z

Copy link
Copy Markdown
Contributor

Nice!!

@paulmolluzzo

Copy link
Copy Markdown
Contributor

I like this a lot. Should probably wait for @sindresorhus to 👍 though.

I agree on both counts. Though it's pretty benign and we all seem to like it. 😄

@sindresorhus

Copy link
Copy Markdown
Member

👍 I actually have a todo item to open an issue about this here. Or rather my idea was to strip the +``- on copy, but this is much better.

@sindresorhus

Copy link
Copy Markdown
Member

Can you add a note about it in the readme highlights? Regarding being able to copy-paste from diffs now.

@sholladay

Copy link
Copy Markdown

FWIW, relying upon red vs green (or even colors at all, but particularly this) is bad for accessibility. Ideally they would be subtle and non-copyable exactly like the line numbers.

@paulmolluzzo

paulmolluzzo commented Jun 24, 2016 •

Copy link
Copy Markdown
Contributor

FWIW, relying upon red vs green (or even colors at all, but particularly this) is bad for accessibility. Ideally they would be subtle and non-copyable exactly like the line numbers.

This is a fair point, sure.

I don't know if this addresses accessibility entirely (I know it won't help screenreaders), but we could attach a :before pseudo element with the + or - to the rows that are addition/deletion code lines, which wouldn't force users to rely on colors, but also wouldn't make the text selectable for copying.

This is working for me locally (you could do the fonts in the custom.css file where we update that code font stack, this is just for illustration):

td.blob-code.blob-code-addition:before,
td.blob-code.blob-code-deletion:before {
    display: inline-block;
    font-family: 'Ubuntu Mono', 'Droid Sans Mono', 'Operator Mono', 'Liberation Mono', 'Source Code Pro', Menlo, Consolas, Courier, monospace !important;
}

td.blob-code.blob-code-addition:before {
    content: '+';
}

td.blob-code.blob-code-deletion:before {
    content: '-';
}

Thoughts? It undoes @jacobbearden's design choice for accessibility.

Edits: Trying to clarify that the pseudo-elements are visible but won't be copied.

@paulmolluzzo

Copy link
Copy Markdown
Contributor

@jacobbearden thanks for the new commit, I was going to make that comment but you fixed it before I could. 🏇

@jacobbearden

jacobbearden commented Jun 24, 2016 •

Copy link
Copy Markdown
Contributor Author

@paulmolluzzo I took your idea a bit further with:

td.blob-code.blob-code-addition:before,
td.blob-code.blob-code-deletion:before {
    display: inline-block;
    font-family: 'Ubuntu Mono', 'Droid Sans Mono', 'Operator Mono', 'Liberation Mono', 'Source Code Pro', Menlo, Consolas, Courier, monospace !important;
    color: rgba(0,0,0,0.3);
    -webkit-user-select: none;
}

td.blob-code.blob-code-addition:before {
    content: '+';
}

td.blob-code.blob-code-deletion:before {
    content: '-';
}

Result:
screenshot from 2016-06-23 19 37 47
Text is not selectable, so it doesn't get copied with everything else. I think this would be the best solution.

@paulmolluzzo

paulmolluzzo commented Jun 24, 2016 •

Copy link
Copy Markdown
Contributor

Text is not selectable, so it doesn't get copied with everything else. I think this would be the best solution.

You don't really need -webkit-user-select: none;. Psuedo elements are not selectable by definition. http://stackoverflow.com/questions/27392228/select-text-in-before-or-after-pseudo-element

Here's the spec, pseudo elements are not in the document tree: https://www.w3.org/TR/2011/REC-CSS2-20110607/generate.html

@jacobbearden

Copy link
Copy Markdown
Contributor Author

TIL, I guess I read your comment wrong and thought the text was still selectable.

@paulmolluzzo

Copy link
Copy Markdown
Contributor

My bad. The point of the pseudo is to make it only visible and not selectable. I tried to edit the other comment...

I do like the reduced opacity though. That's a nice improvement. 👍

@jacobbearden

Copy link
Copy Markdown
Contributor Author

// @sindresorhus

Comment thread extension/custom.css Outdated
td.blob-code.blob-code-addition:before,
td.blob-code.blob-code-deletion:before {
display: inline-block;
font-family: 'Ubuntu Mono', 'Droid Sans Mono', 'Operator Mono', 'Liberation Mono', 'Source Code Pro', Menlo, Consolas, Courier, monospace !important;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please move this to custom.css where we have this font stack defined? Add these new selectors and a comment about what they're for. It'll make it easier if we ever update the font stack for monospace/code text.

@jamestalmage

Copy link
Copy Markdown

I think without the + / - looks better. Could we hide it in an accessible way? This article suggests moving it off screen.

Is accessibility a design goal of refined-github? Would a visually impaired person ever install this extension? My (admittedly uninformed) guess is "No".

@jacobbearden

Copy link
Copy Markdown
Contributor Author

Is accessibility a design goal of refined-github? Would a visually impaired person ever install this extension? My (admittedly uninformed) guess is "No".

This is a good point. How likely is it that they're needed?

@paulmolluzzo

paulmolluzzo commented Jun 24, 2016 •

Copy link
Copy Markdown
Contributor

Would a visually impaired person ever install this extension?

I'm colorblind. Does that count? Add in flux or some crappy screen and it could be tough to see a diff at a glance.

The offscreen thing is for screen reader accessibility and the pseudo elements won't get read regardless of their displayed position (AFAIK). Usually you do offscreen text alignment for logos/images you still want text for.

Edit to add: I proposed a solution for meeting some accessibility requirements, but I'm not saying the solution must be implemented. I am fine with or without the extra symbols being included.

@jamestalmage

Copy link
Copy Markdown

I'm colorblind. Does that count?

Absolutely.

It looks like the +/- exists expressly to address colorblind users: https://government.github.com/accessibility/.

I think we should defer to whichever you think looks best. The Copy / Paste behavior is the more important feature anyways.

@sindresorhus

Copy link
Copy Markdown
Member

Ok, let's go with what @paulmolluzzo suggested.

@jacobbearden

Copy link
Copy Markdown
Contributor Author

@sindresorhus with or without the reduced opacity?

@sindresorhus

Copy link
Copy Markdown
Member

That's up to @paulmolluzzo.

@paulmolluzzo

Copy link
Copy Markdown
Contributor

Let's keep the reduced opacity @jacobbearden. It's still visible but not distracting.

@jacobbearden

Copy link
Copy Markdown
Contributor Author

Alright, then this is ready to go as is!

@paulmolluzzo

Copy link
Copy Markdown
Contributor

👍 I think we can go to master like this. Any last thoughts @sindresorhus?

@sindresorhus

Copy link
Copy Markdown
Member

The + & - has too large font size and is indenting some of the code:

screen shot 2016-06-27 at 03 18 14

screen shot 2016-06-27 at 03 18 21

Comment thread readme.md Outdated
- [Adds ability to collapse/expand files in a pull request diff](https://cloud.githubusercontent.com/assets/170270/13954167/40caa604-f072-11e5-89ba-3145217c4e28.png)
- [Adds links to patch and diff for each commit](https://cloud.githubusercontent.com/assets/737065/13605562/22faa79e-e516-11e5-80db-2da6aa7965ac.png)
- [Differentiates merge commits from regular commits](https://cloud.githubusercontent.com/assets/170270/14101222/2fe2c24a-f5bd-11e5-8b1f-4e589917d4c4.png)
- Makes it easier to copy/paste from diffs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Be more specific. Don't make users ask themselves: "How will it make it easier?"

detect PR files, add readme note

readd as pseudo element

style/sizing changes, reword readme change
Comment thread extension/content.js
$('.blob-code-deletion .blob-code-inner, .blob-code-addition .blob-code-inner').each((index, element) => {
const textNode = element.childNodes[0];

textNode.nodeValue = textNode.nodeValue.replace(/^[+-]/, ' ');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should be replaced with an empty string. Otherwise the copied code has an indentation with one space then the actual indentation.

When copying line 314-316 I get the following when pasting in Sublime:

screen shot 2016-07-02 at 22 33 58

@sindresorhus

Copy link
Copy Markdown
Member

ping :)

@leoj3n

leoj3n commented Jul 23, 2016

Copy link
Copy Markdown

Just for reference, here is an extension that strips characters on copy/paste:

https://github.com/steaks/github.monkeypatch.copypaste/blob/master/GitHubSmartCopying.js#L26

The implementation is definitely hacky.

@sindresorhus

Copy link
Copy Markdown
Member

Closing for lack of response. @jacobbearden Happy to reopen if you ever get to this ;)

@ghost

ghost commented Oct 5, 2017 •

Copy link
Copy Markdown

This is a nice thing, why close it? How else can you get your removed codes without the dash in front?

@fregante

fregante commented Oct 5, 2017 •

Copy link
Copy Markdown
Member

@anoop-ananthan This was implemented later in #282

@ghost

ghost commented Oct 5, 2017 •

Copy link
Copy Markdown

@bfred-it Thanks for the reply. But I don't think this was implemented. Here is a sample of copied text.
<button ng-show="$ctrl.filterParameterObj.selectionId" ng-click="$ctrl.removePackage()"> (dash) - {{ $ctrl.filterParameter.package.selectionName }} {{ $ctrl.filterParameter.package.subtitle }} (dash) - </button>

@fregante

fregante commented Oct 5, 2017 •

Copy link
Copy Markdown
Member

It was definitely implemented so if it doesn't work it's a bug.

Can you open an issue with more information? e.g. a link

@refined-github refined-github locked and limited conversation to collaborators Oct 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

10 participants