Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TAS-2514] 💄Listing page header UI revamp #1966

Merged
merged 20 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/components/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
preset="tertiary"
@click="toggleSearch"
>
<IconSearch />
<div class="flex flex-nowrap items-center gap-[8px]">
<IconSearch />
<p
class="text-medium-gray whitespace-nowrap"
v-text="$t('listing_page_search_label')"
/>
</div>
</ButtonV2>
<div
class="flex items-center justify-center cursor-pointer p-[8px] desktop:hidden"
Expand Down Expand Up @@ -42,10 +48,11 @@
>
<IconSearch />
<input
:value="searchQuery"
ref="searchInput"
class="w-full bg-transparent border-0 focus-visible:outline-none"
type="text"
:placeholder="$t('gutenberg_search_placeholder')"
:value="searchQuery"
:placeholder="placeholderText"
@input="debouncedUpdateSearchKeyword"
/>
<ButtonV2
Expand All @@ -63,6 +70,7 @@

<script>
import debounce from 'lodash.debounce';
import { SEARCH_SUGGESTIONS } from '@/constant/index';

export default {
name: 'SearchBar',
Expand All @@ -75,6 +83,7 @@ export default {
data() {
return {
isSearchOpen: false,
placeholderText: this.$t('gutenberg_search_placeholder'),
};
},
mounted() {
Expand All @@ -88,6 +97,10 @@ export default {
this.$emit('clear');
} else {
this.$emit('open');
this.placeholderText = this.getRandomPlaceholder();
this.$nextTick(() => {
this.$refs.searchInput?.focus();
});
Comment on lines +102 to +105
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should check locale is chinese first, or we need to have a set of suggestion for english/fallback

}
this.isSearchOpen = !this.isSearchOpen;
},
Expand All @@ -97,6 +110,11 @@ export default {
},
200
),
getRandomPlaceholder() {
const shuffled = [...SEARCH_SUGGESTIONS].sort(() => Math.random() - 0.5);
const randomTerms = shuffled.slice(0, 3);
return randomTerms.join('、');
},
},
};
</script>
15 changes: 15 additions & 0 deletions src/constant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,18 @@ export const SIGN_AUTHORIZATION_PERMISSIONS = [
'read:nftcollection',
'write:nftcollection',
];

export const SEARCH_SUGGESTIONS = [
'免費',
'小說',
'旅遊',
'報刊',
'心靈',
'運動',
'董啟章',
'李立峯',
'新聞',
'理財',
'區塊鏈',
'繪本',
];
1 change: 1 addition & 0 deletions src/constant/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const SORTING_OPTIONS = {
RECOMMEND: 'recommend',
DEFAULT: 'default',
LATEST: 'latest',
LOWER_PRICE: 'lower_price',
HIGHER_PRICE: 'higher_price',
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@
"listing_page_header_homePage": "Home",
"listing_page_header_listingPage": "Bookstore",
"listing_page_header_sort": "Sort: {sort}",
"listing_page_header_sort_default": "Default",
"listing_page_header_sort_higher_price": "Price: High to Low",
"listing_page_header_sort_latest": "Latest",
"listing_page_header_sort_lower_price": "Price: Low to High",
Expand All @@ -480,6 +481,7 @@
"listing_page_QA_label": "What is the difference between ebooks and paperbacks?",
"listing_page_QA_title": "FAQ",
"listing_page_search": "Search",
"listing_page_search_label": "book title or author",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"listing_page_search_label": "book title or author",
"listing_page_search_label": "Book title or Author",

"listing_page_search_not_found": "Please try different keywords.",
"listing_page_search_recommend": "Or explore our recommended books:",
"listing_page_search_result": "The search results for '{query}':",
Expand Down Expand Up @@ -1029,6 +1031,8 @@
"Stake your LikeCoin to gain extra reward, and participate in community governance."
],
"tag_all_title": "All",
"tag_all_featured": "Featured",
"tag_all_latest": "Latest Arrivals",
"tooltip_coming_soon": "Coming Soon",
"tooltip_no_nft": "No owned NFTs to transfer",
"tooltip_share": "Copy URL",
Expand Down
6 changes: 5 additions & 1 deletion src/locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@
"listing_page_header_homePage": "主頁",
"listing_page_header_listingPage": "書店",
"listing_page_header_sort": "排序:{sort}",
"listing_page_header_sort_default": "預設",
"listing_page_header_sort_higher_price": "價錢高至低",
"listing_page_header_sort_latest": "最新上架",
"listing_page_header_sort_latest": "上架日期",
"listing_page_header_sort_lower_price": "價錢低至高",
"listing_page_header_sort_recommend": "推薦",
"listing_page_header_total_books": "共 {num} 本書",
Expand All @@ -480,6 +481,7 @@
"listing_page_QA_label": "電子書和紙本書有什麼分別?",
"listing_page_QA_title": "常見問題",
"listing_page_search": "搜尋",
"listing_page_search_label": "搜尋書名或作者",
"listing_page_search_not_found": "請嘗試使用其他關鍵字。",
"listing_page_search_recommend": "或是您可以瀏覽我們的推薦書籍:",
"listing_page_search_result": "以下為 “{query}” 的搜尋結果:",
Expand Down Expand Up @@ -1029,6 +1031,8 @@
"委託 LikeCoin 獲得額外回報,同時參與社群決策"
],
"tag_all_title": "全部",
"tag_all_featured": "精選",
"tag_all_latest": "最新上架",
"tooltip_coming_soon": "快將推出",
"tooltip_no_nft": "沒有可發送的 NFT",
"tooltip_share": "複製網址",
Expand Down
Loading
Loading