Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'gatsby-theme-apollo-core' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
const Wrapper = styled.div({
display: 'flex',
alignItems: 'flex-start'
});
const InnerWrapper = styled.div({
flexGrow: 1,
width: 0
});
const BodyContent = styled.div({
// style all anchors with an href and no prior classes
// this helps avoid anchors with names and styled buttons
'a[href]:not([class])': {
color: colors.primary,
textDecoration: 'none',
':hover': {
textDecoration: 'underline'
},
code: {
color: 'inherit'
}
},
[['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]: {
'&[id]::before': {
// inspired by https://css-tricks.com/hash-tag-links-padding/
content: "''",
display: 'block',
marginTop: -HEADER_HEIGHT,
height: HEADER_HEIGHT,
visibility: 'hidden',
import PropTypes from 'prop-types';
import React, {Fragment, useEffect, useMemo, useRef} from 'react';
import styled from '@emotion/styled';
import useKey from 'react-use/lib/useKey';
import useWindowSize from 'react-use/lib/useWindowSize';
import {IconTwitter} from '@apollo/space-kit/icons/IconTwitter';
import {IconYoutube} from '@apollo/space-kit/icons/IconYoutube';
import {ReactComponent as SpectrumIcon} from '../assets/spectrum.svg';
import {boxShadow} from './search';
import {breakpoints, colors, smallCaps} from 'gatsby-theme-apollo-core';
import {size, transparentize} from 'polished';
const Wrapper = styled.div({
width: '100%',
height: '100%',
backgroundColor: transparentize(0.5, colors.text2),
overflow: 'auto',
position: 'fixed',
top: 0,
left: 0,
zIndex: 3,
perspective: '1000px',
transitionProperty: 'opacity, visibility',
transitionDuration: '150ms',
transitionTimingFunction: 'ease-in-out'
});
const transitionDuration = 150; // in ms
const Menu = styled.div({
width: 700,
marginBottom: 24,
borderRadius: 4,
function AsideLink(props) {
return (
);
}
const EditLink = styled.div({
display: 'none',
marginTop: 48,
justifyContent: 'flex-end',
[breakpoints.lg]: {
display: 'flex'
},
[breakpoints.md]: {
display: 'none'
},
[breakpoints.sm]: {
display: 'flex',
marginTop: 24
}
});
export default function PageContent(props) {
const contentRef = useRef(null);
const [imagesToLoad, setImagesToLoad] = useState(0);
const [imagesLoaded, setImagesLoaded] = useState(0);
useMount(() => {
if (props.hash) {
// turn numbers at the beginning of the hash to unicode
function AsideLink(props) {
return (
)
}
const EditLink = styled.div({
display: 'none',
marginTop: 48,
justifyContent: 'flex-end',
[breakpoints.lg]: {
display: 'flex',
},
[breakpoints.md]: {
display: 'none',
},
[breakpoints.sm]: {
display: 'flex',
marginTop: 24,
},
})
export default function PageContent(props) {
const contentRef = useRef(null)
const [imagesToLoad, setImagesToLoad] = useState(0)
const [imagesLoaded, setImagesLoaded] = useState(0)
useMount(() => {
if (props.hash) {
// turn numbers at the beginning of the hash to unicode
[['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]: {
'&[id]::before': {
// inspired by https://css-tricks.com/hash-tag-links-padding/
content: "''",
display: 'block',
marginTop: -headerHeight,
height: headerHeight,
visibility: 'hidden',
pointerEvents: 'none',
},
':not(:hover) a svg': {
visibility: 'hidden',
},
'a.anchor': {
':hover': {
opacity: colors.hoverOpacity,
},
svg: {
fill: colors.primary,
},
},
},
[['h2', 'h3', 'h4']]: {
':not(:first-child)': {
marginTop: 56,
},
},
img: {
display: 'block',
maxWidth: '100%',
margin: '0 auto',
},
const transitionDuration = 150; // in ms
const Menu = styled.div({
width: 700,
marginBottom: 24,
borderRadius: 4,
boxShadow,
backgroundColor: 'white',
overflow: 'hidden',
position: 'absolute',
transformOrigin: '25% 25%',
transition: `transform ${transitionDuration}ms ease-in-out`,
outline: 'none',
[breakpoints.md]: {
width: 450
},
[breakpoints.sm]: {
width: 'calc(100vw - 48px)'
}
});
const MenuTitle = styled.h6(smallCaps, {
margin: 24,
marginBottom: 0,
fontSize: 13,
fontWeight: 600,
color: colors.text3
});
const StyledNav = styled.nav({
display: 'flex',
flexWrap: 'wrap',
margin: 12
);
}
const EditLink = styled.div({
display: 'none',
marginTop: 48,
justifyContent: 'flex-end',
[breakpoints.lg]: {
display: 'flex'
},
[breakpoints.md]: {
display: 'none'
},
[breakpoints.sm]: {
display: 'flex',
marginTop: 24
}
});
export default function PageContent(props) {
const contentRef = useRef(null);
const [imagesToLoad, setImagesToLoad] = useState(0);
const [imagesLoaded, setImagesLoaded] = useState(0);
useMount(() => {
if (props.hash) {
// turn numbers at the beginning of the hash to unicode
// see https://stackoverflow.com/a/20306237/8190832
const hash = props.hash.toLowerCase().replace(/^#(\d)/, '#\\3$1 ');
try {
/* global docsearch */
import PropTypes from 'prop-types';
import React, {Fragment, useEffect, useRef, useState} from 'react';
import styled from '@emotion/styled';
import {HEADER_HEIGHT} from './header';
import {IconClose} from '@apollo/space-kit/icons/IconClose';
import {breakpoints, colors, smallCaps} from 'gatsby-theme-apollo-core';
import {css} from '@emotion/core';
import {position, size, transparentize} from 'polished';
const borderRadius = 5;
const border = `1px solid ${colors.text3}`;
const verticalAlign = css({
position: 'absolute',
top: '50%',
transform: 'translateY(-50%)'
});
const Hotkey = styled.div(verticalAlign, size(24), {
border,
borderColor: colors.text4,
color: colors.text4,
borderRadius,
textAlign: 'center',
lineHeight: 1.125,
right: 10,
pointerEvents: 'none'
});
import NavItem from './nav-item';
import PropTypes from 'prop-types';
import React from 'react';
import styled from '@emotion/styled';
import {breakpoints} from 'gatsby-theme-apollo-core';
const Container = styled.nav({
display: 'flex',
alignSelf: 'stretch',
marginLeft: 'auto',
paddingLeft: 40,
[breakpoints.sm]: {
display: 'none'
}
});
export default function Nav(props) {
return (
{props.items.map(({value, text, matchRegex, subpages}) => {
let isActive = matchRegex
? new RegExp(matchRegex).test(props.pathname)
: props.isPathActive(value);
if (!isActive && subpages) {
isActive = subpages.some(subpage =>
props.isPathActive(subpage.value)
);
}
/>
<span>{subtitle}</span>
{versions && versions.length > 0 && (