-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Timeline component improvements, added
<FileIcon />
component
- Loading branch information
Showing
14 changed files
with
328 additions
and
223 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 |
---|---|---|
@@ -1 +1,9 @@ | ||
{{yield}} | ||
<div class="file-icon file-icon-{{this.extension}}"> | ||
<FaIcon @icon={{this.icon}} class={{@iconClass}} @size={{@iconSize}} /> | ||
<span class="file-extension truncate"> | ||
{{this.extension}} | ||
</span> | ||
<div> | ||
{{yield}} | ||
</div> | ||
</div> |
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,3 +1,60 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import getWithDefault from '@fleetbase/ember-core/utils/get-with-default'; | ||
|
||
export default class FileIconComponent extends Component {} | ||
export default class FileIconComponent extends Component { | ||
@tracked file; | ||
@tracked extension; | ||
@tracked icon; | ||
|
||
constructor(owner, { file }) { | ||
super(...arguments); | ||
|
||
this.file = file; | ||
this.extension = this.getExtension(file); | ||
this.icon = this.getIcon(file); | ||
} | ||
|
||
getExtension(file) { | ||
return getWithDefault( | ||
{ | ||
'application/vnd.ms-excel': 'xls', | ||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'xls', | ||
'vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'xls', | ||
'vnd.ms-excel': 'xls', | ||
'text/csv': 'csv', | ||
'text/tsv': 'tsv', | ||
xlsx: 'xls', | ||
xls: 'xls', | ||
xlsb: 'xls', | ||
xlsm: 'xls', | ||
docx: 'doc', | ||
docm: 'doc', | ||
}, | ||
getWithDefault(file, 'extension', 'xls'), | ||
'xls' | ||
); | ||
} | ||
|
||
getIcon(file) { | ||
const extension = this.getExtension(file); | ||
|
||
return getWithDefault( | ||
{ | ||
xlsx: 'file-excel', | ||
xls: 'file-excel', | ||
xlsb: 'file-excel', | ||
xlsm: 'file-excel', | ||
csv: 'file-spreadsheet', | ||
tsv: 'file-spreadsheet', | ||
docx: 'file-word', | ||
docm: 'file-word', | ||
pdf: 'file-pdf', | ||
ppt: 'file-powerpoint', | ||
pptx: 'file-powerpoint', | ||
}, | ||
extension, | ||
'file-alt' | ||
); | ||
} | ||
} |
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 +1,11 @@ | ||
<Modal::Default @modalIsOpened={{@modalIsOpened}} @options={{@options}} @confirm={{@onConfirm}} @decline={{@onDecline}}></Modal::Default> | ||
<Modal::Default @modalIsOpened={{@modalIsOpened}} @options={{@options}} @confirm={{@onConfirm}} @decline={{@onDecline}}> | ||
<div class="p-4 space-y-4"> | ||
{{#each @options.promptOptions as |option index|}} | ||
<div class="flex flex-row items-center bg-gray-100 border-gray-200 px-4 py-2 dark:bg-gray-800 dark:border-gray-700 rounded-lg"> | ||
<RadioButton @radioClass="focus:ring-blue-500 mr-3" @radioId={{concat "option_" index}} @value={{option}} @groupValue={{@options.selected}} @name="option" @changed={{fn (mut @options.selected)}}> | ||
<span class="dark:text-white font-semibold">{{humanize option}}</span> | ||
</RadioButton> | ||
</div> | ||
{{/each}} | ||
</div> | ||
</Modal::Default> |
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,15 +1,21 @@ | ||
<div class="timeline timeline-activity-{{@activity.length}}" {{did-insert this.setupComponent}} ...attributes> | ||
<div class="timeline-controls {{@controlsClass}}"> | ||
<button class="timeline-arrow-left {{@arrowClass}} {{@arrowLeftClass}}" disabled={{eq this.startIndex 0}} type="button" {{on "click" this.previous}}>←</button> | ||
<div class="timeline-controls-button-wrapper"> | ||
<button class="timeline-arrow-left {{@arrowClass}} {{@arrowLeftClass}}" disabled={{eq this.startIndex 0}} type="button" {{on "click" this.previous}}>←</button> | ||
</div> | ||
</div> | ||
|
||
<div class="timeline-wrapper {{@wrapperClass}}"> | ||
{{#each this.visibleTimelineData as |activity|}} | ||
{{yield (component "timeline/item" activity=activity context=this.context)}} | ||
{{/each}} | ||
<div class="timeline-items-container {{@itemsContainerClass}}"> | ||
{{#each this.visibleActivities as |activity|}} | ||
{{yield (component "timeline/item" activity=activity context=this.context)}} | ||
{{/each}} | ||
</div> | ||
</div> | ||
|
||
<div class="timeline-controls {{@controlsClass}}"> | ||
<button class="timeline-arrow-right {{@arrowClass}} {{@arrowRightClass}}" disabled={{eq this.endIndex (sub @activity.length 1)}} type="button" {{on "click" this.next}}>→</button> | ||
<div class="timeline-controls-button-wrapper"> | ||
<button class="timeline-arrow-right {{@arrowClass}} {{@arrowRightClass}}" disabled={{eq this.endIndex (sub @activity.length 1)}} type="button" {{on "click" this.next}}>→</button> | ||
</div> | ||
</div> | ||
</div> |
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,61 +1,38 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action, computed, set } from '@ember/object'; | ||
import { isArray } from '@ember/array'; | ||
import { action } from '@ember/object'; | ||
import { htmlSafe } from '@ember/template'; | ||
|
||
export default class TimelineComponent extends Component { | ||
@tracked startIndex = 0; | ||
@tracked endIndex = Math.min(2, this.args.activity.length - 1); | ||
@tracked timelineNode; | ||
@tracked timelineWrapperNode; | ||
@tracked timelineItemWidth; | ||
|
||
context = { | ||
previous: this.previous, | ||
next: this.next, | ||
data: this.visibleTimelineData, | ||
}; | ||
|
||
@computed('args.activity.length', 'endIndex', 'startIndex') get timelineActivity() { | ||
if (isArray(this.args.activity)) { | ||
return this.args.activity.map((activity, index) => { | ||
if (index === this.args.activity.length - 1) { | ||
set(activity, 'isActive', true); | ||
} | ||
|
||
return activity; | ||
}); | ||
} | ||
return []; | ||
} | ||
|
||
@computed('[email protected]', 'startIndex', 'endIndex') get visibleTimelineData() { | ||
return this.timelineActivity.slice(this.startIndex, this.endIndex + 1); | ||
} | ||
|
||
@computed('startIndex', 'timelineItemWidth') get wrapperStyle() { | ||
const translateX = `calc(-${this.startIndex} * ${this.timelineItemWidth}px)`; | ||
return htmlSafe(`transform: translateX(${translateX});`); | ||
} | ||
@tracked visibleActivities = this.args.activity.slice(this.startIndex, this.endIndex + 1); | ||
|
||
@action setupComponent(timelineNode) { | ||
this.timelineNode = timelineNode; | ||
this.timelineWrapperNode = timelineNode.querySelector('.timeline-wrapper'); | ||
this.timelineItemWidth = this.timelineWrapperNode?.firstElementChild?.offsetWidth; | ||
this.timelineItemsContainerNode = this.timelineWrapperNode.firstElementChild; | ||
} | ||
|
||
@action previous() { | ||
if (this.startIndex > 0) { | ||
this.startIndex--; | ||
this.endIndex--; | ||
this.startIndex -= 1; | ||
this.endIndex -= 1; | ||
this.updateTimelinePosition(); | ||
} | ||
} | ||
|
||
@action next() { | ||
if (this.endIndex < this.args.activity.length - 1) { | ||
this.startIndex++; | ||
this.endIndex++; | ||
this.startIndex += 1; | ||
this.endIndex += 1; | ||
this.updateTimelinePosition(); | ||
} | ||
} | ||
|
||
updateTimelinePosition() { | ||
const translateX = `calc(-${this.startIndex * (100 / 3)}%)`; // Assuming each item takes up 33.33% of the width | ||
this.timelineItemsContainerNode.style.transform = `translateX(${translateX})`; | ||
this.visibleActivities = this.args.activity.slice(this.startIndex, this.endIndex + 1); | ||
} | ||
} |
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 +1 @@ | ||
<div class="timeline-item {{if @activity.isActive 'active animate-pulse'}}" ...attributes>{{yield @activity @context}}</div> | ||
<div class="timeline-item {{if this.isActive 'active animate-pulse'}}" ...attributes>{{yield @activity @context}}</div> |
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,3 +1,15 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class TimelineItemComponent extends Component {} | ||
export default class TimelineItemComponent extends Component { | ||
@tracked isActive = false; | ||
|
||
constructor(owner, { activeStatus, activity }) { | ||
super(...arguments); | ||
|
||
this.isActive = typeof activeStatus === 'string' && typeof activity.code === 'string' && activeStatus.toLowerCase() === activity.code.toLowerCase(); | ||
if (typeof activity.isActive === 'boolean') { | ||
this.isActive = activity.isActive; | ||
} | ||
} | ||
} |
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
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
Empty file.
Submodule ember-cli-accounting
deleted from
7864f8
Oops, something went wrong.