Skip to content

Commit 492b639

Browse files
authored
feat: Migrate to TailwindCSS (gitify-app#452)
* chore: Setup TailwindCSS * feat: Migrate all styles to TailwindCSS * chore: Remove styled-components dependency * chore: Convert nprogress bar component to use hooks * chore: Fix Tests * chore: Don't change the message/emoji on every request * chore: Purge config for tailwind
1 parent 86c1744 commit 492b639

36 files changed

+973
-1227
lines changed

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.17.0
1+
12.20.0

index.html

+47
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,51 @@
1313
</body>
1414

1515
<script src="./build/js/app.js"></script>
16+
17+
<style>
18+
html,
19+
body {
20+
height: 100%;
21+
-webkit-user-select: none;
22+
}
23+
24+
body {
25+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
26+
'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
27+
'Helvetica Neue', sans-serif;
28+
margin: 0;
29+
cursor: default;
30+
}
31+
32+
#gitify {
33+
height: 100%;
34+
}
35+
36+
.notification-exit {
37+
transform: translate3d(0px, 0, 0);
38+
opacity: 1;
39+
transition-duration: 250ms;
40+
transition-timing-function: cubic-bezier(0.175, 0.665, 0.32, 1), linear;
41+
}
42+
43+
.notification-exit.notification-exit-active {
44+
transform: translate3d(350px, 0, 0);
45+
opacity: 0;
46+
}
47+
48+
#nprogress {
49+
pointer-events: none;
50+
}
51+
52+
#nprogress .bar {
53+
position: fixed;
54+
top: 0;
55+
left: 50px;
56+
z-index: 1031;
57+
background: #203354;
58+
59+
width: 100%;
60+
height: 2px;
61+
}
62+
</style>
1663
</html>

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@
107107
},
108108
"dependencies": {
109109
"@primer/octicons-react": "^11.1.0",
110+
"autoprefixer": "^10.1.0",
110111
"axios": "=0.21.0",
111112
"date-fns": "^2.16.1",
112113
"electron-updater": "^4.3.5",
113114
"final-form": "^4.19.1",
114115
"lodash": "^4.17.20",
115116
"menubar": "^9.0.1",
116117
"nprogress": "=0.2.0",
118+
"postcss": "^8.2.1",
117119
"react": "=16.13.1",
118120
"react-dom": "=16.13.1",
119121
"react-emojione": "=5.0.1",
@@ -128,7 +130,7 @@
128130
"redux-storage-decorator-filter": "=1.1.8",
129131
"redux-storage-engine-localstorage": "=1.1.4",
130132
"redux-thunk": "=2.3.0",
131-
"styled-components": "^5.0.1",
133+
"tailwindcss": "^2.0.2",
132134
"ts-loader": "^8.0.11",
133135
"typescript": "^4.1.2"
134136
},
@@ -141,14 +143,17 @@
141143
"@types/react-redux": "^7.1.7",
142144
"@types/react-transition-group": "^4.2.4",
143145
"@types/styled-components": "^5.0.1",
146+
"css-loader": "^5.0.1",
144147
"electron": "^11.0.2",
145148
"electron-builder": "^22.9.1",
146149
"electron-notarize": "^1.0.0",
147150
"jest": "^26.6.3",
148151
"nock": "^12.0.3",
152+
"postcss-loader": "^4.1.0",
149153
"prettier": "=2.2.0",
150154
"react-test-renderer": "=16.13.1",
151155
"redux-mock-store": "=1.5.4",
156+
"style-loader": "^2.0.0",
152157
"ts-jest": "^26.4.4",
153158
"webpack": "^5.6.0",
154159
"webpack-cli": "^4.2.0",

postcss.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

src/js/app.tsx

+14-97
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ import {
66
Switch,
77
} from 'react-router-dom';
88
import { Provider } from 'react-redux';
9-
import styled, {
10-
ThemeProvider,
11-
createGlobalStyle,
12-
DefaultTheme,
13-
} from 'styled-components';
149

1510
import configureStore from './store/configureStore';
1611
import Loading from './components/loading';
17-
import Sidebar, { SIDEBAR_WIDTH } from './components/sidebar';
12+
import Sidebar from './components/sidebar';
1813

1914
import EnterpriseLoginRoute from './routes/enterprise-login';
2015
import LoginRoute from './routes/login';
@@ -46,100 +41,22 @@ export const PrivateRoute = ({ component: Component, ...rest }) => {
4641
);
4742
};
4843

49-
const theme: DefaultTheme = {
50-
borderRadius: '3px',
51-
52-
primary: '#203354',
53-
success: '#2CC966',
54-
info: '#8BA9C6',
55-
warning: '#FCAA67',
56-
danger: '#B7524F',
57-
58-
grayLighter: '#f9fafa',
59-
grayLight: '#eceeef',
60-
grayDarker: '#3d3f41',
61-
grayDark: '#55595C',
62-
63-
primaryDark: '#071A3B',
64-
};
65-
66-
const GlobalStyle = createGlobalStyle`
67-
html,
68-
body {
69-
height: 100%;
70-
-webkit-user-select: none;
71-
}
72-
73-
body {
74-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
75-
'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
76-
sans-serif;
77-
margin: 0;
78-
cursor: default;
79-
}
80-
81-
#gitify {
82-
height: 100%;
83-
}
84-
85-
button {
86-
&:hover {
87-
cursor: pointer;
88-
}
89-
}
90-
91-
#nprogress {
92-
pointer-events: none;
93-
94-
.bar {
95-
position: fixed;
96-
top: 0;
97-
left: ${SIDEBAR_WIDTH};
98-
z-index: 1031;
99-
background: ${(props) => props.theme.primary};
100-
101-
width: 100%;
102-
height: 2px;
103-
}
104-
}
105-
106-
.notification-exit {
107-
transform: translate3d(0px, 0, 0);
108-
opacity: 1;
109-
transition-duration: 250ms;
110-
transition-timing-function: cubic-bezier(0.175, 0.665, 0.32, 1), linear;
111-
112-
&.notification-exit-active {
113-
transform: translate3d(350px, 0, 0);
114-
opacity: 0;
115-
}
116-
}
117-
`;
118-
119-
const Wrapper = styled.div`
120-
height: 100%;
121-
padding-left: ${SIDEBAR_WIDTH};
122-
`;
123-
12444
export const App = () => {
12545
return (
12646
<Provider store={store}>
127-
<ThemeProvider theme={theme}>
128-
<Router>
129-
<GlobalStyle />
130-
<Wrapper>
131-
<Loading />
132-
<Sidebar />
133-
134-
<Switch>
135-
<PrivateRoute path="/" exact component={NotificationsRoute} />
136-
<PrivateRoute path="/settings" exact component={SettingsRoute} />
137-
<Route path="/login" component={LoginRoute} />
138-
<Route path="/enterpriselogin" component={EnterpriseLoginRoute} />
139-
</Switch>
140-
</Wrapper>
141-
</Router>
142-
</ThemeProvider>
47+
<Router>
48+
<div className="flex flex-col pl-14 h-full">
49+
<Loading />
50+
<Sidebar />
51+
52+
<Switch>
53+
<PrivateRoute path="/" exact component={NotificationsRoute} />
54+
<PrivateRoute path="/settings" exact component={SettingsRoute} />
55+
<Route path="/login" component={LoginRoute} />
56+
<Route path="/enterpriselogin" component={EnterpriseLoginRoute} />
57+
</Switch>
58+
</div>
59+
</Router>
14360
</Provider>
14461
);
14562
};

src/js/components/__snapshots__/account-notifications.test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`components/account-notifications.tsx should render itself (github.com with notifications) 1`] = `
44
<div
5-
className="sc-AxjAm hCwqHM"
5+
className="flex flex-1 items-center justify-between py-2 px-4 bg-gray-300 text-sm"
66
>
77
github.com
88
<svg
@@ -31,7 +31,7 @@ exports[`components/account-notifications.tsx should render itself (github.com w
3131

3232
exports[`components/account-notifications.tsx should render itself (github.com without notifications) 1`] = `
3333
<div
34-
className="sc-AxjAm hCwqHM"
34+
className="flex flex-1 items-center justify-between py-2 px-4 bg-gray-300 text-sm"
3535
>
3636
github.com
3737
<svg

src/js/components/__snapshots__/all-read.test.tsx.snap

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22

33
exports[`components/all-read.tsx should render itself & its children 1`] = `
44
<div
5-
className="sc-AxjAm bVUrJb"
5+
className="flex flex-1 flex-col justify-center items-center p-4"
66
>
7-
<div
8-
className="sc-AxirZ joxCwg"
7+
<h1
8+
className="text-5xl mb-5"
99
>
1010
😉
11-
</div>
11+
</h1>
1212
<h2
13-
className="sc-AxiKw dlazZW"
13+
className="font-semibold text-xl mb-2 text-semibold"
1414
/>
15-
<h4
16-
className="sc-AxhCb jUqlrV"
17-
>
15+
<div>
1816
No new notifications.
19-
</h4>
17+
</div>
2018
</div>
2119
`;

src/js/components/__snapshots__/notification.test.tsx.snap

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
exports[`components/notification.js should render itself & its children 1`] = `
44
<div
5-
className="sc-AxjAm esvKhw"
5+
className="flex space-x-2 p-2 bg-white hover:bg-gray-100 border-b border-gray-100"
66
>
77
<div
8-
className="sc-AxhUy cNkvzS"
8+
className="flex justify-center items-center w-8"
99
>
1010
<svg
1111
aria-hidden="false"
@@ -17,7 +17,7 @@ exports[`components/notification.js should render itself & its children 1`] = `
1717
}
1818
}
1919
fill="currentColor"
20-
height={20}
20+
height={18}
2121
role="img"
2222
style={
2323
Object {
@@ -27,21 +27,21 @@ exports[`components/notification.js should render itself & its children 1`] = `
2727
}
2828
}
2929
viewBox="0 0 16 16"
30-
width={20}
30+
width={18}
3131
/>
3232
</div>
3333
<div
34-
className="sc-AxirZ ibrlFv"
34+
className="flex-1 overflow-hidden"
3535
onClick={[Function]}
3636
role="main"
3737
>
38-
<h6
39-
className="sc-AxiKw fXbfXY"
38+
<div
39+
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden"
4040
>
4141
I am a robot and this is a test!
42-
</h6>
42+
</div>
4343
<div
44-
className="sc-AxhCb fqclhB"
44+
className="text-xs text-capitalize"
4545
>
4646
<span
4747
title="You're watching the repository."
@@ -52,14 +52,14 @@ exports[`components/notification.js should render itself & its children 1`] = `
5252
5353
in over 3 years
5454
<button
55-
className="sc-AxheI hMkKFy"
55+
className="border-0 bg-none float-right"
5656
onClick={[Function]}
5757
title="Unsubscribe"
5858
>
5959
<svg
6060
aria-hidden="false"
6161
aria-label="Unsubscribe"
62-
className="octicon"
62+
className="hover:text-red-500"
6363
dangerouslySetInnerHTML={
6464
Object {
6565
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M8 2.75a.75.75 0 00-1.238-.57L3.472 5H1.75A1.75 1.75 0 000 6.75v2.5C0 10.216.784 11 1.75 11h1.723l3.289 2.82A.75.75 0 008 13.25V2.75zM4.238 6.32L6.5 4.38v7.24L4.238 9.68a.75.75 0 00-.488-.18h-2a.25.25 0 01-.25-.25v-2.5a.25.25 0 01.25-.25h2a.75.75 0 00.488-.18zm7.042-1.1a.75.75 0 10-1.06 1.06L11.94 8l-1.72 1.72a.75.75 0 101.06 1.06L13 9.06l1.72 1.72a.75.75 0 101.06-1.06L14.06 8l1.72-1.72a.75.75 0 00-1.06-1.06L13 6.94l-1.72-1.72z\\"></path>",
@@ -82,17 +82,17 @@ exports[`components/notification.js should render itself & its children 1`] = `
8282
</div>
8383
</div>
8484
<div
85-
className="sc-AxhUy cNkvzS"
85+
className="flex justify-center items-center w-8"
8686
>
8787
<button
88-
className="sc-AxgMl beGRRX"
88+
className="focus:outline-none"
8989
onClick={[Function]}
9090
title="Mark as Read"
9191
>
9292
<svg
9393
aria-hidden="false"
9494
aria-label="Mark as Read"
95-
className="octicon"
95+
className="hover:text-green-500"
9696
dangerouslySetInnerHTML={
9797
Object {
9898
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z\\"></path>",

src/js/components/__snapshots__/oops.test.tsx.snap

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22

33
exports[`components/oops.tsx should render itself & its children 1`] = `
44
<div
5-
className="sc-AxjAm bVUrJb"
5+
className="flex flex-1 flex-col justify-center items-center p-4"
66
>
7-
<div
8-
className="sc-AxirZ joxCwg"
7+
<h1
8+
className="text-5xl mb-5"
99
>
1010
😔
11-
</div>
11+
</h1>
1212
<h2
13-
className="sc-AxiKw dlazZW"
13+
className="font-semibold text-xl mb-2 text-semibold"
1414
>
1515
Something went wrong.
1616
</h2>
17-
<h4
18-
className="sc-AxhCb jUqlrV"
19-
>
17+
<div>
2018
Couldn't get your notifications.
21-
</h4>
19+
</div>
2220
</div>
2321
`;

0 commit comments

Comments
 (0)