-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8034 from michaelchadwick/frontend-3482-better-te…
…xt-truncation add better text truncation method
- Loading branch information
Showing
21 changed files
with
426 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,4 +157,4 @@ | |
"dependencies": { | ||
"ember-auto-import": "^2.7.4" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/ilios-common/addon-test-support/ilios-common/page-objects/components/fade-text.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { create } from 'ember-cli-page-object'; | ||
|
||
const definition = { | ||
scope: '[data-test-fade-text]', | ||
expand: { | ||
scope: '[data-test-expand]', | ||
}, | ||
collapse: { | ||
scope: '[data-test-collapse]', | ||
}, | ||
}; | ||
|
||
export default definition; | ||
export const component = create(definition); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{#if (has-block)}} | ||
<span class="fade-text" data-test-fade-text ...attributes> | ||
{{yield this.displayText this.expand this.collapse this.updateTextDims this.isFaded this.expanded}} | ||
</span> | ||
{{else}} | ||
<span class="fade-text" data-test-fade-text ...attributes> | ||
<div class="display-text-wrapper{{if this.isFaded ' is-faded'}}"> | ||
<div | ||
class="display-text" | ||
{{on-resize this.updateTextDims}} | ||
> | ||
{{this.displayText}} | ||
</div> | ||
</div> | ||
{{#if this.isFaded}} | ||
<div class="fade-text-control" data-test-fade-text-control> | ||
<button | ||
class="expand-buttons" | ||
aria-label={{t "general.expand"}} | ||
title={{t "general.expand"}} | ||
type="button" | ||
data-test-expand | ||
{{on "click" this.expand}} | ||
> | ||
<FaIcon @icon="angles-down" /> | ||
</button> | ||
</div> | ||
{{else}} | ||
{{#if this.expanded}} | ||
<button | ||
class="expand-buttons" | ||
aria-label={{t "general.collapse"}} | ||
title={{t "general.collapse"}} | ||
type="button" | ||
data-test-collapse | ||
{{on "click" this.collapse}} | ||
> | ||
<FaIcon @icon="angles-up" /> | ||
</button> | ||
{{/if}} | ||
{{/if}} | ||
</span> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { typeOf } from '@ember/utils'; | ||
import { htmlSafe } from '@ember/template'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class FadeTextComponent extends Component { | ||
@tracked textHeight; | ||
@tracked expanded = false; | ||
|
||
MAX_HEIGHT = 200; | ||
|
||
get text() { | ||
if (!this.args.text) { | ||
return ''; | ||
} | ||
if (typeOf(this.args.text) !== 'string') { | ||
return this.args.text.toString(); | ||
} | ||
|
||
return this.args.text; | ||
} | ||
get displayText() { | ||
return new htmlSafe(this.text); | ||
} | ||
|
||
get textWidthRounded() { | ||
return Math.floor(this.textWidth); | ||
} | ||
|
||
get textHeightRounded() { | ||
return Math.floor(this.textHeight); | ||
} | ||
|
||
get isFaded() { | ||
if (!this.expanded) { | ||
return this.textHeightRounded >= this.MAX_HEIGHT; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
@action | ||
updateTextDims({ contentRect: { height } }) { | ||
this.textHeight = height; | ||
} | ||
|
||
@action | ||
expand(event) { | ||
event.stopPropagation(); | ||
this.expanded = true; | ||
} | ||
|
||
@action | ||
collapse(event) { | ||
event.stopPropagation(); | ||
this.expanded = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ilios-common/components/fade-text'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/ilios-common/app/styles/ilios-common/components/course/objective-list.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
@use "../../mixins" as m; | ||
@use "../../colors" as c; | ||
|
||
.course-objective-list { | ||
@include m.objective-list; | ||
|
||
.fade-text-control { | ||
background-image: linear-gradient(to bottom, transparent, c.$white); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
.editable { | ||
color: c.$blueMunsell; | ||
cursor: pointer; | ||
display: block; | ||
|
||
&.prompt { | ||
font-style: italic; | ||
|
24 changes: 24 additions & 0 deletions
24
packages/ilios-common/app/styles/ilios-common/components/fade-text.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@use "../colors" as c; | ||
|
||
.fade-text { | ||
.display-text-wrapper { | ||
&.is-faded { | ||
max-height: 200px; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
} | ||
|
||
.fade-text-control { | ||
bottom: 105px; | ||
cursor: pointer; | ||
height: 110px; | ||
padding: 0; | ||
position: relative; | ||
|
||
button { | ||
position: relative; | ||
top: 110px; | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/ilios-common/app/styles/ilios-common/components/session/objective-list.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
@use "../../mixins" as m; | ||
@use "../../colors" as c; | ||
|
||
.session-objective-list { | ||
@include m.objective-list; | ||
|
||
.fade-text-control { | ||
background-image: linear-gradient(to bottom, transparent, c.$lightBlue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,4 +115,4 @@ | |
] | ||
}, | ||
"private": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.