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

Remove flare tag from title and hightlight it within the tags row #10528

Merged
merged 8 commits into from Oct 15, 2020

Conversation

akshayymahajan
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This PR does 2 things:

  1. Remove the Flare Tag from the post title.
  2. Moves the flare tag to the first position within the list of tags and highlights it.

Related Tickets & Documents

Closes #10523

QA Instructions, Screenshots, Recordings

image

Added tests?

  • yes
  • no, because they aren't needed
  • no, because I need help

Added to documentation?

  • docs.forem.com
  • readme
  • no documentation needed

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Oct 2, 2020
Copy link
Contributor

@ludwiczakpawel ludwiczakpawel left a comment

Choose a reason for hiding this comment

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

Oh damn, I love it! Thank you so much! I have one very tiny change request - other than that it's awesome!

color: flare_tag.text_color_hex,
}}
>
{`#${flare_tag.name}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you wrap # with <span className="crayons-tag__prefix"> similar to how we do it with other tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing!

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 2, 2020
@ludwiczakpawel
Copy link
Contributor

I've just realized, that when you scroll down quite a lot on your feed we actually load feed cards differently (I don't know why...) - so the feed card code is generated in multiple places. That jsx component is one of them and it works great. But we gonna need it in other places too.. Do you think you can look at it as well? You can also spot it in logged out version of the page where we also load feed card differently.

@akshayymahajan
Copy link
Contributor Author

Sure.. I'll look into it..

@ludwiczakpawel
Copy link
Contributor

@akshayymahajan awesome! I'm super excited about this one :)

Btw. here are some references you may find useful:

@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Oct 2, 2020
@akshayymahajan
Copy link
Contributor Author

Hey @ludwiczakpawel, I have updated both files and tested in the logged out page and the search results. Can you check again?

Copy link
Contributor

@ludwiczakpawel ludwiczakpawel left a comment

Choose a reason for hiding this comment

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

Awesome! I left few last change request - nothing really major :)

Comment on lines 35 to 46
flareTag =
"<a href='/t/" +
article.flare_tag.name +
"' class='crayons-tag'>" +
"<span class='crayons-story__flare-tag' style='background:" +
article.flare_tag.bg_color_hex +
';color:' +
article.flare_tag.text_color_hex +
"'><span className='crayons-tag__prefix'>#</span>" +
article.flare_tag.name +
'</span>' +
'</a>';
Copy link
Contributor

Choose a reason for hiding this comment

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

We should drop this extra container crayons-story__flare-tag - it's not needed anymore.

Suggested change
flareTag =
"<a href='/t/" +
article.flare_tag.name +
"' class='crayons-tag'>" +
"<span class='crayons-story__flare-tag' style='background:" +
article.flare_tag.bg_color_hex +
';color:' +
article.flare_tag.text_color_hex +
"'><span className='crayons-tag__prefix'>#</span>" +
article.flare_tag.name +
'</span>' +
'</a>';
flareTag = `<a href="/t/${article.flare_tag.name}" class="crayons-tag" style="background: ${article.flare_tag.bg_color_hex}; color: ${article.flare_tag.text_color_hex};">
<span class="crayons-tag__prefix>#</span>
${article.flare_tag.name}
</a>`;

Copy link
Contributor

Choose a reason for hiding this comment

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

The flare tag is basically now a classic crayons-tag with custom background and color.

@@ -135,7 +135,7 @@

&__flare-tag {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should now be able to remove this entire class, right?

{flare_tag && (
<a className="crayons-tag" href={`/t/${flare_tag.name}`}>
<span
className="crayons-story__flare-tag"
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly to what I suggested in previous comment, we should drop .crayons-stroy__flare-tag

<% story.cached_tag_list_array.each do |tag| %>
<% flare_tag = FlareTag.new(story, @tag).tag %>
<% if flare_tag %>
<a href="/t/<%= flare_tag.name %>" class="crayons-tag"><span class="crayons-story__flare-tag" style="background:<%= flare_tag.bg_color_hex %>;color:<%= flare_tag.text_color_hex %>"><span className="crayons-tag__prefix">#</span><%= flare_tag.name %></span></a>
Copy link
Contributor

Choose a reason for hiding this comment

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

And same here.

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 2, 2020
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Oct 2, 2020
@akshayymahajan
Copy link
Contributor Author

@ludwiczakpawel updated!

Copy link
Contributor

@ludwiczakpawel ludwiczakpawel left a comment

Choose a reason for hiding this comment

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

One tiny change and it's ready!

app/assets/stylesheets/components/stories.scss Outdated Show resolved Hide resolved
@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 2, 2020
Copy link
Contributor

@lisasy lisasy left a comment

Choose a reason for hiding this comment

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

Nice! Thank you :) This looks great.

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Oct 2, 2020
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Oct 3, 2020
@rhymes
Copy link
Contributor

rhymes commented Oct 4, 2020

@akshayymahajan it looks like some of the tests are failing, please take a look at the build here: https://github.com/forem/forem/pull/10528/checks?check_run_id=1201884642

@akshayymahajan
Copy link
Contributor Author

Hey @rhymes, I have updated the code to fix the failing test.

@ludwiczakpawel ludwiczakpawel self-requested a review October 5, 2020 07:02
Copy link
Contributor

@ludwiczakpawel ludwiczakpawel left a comment

Choose a reason for hiding this comment

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

Hey, I've taken it for another ride and there's still something a little bit off, when I scroll down the feed. Here's a video showing the issue. Looks like on the feed cards that are being loaded with infinity scroll we don't apply appropriate colors/styling to the flare tag.

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: unreviewed bot applied label for PR's with no review labels Oct 5, 2020
@akshayymahajan
Copy link
Contributor Author

Hey @ludwiczakpawel, looks like the data being returned from the API has some null values. Not sure if this is related to the changes I made. Would really appreciate some help.

Screenshot 2020-10-05 at 2 55 34 PM

@ludwiczakpawel
Copy link
Contributor

Interesting. I can see this working properly on prod dev.to...

@rhymes I SUMMON YOU.

summon rhymes

@rhymes
Copy link
Contributor

rhymes commented Oct 8, 2020

Hi @akshayymahajan, that indicates that the tag has no defined colors:

forem/app/models/tag.rb

Lines 26 to 27 in a943f04

validates :text_color_hex, format: HEX_COLOR_REGEXP, allow_nil: true
validates :bg_color_hex, format: HEX_COLOR_REGEXP, allow_nil: true

both hex colors can be nil

@akshayymahajan
Copy link
Contributor Author

Thanks, @rhymes. @ludwiczakpawel in that case, I think it would be best to add back the span.crayons-stroy__flare-tag wrapper in all the places. What do you say?

@ludwiczakpawel
Copy link
Contributor

ludwiczakpawel commented Oct 8, 2020

@rhymes are you sure? can you please checkout the screen recording here: https://d.pr/v/Pzx0DE - it's the same tag. one time it has colors applied and the other time it does not... which means that this tag in general has colors applied but they are not returned in certain cases.

@rhymes
Copy link
Contributor

rhymes commented Oct 8, 2020

@ludwiczakpawel I'm not very familiar with how flare tags work but I came up with these two clues:

article.flare_tag always calls the FlareTag class with just the article object, without the "except tag" parameter:

forem/app/models/article.rb

Lines 312 to 314 in a943f04

def flare_tag
@flare_tag ||= FlareTag.new(self).tag_hash
end

def initialize(article, except_tag = nil)
@article = article.decorate
@except_tag = except_tag
end

It looks to me that if FlareTag were to be initialized with a second argument, it would send back nil even if the Tag itself has the colors assigned to it:

def tag_id
tag_name, tag_id = FLARE_TAG_IDS_HASH.slice(*article.cached_tag_list_array).first
tag_id if tag_name && tag_name != except_tag
end

The clue for what might be going on in your recording is to be found in:

<% flare_tag = FlareTag.new(story, @tag).tag %>
<% if flare_tag %>
<span class="crayons-story__flare-tag" style="background:<%= flare_tag.bg_color_hex %>;color:<%= flare_tag.text_color_hex %>">

which is passing @tag as the "except tag".

This comes from https://github.com/forem/forem/blob/master/app/views/articles/_single_story.html.erb

I seem to recall that the first page of the feed is rendered one way, subsequent pages are rendered in a different way but I'm not sure how all that works, @joshpuetz or @nickytonline might instantly know what's going on here.

There might be a different behavior between the flare tag appearing in the first batch of articles and the following batches

@akshayymahajan
Copy link
Contributor Author

I tried removing the "except tag" from the call, but it still returns null value for colors. I also tried the latest master branch locally and the JSON returned still has null values. Looks to me like this is something related to the local development environment.

@ludwiczakpawel
Copy link
Contributor

@akshayymahajan let me give it another look tomorrow and I'll get back to you then.

@ludwiczakpawel
Copy link
Contributor

Yea, looks like it's being broken on master as well.. So I'll go ahead and approve this PR :) Thanks for all the work you've done, it's really something I've been looking for for a quite long time so I appreciate your effort :)

@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Oct 15, 2020
@ludwiczakpawel ludwiczakpawel merged commit ff918da into forem:master Oct 15, 2020
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels Oct 15, 2020
boardfish pushed a commit to boardfish/forem that referenced this pull request Oct 17, 2020
…rem#10528)

* Remove flare tag from title and hightlight it within the tags row

* wrap flare tag # in a span with class crayons-tag__prefix

* updated buildArticleHTML.js to show flare tag in the tags row

* updated _single_story.html.erb to show flare tag in the tags row

* fixed missing opening tag

* removed crayons-story__flare-tag class and containers

* added .crayons-story__flare-tag back to stories.scss for search results

* added check for undefined tagList in buildArticleHTML.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust flare tag display on Feed card
4 participants