Skip to content

Commit de47803

Browse files
authored
Merge pull request #1038 from webpack/advertisement-feature
Advertisement
2 parents 26fbff6 + 8f501b3 commit de47803

File tree

7 files changed

+71
-8
lines changed

7 files changed

+71
-8
lines changed

assets/ag-grid-logo.png

6.31 KB
Loading

components/link/link.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if (__DEV__) {
66
RRouter = require('react-router');
77
}
88

9-
const Link = ({ to, ...props }) => {
9+
export default ({ to, ...props }) => {
1010
if (startsWith(to, 'http') || startsWith(to, '//')) {
1111
return <a href={to} target="_blank" {...props} />;
1212
}
@@ -17,5 +17,3 @@ const Link = ({ to, ...props }) => {
1717

1818
return <a href={to} {...props} />;
1919
};
20-
21-
export default Link;

components/page/page.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Gitter from '../gitter/gitter';
66
import Contributors from '../contributors/contributors';
77
import './page-style';
88
import '../sidebar/sidebar-style';
9+
import '../sponsors/sponsors-style';
910
import '../gitter/gitter-style';
1011
import { trimEnd } from 'lodash';
1112

components/sidebar/sidebar-style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
overflow: auto;
99

1010
@include break {
11-
display:block;
11+
display: block;
1212
}
1313
}
1414

components/sidebar/sidebar.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { Component } from 'react';
22
import SidebarItem from '../sidebar-item/sidebar-item';
3+
import Sponsors from '../sponsors/sponsors';
34

45
export default class Sidebar extends Component {
56
constructor(props) {
@@ -8,13 +9,14 @@ export default class Sidebar extends Component {
89
this.state = {
910
fixed: false,
1011
availableHeight: null,
11-
maxWidth: null
12+
maxWidth: null,
13+
adDistance: null
1214
};
1315
}
1416

1517
render() {
1618
let { sectionName, pages, currentPage } = this.props;
17-
let { fixed, availableHeight, maxWidth } = this.state;
19+
let { fixed, availableHeight, maxWidth, adDistance } = this.state;
1820
let isGuides = sectionName === 'guides';
1921

2022
return (
@@ -28,6 +30,10 @@ export default class Sidebar extends Component {
2830
maxHeight: availableHeight
2931
}}>
3032

33+
<Sponsors
34+
distanceFromTop={ adDistance }
35+
height={ availableHeight } />
36+
3137
<div className="sidebar__inner">
3238
<h3 className="sidebar-item__version">Version 2.2</h3>
3339

@@ -56,6 +62,11 @@ export default class Sidebar extends Component {
5662
}
5763

5864
componentDidMount() {
65+
setTimeout(
66+
this._recalculate.bind(this),
67+
250
68+
);
69+
5970
document.addEventListener(
6071
'scroll',
6172
this._recalculate.bind(this)
@@ -78,7 +89,7 @@ export default class Sidebar extends Component {
7889
let { scrollHeight } = document.body;
7990
let { offsetHeight: sidebarHeight } = this._container;
8091
let { offsetWidth: parentWidth, offsetHeight: parentHeight } = this._container.parentNode;
81-
let headerHeight = document.querySelector('header').offsetHeight;
92+
let headerHeight = document.querySelector('header').offsetHeight + document.querySelector('.notification-bar').offsetHeight;
8293
let footerHeight = document.querySelector('footer').offsetHeight;
8394
let distToBottom = scrollHeight - scrollY - innerHeight;
8495

@@ -89,7 +100,8 @@ export default class Sidebar extends Component {
89100
this.setState({
90101
fixed: scrollY >= headerHeight && sidebarHeight < parentHeight,
91102
availableHeight: innerHeight - headerSpace - footerSpace,
92-
maxWidth: parentWidth
103+
maxWidth: parentWidth,
104+
adDistance: scrollY < headerHeight ? headerHeight - scrollY : 0
93105
});
94106
}
95107
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import 'functions';
2+
3+
.sponsors {
4+
position: fixed;
5+
display: flex;
6+
width: 250px;
7+
margin-top: 1.5em;
8+
margin-left: calc(-250px - 1.5em);
9+
padding: 0 1.5em;
10+
flex-wrap: wrap;
11+
justify-content: center;
12+
align-items: flex-start;
13+
align-content: flex-start;
14+
border-right: 1px solid getColor(concrete);
15+
overflow: hidden;
16+
transition: background-color 250ms;
17+
18+
&:hover {
19+
background-color: getColor(concrete);
20+
}
21+
}

components/sponsors/sponsors.jsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import Link from '../link/link';
3+
4+
// Imports for Ad Content
5+
import AGLogo from '../../assets/ag-grid-logo.png';
6+
import WebpackIcon from '../../assets/icon-square-small.svg';
7+
8+
export default ({ distanceFromTop, height }) => {
9+
return (
10+
<Link
11+
className="sponsors"
12+
to="https://www.ag-grid.com/?utm_source=webpack&utm_medium=banner&utm_campaign=sponsorship"
13+
style={{
14+
top: distanceFromTop,
15+
height: `calc(${height}px - 3em)`
16+
}}>
17+
18+
<img src={ AGLogo } />
19+
<img src={ WebpackIcon } style={{ width: '100px' }} />
20+
<div style={{
21+
marginTop: '1em',
22+
fontSize: '2em',
23+
textAlign: 'center',
24+
color: '#535353'
25+
}}>
26+
ag-grid is proud to partner with webpack
27+
</div>
28+
29+
</Link>
30+
);
31+
};

0 commit comments

Comments
 (0)