refactor: extract parseClassList to shared utils

This commit is contained in:
2026-04-21 01:22:04 +02:00
parent 1ceca3bd9e
commit bece1a970a
3 changed files with 12 additions and 24 deletions

View File

@@ -1,15 +1,4 @@
export {}
const parseClassList = (value: string | null): string[] => {
if (!value) {
return []
}
return value
.split(' ')
.map((entry: string): string => entry.trim())
.filter((entry: string): boolean => entry.length > 0)
}
import { parseClassList } from './utils'
const setDropdownMenuState = (menu: HTMLElement, isOpen: boolean): void => {
const openClasses = parseClassList(menu.getAttribute('data-dropdown-open-classes'))

View File

@@ -1,15 +1,4 @@
export {}
const parseClassList = (value: string | null): string[] => {
if (!value) {
return []
}
return value
.split(' ')
.map((entry: string): string => entry.trim())
.filter((entry: string): boolean => entry.length > 0)
}
import { parseClassList } from './utils'
const setActiveDiscoverTab = (clickedTab: Element): void => {
const group = clickedTab.closest('[data-tab-group="discover"]')

10
static/utils.ts Normal file
View File

@@ -0,0 +1,10 @@
export const parseClassList = (value: string | null): string[] => {
if (!value) {
return []
}
return value
.split(' ')
.map((entry: string): string => entry.trim())
.filter((entry: string): boolean => entry.length > 0)
}