Skip to content

Commit b580ea1

Browse files
committed
better update notice & get rid of github change log redirect
1 parent e563462 commit b580ea1

File tree

5 files changed

+57
-21
lines changed

5 files changed

+57
-21
lines changed

src/pages/Background/helpers/InstallationHelper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ chrome.runtime.onInstalled.addListener((details) => {
1818
const prevVersion = details.previousVersion;
1919
console.log(thisVersion, prevVersion);
2020
}
21-
if (details.reason === 'install' || details.reason === 'update') {
21+
if (
22+
details.reason === 'install'
23+
// || details.reason === 'update'
24+
) {
2225
console.log('go to release log page');
2326
chrome.tabs.create({
2427
url: `https://github.com/lxieyang/vertical-tabs-chrome-extension/blob/master/CHANGELOG.md#v2x-official-releases`,

src/pages/Content/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import copy from 'clipboard-copy';
2-
import './helpers/UpdateNoticeHelper';
32
import './helpers/SidebarHelper';
43
import './helpers/TabPreviewHelper';
4+
import './helpers/UpdateNoticeHelper';
55

66
window.addEventListener('message', (event) => {
77
const { msg, payload } = event.data;

src/pages/Content/modules/UpdateNotice/UpdateNotice.jsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
import React, { useState } from 'react';
22
import styled from 'styled-components';
3-
import { FaSyncAlt, FaTimesCircle } from 'react-icons/fa';
3+
import { FaTimesCircle as DismissIcon } from 'react-icons/fa';
4+
import { MdRefresh as RefreshIcon } from 'react-icons/md';
45
import { APP_NAME_FULL } from '../../../../shared/constants';
56

67
const UpdateNoticeContainer = styled.div`
7-
max-width: 560px;
8+
max-width: 360px;
89
position: relative;
9-
background-color: #fff;
10-
border: 1px solid #ffb74d;
11-
padding: 8px 8px;
12-
border-radius: 4px;
10+
border: 2px solid #ff8f34;
11+
box-sizing: border-box;
12+
padding: 8px 16px;
13+
border-radius: 10px;
1314
color: #000;
14-
background-color: #fff3e0;
15+
background-color: #fff;
1516
1617
font-family: sans-serif;
1718
text-align: center;
1819
font-size: 14px;
1920
font-weight: 400;
2021
font-style: normal;
21-
box-shadow: 0 1px 6px 0 rgba(32, 33, 36, 0.28);
22+
box-shadow: 0 4px 10px 0 rgb(0 0 0 / 20%), 0 4px 20px 0 rgb(0 0 0 / 19%);
23+
line-height: 22px;
24+
25+
z-index: 999999999;
2226
`;
2327

2428
const ExtensionNameContainerSpan = styled.span`
25-
background-color: rgb(233, 115, 46);
26-
color: #fff;
27-
padding: 2px 4px;
29+
background-color: rgb(255, 196, 161);
30+
color: #000;
31+
padding: 2px 6px;
2832
border-radius: 4px;
2933
font-weight: 600;
3034
`;
@@ -42,12 +46,16 @@ const ActionButton = styled.div`
4246
display: flex;
4347
align-items: center;
4448
transition: all 0.05s ease-in;
45-
padding: 2px 6px;
49+
padding: 4px 8px;
4650
border-radius: 4px;
4751
52+
text-decoration: underline;
53+
4854
&:hover {
49-
background-color: rgb(233, 115, 46);
50-
color: #fff;
55+
background-color: ${(props) =>
56+
props.action === 'reload' ? '#198754' : 'gray'};
57+
color: ${(props) => (props.action === 'reload' ? '#fff' : '#fff')};
58+
text-decoration: none;
5159
}
5260
`;
5361

@@ -60,7 +68,7 @@ const UpdateNotice = () => {
6068
<div
6169
style={{
6270
position: 'fixed',
63-
bottom: 5,
71+
bottom: 10,
6472
left: 0,
6573
right: 0,
6674
display: 'flex',
@@ -78,21 +86,23 @@ const UpdateNotice = () => {
7886
</div>
7987
<ActionButtonsContainer>
8088
<ActionButton
89+
action={'reload'}
8190
onClick={() => {
8291
localStorage.removeItem('vt-update-notice-dismissed');
8392
window.location.reload();
8493
}}
8594
>
86-
<FaSyncAlt size="12px" style={{ marginRight: '4px' }} />
95+
<RefreshIcon size="20px" style={{ marginRight: '4px' }} />
8796
Refresh Now
8897
</ActionButton>
8998
<ActionButton
99+
action={'dismiss'}
90100
onClick={() => {
91101
localStorage.setItem('vt-update-notice-dismissed', 'true');
92102
setShouldDisplay(false);
93103
}}
94104
>
95-
<FaTimesCircle size="12px" style={{ marginRight: '4px' }} />
105+
<DismissIcon size="16px" style={{ marginRight: '4px' }} />
96106
Dismiss
97107
</ActionButton>
98108
</ActionButtonsContainer>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component } from 'react';
2+
3+
class ErrorBoundary extends Component {
4+
state = { hasError: false };
5+
6+
static getDerivedStateFromError(error) {
7+
return { hasError: true };
8+
}
9+
10+
componentDidCatch(error, errorInfo) {
11+
console.log({ error, errorInfo });
12+
}
13+
14+
render() {
15+
// if (this.state.hasError) {
16+
// return <h1>Oops, we done goofed up</h1>;
17+
// }
18+
return this.props.children;
19+
}
20+
}
21+
22+
export default ErrorBoundary;

src/pages/Sidebar/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DndProvider } from 'react-dnd';
44
import { HTML5Backend } from 'react-dnd-html5-backend';
55
import SnackbarProvider from 'react-simple-snackbar';
66
import MediaQuery from 'react-responsive';
7+
import EB from './containers/ErrorBoundary/ErrorBoundary';
78

89
import Sidebar from './Sidebar';
910
import './index.css';
@@ -50,7 +51,7 @@ const App = () => {
5051
}
5152

5253
return (
53-
<React.Fragment>
54+
<EB>
5455
<SnackbarProvider>
5556
<DarkModeContext.Provider
5657
value={{ mediaQueryDark, isDark, setDarkStatus }}
@@ -71,7 +72,7 @@ const App = () => {
7172
<div style={{ width: 0, height: 0 }}></div>
7273
</MediaQuery>
7374
</SnackbarProvider>
74-
</React.Fragment>
75+
</EB>
7576
);
7677
};
7778

0 commit comments

Comments
 (0)