refactor to Section components to accept SVG prop

pull/26459/head^2
Paul Wackerow 2 years ago
parent d791e0a1a3
commit caaedf0335
No known key found for this signature in database
GPG Key ID: BB63E296FE9CAB8D
  1. 18
      src/components/UI/downloads/DownloadsSection.tsx
  2. 20
      src/components/UI/homepage/HomeSection.tsx
  3. 4
      src/pages/downloads.tsx
  4. 5
      src/pages/index.tsx

@ -1,24 +1,20 @@
import { Box, Image, Stack } from '@chakra-ui/react'; import { Box, IconProps, Stack } from '@chakra-ui/react';
import { FC } from 'react'; import { FC } from 'react';
import { GopherHomeLinks } from '../svgs'
interface Props { interface Props {
children: React.ReactNode;
id: string; id: string;
imgSrc?: string;
imgAltText?: string;
sectionTitle: string; sectionTitle: string;
showGopher?: boolean; children: React.ReactNode;
Svg?: React.FC<IconProps>;
ariaLabel?: string;
} }
export const DownloadsSection: FC<Props> = ({ children, imgSrc, imgAltText, sectionTitle, id, showGopher }) => { export const DownloadsSection: FC<Props> = ({ children, Svg, ariaLabel, sectionTitle, id, showGopher }) => {
return ( return (
<Stack border='2px solid' borderColor='primary' id={id}> <Stack border='2px solid' borderColor='primary' id={id}>
{imgSrc || showGopher && ( {Svg && (
<Stack alignItems='center' p={4} borderBottom='2px solid' borderColor='primary'> <Stack alignItems='center' p={4} borderBottom='2px solid' borderColor='primary'>
{/* TODO: use NextImage */} <Svg aria-label={ariaLabel} />
{imgSrc && <Image src={imgSrc} alt={imgAltText} />}
{showGopher && < GopherHomeLinks/>}
</Stack> </Stack>
)} )}

@ -1,35 +1,29 @@
import { Box, Image, Link, Stack, Text } from '@chakra-ui/react'; import { Box, IconProps, Link, Stack, Text } from '@chakra-ui/react';
import { FC } from 'react'; import { FC } from 'react';
import NextLink from 'next/link'; import NextLink from 'next/link';
import { GopherHomeFront } from '../svgs/';
interface Props { interface Props {
imgSrc?: string;
imgAltText?: string;
sectionTitle: string; sectionTitle: string;
linkLabel: string; linkLabel: string;
buttonHref: string; buttonHref: string;
children?: React.ReactNode; children?: React.ReactNode;
showGopher?: boolean; Svg?: React.FC<IconProps>;
ariaLabel?: string;
} }
export const HomeSection: FC<Props> = ({ export const HomeSection: FC<Props> = ({
imgSrc, Svg,
imgAltText, ariaLabel,
sectionTitle, sectionTitle,
linkLabel, linkLabel,
buttonHref, buttonHref,
showGopher,
children children
}) => { }) => {
return ( return (
<Stack border='2px solid' borderColor='primary' h='100%'> <Stack border='2px solid' borderColor='primary' h='100%'>
{imgSrc || showGopher && ( {Svg && (
<Stack alignItems='center' p={4} borderBottom='2px solid' borderColor='primary'> <Stack alignItems='center' p={4} borderBottom='2px solid' borderColor='primary'>
{/* TODO: use NextImage */} <Svg aria-label={ariaLabel} />
{imgSrc && <Image src={imgSrc} alt={imgAltText} />}
{showGopher && <GopherHomeFront />}
</Stack> </Stack>
)} )}
<Stack <Stack

@ -4,6 +4,7 @@ import { useState } from 'react';
import { DownloadsHero, DownloadsSection, DownloadsTable } from '../components/UI/downloads'; import { DownloadsHero, DownloadsSection, DownloadsTable } from '../components/UI/downloads';
import { DataTable } from '../components/UI'; import { DataTable } from '../components/UI';
import { GopherDownloads } from '../components/UI/svgs'
import { import {
DEFAULT_BUILD_AMOUNT_TO_SHOW, DEFAULT_BUILD_AMOUNT_TO_SHOW,
@ -54,7 +55,8 @@ const DownloadsPage: NextPage = () => {
<DownloadsSection <DownloadsSection
sectionTitle='Specific Versions' sectionTitle='Specific Versions'
id='specificversions' id='specificversions'
showGopher Svg={GopherDownloads}
ariaLabel="Gopher facing right"
> >
<Stack p={4}> <Stack p={4}>
<Text textStyle='quick-link-text'> <Text textStyle='quick-link-text'>

@ -1,6 +1,8 @@
import { Box, Grid, GridItem, Link, Stack, Text } from '@chakra-ui/react'; import { Box, Grid, GridItem, Link, Stack, Text } from '@chakra-ui/react';
import type { NextPage } from 'next'; import type { NextPage } from 'next';
import { GopherHomeFront } from '../components/UI/svgs';
import { import {
HomeHero, HomeHero,
HomeSection, HomeSection,
@ -35,7 +37,8 @@ const HomePage: NextPage = ({}) => {
sectionTitle='What is Geth' sectionTitle='What is Geth'
linkLabel='Get started with Geth' linkLabel='Get started with Geth'
buttonHref={`${DOCS_PAGE}/getting-started`} buttonHref={`${DOCS_PAGE}/getting-started`}
showGopher Svg={GopherHomeFront}
ariaLabel='Gopher greeting'
> >
<Text fontFamily='"Inter", sans-serif' lineHeight='26px'> <Text fontFamily='"Inter", sans-serif' lineHeight='26px'>
Geth (go-ethereum) is a{' '} Geth (go-ethereum) is a{' '}

Loading…
Cancel
Save