-
Notifications
You must be signed in to change notification settings - Fork 166
[terra-hyperlink] Hyperlink ellipses #4072
Changes from all commits
e3cfb14
f993a65
f1e328e
fae735b
5b4f020
6207ba5
013da1f
941c61b
c1d7434
4259023
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable react/forbid-dom-props */ | ||
import React from 'react'; | ||
import Hyperlink from 'terra-hyperlink'; | ||
|
||
const styles = { | ||
truncated: { | ||
width: '150px', | ||
height: '50px', | ||
borderStyle: 'dashed', | ||
marginBottom: '10px', | ||
}, | ||
}; | ||
|
||
export default () => ( | ||
<div role="main"> | ||
<div style={styles.truncated}> | ||
Basic Test | ||
<Hyperlink id="basic-hyperlink1" href="https://www.cerner.com" text="Default hyperlink that is really long and will get truncated" /> | ||
</div> | ||
<div style={styles.truncated}> | ||
<Hyperlink id="basic-hyperlink2" href="https://www.cerner.com" text="Default hyperlink that is really long and will get truncated" /> | ||
</div> | ||
|
||
<div style={styles.truncated}> | ||
External Test | ||
<Hyperlink id="external-hyperlink1" href="https://www.cerner.com" variant="external" text="External Hyperlink that is really long and will get truncated" /> | ||
</div> | ||
<div style={styles.truncated}> | ||
<Hyperlink id="external-hyperlink2" href="https://www.cerner.com" variant="external" text="External Hyperlink that is really long and will get truncated" /> | ||
</div> | ||
|
||
<div style={styles.truncated}> | ||
Button Test | ||
<Hyperlink id="button-hyperlink1" href="https://www.cerner.com" onClick={() => {}} text="Button Hyperlink that is really long and will get truncated" /> | ||
</div> | ||
<div style={styles.truncated}> | ||
<Hyperlink id="button-hyperlink2" href="https://www.cerner.com" onClick={() => {}} text="Button Hyperlink that is really long and will get truncated" /> | ||
</div> | ||
|
||
<div style={styles.truncated}> | ||
Document Test | ||
<Hyperlink id="document-hyperlink1" href="https://www.cerner.com" onClick={() => {}} variant="document" text="Document Hyperlink that is really long and will get truncated" /> | ||
</div> | ||
<div style={styles.truncated}> | ||
<Hyperlink id="document-hyperlink2" href="https://www.cerner.com" onClick={() => {}} variant="document" text="Document Hyperlink that is really long and will get truncated" /> | ||
</div> | ||
</div> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,14 @@ | |
background-color: transparent; // Remove the gray background on active links in IE 10 | ||
color: var(--terra-hyperlink-color, #006fc3); | ||
cursor: pointer; | ||
display: inline-block; // prevents variant icon from breaking onto its own line | ||
outline: none; | ||
text-decoration: var(--terra-hyperlink-text-decoration, underline); | ||
touch-action: manipulation; // Enable fast tap interaction in webkit browsers; see https://webkit.org/blog/5610/more-responsive-tapping-on-ios/ | ||
vertical-align: baseline; | ||
display: inline-flex; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we changing the style from inline-block to inline-flex? I would not expect this change to be necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're needing to have 2 spans with 1 being an ellipses but another being on the same level, we'll need to go with this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also inline-block wasn't allowing us to properly truncate without the hyperlink "clickable" area extending past the "visual" area of the hyperlink or other visual issues. Using inline-flex, we were able to properly have the "text" portion of hyperlink resize itself so it would truncate without issue while allowing the icon to always render at full size. |
||
align-items: baseline; | ||
max-width: min-content; | ||
width: 100%; | ||
|
||
&:visited, | ||
&.is-visited { | ||
|
@@ -129,14 +132,15 @@ | |
line-height: inherit; | ||
margin: 0; // reset for Safari, defaults to 2px | ||
outline: none; | ||
overflow: visible; // reset for IE | ||
overflow: hidden; // reset for IE | ||
padding: 0; | ||
pointer-events: auto; | ||
position: relative; // reset for IE | ||
text-align: left; | ||
top: 0; // reset for IE | ||
touch-action: manipulation; // Enable fast tap interaction in webkit browsers; see https://webkit.org/blog/5610/more-responsive-tapping-on-ios/ | ||
vertical-align: baseline; | ||
width: 100%; | ||
|
||
.button-inner { | ||
font-family: inherit; | ||
|
@@ -145,6 +149,15 @@ | |
min-width: 0; | ||
position: relative; // reset for IE | ||
top: 0; // reset for IE | ||
display: flex; | ||
min-width: 0; | ||
max-width: min-content; | ||
} | ||
} | ||
|
||
.inner-text { | ||
overflow: hidden; | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
} |
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.
Shouldn't we be able to accomplish this with one span?
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.
As per the requirements, we need to make only the text have an ellipsis while the icon stays at the same level. So we need to use 2 spans for this. Otherwise it will start wrapping around if we try to implement the ellipses without having an additional inner span.