Skip to content

Commit

Permalink
feat(tts): add aria markup to table sorting for tts dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
marisademeglio committed Sep 27, 2023
1 parent 9400a26 commit cf1ddc1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 13 deletions.
62 changes: 49 additions & 13 deletions src/renderer/components/TtsConfig/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export function TtsConfigPane({
}
}


let sortVoices = (sortBy) => {
let sortedVoices = sortVoicesArray(voiceList, preferredVoices, sortBy)

Expand Down Expand Up @@ -99,6 +98,13 @@ export function TtsConfigPane({
// setVoiceList(tmpVoices)
// }

let getAriaSortValue = (colName) => {
return sortSettings.selected == colName
? sortSettings[colName] == 1
? 'ascending'
: 'descending'
: 'none'
}
return (
<>
<p id="available-voices-label" className="label">
Expand Down Expand Up @@ -131,20 +137,50 @@ export function TtsConfigPane({
<table aria-labelledby="available-voices-label">
<thead>
<tr>
<th onClick={(e) => sortVoices('prefer')}>
Prefer
<th
onClick={(e) => sortVoices('prefer')}
aria-sort={getAriaSortValue('prefer')}
title="Sort by preference"
>
<span tabIndex={0} role="button">
Prefer
</span>
</th>
<th onClick={(e) => sortVoices('name')}>
Name
<th
onClick={(e) => sortVoices('name')}
aria-sort={getAriaSortValue('name')}
title="Sort by name"
>
<span tabIndex={0} role="button">
Name
</span>
</th>
<th onClick={(e) => sortVoices('engine')}>
Engine
<th
onClick={(e) => sortVoices('engine')}
aria-sort={getAriaSortValue('engine')}
title="Sort by engine"
>
<span tabIndex={0} role="button">
Engine
</span>
</th>
<th onClick={(e) => sortVoices('lang')}>
Language
<th
onClick={(e) => sortVoices('lang')}
aria-sort={getAriaSortValue('lang')}
title="Sort by language"
>
<span tabIndex={0} role="button">
Language
</span>
</th>
<th onClick={(e) => sortVoices('gender')}>
Gender
<th
onClick={(e) => sortVoices('gender')}
aria-sort={getAriaSortValue('gender')}
title="Sort by gender"
>
<span tabIndex={0} role="button">
Gender
</span>
</th>
{/* <th>Move</th> */}
</tr>
Expand Down Expand Up @@ -233,7 +269,7 @@ export function TtsConfigPane({
)
}

function sortVoicesArray (voiceList, preferredVoices, sortBy) {
function sortVoicesArray(voiceList, preferredVoices, sortBy) {
let alphasort = (a, b) => (a > b ? 1 : a == b ? 0 : -1)

let sortedVoices = voiceList.sort((a, b) => {
Expand All @@ -253,4 +289,4 @@ function sortVoicesArray (voiceList, preferredVoices, sortBy) {
})

return sortedVoices
}
}
14 changes: 14 additions & 0 deletions src/renderer/style/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ $engineColWidth: 8rem;
top: 0;
padding: 5px;
}

/* sorting */
thead th {
cursor: pointer;
}
thead th::after {
margin-left: 5px;
}
thead th[aria-sort='ascending']::after {
content: '';
}
thead th[aria-sort='descending']::after {
content: '';
}
}
}

Expand Down

0 comments on commit cf1ddc1

Please sign in to comment.