Skip to content

Commit e031239

Browse files
refactor(CheckMultiple): extract innerClass function
1 parent 698d7ff commit e031239

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/input/check/CheckMultiple.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,8 @@ interface OptionListProps
6262
}
6363

6464
function OptionList(p: OptionListProps) {
65-
const innerClass = () => {
66-
if (p.innerClass) return p.innerClass
67-
const optionAmount = p.getOptions().length
68-
if (optionAmount <= 0) return ""
69-
const base = " gap-x-2 gap-y-1"
70-
if (optionAmount <= 5) return `grid grid-cols-1${base}`
71-
if (optionAmount <= 9) return `grid grid-cols-2${base}`
72-
return `${classesGridCols3xl}${base}`
73-
}
74-
7565
return (
76-
<div class={innerClass()}>
66+
<div class={innerClass(p.getOptions().length, p.innerClass)}>
7767
<For each={p.getOptions()}>
7868
{(option) => (
7969
<CheckOption
@@ -115,6 +105,15 @@ function CheckOption(p: CheckOptionProps) {
115105
)
116106
}
117107

108+
function innerClass(optionAmount: number, innerClass?: string): string {
109+
if (innerClass) return innerClass
110+
if (optionAmount <= 0) return ""
111+
const base = "gap-x-2 gap-y-1"
112+
if (optionAmount <= 5) return classArr("grid grid-cols-1", base)
113+
if (optionAmount <= 9) return classArr("grid grid-cols-2", base)
114+
return classArr(classesGridCols3xl, base)
115+
}
116+
118117
function toggleOption(p: CheckOptionProps) {
119118
const hasOption = p.valueSignal.get().includes(p.option)
120119
if (hasOption) {

0 commit comments

Comments
 (0)