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

BUG: Quote marks in Dropcaps #459

Closed
designerbrent opened this issue Jun 10, 2020 · 13 comments
Closed

BUG: Quote marks in Dropcaps #459

designerbrent opened this issue Jun 10, 2020 · 13 comments
Assignees
Labels

Comments

@designerbrent
Copy link
Collaborator

Text that starts with " or other quote marks has that mark put in the dropcap.

@davideleuterius
Copy link
Contributor

@designerbrent Is this only happening within the WP context? It looks like the dropcap is being set by a data attribute. If it is being set manually, then the quote could come first and then the actual letter could be set:

"<span class="o-dropcap u-theme--background-color--base" data-letter="L"></span>

But if this is being set programmatically from WP then I'll have to look at how that is being set.

@brentawilson
Copy link

@davideleuterius @designerbrent Any update on fixing this bug?

@davideleuterius
Copy link
Contributor

@brentawilson
Are you using WordPress? Or just the ALPS CSS?

@brentawilson
Copy link

@davideleuterius WordPress

@davideleuterius
Copy link
Contributor

What should happen to the opening quote mark when we fix this to show the first actual letter? @designerbrent

@designerbrent
Copy link
Collaborator Author

designerbrent commented Jun 15, 2020 via email

@davideleuterius
Copy link
Contributor

@designerbrent @brentawilson
It seems this isn't a bug. This is the actual behavior / consequence of using the CSS pseudo-element ::first-letter:

https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter

Punctuation that precedes or immediately follows the first letter is included in the match.

So the options are:

  • stop using an opening quote when selecting the Drop Cap option on paragraphs, or
  • either use PHP or JavaScript to check for the drop cap option and then remove the opening quote on it.

More than likely the best option is the second one, so unless directed otherwise, I will look into this. I am leaning more towards JavaScript because should the user turn off the drop cap from the paragraph, the opening quote would still be there, but if removed via PHP, it would be dropped from the DB so if the drop cap is deactivated, the opening quote would not be restored.

Let me know what you think.

@davideleuterius
Copy link
Contributor

@designerbrent
I went ahead and created a small JS patch for this in the ALPS WP repo:
adventistchurch/alps-wordpress#489

My thinking on this is that this is a display issue only, and this only affects display, not the content within the DB itself. This also handles multiple drop caps on the same page.

@designerbrent
Copy link
Collaborator Author

@davideleuterius To clarify then, are you saying that ALPS only uses ::first-letter to do this? I thought that is some JS that applies this and wraps the span around the first letter.

When I put a " (quote) at the start of a paragraph in ALPS core, not Wordpress, it applies this to the quote mark. That's why I'm not sure about adventistchurch/alps-wordpress#489 as it is just a bandaid down the line.

@davideleuterius
Copy link
Contributor

davideleuterius commented Jun 16, 2020

In ALPS WP, it is just using the .has-drop-cap class assigned to the paragraph when someone selects that option from the block editor, and ::first-letter is applied to it through the style for that class.

In ALPS core, a js script is looking for the .has-dropcap class, and then finding the first p tag within that selector, and gets the first character. It then creates a data attribute of data-letter that it then sets on an injected span tag ( <span class="o-dropcap u-theme--background-color--base"></span> ) that replaces the first character to create the drop cap.

Then in the CSS, the letter is put back in to the span by setting it as content by reading that data-letter attribute:

.o-dropcap &::before { content: attr(data-letter);

So it seems there is different methods here for WP and ALPS core.

@designerbrent
Copy link
Collaborator Author

So it seems there is a little confusion. On ALPS for Wordpress, there are two ways to do a dropcap:

  1. ALPS method
  2. Wordpress method

Currently, we don't do anything with the Wordpress dropcap. The styling comes from Wordpress. We do have the ALPS version, complete with a checkbox to disable it.

2020-06-16 at 4 56 PM

@davideleuterius
Copy link
Contributor

Yes, that definitely explains it. Sorry for not understanding how that was set up. I think what I did for WP just needs to be ported into ALPS core and then removed from the WP part, because I think this is done the same exact way. Again sorry for the confusion on this!

@designerbrent
Copy link
Collaborator Author

ok. So yes, move that to the WP core part and I will not commit that PR to Wordpress.

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

No branches or pull requests

4 participants