Skip to content

Commit 59b2e93

Browse files
authored
Highlights banners on home page (#3175)
* basic implementation * fix loading state of image * tests * try to fix flaky tests
1 parent dd90439 commit 59b2e93

24 files changed

+330
-3
lines changed

configs/app/ui.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const UI = Object.freeze({
7171
charts: parseEnvJson<Array<ChainIndicatorId>>(getEnvValue('NEXT_PUBLIC_HOMEPAGE_CHARTS')) || [],
7272
stats: homePageStats,
7373
heroBanner: parseEnvJson<HeroBannerConfig>(getEnvValue('NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG')),
74+
highlights: getExternalAssetFilePath('NEXT_PUBLIC_HOMEPAGE_HIGHLIGHTS_CONFIG'),
7475
},
7576
views,
7677
indexingAlert: {

configs/envs/.env.main

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ NEXT_PUBLIC_APP_PORT=3000
99
NEXT_PUBLIC_APP_ENV=development
1010
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
1111

12+
NEXT_PUBLIC_HOMEPAGE_HIGHLIGHTS_CONFIG=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/homepage-highlights/test.json
13+
1214
# Instance ENVs
1315
NEXT_PUBLIC_AD_BANNER_ENABLE_SPECIFY=true
1416
NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS=['talentprotocol', 'efp', 'webacy', 'deepdao', 'humanpassport', 'trustblock', 'smartmuv', 'blockscoutbadges', 'etherscore', 'gitpoap', 'drops', 'humanode']

deploy/scripts/download_assets.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ASSETS_ENVS=(
2727
"NEXT_PUBLIC_OG_IMAGE_URL"
2828
"NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS_CONFIG_URL"
2929
"NEXT_PUBLIC_ZETACHAIN_SERVICE_CHAINS_CONFIG_URL"
30+
"NEXT_PUBLIC_HOMEPAGE_HIGHLIGHTS_CONFIG"
3031
)
3132

3233
# Create the assets directory if it doesn't exist

deploy/tools/envs-validator/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async function validateEnvs(appEnvs: Record<string, string>) {
4848
'NEXT_PUBLIC_FOOTER_LINKS',
4949
'NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS_CONFIG_URL',
5050
'NEXT_PUBLIC_ZETACHAIN_SERVICE_CHAINS_CONFIG_URL',
51+
'NEXT_PUBLIC_HOMEPAGE_HIGHLIGHTS_CONFIG',
5152
];
5253

5354
for await (const envName of envsWithJsonConfig) {

deploy/tools/envs-validator/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ const schema = yup
164164
.concat(featuresSchemas.beaconChainSchema)
165165
.concat(featuresSchemas.bridgedTokensSchema)
166166
.concat(featuresSchemas.defiDropdownSchema)
167+
.concat(featuresSchemas.highlightsConfigSchema)
167168
.concat(featuresSchemas.marketplaceSchema)
168169
.concat(featuresSchemas.megaEthSchema)
169170
.concat(featuresSchemas.rollupSchema)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { HighlightsBannerConfig } from "types/homepage";
2+
import { urlTest } from "../../utils";
3+
import * as yup from 'yup';
4+
5+
const highlightsBannerConfigSchema: yup.ObjectSchema<HighlightsBannerConfig> = yup.object({
6+
title: yup.string().required(),
7+
description: yup.string().required(),
8+
title_color: yup.array().max(2).of(yup.string()),
9+
description_color: yup.array().max(2).of(yup.string()),
10+
background: yup.array().max(2).of(yup.string()),
11+
side_img_url: yup.array().max(2).of(yup.string()),
12+
is_pinned: yup.boolean(),
13+
page_path: yup.string(),
14+
redirect_url: yup.string().test(urlTest),
15+
});
16+
17+
export const highlightsConfigSchema = yup
18+
.object()
19+
.shape({
20+
NEXT_PUBLIC_HOMEPAGE_HIGHLIGHTS_CONFIG: yup
21+
.array()
22+
.json()
23+
.of(highlightsBannerConfigSchema)
24+
.min(2)
25+
});

deploy/tools/envs-validator/schemas/features/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './apiDocs';
44
export * from './beaconChain';
55
export * from './bridgedToken';
66
export * from './defiDropdown';
7+
export * from './highlights';
78
export * from './marketplace';
89
export * from './megaEth';
910
export * from './rollup';

deploy/tools/envs-validator/test/.env.base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS=['widget-1', 'widget-2']
9292
NEXT_PUBLIC_ADDRESS_3RD_PARTY_WIDGETS_CONFIG_URL=https://example.com
9393
NEXT_PUBLIC_NAVIGATION_PROMO_BANNER_CONFIG={'img_url': 'https://example.com/promo.svg', 'text': 'Promo text', 'bg_color': {'light': 'rgb(250, 245, 255)', 'dark': 'rgb(68, 51, 122)'}, 'text_color': {'light': 'rgb(107, 70, 193)', 'dark': 'rgb(233, 216, 253)'}, 'link_url': 'https://example.com'}
9494
NEXT_PUBLIC_FLASHBLOCKS_SOCKET_URL=wss://example.com/ws
95+
NEXT_PUBLIC_HOMEPAGE_HIGHLIGHTS_CONFIG=https://example.com
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
{
3+
"title": "Duck Deep into Transactions",
4+
"description": "Explore and track all blockchain transactions",
5+
"title_color": ["#1a472a", "#4ade80"],
6+
"description_color": ["#374151", "#d1d5db"],
7+
"background": ["#e0f2fe", "#0f172a"],
8+
"side_img_url": [
9+
"https://example.com",
10+
"https://example.com"
11+
],
12+
"page_path": "/txs"
13+
},
14+
{
15+
"title": "Capybara Hot Spring Pools",
16+
"description": "Monitor liquidity and staking pools",
17+
"is_pinned": true,
18+
"redirect_url": "https://example.com"
19+
}
20+
]
21+

docs/ENVS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Also, be aware that if you customize the name of the currency or any of its deno
144144
| NEXT_PUBLIC_HOMEPAGE_CHARTS | `Array<'daily_txs' \| 'daily_operational_txs' \| 'coin_price' \| 'secondary_coin_price' \| 'market_cap' \| 'tvl'>` | List of charts displayed on the home page | - | - | `['daily_txs','coin_price','market_cap']` | v1.0.x+ |
145145
| NEXT_PUBLIC_HOMEPAGE_STATS | `Array<'latest_batch' \| 'total_blocks' \| 'average_block_time' \| 'total_txs' \| 'total_operational_txs' \| 'latest_l1_state_batch' \| 'wallet_addresses' \| 'gas_tracker' \| 'btc_locked' \| 'current_epoch'>` | List of stats widgets displayed on the home page | - | For zkSync, zkEvm and Arbitrum rollups: `['latest_batch','average_block_time','total_txs','wallet_addresses','gas_tracker']`, for other cases: `['total_blocks','average_block_time','total_txs','wallet_addresses','gas_tracker']` | `['total_blocks','total_txs','wallet_addresses']` | v1.35.x+ |
146146
| NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG | `HeroBannerConfig`, see details [below](#hero-banner-configuration-properties) | Configuration of hero banner appearance. | - | - | See [below](#hero-banner-configuration-properties) | v1.35.0+ |
147+
| NEXT_PUBLIC_HOMEPAGE_HIGHLIGHTS_CONFIG | `string` | URL of the file (in `.json` format only) that contains the configuration for banners on the application's homepage, showcasing some of its key functionality. See the full config format [below](#highlights-banner-configuration-properties). The config should contain at least 2 banners, but only 3 banners will be visible at the same time. A larger number of banners in the config allows for random banner rotation upon page load. | - | - | See [below](#highlights-banner-configuration-properties) | upcoming |
147148

148149
#### Hero banner configuration properties
149150

@@ -157,6 +158,23 @@ _Note_ Here, all values are arrays of up to two strings. The first string repres
157158
| search | `{ border_width: [string, string] }` | Search bar customization. Currently supports only width of the border (in px). | - | - | `{ 'border_width': ['0px', '2px'] }` |
158159
| button | `Partial<Record<'_default' \| '_hover' \| '_selected', {'background'?: [string, string]; 'text_color?:[string, string]'}>>` | The button on the banner. It has three possible states: `_default`, `_hover`, and `_selected`. The `_selected` state reflects when the user is logged in or their wallet is connected to the app. | - | - | `{'_default':{'background':['deeppink'],'text_color':['white']}}` |
159160

161+
#### Highlights banner configuration properties
162+
163+
_Note_ Some properties can hold an array of up to two strings. The first string represents the value for the light color mode, while the second string represents the value for the dark color mode. If the array contains only one string, it will be used for both color modes.
164+
165+
| Variable | Type| Description | Compulsoriness | Default value | Example value |
166+
| --- | --- | --- | --- | --- | --- |
167+
| title | `string` | Title on the banner | Required | - | `Duck Deep into Transactions` |
168+
| description | `string` | Short description of the feature | Required | - | `Explore and track all blockchain transactions` |
169+
| title_color | `[string, string]` | Text color of the title. | - | `['#101112', '#F8FCFF']` | `['#FFB8D4', '#D9FE41']` |
170+
| description_color | `[string, string]` | Text color of the description. | - | `['#718096', '#AEB1B6']` | `['#FFB8D4', '#D9FE41']` |
171+
| background | `[string, string]` | Banner background (could be a solid color, gradient or picture). The string should be a valid `background` CSS property value. | - | `['#EFF7FF', '#2A3340']` | `['deeppink']` |
172+
| side_img_url | `[string, string]` | URL of an image that appears on the right side of the banner. | - | - | `https://placekitten/1400/200` |
173+
| is_pinned | `boolean` | Indicates whether the banner should remain always visible despite potential rotation. | - | - | `https://placekitten/1400/200` |
174+
| page_path | `string` | Internal page path for constructing the banner link. | - | - | `/pools` |
175+
| redirect_url | `string` | External link on the banner. | - | - | `https://example.com` |
176+
177+
160178
&nbsp;
161179

162180
### Navigation

0 commit comments

Comments
 (0)