Skip to content

Commit

Permalink
chore: fix site
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Sep 24, 2023
1 parent f38501f commit fbb0a9c
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions docs/.vitepress/theme/components/components/RulesSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,12 @@
</label>
<label class="tool">
<input
:checked="
categories.every((category) =>
v-bind="
checkedBinds(categories, (category) =>
category.rules.every((rule) => isErrorState(rule.ruleId)),
)
"
type="checkbox"
:indeterminate.prop="
categories.some((category) =>
category.rules.some((rule) => isErrorState(rule.ruleId)),
) &&
categories.some((category) =>
category.rules.some((rule) => !isErrorState(rule.ruleId)),
)
"
@input="onAllClick($event)"
/>
<span class="tool-label">All Rules</span>
Expand Down Expand Up @@ -61,14 +53,12 @@
<div class="category-title-wrapper">
<label class="category-title">
<input
:checked="
category.rules.every((rule) => isErrorState(rule.ruleId))
v-bind="
checkedBinds(category.rules, (rule) =>
isErrorState(rule.ruleId),
)
"
type="checkbox"
:indeterminate.prop="
!category.rules.every((rule) => isErrorState(rule.ruleId)) &&
!category.rules.every((rule) => !isErrorState(rule.ruleId))
"
@input="onCategoryClick(category, $event)"
/>
{{ category.title }}
Expand Down Expand Up @@ -201,6 +191,24 @@ export default {
isErrorState(ruleId) {
return this.rules[ruleId] === "error" || this.rules[ruleId] === 2;
},
checkedBinds(array, fn) {
if (array.every(fn)) {
return {
checked: true,
indeterminate: undefined,
};
}
if (array.every((...args) => !fn(...args))) {
return {
checked: false,
indeterminate: undefined,
};
}
return {
checked: undefined,
indeterminate: true,
};
},
},
};
</script>
Expand Down

0 comments on commit fbb0a9c

Please sign in to comment.