-
Notifications
You must be signed in to change notification settings - Fork 12
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
[QUO-325] Clean up blank underline block #1595
Conversation
src/Nri/Ui/Block/V6.elm
Outdated
Underline -> | ||
[ Css.textDecoration Css.underline | ||
, Css.property "text-decoration-thickness" "1px" | ||
, Css.property "text-underline-offset" "4.5px" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main issue I was running into was getting it aligned with a blank underline, which is why I was moving it at all. Happy to go toward a different solution, I wasn't attached or happy with how this was turning out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay! I think I'm following. So border-bottom is used for adding a "blank" underline and text-decoration is used for adding underlines to actual text?
I think this brings me back to my question from yesterday: "Should non-blanks ever be underlined?" Like, is the intention of the underline just to be a different styling for a blank? If so, then I don't think we'd ever need text-decoration at all? (Although I think an API change could clarify the expected behavior a bit.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like, is the intention of the underline just to be a different styling for a blank?
Yes. In our context, students thought the dashed bordered rectangle versions of the blanks meant that it was interactive (they're not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, missed the first part of Tessa's question. We don't underline text in Short Response. I'm not 💯 sure but don't think there's a use case for it in scaffolding or Guided Tutorials either? (the other 2 places currently using Block)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just aiming for some consistency between the two modes. Taking away the names the component is currently using, we have two display modes that we want to be able to choose between:
- Show blanks with dashes
- Show blanks with underlines
Originally, I felt it made more sense to make that a global thing: show everything with dashes, or show everything as underlined. If we are feeling this is not the case, I can scope that down to just blanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I get where the other underlines came from. We want to apply underline to just blanks. Or apply to everything, but have the border go all the way around except in blanks, where it should just be on the bottom.
We don't currently have a use case to change the dashes on the other Block elements. The border is there for added contrast in addition to the background color.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Nri/Ui/Block/V6.elm
Outdated
@@ -542,7 +542,7 @@ toMark config { backgroundColor, borderColor } = | |||
Underline -> | |||
Css.solid | |||
|
|||
notBottomBorderColor = | |||
borderColor_ = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we definitely want the text color to apply to the underline. I was not finding a solution that felt good for that, because I wasn't finding where the text color is set inside the component. I was assuming it came from outside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see! This is happening because of the user agent stylesheet.
In the screenshot above, there's a label, so the blank is treated as highlighted by "fruit." Semantically, we're using the mark
tag for this:
If there's no label or emphasis, the styles apply as expected:
(I don't have an opinion on whether this is worth addressing as part of this PR, but if you do override the user agent stylesheet, please check that high contrast mode keeps working.)
src/Nri/Ui/Block/V6.elm
Outdated
config.labelCss | ||
++ (case ( config.borderStyle, config.content ) of | ||
( Underline, [ Blank _ ] ) -> | ||
[ Css.top (Css.px 6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think adjusting the top px will work consistently for a couple of reasons.
The first reason is variable font size. As far as I am aware, the Block component is used in containers that set the font to 30px and in containers that set the font to 18px. I believe the place the underline is going to be used has 18px font.
30px | 18px | 12px | |
---|---|---|---|
Original Spacing | |||
New Spacing |
Users should be able to customize their font size without all our styles breaking. But even if we don't set that as a goal, I'm not sure that the 6px from the top will land in the right spot, you know?
The second reason I think we should change approaches here is that setting the top to 6px will sometimes play badly with repositioning:
previous behavior | top: 6px |
---|---|
Code for the above screenshots
On #1594 or with it merged in, adjust the first repositioning example to use:
, Block.view
[ Block.plaintext "gifts"
, Block.label "direct object collision"
, Block.yellow
, Block.labelId directObjectId
, Block.labelPosition (Dict.get directObjectId offsets)
]
, Block.view [ Block.plaintext " " ]
, Block.view
[ Block.label "long adjectives shouldn't hit a lil"
, Block.underline
, Block.purple
, Block.labelId adjectiveId
, Block.labelPosition (Dict.get adjectiveId offsets)
]
A third reason is that when labels aren't repositioned, the 6px change will make them look a little funky when they're rendered next to normal labels:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @staceyadams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lindsaykwardell let's revert this part.
@tesk9 for context of why we wanted to change this: the labels look more detached in the use in Short Response because we use the blank in 3 sentences in a column, sometimes with label, sometimes without. In the third sentence frame example, you can see that it appears equidistant between the second and third bullet so not immediately visually clear at a glance that it belongs to the third one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted this change.
Looks good! @lindsaykwardell would you please review/merge #1594 so that the changes are a little easier to double check? |
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks!
Someone may want to update the corresponding Paper document still (although I'm not sure who owns that work at this point! Not me, I'm pretty sure 😆)
I just pushed up a change to support the correct background in high contrast mode, although I'm not 100% certain how to enable it locally to test. |
Yay, thank you!!
We have an instructional guide for testing in high contrast mode! 🎉 |
I can own updating the Paper doc |
Change some minor styles based on feedback from Stacey.
🔧 Modifying a component
Context
https://github.com/NoRedInk/NoRedInk/pull/46846#issuecomment-1883598283
🖼️ What does this change look like?
Component completion checklist
nriDescription