Skip to content

Commit b440447

Browse files
author
Ives van Hoorne
committed
Add Patron badge to header
1 parent 760702e commit b440447

File tree

4 files changed

+50
-20
lines changed

4 files changed

+50
-20
lines changed

src/app/containers/Navigation/index.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import styled from 'styled-components';
44
import { connect } from 'react-redux';
55
import { Link } from 'react-router-dom';
66

7-
import SearchIcon from 'react-icons/lib/md/search';
8-
97
import SignInButton from 'app/containers/SignInButton';
108

119
import Logo from 'app/components/Logo';
1210
import Row from 'app/components/flex/Row';
1311
import Tooltip from 'app/components/Tooltip';
1412
import HeaderSearchBar from 'app/components/HeaderSearchBar';
1513

16-
import { jwtSelector } from 'app/store/user/selectors';
17-
import { newSandboxUrl, searchUrl } from 'app/utils/url-generator';
14+
import { jwtSelector, isPatronSelector } from 'app/store/user/selectors';
15+
import { newSandboxUrl, patronUrl } from 'app/utils/url-generator';
16+
// $FlowIssue
17+
import PatronBadge from '-!svg-react-loader!app/utils/badges/svg/patron-4.svg'; // eslint-disable-line import/no-webpack-loader-syntax
1818

1919
import UserMenu from '../UserMenu';
2020

@@ -71,16 +71,18 @@ const PlusIcon = styled(Link)`
7171
type Props = {
7272
title: string,
7373
hasLogin: boolean,
74+
isPatron: boolean,
7475
};
7576

7677
const mapStateToProps = state => ({
7778
hasLogin: !!jwtSelector(state),
79+
isPatron: isPatronSelector(state),
7880
});
7981
class Navigation extends React.PureComponent {
8082
props: Props;
8183

8284
render() {
83-
const { title, hasLogin } = this.props;
85+
const { title, hasLogin, isPatron } = this.props;
8486

8587
return (
8688
<Row justifyContent="space-between">
@@ -98,6 +100,14 @@ class Navigation extends React.PureComponent {
98100
<Action>
99101
<HeaderSearchBar />
100102
</Action>
103+
{!isPatron &&
104+
<Action>
105+
<Tooltip position="bottom" title="Become a Patron">
106+
<Link to={patronUrl()}>
107+
<PatronBadge width={40} height={40} />
108+
</Link>
109+
</Tooltip>
110+
</Action>}
101111
<Action>
102112
<Tooltip title="New Sandbox">
103113
<PlusIcon to={newSandboxUrl()}>+</PlusIcon>

src/app/containers/UserMenu/UserMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default ({ username, openPreferences, signOut }: Props) =>
7272
<Item>
7373
<Icon>
7474
<PatronBadge style={{ width: 24, margin: '-6px -5px' }} size={24} />
75-
</Icon>Become a Patron
75+
</Icon>Patron Page
7676
</Item>
7777
</Link>
7878
<Item onClick={signOut}>

src/app/pages/Sandbox/Editor/Content/Header/Action.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ type Props = {
9191
moreInfo: ?boolean,
9292
unresponsive: boolean,
9393
a: ?boolean,
94+
iconProps: Object,
95+
iconContainerProps: Object,
9496
};
9597

9698
export default ({
@@ -104,16 +106,20 @@ export default ({
104106
moreInfo,
105107
unresponsive,
106108
a,
109+
iconProps = {},
110+
iconContainerProps = {},
111+
...props
107112
}: Props) => {
108113
if (!href && (placeholder || tooltip)) {
109114
return (
110115
<ActionTooltip
111116
disabledAction={!onClick}
112117
title={placeholder || tooltip}
113118
hideOnClick={false}
119+
{...props}
114120
>
115-
<IconContainer onClick={onClick}>
116-
<Icon />
121+
<IconContainer onClick={onClick} {...iconContainerProps}>
122+
<Icon {...iconProps} />
117123
{title !== undefined &&
118124
<Title unresponsive={unresponsive}>
119125
{title}
@@ -125,9 +131,9 @@ export default ({
125131
}
126132
if (onClick) {
127133
return (
128-
<Action disabledAction={!onClick} highlight={highlight}>
129-
<IconContainer onClick={onClick}>
130-
<Icon />
134+
<Action disabledAction={!onClick} highlight={highlight} {...props}>
135+
<IconContainer onClick={onClick} {...iconContainerProps}>
136+
<Icon {...iconProps} />
131137
{title !== undefined &&
132138
<Title unresponsive={unresponsive}>
133139
{title}
@@ -142,8 +148,8 @@ export default ({
142148
return (
143149
<ActionA href={href} target="_blank" rel="noopener noreferrer">
144150
<Tooltip title={placeholder || tooltip}>
145-
<IconContainer>
146-
<Icon />
151+
<IconContainer {...iconContainerProps}>
152+
<Icon {...iconProps} />
147153
{title !== undefined &&
148154
<Title unresponsive={unresponsive}>
149155
{title}
@@ -157,10 +163,10 @@ export default ({
157163

158164
if (href && (placeholder || tooltip)) {
159165
return (
160-
<ActionLink to={href}>
166+
<ActionLink to={href} {...props}>
161167
<Tooltip title={placeholder || tooltip}>
162168
<IconContainer>
163-
<Icon />
169+
<Icon {...iconProps} />
164170
{title !== undefined &&
165171
<Title unresponsive={unresponsive}>
166172
{title}
@@ -173,9 +179,9 @@ export default ({
173179
}
174180

175181
return (
176-
<ActionLink to={href}>
177-
<IconContainer>
178-
<Icon />
182+
<ActionLink to={href} {...props}>
183+
<IconContainer {...iconContainerProps}>
184+
<Icon {...iconProps} />
179185
{title !== undefined &&
180186
<Title unresponsive={unresponsive}>
181187
{title}

src/app/pages/Sandbox/Editor/Content/Header/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ import {
2222
searchUrl,
2323
newSandboxUrl,
2424
importFromGitHubUrl,
25+
patronUrl,
2526
} from 'app/utils/url-generator';
2627
import ModeIcons from 'app/components/sandbox/ModeIcons';
2728

29+
// $FlowIssue
30+
import PatronBadge from '-!svg-react-loader!app/utils/badges/svg/patron-2.svg'; // eslint-disable-line import/no-webpack-loader-syntax
2831
import Margin from 'app/components/spacing/Margin';
2932
import HeaderSearchBar from 'app/components/HeaderSearchBar';
3033
import UserMenu from 'app/containers/UserMenu';
@@ -201,7 +204,7 @@ export default class Header extends React.PureComponent {
201204
</Left>
202205

203206
<Right>
204-
<Media query="(max-width: 1450px)">
207+
<Media query="(max-width: 1560px)">
205208
{matches =>
206209
matches
207210
? <Action
@@ -214,6 +217,18 @@ export default class Header extends React.PureComponent {
214217
</div>}
215218
</Media>
216219

220+
{!user ||
221+
(!user.subscription &&
222+
<Action
223+
href={patronUrl()}
224+
tooltip="Become a Patron"
225+
Icon={PatronBadge}
226+
iconProps={{
227+
width: 16,
228+
height: 32,
229+
transform: 'scale(1.5, 1.5)',
230+
}}
231+
/>)}
217232
<Action
218233
href="https://twitter.com/CompuIves"
219234
a
@@ -229,7 +244,6 @@ export default class Header extends React.PureComponent {
229244
tooltip="Import from GitHub"
230245
Icon={GithubIcon}
231246
/>
232-
233247
<Action
234248
href={newSandboxUrl()}
235249
tooltip="New Sandbox"

0 commit comments

Comments
 (0)