Skip to content

Commit

Permalink
Add banner for non-default version pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarrow committed Feb 16, 2022
1 parent 9435833 commit c1a042f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/@chakra-ui/gatsby-plugin/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@apollo/chakra-helpers';
import {extendTheme} from '@chakra-ui/react';

const {grey, silver, indigo, teal, blilet, midnight} = colors;
const {grey, silver, indigo, teal, blilet, midnight, yellow} = colors;

const theme = extendTheme({
config: {
Expand Down Expand Up @@ -41,7 +41,8 @@ const theme = extendTheme({
gray: createGrayPalette(silver, grey, midnight),
indigo: createColorPalette(indigo),
teal: createColorPalette(teal),
blue: createColorPalette(blilet)
blue: createColorPalette(blilet),
yellow: createColorPalette(yellow)
}
});

Expand Down
27 changes: 26 additions & 1 deletion src/templates/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ import {
Tr,
UnorderedList,
chakra,
useColorModeValue,
useToken
} from '@chakra-ui/react';
import {FaDiscourse, FaGithub} from 'react-icons/fa';
import {FiChevronsRight, FiStar} from 'react-icons/fi';
import {Link as GatsbyLink, graphql} from 'gatsby';
import {GatsbySeo} from 'gatsby-plugin-next-seo';
import {Global} from '@emotion/react';
import {MDXProvider} from '@mdx-js/react';
import {MDXRenderer} from 'gatsby-plugin-mdx';
import {PathContext} from '../utils';
import {YouTube} from 'mdx-embed';
import {default as getShareImage} from '@jlengstorf/get-share-image';
import {graphql} from 'gatsby';
import {rehype} from 'rehype';
import {useMermaidStyles} from '../utils/mermaid';

Expand Down Expand Up @@ -124,6 +125,8 @@ const {processSync} = rehype()

export default function PageTemplate({data, uri, pageContext}) {
const sidebarWidth = useSidebarWidth();
const versionBannerBgColor = useColorModeValue('yellow.100', 'yellow.700');
const versionBannerTextColor = useColorModeValue('yellow.900', 'yellow.50');
const paddingTop = useToken('space', 10);
const paddingBottom = useToken('space', 12);
const scrollPaddingTop = useMemo(
Expand Down Expand Up @@ -227,6 +230,28 @@ export default function PageTemplate({data, uri, pageContext}) {
transitionProperty="margin-left"
transitionDuration="normal"
>
{basePath.includes('/') && basePath !== '/' && (
<Box
textAlign="center"
w="full"
py="4"
px="8"
bgColor={versionBannerBgColor}
color={versionBannerTextColor}
>
You&apos;re viewing documentation for a previous version of this
software.{' '}
<Flex
as={GatsbyLink}
to={'/' + basePath.split('/')[0]}
display="inline-flex"
textDecoration="underline"
fontWeight="semibold"
>
Switch to the latest stable version
</Flex>
</Box>
)}
<Flex
maxW="7xl"
mx="auto"
Expand Down

0 comments on commit c1a042f

Please sign in to comment.