-
Notifications
You must be signed in to change notification settings - Fork 33
Use overflowEllipsisDeclarations when lines=1 #7293
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -1,22 +1,22 @@ | ||
| import { set } from './template-tags.js'; | ||
| import { unsafeCSS } from 'lit'; | ||
|
|
||
| export const overflowHiddenDeclarations = getOverflowDeclarations({}); | ||
| export const overflowEllipsisDeclarations = getOverflowDeclarations({ textOverflow: 'ellipsis' }); | ||
| export const overflowHiddenDeclarations = getOverflowDeclarations({ lines: 0 }); | ||
| export const overflowEllipsisDeclarations = getOverflowDeclarations({ textOverflow: 'ellipsis', lines: 0 }); | ||
|
|
||
| export function getOverflowDeclarations({ textOverflow = '', lines = 0, lit = true } = {}) { | ||
| export function getOverflowDeclarations({ textOverflow = '', lines = 1, lit = true } = {}) { | ||
| if (!arguments.length) return overflowHiddenDeclarations; | ||
| if (arguments[0].lines === 1) return overflowEllipsisDeclarations; | ||
|
Contributor
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. Would this not ignore the
Contributor
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 does just
Contributor
Author
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.
|
||
|
|
||
| const declarations = set` | ||
| min-width: 0; /* clamps width of flex items */ | ||
| overflow-x: clip; | ||
| ${lines | ||
| ${lines > 1 || lines.constructor === String | ||
| ? set` | ||
| display: -webkit-box; | ||
| overflow-clip-margin: 0.2em; | ||
| overflow-wrap: anywhere; | ||
| overflow-y: clip; | ||
| text-overflow: ${textOverflow || 'ellipsis'}; | ||
| -webkit-box-orient: vertical; | ||
| -webkit-line-clamp: ${lines};` | ||
| : set` | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Instead of handling 1 and >1 lines cases with separate classes, we can use the same it seemed simpler to just apply the styles inline. Even though the same call gets us the correct style now, the stylesheet doesn't update with property changes so it needs to either happen on render, or go back to separate classes