Skip to content

Commit 8c8c0f0

Browse files
authored
Replace Affix with position: sticky, remove dependencies (#325)
1 parent f7606e8 commit 8c8c0f0

File tree

6 files changed

+33
-211
lines changed

6 files changed

+33
-211
lines changed

package-lock.json

Lines changed: 0 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,13 @@
4848
},
4949
"dependencies": {
5050
"@monaco-editor/react": "^4.7.0",
51-
"classnames": "^2.5.1",
5251
"cross-fetch": "^3.1.2",
5352
"d3-scale": "^3.2.3",
5453
"d3-scale-chromatic": "^1.3.3",
5554
"d3-shape": "^2.0.0",
5655
"highlight.js": "~9.8.0",
5756
"lodash": "^4.17.20",
5857
"monaco-editor": "^0.52.2",
59-
"oui-dom-events": "^0.2.2",
60-
"oui-dom-utils": "^0.3.8",
6158
"prop-types": "^15.8.1",
6259
"react": "^17.0.2",
6360
"react-dom": "^17.0.2",

src/components/Affix.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/components/Affix.tsx

Lines changed: 0 additions & 139 deletions
This file was deleted.

src/layouts/Frame.tsx

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Link } from 'react-router-dom';
33
import { RouteComponentProps, withRouter } from 'react-router';
44
import Helmet from 'react-helmet';
55
import { getLocaleType, localeGet } from '../utils/LocaleUtils.ts';
6-
import Affix from '../components/Affix';
76
import '../styles/app.scss';
87

98
const modules = ['guide', 'api', 'examples', 'blog', 'storybook'];
@@ -51,39 +50,37 @@ class Frame extends Component<FrameProps> {
5150
return (
5251
<div className="container">
5352
<Helmet titleTemplate="%s | Recharts" />
54-
<Affix>
55-
<header>
56-
<div className="header-wrapper">
57-
<h1 className="logo">
58-
<Link className="nav-logo" to={`/${locale}`}>
59-
&lt;Recharts /&gt;
60-
</Link>
61-
</h1>
62-
<nav>
63-
<ul className="nav" id="nav">
64-
{modules.map((entry, index) => (
65-
<li key={`item-${index}`}>
66-
<Link className={`nav-link ${entry === page ? 'active' : ''}`} to={`/${locale}/${entry}`}>
67-
{localeGet(locale, 'frame', entry)}
68-
</Link>
69-
</li>
70-
))}
71-
<li className="github-wrapper">
72-
<a
73-
href="https://github.com/recharts/recharts"
74-
target="_blank"
75-
className="nav-github"
76-
rel="noreferrer"
77-
>
78-
GitHub
79-
</a>
53+
<header>
54+
<div className="header-wrapper">
55+
<h1 className="logo">
56+
<Link className="nav-logo" to={`/${locale}`}>
57+
&lt;Recharts /&gt;
58+
</Link>
59+
</h1>
60+
<nav>
61+
<ul className="nav" id="nav">
62+
{modules.map((entry, index) => (
63+
<li key={`item-${index}`}>
64+
<Link className={`nav-link ${entry === page ? 'active' : ''}`} to={`/${locale}/${entry}`}>
65+
{localeGet(locale, 'frame', entry)}
66+
</Link>
8067
</li>
81-
<li className="language-switch-wrapper">{this.renderLocaleSwitch(locale)}</li>
82-
</ul>
83-
</nav>
84-
</div>
85-
</header>
86-
</Affix>
68+
))}
69+
<li className="github-wrapper">
70+
<a
71+
href="https://github.com/recharts/recharts"
72+
target="_blank"
73+
className="nav-github"
74+
rel="noreferrer"
75+
>
76+
GitHub
77+
</a>
78+
</li>
79+
<li className="language-switch-wrapper">{this.renderLocaleSwitch(locale)}</li>
80+
</ul>
81+
</nav>
82+
</div>
83+
</header>
8784
{children}
8885
<footer>
8986
<p>

src/styles/container.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ header {
55
width: 100%;
66
background-color: #fcfcfc;
77
box-shadow: 0 0 4px rgba(0,0,0,0.25);
8+
position: sticky;
9+
top: 0;
10+
z-index: 1000;
811

912
.header-wrapper {
1013
min-width: 1200px;

0 commit comments

Comments
 (0)