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 Internet Explorer 11 specific logic from KTextTruncator #652

Merged
merged 6 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ Changelog is rather internal in nature. See release notes for the public overvie

## Upcoming version 5.x.x (`develop` branch)

- [#652]
- **Description:** Remove Internet Explorer 11 specific logic from KTextTruncator.
- **Products impact:** bugfix.
- **Addresses:** https://github.com/learningequality/kolibri-design-system/issues/643
- **Components:** KTextTruncator
- **Breaking:** no
- **Impacts a11y:** -
- **Guidance:** Consumers need to ensure the modal is still working correctly.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think these changes have anything to do with the modal, possibly result of copy-paste? Please cleanup.


[#652]: https://github.com/learningequality/kolibri-design-system/pull/652/

- [#590]
- **Description:** Modal now shrinks when the content has a smaller height.
- **Products impact:** bugfix.
Expand Down
55 changes: 2 additions & 53 deletions lib/KTextTruncator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
/**
* Truncates text to a certain number of lines
* and adds an ellipsis character "…"
*
* Internet Explorer note:
* Depending on length of words of the text, there might
* be a gap between the last visible word and "…"
*/
export default {
name: 'KTextTruncator',
Expand All @@ -56,15 +52,6 @@
required: false,
default: 1,
},
/**
* Text line height in rem.
* Used only for Internet Explorer fallback.
*/
lineHeightIE: {
type: Number,
required: false,
default: 1.4,
},
},
computed: {
truncate() {
Expand Down Expand Up @@ -101,47 +88,9 @@
// needed to make line clamp work for very long word with no spaces
overflowWrap: 'break-word',
};
} else {
/*
(C)
Fallback for multiple lines in Internet Explorer and some older versions
of other browsers that don't support line clamp
(https://caniuse.com/mdn-css_properties_-webkit-line-clamp).
Calculate max height and add "..." in `::before` while covering it with
white rectangle defined in `::after` when text doesn't need to be truncated.
Adapted from https://hackingui.com/a-pure-css-solution-for-multiline-text-truncation/
and https://css-tricks.com/line-clampin/#the-hide-overflow-place-ellipsis-pure-css-way.
*/
const ellipsisWidth = '1rem';
return {
overflow: 'hidden',
position: 'relative',
lineHeight: `${this.lineHeightIE}rem`,
maxHeight: `${this.maxLines * this.lineHeightIE}rem`,
// needed to make truncation work for very long word with no spaces
// `word-wrap` is a legacy name for `overflow-wrap` that needs to be used for IE
wordWrap: 'break-word',
// create space for "..."
paddingRight: ellipsisWidth,
marginRigth: `-${ellipsisWidth}`,
'::before': {
content: "'…'",
position: 'absolute',
right: 0,
bottom: 0,
},
// cover "..." with white rectangle when text
// doesn't need to be truncated
'::after': {
content: "''",
position: 'absolute',
right: 0,
width: ellipsisWidth,
height: '100%',
background: this.$themeTokens.surface,
},
};
}
// Default return value for when neither condition is met
return {};
Copy link
Member

Choose a reason for hiding this comment

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

This won't be needed, see #652 (comment)

},
},
};
Expand Down
Loading