Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add styled scrollbar #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
### JetBrains ###
/.idea/

### dependencies ###
/node_modules
/.pnp
.pnp.js

# testing
### testing ###
/coverage

# production
### production ###
/build
/package-lock.json

# misc
### misc ###
.DS_Store
.env.local
.env.development.local
Expand Down
4 changes: 3 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<!--suppress HtmlUnknownTarget -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suppress ide warning check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to set this up in a config file which can be ignored by .gitignore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel so. This is autogenerated by IDEA

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then one of the approaches may put this file into .gitignore.
It will be confusing to have a ide specific feature implemented in the code other than configuration files

<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--suppress HtmlUnknownTarget -->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Iceberx NTUOSS</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<div class="iceberx-app-container" id="root"></div>
</body>
</html>
16 changes: 8 additions & 8 deletions src/components/A/index.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import styled from 'styled-components';

const A = styled.a`
&,
&:hover,
&:focus,
&:visited {
color: ${props => props.theme.primaryColor};
background: inherit;
box-shadow: inherit;
}
&,
&:hover,
&:focus,
&:visited {
color: ${props => props.theme.primaryColor};
background: inherit;
box-shadow: inherit;
}
`;

export default A;
3 changes: 1 addition & 2 deletions src/layout/SideBar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';

import { Icon } from '@material-ui/core';
Expand All @@ -8,7 +8,6 @@ import Logo from 'components/Logo';
import {
Drawer,
SideBarHeader,
BreakLine,
List,
NavLink,
ListItem,
Expand Down
31 changes: 29 additions & 2 deletions src/styles/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as PropTypes from 'prop-types';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are doing this? isn't PropTypes directly good enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As PropTypes is no longer the default export name, we use * and change the name to PropTypes for better ide support

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Good one.

import { createGlobalStyle, ThemeProvider } from 'styled-components';

const GlobalStyle = createGlobalStyle`
html {
font-size:1vw;
color: ${props => props.theme.primaryColor};
background: ${props => props.theme.backgroundColor};
overflow: hidden;
}
html, body {
height: 100%;
margin:0;
overflow: hidden;
}
a {
text-decoration: none;
}
/* only apply in webkit */
@media screen and (-webkit-min-device-pixel-ratio:0) {
Copy link
Member

@ZaynJarvis ZaynJarvis Feb 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be good if the scroll bar changes only apply to Windows users. Since mac has a built-in feature to hide scroll bar when no action performed.
refer here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marked. Will do later

.iceberx-app-container {
color: rgba(0,0,0,0);
text-shadow: 0 0 black;
box-shadow: 0 1px 6px black;
transition: color .8s;
}
.iceberx-app-container:hover {
color: rgba(0,0,0,0.3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems when hover on the window the hover will take effect in Mac.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. This is some tricky part. Scrollbar itself does not have the transition effect. Check here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay for now. If no better solution, the implementation is good enough. Just try to make it Windows specific.

}
*::-webkit-scrollbar {
width: 6px;
height: 8px;
}
*::-webkit-scrollbar-track {
display: none;
}
*::-webkit-scrollbar-thumb {
border-radius: 3px;
box-shadow: inset 0 0 0 3px;
background-color: inherit;
}
}
`;

const theme = {
Expand Down