Skip to content

Commit d4737be

Browse files
committed
feat: add prefill buttons to search on product landing page
See: FE-94
1 parent 1635a45 commit d4737be

File tree

6 files changed

+106
-10
lines changed

6 files changed

+106
-10
lines changed

frontend/i18n/locales/en.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,16 @@
12231223
}
12241224
},
12251225
"search": {
1226+
"examples": {
1227+
"address": "Address",
1228+
"latest_block": "Latest Block",
1229+
"latest_epoch": "Latest Epoch",
1230+
"title": "Examples:",
1231+
"token": "Token",
1232+
"transaction": "Transaction",
1233+
"tx": "TX",
1234+
"validator": "Validator"
1235+
},
12261236
"filter_aria_label": "Filter by type",
12271237
"input_label": "Search by Address / Tx hash / Block / Token / ENS",
12281238
"input_placeholder": "Search anything...",

frontend/layers/base/app/components/BaseChip.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<script setup lang="ts">
2+
import type { IconName } from '#layers/base/app/components/BaseIcon.vue'
3+
24
const {
35
size = 'sm',
46
variant = 'neutral',
57
} = defineProps<{
8+
icon?: IconName,
69
isSelected: boolean,
710
size?: 'sm',
811
variant?: 'neutral',
@@ -12,12 +15,18 @@ const {
1215
<template>
1316
<button
1417
class="text-nowrap border-1 font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-300"
18+
type="button"
1519
:class="[
1620
variant === 'neutral' && 'bg-gray-100 dark:bg-gray-900 border-gray-200 dark:border-gray-800 text-gray-600 dark:text-gray-400 aria-pressed:bg-gray-200 dark:aria-pressed:bg-gray-700 aria-pressed:border-gray-300 dark:aria-pressed:border-gray-700 aria-pressed:text-black dark:aria-pressed:text-white aria-pressed:shadow-none',
1721
size === 'sm' && 'px-md py-xs rounded-md ',
22+
icon && 'flex items-center gap-md',
1823
]"
1924
:aria-pressed="isSelected"
2025
>
26+
<BaseIcon
27+
v-if="icon"
28+
:name="icon"
29+
/>
2130
<slot />
2231
</button>
2332
</template>

frontend/layers/base/app/components/BaseChipGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const handleSelectFilter = (value: ChipItem['value']) => {
6161

6262
<template>
6363
<ul
64-
class="flex gap-md px-2xl py-lg"
64+
class="flex gap-md p-2xl"
6565
role="group"
6666
:aria-label
6767
>

frontend/layers/base/app/components/BaseSearchInput.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ const input = defineModel<string>({
3030
3131
watchDebounced(
3232
input,
33-
async () => {
33+
() => {
3434
if (input.value.length) {
3535
emit('search', input.value)
3636
hasSearched.value = true
3737
}
3838
},
39-
{
40-
immediate: false,
41-
},
4239
)
4340
4441
const showDropdown = computed(() => isLoading || hasSearched.value)
@@ -172,6 +169,13 @@ const handleClickOutside = (e: PointerDownOutsideEvent) => {
172169
</div>
173170
</RkComboboxContent>
174171
</RkComboboxRoot>
172+
173+
<div
174+
v-if="$slots['search-examples']"
175+
class="overflow-x-auto p-2xl z-10 bg-gray-50 dark:bg-gray-950 mt-xl rounded-xl shadow-[inset_0_-1px_0_0_rgba(255,255,255,0.18)]"
176+
>
177+
<slot name="search-examples" />
178+
</div>
175179
</form>
176180
</template>
177181

@@ -185,6 +189,7 @@ form {
185189
186190
&:before {
187191
position: absolute;
192+
z-index: -1;
188193
content: '';
189194
top: 0;
190195
left: 0;

frontend/layers/products/app/components/BlockchainSearchInput.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const { t: $t } = useTranslation()
2121
2222
const emit = defineEmits<{
2323
(e: 'search'): void,
24+
(e: 'click:example', type: 'address' | 'token' | 'transaction' | 'validator'): void,
2425
}>()
2526
2627
const searchParams = defineModel<BlockchainSearchParams>({
@@ -76,6 +77,44 @@ const handleTypeFilterChange = () => {
7677
:results
7778
@search="handleSearch"
7879
>
80+
<template #search-examples>
81+
<div class="flex items-center">
82+
<section class="flex gap-lg">
83+
<div class="py-xs px-md +pl-lg +border-l border-gray-400 font-semibold text-gray-400">
84+
{{ $t('products.landing_page.search.examples.title') }}
85+
</div>
86+
<BaseChip
87+
:is-selected="false"
88+
icon="switch-horizontal"
89+
:aria-label="$t('products.landing_page.search.examples.transaction')"
90+
@click="emit('click:example', 'transaction')"
91+
>
92+
{{ $t('products.landing_page.search.examples.tx') }}
93+
</BaseChip>
94+
<BaseChip
95+
:is-selected="false"
96+
icon="hash"
97+
@click="emit('click:example', 'address')"
98+
>
99+
{{ $t('products.landing_page.search.examples.address') }}
100+
</BaseChip>
101+
<BaseChip
102+
:is-selected="false"
103+
icon="stack-2"
104+
@click="emit('click:example', 'validator')"
105+
>
106+
{{ $t('products.landing_page.search.examples.validator') }}
107+
</BaseChip>
108+
<BaseChip
109+
:is-selected="false"
110+
icon="hexagon"
111+
@click="emit('click:example', 'token')"
112+
>
113+
{{ $t('products.landing_page.search.examples.token') }}
114+
</BaseChip>
115+
</section>
116+
</div>
117+
</template>
79118
<template #dropdown-fixed-header>
80119
<BaseChipGroup
81120
v-model="searchParams.types"

frontend/layers/products/app/pages/products/index.vue

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ const searchTypes: BlockchainSearchParams['types'] = [
4444
'validator_by_public_key',
4545
'validators_by_withdrawal_credential',
4646
]
47+
const networks = [
48+
1,
49+
560048,
50+
] satisfies ChainId[]
4751
const searchParams = ref<BlockchainSearchParams>({
4852
input: '',
49-
networks: [
50-
1,
51-
560048,
52-
],
53+
networks,
5354
types: searchTypes,
5455
})
5556
@@ -64,6 +65,37 @@ const {
6465
method: 'POST',
6566
watch: false,
6667
})
68+
69+
const handleExampleClick = (type: 'address' | 'token' | 'transaction' | 'validator') => {
70+
if (type === 'address') {
71+
searchParams.value = {
72+
...searchParams.value,
73+
input: '0x5AbfEc25f74Cd88437631A7731906932776356f9',
74+
types: [ 'address' ],
75+
}
76+
}
77+
if (type === 'token') {
78+
searchParams.value = {
79+
...searchParams.value,
80+
input: '0x26D5Bd2dfEDa983ECD6c39899e69DAE6431Dffbb',
81+
types: [ 'token' ],
82+
}
83+
}
84+
if (type === 'transaction') {
85+
searchParams.value = {
86+
...searchParams.value,
87+
input: '0x4978b2aeed51747c2fd1d681e7da3fd73e7ef328c3634c1a2dc1e7829f1c2622',
88+
types: [ 'transaction' ],
89+
}
90+
}
91+
if (type === 'validator') {
92+
searchParams.value = {
93+
...searchParams.value,
94+
input: '5',
95+
types: [ 'validator_by_index' ],
96+
}
97+
}
98+
}
6799
</script>
68100

69101
<template>
@@ -93,7 +125,8 @@ const {
93125
:type-filters="searchTypes"
94126
:is-loading="status === 'pending'"
95127
:has-error="!!error"
96-
@search="execute()"
128+
@search="execute"
129+
@click:example="handleExampleClick"
97130
/>
98131
</ProductLandingpageSection>
99132
<ProductLandingpageSection class="mt-11xl">

0 commit comments

Comments
 (0)