Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
feat: 💄 use custom-styled scrollbar in scrollable areas
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jun 6, 2020
1 parent c1a8ca7 commit 651b318
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ContentTree from './contentTree';
import Links from './links';
import PoweredBy from './poweredBy';
import { getNavigationData } from '../navigation';
import { scrollbar } from '../../styles/base'

const Sidebar = styled.div`
margin-left: ${(props) => props.theme.layout.leftMargin};
Expand Down Expand Up @@ -112,7 +113,7 @@ const ContentNavigation = ({ className, location }) => {
const edges = getNavigationData();
return (
<NavigationWrapper className={className}>
<SidebarMain>
<SidebarMain css={scrollbar}>
<ContentTree edges={edges} location={location} />
{config.sidebar.links && config.sidebar.links.length > 0 ? (
<>
Expand Down
3 changes: 2 additions & 1 deletion src/components/tableOfContents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AlignRight } from 'react-feather';
import config from 'config';
import Scrollspy from 'react-scrollspy';
import { sleep } from '../../utils/utils';
import { scrollbar } from '../../styles/base'

const Sidebar = styled.aside`
background-color: ${(props) => props.theme.tableOfContents.background};
Expand Down Expand Up @@ -195,7 +196,7 @@ const TableOfContents = ({ className, location }) => (
}
};
return (
<Sidebar className={className}>
<Sidebar className={className} css={scrollbar}>
<TocTitle>Contents</TocTitle>
<Scrollspy
ref={scrollspyRef}
Expand Down
3 changes: 2 additions & 1 deletion src/html.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import config from 'config';
import { scrollbar } from './styles/base';

export default class HTML extends React.Component {
render() {
Expand All @@ -23,7 +24,7 @@ export default class HTML extends React.Component {
<noscript key="noscript"></noscript>
{this.props.headComponents}
</head>
<body {...this.props.bodyAttributes}>
<body css={scrollbar} {...this.props.bodyAttributes}>
{this.props.preBodyComponents}
<div key={`body`} id="___gatsby" dangerouslySetInnerHTML={{ __html: this.props.body }} />
{this.props.postBodyComponents}
Expand Down
19 changes: 19 additions & 0 deletions src/styles/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,22 @@ export const table = (theme) => css`
margin-bottom: 0;
}
`;

export const scrollbar = css`
&::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 8px;
background-color: #F5F5F5;
}
&::-webkit-scrollbar {
width: 10px;
background-color: #F5F5F5;
}
&::-webkit-scrollbar-thumb {
border-radius: 8px;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
background-color: #555;
}
`;

0 comments on commit 651b318

Please sign in to comment.