diff --git a/src/common/constants.ts b/src/common/constants.ts index 37016352..98c47c24 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -5,3 +5,5 @@ export const PAGE_WIDTH = 1104; export const SHIKI_THEME = 'Material-Theme-Default'; export const THEME_STORAGE_KEY = 'theme'; + +export const STATUS_CHECKER_URL = 'https://status.test-blockstack.com'; diff --git a/src/components/feedback.tsx b/src/components/feedback.tsx index 0bf4d4b5..39530e18 100644 --- a/src/components/feedback.tsx +++ b/src/components/feedback.tsx @@ -18,6 +18,7 @@ import { border } from '@common/utils'; import { useRouter } from 'next/router'; import { getHeadingStyles } from '@components/mdx/typography'; import { css } from '@styled-system/css'; +import { StatusCheck } from '@components/status-check'; const Icon: React.FC }> = ({ icon: IconComponent, ...props }) => { const { bind, hover, active } = useTouchable(); @@ -117,15 +118,22 @@ export const FeedbackSection: React.FC = props => { setShowButton(false)} /> - + Edit this page on GitHub - + + ); }; diff --git a/src/components/icons/circle-check.tsx b/src/components/icons/circle-check.tsx new file mode 100644 index 00000000..ddceff12 --- /dev/null +++ b/src/components/icons/circle-check.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { BaseSvg, SvgProps } from '@components/icons/_base'; + +export const CircleCheck: SvgProps = props => ( + + + + + +); diff --git a/src/components/mdx/components/link.tsx b/src/components/mdx/components/link.tsx index f251a929..c208b241 100644 --- a/src/components/mdx/components/link.tsx +++ b/src/components/mdx/components/link.tsx @@ -28,6 +28,7 @@ export const Link = forwardRef( textDecoration="underline" _hover={{ textDecoration: 'none' }} _focus={{ boxShadow: 'outline' }} + rel="nofollow noopener noreferrer" {...props} /> ) diff --git a/src/components/status-check.tsx b/src/components/status-check.tsx index 11bba8ca..9d957ad5 100644 --- a/src/components/status-check.tsx +++ b/src/components/status-check.tsx @@ -1,64 +1,75 @@ import React from 'react'; -import { Box, Flex, space, themeColor, color } from '@blockstack/ui'; +import useSWR from 'swr'; +import { Box, Flex, space, color, BoxProps } from '@blockstack/ui'; import { border } from '@common/utils'; import { Link } from '@components/mdx'; -import { Text } from '@components/typography'; -import { CheckmarkCircleIcon, ExclamationMarkCircleIcon, Spinner } from '@blockstack/ui'; -import useSWR from 'swr'; +import { LinkProps, Text } from '@components/typography'; +import { Spinner } from '@blockstack/ui'; +import { CircleCheck } from '@components/icons/circle-check'; +import { AlertCircleIcon } from '@components/icons/alert-circle'; +import { STATUS_CHECKER_URL } from '@common/constants'; +import { css } from '@styled-system/css'; +import { getCapsizeStyles } from '@components/mdx/typography'; const fetcher = url => fetch(url).then(r => r.json()); -export const StatusCheck: React.FC = () => { - const STATUS_CHECKER_URL = 'https://status.test-blockstack.com'; +const StatusWords: React.FC = ({ status, ...rest }) => ( + <> + : + {`${ + status ? ' online' : ' offline' + }`} + +); + +export const StatusCheck: React.FC = props => { const { data, error } = useSWR(`${STATUS_CHECKER_URL}/json`, fetcher); - let status = false; + const [status, setStatus] = React.useState(undefined); - if (data && data.hasOwnProperty('masterNodePings') && data.masterNodePings.length > 1) { - status = data.masterNodePings[0].value; - } + React.useEffect(() => { + if (data?.masterNodePings?.length > 1) { + setStatus(data.masterNodePings[0].value); + } else if (status) { + setStatus(undefined); + } + }, [data, error]); + + const critical = error && !status; + const positive = data && status && !error; return ( - - - + + + {!data && !error ? ( + + ) : critical ? ( + + ) : ( + positive && + )} + + - - {!data && !error && ( - - )} - {error && !status && ( - - )} - {data && status && ( - - )} - - - {!data && `Stack 2.0 testnet status`} - {data && `Stacks 2.0 testnet is ${status ? 'online' : 'offline'}`} - - - + Stacks 2.0 testnet status + + + ); }; - -const SpinnerComponent = ({ color }: { color: string }) => ( - -);