Skip to content

Commit a99a269

Browse files
feat: add sort by
1 parent 3cc8fd6 commit a99a269

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

website/src/catalog/RuleFilter.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
features,
88
ruleTypes,
99
type Filter,
10-
} from './data'
10+
} from './data.js'
1111
1212
const model = defineModel<Filter>()
1313
@@ -23,7 +23,7 @@ watchEffect(() => {
2323
})
2424
// :( cyclic assign, for reset event
2525
watchEffect(() => {
26-
filter.value = model.value
26+
filter.value = model.value!
2727
})
2828
2929
</script>

website/src/catalog/RuleList.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import NumberFlow, { continuous } from '@number-flow/vue'
33
import { type Filter, getRuleMetaData } from './data'
44
import { computed, type PropType } from 'vue'
55
import RuleItem from './RuleItem.vue'
6+
import IconDown from '../components/utils/IconDown.vue'
67
78
const props = defineProps({
89
filter: {
@@ -27,6 +28,14 @@ const ruleMetaData = computed(() => getRuleMetaData(props.filter))
2728
:plugins="[continuous]"
2829
:value="ruleMetaData.length"
2930
/>
31+
<label class="sort-by">
32+
Sort by:
33+
<select>
34+
<option>Name</option>
35+
<option>Lang</option>
36+
</select>
37+
<IconDown/>
38+
</label>
3039
</h3>
3140
<TransitionGroup class="rule-list" tag="ul">
3241
<RuleItem
@@ -109,6 +118,21 @@ h3 {
109118
color: var(--vp-c-text-2);
110119
}
111120
121+
h3 {
122+
display: flex;
123+
}
124+
.sort-by {
125+
display: inline-flex;
126+
align-items: center;
127+
margin-left: auto;
128+
font-size: 14px;
129+
font-weight: 400;
130+
}
131+
.sort-by > select {
132+
margin-left: 6px;
133+
padding-right: 4px;
134+
}
135+
112136
.not-found-enter-active,
113137
.not-found-leave-active {
114138
transition: all 0.4s cubic-bezier(0.59, 0.12, 0.34, 0.95);

website/src/catalog/data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { data as allRules } from '../../_data/catalog.data'
2-
export type { RuleMeta } from '../../_data/catalog.data'
1+
import { data as allRules } from '../../_data/catalog.data.js'
2+
export type { RuleMeta } from '../../_data/catalog.data.js'
33

44
export function intersect(a: string[], b: string[]) {
55
return a.some(x => b.includes(x))

0 commit comments

Comments
 (0)