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

SFD 152 Add tabular data #115

Merged
merged 37 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f110eae
Create tab-item component
jmain-scottlogic Jul 16, 2024
d827bba
Create tabs component
jmain-scottlogic Jul 16, 2024
c247e9c
Create treemap component and refactor chart logic from estimator into it
jmain-scottlogic Jul 16, 2024
effaf05
Create estimations util service and move functions from treemap
jmain-scottlogic Jul 17, 2024
2bd22a5
Create table view for emissions data
jmain-scottlogic Jul 17, 2024
b875d03
Remove unused css file
jmain-scottlogic Jul 17, 2024
e12afa4
Add treemap unit tests
jmain-scottlogic Jul 17, 2024
7647138
Refactor carbon-estimation to use new treemap and table components
jmain-scottlogic Jul 17, 2024
5afdc9b
Style tabs
jmain-scottlogic Jul 18, 2024
39e8e24
make sure only ever 1 active tab
jmain-scottlogic Jul 18, 2024
24d947c
add tab unit tests
jmain-scottlogic Jul 18, 2024
f7a6e4d
Update table styling
jmain-scottlogic Jul 18, 2024
1068cfe
Fix treemap not rendering properly after resize
jmain-scottlogic Jul 18, 2024
78870f8
Add table placeholder
jmain-scottlogic Jul 22, 2024
ab80298
Update tab names
jmain-scottlogic Jul 23, 2024
0208097
Update tab names and make diagram main active tab
jmain-scottlogic Jul 23, 2024
4de2967
Fix unit tests
jmain-scottlogic Jul 23, 2024
364e779
Fix row toggle, and make expanded state maintained
jmain-scottlogic Jul 23, 2024
146341d
Make sure treemap re-render if values change
jmain-scottlogic Jul 23, 2024
2d233b5
Make the table accessible
jmain-scottlogic Jul 24, 2024
fcf7566
Add spellings to workspace
jmain-scottlogic Jul 24, 2024
415db35
Add unit test for keyboard interactions
jmain-scottlogic Jul 25, 2024
cb005d5
Align table headings to be same as columns
jmain-scottlogic Jul 25, 2024
b61b3c4
Hide expand element from screen readers are cell handles expanding fo…
jmain-scottlogic Jul 29, 2024
7b63450
Tidy up code and add script for package start
jmain-scottlogic Jul 29, 2024
87f072c
Remove optionality of expanded
jmain-scottlogic Jul 29, 2024
d1fe3a3
Remove placeholder table and no estimations message instead
jmain-scottlogic Jul 29, 2024
4107078
Add maintained expanded state for parent and linked children
jmain-scottlogic Jul 29, 2024
778aa9a
Added dark mode text colour for table
jmain-scottlogic Jul 29, 2024
458945b
Fix table unit test since adding table levels
jmain-scottlogic Jul 29, 2024
c3251e6
Change getPercentageLabel to call tooltipFormatter
jmain-scottlogic Jul 29, 2024
99b1aa6
Change hasUpdated to be changed from an observable to within an effec…
jmain-scottlogic Jul 29, 2024
8e796ba
Add effect to tab to handle tab being selected event emitted, instead…
jmain-scottlogic Jul 29, 2024
84fad3f
Move setting expand state so only once per toggle
jmain-scottlogic Jul 30, 2024
db665cd
Update home ENd key function to pull if home or end fom event
jmain-scottlogic Jul 30, 2024
923d647
Change empty table check to use table data
jmain-scottlogic Jul 30, 2024
ea6d233
Change getTableData to private
jmain-scottlogic Jul 30, 2024
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
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
"typescript.tsdk": "node_modules\\typescript\\lib",
"editor.tabSize": 2,
"files.eol": "\n",
"cSpell.words": ["apexcharts", "treemap"]
"cSpell.words": [
"apexcharts",
"arrowdown",
"arrowleft",
"arrowright",
"arrowup",
"treemap"
]
}
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:npm-package": "ng serve --configuration npm-package",
"prepare": "ng build --configuration npm-package",
"build": "ng build",
"watch": "ng build --watch --configuration development",
Expand Down Expand Up @@ -61,6 +62,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jasmine-core": "~5.1.0",
"ng-mocks": "^14.13.0",
"postcss": "^8.4.35",
"prettier": "^3.2.5",
"prettier-eslint": "^16.3.0",
Expand Down
jmain-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->
<table role="treegrid" aria-label="Estimation of emissions" class="tce-table-fixed tce-w-full">
<thead>
<tr class="tce-border-b-2">
<th class="tce-text-left">Category</th>
<th class="tce-w-40 tce-text-left">Emissions</th>
</tr>
</thead>
@if (carbonEstimation()) {
jmain-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
<tbody
(keydown.home)="homeEndKeyBoardEvent($event, true)"
jmain-scottlogic marked this conversation as resolved.
Show resolved Hide resolved
(keydown.end)="homeEndKeyBoardEvent($event, false)"
(keydown.control.home)="homeEndKeyBoardEvent($event, true)"
(keydown.control.end)="homeEndKeyBoardEvent($event, false)"
(keydown.arrowup)="arrowKeyBoardEvent($event, 'up')"
(keydown.arrowdown)="arrowKeyBoardEvent($event, 'down')">
@for (tableItem of tableData(); track $index) {
@if (tableItem.level === 1) {
<tr
role="row"
[tabindex]="$index === 0 ? 0 : -1"
[attr.aria-level]="tableItem.level"
[attr.aria-setsize]="tableItem.setSize"
[attr.aria-posinset]="tableItem.positionInSet"
[attr.aria-expanded]="tableItem.expanded"
(keydown.arrowright)="parentRowArrowKeyBoardEvent($event, 'right', tableItem.category, tableItem.expanded)"
(keydown.arrowleft)="parentRowArrowKeyBoardEvent($event, 'left', tableItem.category, tableItem.expanded)"
[style.background-color]="tableItem.colour.background">
<td
role="gridcell"
tabindex="-1"
class="tce-flex tce-text-white tce-items-center"
(keydown.enter)="toggle(tableItem.category)">
<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events -->
<div
tabindex="-1"
aria-hidden="true"
(click)="toggle(tableItem.category)"
class="material-icons-outlined hover:tce-opacity-50 tce-m-1 tce-cursor-pointer">
{{ tableItem.expanded ? 'expand_less' : 'expand_more' }}
</div>
{{ tableItem.category }}
</td>
<td role="gridcell" tabindex="-1" class="tce-text-white">
{{ tableItem.emissions }}
</td>
</tr>
} @else {
<tr
role="row"
tabindex="-1"
[attr.aria-level]="tableItem.level"
[attr.aria-setsize]="tableItem.setSize"
[attr.aria-posinset]="tableItem.positionInSet"
[style.background-color]="tableItem.colour.background"
(keydown.arrowright)="arrowKeyBoardEvent($event, 'right')"
(keydown.arrowleft)="arrowKeyBoardEvent($event, 'left')"
[class.tce-hidden]="!tableItem.display">
<td role="gridcell" tabindex="-1" class="tce-flex tce-ml-8 dark:tce-text-slate-600">
<div
class="tce-p-1 tce-flex tce-rounded-sm tce-mr-2"
[style.background-color]="tableItem.colour.svg ?? tableItem.colour.background">
<div class="tce-m-auto tce-size-4 {{ tableItem.svg }}"></div>
</div>
{{ tableItem.category }}
</td>
<td role="gridcell" tabindex="-1">
{{ tableItem.emissions }}
</td>
</tr>
}
}
</tbody>
} @else {
<tbody>
<tr tabindex="0">
<td role="gridcell" class="tce-text-center tce-h-20" colspan="2">No estimation available</td>
</tr>
</tbody>
}
</table>
Loading