Sort heatmap colour options alphabetically

This commit is contained in:
Ewan Breakey 2022-12-23 16:01:34 +11:00
parent 583671bd5e
commit 9d4e3c833a
2 changed files with 8 additions and 4 deletions

View file

@ -17,6 +17,7 @@ import {
} from './Settings.styles' } from './Settings.styles'
import locales from '/src/i18n/locales' import locales from '/src/i18n/locales'
import { unhyphenate } from '/src/utils'
// Language specific options // Language specific options
const setDefaults = (lang, store) => { const setDefaults = (lang, store) => {
@ -132,11 +133,9 @@ const Settings = () => {
id="colormap" id="colormap"
options={{ options={{
'crabfit': t('options.colormap.classic'), 'crabfit': t('options.colormap.classic'),
...Object.fromEntries(Object.keys(maps).map(palette => [ ...Object.fromEntries(Object.keys(maps).sort().map(palette => [
palette, palette,
palette.split('-') unhyphenate(palette)
.map(w => w[0].toLocaleUpperCase() + w.substring(1).toLocaleLowerCase())
.join(' '),
])), ])),
}} }}
small small

View file

@ -30,3 +30,8 @@ export const detect_browser = () => {
if (isFirefox) return 'firefox' if (isFirefox) return 'firefox'
if (isOpera) return 'opera' if (isOpera) return 'opera'
} }
export const unhyphenate = s =>
s.split('-')
.map(w => w[0].toLocaleUpperCase() + w.substring(1).toLocaleLowerCase())
.join(' ')