Skip to content

Commit

Permalink
feat: set lighter colors on anchors
Browse files Browse the repository at this point in the history
closses: #16
  • Loading branch information
Marvin Heilemann committed Feb 9, 2020
1 parent b902632 commit 86b3a74
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 35 deletions.
17 changes: 1 addition & 16 deletions src/layouts/Article.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { useEffect } from 'react'
import React from 'react'
import { MDXRenderer } from 'gatsby-plugin-mdx'
import { globalHistory } from '@reach/router'
import { scroller } from 'react-scroll'

const Article = ({ children, mdx, slug }) => {
const props = {
Expand All @@ -12,19 +10,6 @@ const Article = ({ children, mdx, slug }) => {
itemRef: 'hero',
}

useEffect(() => {
const hash = globalHistory.location.hash
if (hash) {
setTimeout(() => {
scroller.scrollTo(hash.substr(1), {
offset: -50,
duration: 200,
smooth: true,
})
}, 300)
}
})

// console.log(props.toc)
// const toc = props.toc && (
// <div
Expand Down
51 changes: 33 additions & 18 deletions src/layouts/index.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
import React, { useContext } from 'react'
import React from 'react'
import { Helmet } from 'react-helmet-async'
import { MDXProvider } from '@mdx-js/react'
import { globalHistory } from '@reach/router'
import { scroller } from 'react-scroll'

import { ThemeContext } from '../provider/theme'
import Header from './Header'
import Footer from './Footer'
import ScrollToTop from '../components/ScrollToTop'
import mdxElements from '../components/MDXElements'

const Index = ({ children }) => {
const { theme } = useContext(ThemeContext)
export default class Index extends React.Component {
static contextType = ThemeContext

return (
<>
<Helmet htmlAttributes={{ theme }} />
<Header></Header>
<MDXProvider components={mdxElements}>
<main role="main" id="main">
{children}
</main>
</MDXProvider>
<Footer></Footer>
<ScrollToTop />
</>
)
}
componentDidMount() {
const hash = globalHistory.location.hash
if (hash) {
setTimeout(() => {
scroller.scrollTo(hash.substr(1), {
offset: -30,
duration: 200,
smooth: true,
})
}, 300)
}
}

export default Index
render() {
return (
<>
<Helmet htmlAttributes={{ theme: this.context.theme }} />
<Header></Header>
<MDXProvider components={mdxElements}>
<main role="main" id="main">
{this.props.children}
</main>
</MDXProvider>
<Footer></Footer>
<ScrollToTop />
</>
)
}
}
6 changes: 5 additions & 1 deletion src/styles/components/_anchor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ $size: 15px;
svg {
width: $size;
height: $size;
fill: var(--text-color-light);
fill: var(--text-color-dark);

@include breakpoint-up(md) {
fill: var(--text-color-light);
}
}
}

Expand Down

0 comments on commit 86b3a74

Please sign in to comment.