Commit da335f6a authored by Max Alekseenko's avatar Max Alekseenko

change variable names

parent ef8a2448
...@@ -24,8 +24,8 @@ const hiddenLinks = (() => { ...@@ -24,8 +24,8 @@ const hiddenLinks = (() => {
return result; return result;
})(); })();
const lightningLabels = (() => { const highlightedRoutes = (() => {
const parsedValue = parseEnvJson<Array<NavigationLinkId>>(getEnvValue('NEXT_PUBLIC_MENU_LIGHTNING_LABELS')); const parsedValue = parseEnvJson<Array<NavigationLinkId>>(getEnvValue('NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES'));
return Array.isArray(parsedValue) ? parsedValue : []; return Array.isArray(parsedValue) ? parsedValue : [];
})(); })();
...@@ -48,7 +48,7 @@ const UI = Object.freeze({ ...@@ -48,7 +48,7 @@ const UI = Object.freeze({
dark: getExternalAssetFilePath('NEXT_PUBLIC_NETWORK_ICON_DARK'), dark: getExternalAssetFilePath('NEXT_PUBLIC_NETWORK_ICON_DARK'),
}, },
hiddenLinks, hiddenLinks,
lightningLabels, highlightedRoutes,
otherLinks: parseEnvJson<Array<NavItemExternal>>(getEnvValue('NEXT_PUBLIC_OTHER_LINKS')) || [], otherLinks: parseEnvJson<Array<NavItemExternal>>(getEnvValue('NEXT_PUBLIC_OTHER_LINKS')) || [],
featuredNetworks: getExternalAssetFilePath('NEXT_PUBLIC_FEATURED_NETWORKS'), featuredNetworks: getExternalAssetFilePath('NEXT_PUBLIC_FEATURED_NETWORKS'),
}, },
......
...@@ -33,7 +33,7 @@ NEXT_PUBLIC_NETWORK_LOGO_DARK=https://raw.githubusercontent.com/blockscout/front ...@@ -33,7 +33,7 @@ NEXT_PUBLIC_NETWORK_LOGO_DARK=https://raw.githubusercontent.com/blockscout/front
NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/sepolia.png NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/sepolia.png
NEXT_PUBLIC_NETWORK_ICON_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/sepolia.png NEXT_PUBLIC_NETWORK_ICON_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/sepolia.png
NEXT_PUBLIC_OTHER_LINKS=[{'url':'https://sepolia.drpc.org?ref=559183','text':'Public RPC'}] NEXT_PUBLIC_OTHER_LINKS=[{'url':'https://sepolia.drpc.org?ref=559183','text':'Public RPC'}]
NEXT_PUBLIC_MENU_LIGHTNING_LABELS=['/blocks','/apps'] NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES=['/blocks','/apps']
## footer ## footer
NEXT_PUBLIC_FOOTER_LINKS=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/footer-links/sepolia.json NEXT_PUBLIC_FOOTER_LINKS=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/footer-links/sepolia.json
##views ##views
......
...@@ -28,7 +28,7 @@ NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs'] ...@@ -28,7 +28,7 @@ NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
NEXT_PUBLIC_FEATURED_NETWORKS=https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/featured-networks/eth-goerli.json NEXT_PUBLIC_FEATURED_NETWORKS=https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/featured-networks/eth-goerli.json
NEXT_PUBLIC_NETWORK_LOGO=https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/network-logos/goerli.svg NEXT_PUBLIC_NETWORK_LOGO=https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/network-logos/goerli.svg
NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/network-icons/goerli.svg NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/dev/configs/network-icons/goerli.svg
NEXT_PUBLIC_MENU_LIGHTNING_LABELS=['/accounts','/apps'] NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES=['/accounts','/apps']
## footer ## footer
##views ##views
NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES=[{'name':'LooksRare','collection_url':'https://goerli.looksrare.org/collections/{hash}','instance_url':'https://goerli.looksrare.org/collections/{hash}/{id}','logo_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/nft-marketplace-logos/looks-rare.png'}] NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES=[{'name':'LooksRare','collection_url':'https://goerli.looksrare.org/collections/{hash}','instance_url':'https://goerli.looksrare.org/collections/{hash}/{id}','logo_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/nft-marketplace-logos/looks-rare.png'}]
......
...@@ -528,15 +528,15 @@ const schema = yup ...@@ -528,15 +528,15 @@ const schema = yup
.transform(replaceQuotes) .transform(replaceQuotes)
.json() .json()
.of(yup.string<NavigationLinkId>().oneOf(NAVIGATION_LINK_IDS)), .of(yup.string<NavigationLinkId>().oneOf(NAVIGATION_LINK_IDS)),
NEXT_PUBLIC_NETWORK_LOGO: yup.string().test(urlTest), NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES: yup
NEXT_PUBLIC_NETWORK_LOGO_DARK: yup.string().test(urlTest),
NEXT_PUBLIC_NETWORK_ICON: yup.string().test(urlTest),
NEXT_PUBLIC_NETWORK_ICON_DARK: yup.string().test(urlTest),
NEXT_PUBLIC_MENU_LIGHTNING_LABELS: yup
.array() .array()
.transform(replaceQuotes) .transform(replaceQuotes)
.json() .json()
.of(yup.string()), .of(yup.string()),
NEXT_PUBLIC_NETWORK_LOGO: yup.string().test(urlTest),
NEXT_PUBLIC_NETWORK_LOGO_DARK: yup.string().test(urlTest),
NEXT_PUBLIC_NETWORK_ICON: yup.string().test(urlTest),
NEXT_PUBLIC_NETWORK_ICON_DARK: yup.string().test(urlTest),
// c. footer // c. footer
NEXT_PUBLIC_FOOTER_LINKS: yup NEXT_PUBLIC_FOOTER_LINKS: yup
......
...@@ -26,7 +26,7 @@ NEXT_PUBLIC_CONTRACT_CODE_IDES=[{'title':'Remix IDE','url':'https://remix.blocks ...@@ -26,7 +26,7 @@ NEXT_PUBLIC_CONTRACT_CODE_IDES=[{'title':'Remix IDE','url':'https://remix.blocks
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://example.com NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://example.com
NEXT_PUBLIC_DATA_AVAILABILITY_ENABLED=true NEXT_PUBLIC_DATA_AVAILABILITY_ENABLED=true
NEXT_PUBLIC_FEATURED_NETWORKS=https://example.com NEXT_PUBLIC_FEATURED_NETWORKS=https://example.com
NEXT_PUBLIC_MENU_LIGHTNING_LABELS=['/accounts','/apps'] NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES=['/accounts','/apps']
NEXT_PUBLIC_FOOTER_LINKS=https://example.com NEXT_PUBLIC_FOOTER_LINKS=https://example.com
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0xf7d4972356e6ae44ae948d0cf19ef2beaf0e574c180997e969a2837da15e349d NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0xf7d4972356e6ae44ae948d0cf19ef2beaf0e574c180997e969a2837da15e349d
NEXT_PUBLIC_HIDE_INDEXING_ALERT_BLOCKS=false NEXT_PUBLIC_HIDE_INDEXING_ALERT_BLOCKS=false
......
...@@ -128,7 +128,7 @@ Please be aware that all environment variables prefixed with `NEXT_PUBLIC_` will ...@@ -128,7 +128,7 @@ Please be aware that all environment variables prefixed with `NEXT_PUBLIC_` will
| NEXT_PUBLIC_FEATURED_NETWORKS | `string` | URL of configuration file (`.json` format only) which contains list of featured networks that will be shown in the network menu. See [below](#featured-network-configuration-properties) list of available properties for particular network | - | - | `https://example.com/featured_networks_config.json` | | NEXT_PUBLIC_FEATURED_NETWORKS | `string` | URL of configuration file (`.json` format only) which contains list of featured networks that will be shown in the network menu. See [below](#featured-network-configuration-properties) list of available properties for particular network | - | - | `https://example.com/featured_networks_config.json` |
| NEXT_PUBLIC_OTHER_LINKS | `Array<{url: string; text: string}>` | List of links for the "Other" navigation menu | - | - | `[{'url':'https://blockscout.com','text':'Blockscout'}]` | | NEXT_PUBLIC_OTHER_LINKS | `Array<{url: string; text: string}>` | List of links for the "Other" navigation menu | - | - | `[{'url':'https://blockscout.com','text':'Blockscout'}]` |
| NEXT_PUBLIC_NAVIGATION_HIDDEN_LINKS | `Array<LinkId>` | List of external links hidden in the navigation. Supported ids are `eth_rpc_api`, `rpc_api` | - | - | `['eth_rpc_api']` | | NEXT_PUBLIC_NAVIGATION_HIDDEN_LINKS | `Array<LinkId>` | List of external links hidden in the navigation. Supported ids are `eth_rpc_api`, `rpc_api` | - | - | `['eth_rpc_api']` |
| NEXT_PUBLIC_MENU_LIGHTNING_LABELS | `Array<string>` | List of menu item routes that should have a lightning label | - | - | `['/accounts']` | | NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES | `Array<string>` | List of menu item routes that should have a lightning label | - | - | `['/accounts']` |
#### Featured network configuration properties #### Featured network configuration properties
......
...@@ -63,7 +63,7 @@ export const ENVS_MAP: Record<string, Array<[string, string]>> = { ...@@ -63,7 +63,7 @@ export const ENVS_MAP: Record<string, Array<[string, string]>> = {
noNftMarketplaces: [ noNftMarketplaces: [
[ 'NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES', '' ], [ 'NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES', '' ],
], ],
menuLightningLabels: [ navigationHighlightedRoutes: [
[ 'NEXT_PUBLIC_MENU_LIGHTNING_LABELS', '["/blocks", "/apps"]' ], [ 'NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES', '["/blocks", "/apps"]' ],
], ],
}; };
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
| "integration/full" | "integration/full"
| "integration/partial" | "integration/partial"
| "key" | "key"
| "lightning_sidebar" | "lightning_navbar"
| "lightning" | "lightning"
| "link" | "link"
| "lock" | "lock"
......
...@@ -21,7 +21,7 @@ const LightningLabel = ({ bgColor, isCollapsed }: { bgColor?: string; isCollapse ...@@ -21,7 +21,7 @@ const LightningLabel = ({ bgColor, isCollapsed }: { bgColor?: string; isCollapse
return ( return (
<IconSvg <IconSvg
className="lightning-label" className="lightning-label"
name="lightning_sidebar" name="lightning_navbar"
boxSize={ 4 } boxSize={ 4 }
ml={{ base: 1, lg: isExpanded ? 1 : 0, xl: isCollapsed ? 0 : 1 }} ml={{ base: 1, lg: isExpanded ? 1 : 0, xl: isCollapsed ? 0 : 1 }}
position={{ lg: isExpanded ? 'relative' : 'absolute', xl: isCollapsed ? 'absolute' : 'relative' }} position={{ lg: isExpanded ? 'relative' : 'absolute', xl: isCollapsed ? 'absolute' : 'relative' }}
......
...@@ -13,7 +13,7 @@ import IconSvg from 'ui/shared/IconSvg'; ...@@ -13,7 +13,7 @@ import IconSvg from 'ui/shared/IconSvg';
import LightningLabel from './LightningLabel'; import LightningLabel from './LightningLabel';
import NavLinkIcon from './NavLinkIcon'; import NavLinkIcon from './NavLinkIcon';
import useColors from './useColors'; import useColors from './useColors';
import useLightningLabel from './useLightningLabel'; import useHighlightedRoute from './useHighlightedRoute';
import useNavLinkStyleProps from './useNavLinkStyleProps'; import useNavLinkStyleProps from './useNavLinkStyleProps';
type Props = { type Props = {
...@@ -36,7 +36,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState ...@@ -36,7 +36,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
const isXLScreen = useBreakpointValue({ base: false, xl: true }); const isXLScreen = useBreakpointValue({ base: false, xl: true });
const href = isInternalLink ? route(item.nextRoute) : item.url; const href = isInternalLink ? route(item.nextRoute) : item.url;
const hasLightningLabel = useLightningLabel(item); const isHighlighted = useHighlightedRoute(item);
const content = ( const content = (
<Link <Link
...@@ -71,7 +71,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState ...@@ -71,7 +71,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
<span>{ item.text }</span> <span>{ item.text }</span>
{ !isInternalLink && <IconSvg name="arrows/north-east" boxSize={ 4 } color="text_secondary" verticalAlign="middle"/> } { !isInternalLink && <IconSvg name="arrows/north-east" boxSize={ 4 } color="text_secondary" verticalAlign="middle"/> }
</Text> </Text>
{ hasLightningLabel && ( { isHighlighted && (
<LightningLabel bgColor={ styleProps.itemProps.bgColor } isCollapsed={ isCollapsed }/> <LightningLabel bgColor={ styleProps.itemProps.bgColor } isCollapsed={ isCollapsed }/>
) } ) }
</HStack> </HStack>
......
...@@ -18,7 +18,7 @@ import IconSvg from 'ui/shared/IconSvg'; ...@@ -18,7 +18,7 @@ import IconSvg from 'ui/shared/IconSvg';
import LightningLabel from './LightningLabel'; import LightningLabel from './LightningLabel';
import NavLink from './NavLink'; import NavLink from './NavLink';
import NavLinkIcon from './NavLinkIcon'; import NavLinkIcon from './NavLinkIcon';
import useLightningLabel from './useLightningLabel'; import useHighlightedRoute from './useHighlightedRoute';
import useNavLinkStyleProps from './useNavLinkStyleProps'; import useNavLinkStyleProps from './useNavLinkStyleProps';
type Props = { type Props = {
...@@ -31,7 +31,7 @@ const NavLinkGroupDesktop = ({ item, isCollapsed }: Props) => { ...@@ -31,7 +31,7 @@ const NavLinkGroupDesktop = ({ item, isCollapsed }: Props) => {
const styleProps = useNavLinkStyleProps({ isCollapsed, isExpanded, isActive: item.isActive }); const styleProps = useNavLinkStyleProps({ isCollapsed, isExpanded, isActive: item.isActive });
const hasLightningLabel = useLightningLabel(item.subItems); const isHighlighted = useHighlightedRoute(item.subItems);
return ( return (
<Box as="li" listStyleType="none" w="100%"> <Box as="li" listStyleType="none" w="100%">
...@@ -57,7 +57,7 @@ const NavLinkGroupDesktop = ({ item, isCollapsed }: Props) => { ...@@ -57,7 +57,7 @@ const NavLinkGroupDesktop = ({ item, isCollapsed }: Props) => {
> >
{ item.text } { item.text }
</Text> </Text>
{ hasLightningLabel && ( { isHighlighted && (
<LightningLabel bgColor={ styleProps.itemProps.bgColor } isCollapsed={ isCollapsed }/> <LightningLabel bgColor={ styleProps.itemProps.bgColor } isCollapsed={ isCollapsed }/>
) } ) }
<IconSvg <IconSvg
......
...@@ -12,7 +12,7 @@ import IconSvg from 'ui/shared/IconSvg'; ...@@ -12,7 +12,7 @@ import IconSvg from 'ui/shared/IconSvg';
import LightningLabel from './LightningLabel'; import LightningLabel from './LightningLabel';
import NavLinkIcon from './NavLinkIcon'; import NavLinkIcon from './NavLinkIcon';
import useLightningLabel from './useLightningLabel'; import useHighlightedRoute from './useHighlightedRoute';
import useNavLinkStyleProps from './useNavLinkStyleProps'; import useNavLinkStyleProps from './useNavLinkStyleProps';
type Props = { type Props = {
...@@ -24,7 +24,7 @@ type Props = { ...@@ -24,7 +24,7 @@ type Props = {
const NavLinkGroup = ({ item, onClick, isExpanded }: Props) => { const NavLinkGroup = ({ item, onClick, isExpanded }: Props) => {
const styleProps = useNavLinkStyleProps({ isActive: item.isActive, isExpanded }); const styleProps = useNavLinkStyleProps({ isActive: item.isActive, isExpanded });
const hasLightningLabel = useLightningLabel(item.subItems); const isHighlighted = useHighlightedRoute(item.subItems);
return ( return (
<Box as="li" listStyleType="none" w="100%" onClick={ onClick }> <Box as="li" listStyleType="none" w="100%" onClick={ onClick }>
...@@ -43,7 +43,7 @@ const NavLinkGroup = ({ item, onClick, isExpanded }: Props) => { ...@@ -43,7 +43,7 @@ const NavLinkGroup = ({ item, onClick, isExpanded }: Props) => {
> >
{ item.text } { item.text }
</Text> </Text>
{ hasLightningLabel && (<LightningLabel bgColor={ styleProps.itemProps.bgColor }/>) } { isHighlighted && (<LightningLabel bgColor={ styleProps.itemProps.bgColor }/>) }
</HStack> </HStack>
<IconSvg name="arrows/east-mini" transform="rotate(180deg)" boxSize={ 6 }/> <IconSvg name="arrows/east-mini" transform="rotate(180deg)" boxSize={ 6 }/>
</Flex> </Flex>
......
...@@ -219,11 +219,11 @@ test.describe('hover xl screen', () => { ...@@ -219,11 +219,11 @@ test.describe('hover xl screen', () => {
}); });
}); });
test.describe('with lightning labels', () => { test.describe('with highlighted routes', () => {
let component: Locator; let component: Locator;
test.beforeEach(async({ render, mockEnvs }) => { test.beforeEach(async({ render, mockEnvs }) => {
await mockEnvs(ENVS_MAP.menuLightningLabels); await mockEnvs(ENVS_MAP.navigationHighlightedRoutes);
component = await render( component = await render(
<Flex w="100%" minH="100vh" alignItems="stretch"> <Flex w="100%" minH="100vh" alignItems="stretch">
......
...@@ -3,13 +3,13 @@ import type { NavItem } from 'types/client/navigation-items'; ...@@ -3,13 +3,13 @@ import type { NavItem } from 'types/client/navigation-items';
import config from 'configs/app'; import config from 'configs/app';
import { isInternalItem } from 'lib/hooks/useNavItems'; import { isInternalItem } from 'lib/hooks/useNavItems';
export default function useLightningLabel(item: NavItem | Array<NavItem> | Array<Array<NavItem>>) { export default function useHighlightedRoute(item: NavItem | Array<NavItem> | Array<Array<NavItem>>) {
function checkForLightningLabel(item: NavItem | Array<NavItem> | Array<Array<NavItem>>): boolean { function checkForLightningLabel(item: NavItem | Array<NavItem> | Array<Array<NavItem>>): boolean {
if (Array.isArray(item)) { if (Array.isArray(item)) {
return item.some((subItem) => checkForLightningLabel(subItem)); return item.some((subItem) => checkForLightningLabel(subItem));
} }
return isInternalItem(item) && (config.UI.sidebar.lightningLabels.includes(item.nextRoute.pathname)); return isInternalItem(item) && (config.UI.sidebar.highlightedRoutes.includes(item.nextRoute.pathname));
} }
return checkForLightningLabel(item); return checkForLightningLabel(item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment