Skip to content

Commit 9faaaa5

Browse files
feat: add empty filter
1 parent d22f7f0 commit 9faaaa5

File tree

1 file changed

+94
-20
lines changed

1 file changed

+94
-20
lines changed

website/src/catalog/RuleList.vue

Lines changed: 94 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,112 @@ const ruleMetaData = computed(() => getRuleMetaData(props.filter))
1515
</script>
1616

1717
<template>
18-
<h3>
19-
Rule List
20-
<NumberFlow
21-
:plugins="[continuous]"
22-
:value="ruleMetaData.length"
23-
/>
24-
</h3>
25-
<TransitionGroup class="rule-list" tag="ul">
26-
<RuleItem
27-
v-for="meta in ruleMetaData"
28-
:key="meta.language + meta.id"
29-
:meta="meta"
30-
:filter="filter"
31-
/>
32-
</TransitionGroup>
18+
<div class="rule-list-container">
19+
<h3>
20+
Rule List
21+
<NumberFlow
22+
prefix="("
23+
suffix=")"
24+
:plugins="[continuous]"
25+
:value="ruleMetaData.length"
26+
/>
27+
</h3>
28+
<TransitionGroup class="rule-list" tag="ul">
29+
<RuleItem
30+
v-for="meta in ruleMetaData"
31+
:key="meta.language + meta.id"
32+
:meta="meta"
33+
:filter="filter"
34+
/>
35+
</TransitionGroup>
36+
<Transition name="not-found">
37+
<div class="no-rule" v-if="ruleMetaData.length === 0">
38+
<p class="title">No Matching Rule</p>
39+
<hr class="divider"/>
40+
<div class="actions">
41+
Try resetting the filter to discover all rules.<br/>
42+
Contributing a new rule is also warmly welcomed. 🎉
43+
<ol>
44+
<li>
45+
Read the
46+
<a href="/reference/rule.html" target="_blank">rule</a> and
47+
<a href="/reference/yaml.html" target="_blank">YAML</a> doc.</li>
48+
<li>Write your own rule in the
49+
<a href="/playground.html" target="_blank">
50+
playground
51+
</a>.
52+
</li>
53+
<li>
54+
Add a new example in the ast-grep
55+
<a href="https://github.com/ast-grep/ast-grep.github.io/tree/main/website/catalog" target="_blank">
56+
website repo
57+
</a>.
58+
</li>
59+
</ol>
60+
</div>
61+
</div>
62+
</Transition>
63+
</div>
3364
</template>
3465

3566
<style scoped>
67+
.rule-list-container {
68+
position: relative;
69+
min-height: 280px;
70+
}
3671
h3 {
3772
margin: 20px 0 8px;
38-
display: flex;
39-
justify-content: space-between;
4073
}
4174
.rule-list {
4275
list-style: none;
4376
padding: 0;
4477
margin: 0;
4578
}
4679
80+
.divider {
81+
margin: 24px auto 18px;
82+
width: 64px;
83+
height: 1px;
84+
background-color: var(--vp-c-divider);
85+
}
86+
87+
.title {
88+
padding-top: 12px;
89+
letter-spacing: 2px;
90+
line-height: 20px;
91+
font-size: 20px;
92+
font-weight: 700;
93+
margin: 0;
94+
}
95+
.no-rule {
96+
display: flex;
97+
justify-content: center;
98+
align-items: center;
99+
flex-direction: column;
100+
width: 100%;
101+
}
102+
.actions {
103+
margin: 0 auto;
104+
font-size: 14px;
105+
font-weight: 500;
106+
color: var(--vp-c-text-2);
107+
}
108+
109+
.not-found-enter-active,
110+
.not-found-leave-active {
111+
transition: all 0.4s cubic-bezier(0.59, 0.12, 0.34, 0.95);
112+
}
113+
.not-found-enter-from,
114+
.not-found-leave-to {
115+
opacity: 0;
116+
transform: translateY(10px) scale(0.9);
117+
}
118+
.not-found-leave-active {
119+
position: absolute;
120+
/* this is somehow hard coded*/
121+
top: 38px;
122+
}
123+
47124
.v-move,
48125
.v-enter-active,
49126
.v-leave-active {
@@ -61,8 +138,5 @@ h3 {
61138
}
62139
number-flow-vue::part(integer) {
63140
font-variant-numeric: tabular-nums;
64-
font-style: italic;
65-
font-weight: 500;
66141
}
67-
68142
</style>

0 commit comments

Comments
 (0)