refactor: extract parseClassList to shared utils
This commit is contained in:
@@ -1,15 +1,4 @@
|
|||||||
export {}
|
import { parseClassList } from './utils'
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
const setDropdownMenuState = (menu: HTMLElement, isOpen: boolean): void => {
|
const setDropdownMenuState = (menu: HTMLElement, isOpen: boolean): void => {
|
||||||
const openClasses = parseClassList(menu.getAttribute('data-dropdown-open-classes'))
|
const openClasses = parseClassList(menu.getAttribute('data-dropdown-open-classes'))
|
||||||
|
|||||||
@@ -1,15 +1,4 @@
|
|||||||
export {}
|
import { parseClassList } from './utils'
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
const setActiveDiscoverTab = (clickedTab: Element): void => {
|
const setActiveDiscoverTab = (clickedTab: Element): void => {
|
||||||
const group = clickedTab.closest('[data-tab-group="discover"]')
|
const group = clickedTab.closest('[data-tab-group="discover"]')
|
||||||
|
|||||||
10
static/utils.ts
Normal file
10
static/utils.ts
Normal 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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user