Skip to content

Commit 1784eca

Browse files
author
Emre Bogazliyanlioglu
committed
feat: Light mode theme for Connect
Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz>
1 parent e1dfc49 commit 1784eca

22 files changed

Lines changed: 245 additions & 160 deletions

src/SampleApp.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import SampleApp from './components/SampleApp';
55

66
// This is the sample app used for local development
77

8-
const container = document.getElementById('root')!;
9-
const root = ReactDOM.createRoot(container);
8+
const root = ReactDOM.createRoot(
9+
document.getElementById('root') as HTMLElement,
10+
);
1011

1112
root.render(
1213
<React.StrictMode>

src/components/SampleApp/styles.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ body {
88

99
main {
1010
width: 100%;
11-
min-height: 100%;
11+
min-height: 100vh;
12+
display: flex;
13+
flex-direction: column;
1214
}
1315

1416
aside textarea,
@@ -30,6 +32,7 @@ main a:hover {
3032

3133
article {
3234
display: flex;
35+
flex: 1;
3336
}
3437

3538
#sample-app {

src/components/v3/Button.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,33 @@ const BASE_BUTTON_STYLES: SxProps<Theme> = {
2424
} as const;
2525

2626
const PRIMARY_BUTTON_STYLES: SxProps<Theme> = {
27-
backgroundColor: 'button.primary',
28-
color: 'button.primaryText',
27+
backgroundColor: (theme) => theme.palette.button.primary,
28+
color: (theme) => theme.palette.button.primaryText,
2929
'&.Mui-disabled': {
30-
backgroundColor: 'button.disabled',
31-
color: 'button.disabledText',
30+
backgroundColor: (theme) => theme.palette.button.disabled,
31+
color: (theme) => theme.palette.button.disabledText,
3232
},
3333
'&:hover': {
3434
boxShadow: 'none',
35-
backgroundColor: 'button.hover',
35+
backgroundColor: (theme) => theme.palette.button.hover,
3636
'&:disabled': {
37-
backgroundColor: 'button.disabled',
38-
color: 'button.disabledText',
37+
backgroundColor: (theme) => theme.palette.button.disabled,
38+
color: (theme) => theme.palette.button.disabledText,
3939
},
4040
},
4141
'&:active': {
4242
boxShadow: 'none',
43-
backgroundColor: 'button.action',
44-
color: 'button.actionText',
43+
backgroundColor: (theme) => theme.palette.button.action,
44+
color: (theme) => theme.palette.button.actionText,
4545
},
4646
} as const;
4747

4848
const ERROR_BUTTON_STYLES: SxProps<Theme> = {
49-
backgroundColor: 'error.main',
50-
color: 'error.contrastText',
49+
backgroundColor: (theme) => theme.palette.error.main,
50+
color: (theme) => theme.palette.error.contrastText,
5151
'&:disabled': {
52-
backgroundColor: 'error.main',
53-
color: 'error.contrastText',
52+
backgroundColor: (theme) => theme.palette.error.main,
53+
color: (theme) => theme.palette.error.contrastText,
5454
opacity: 0.4,
5555
},
5656
} as const;

src/icons/Plus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const PlusIcon = createSvgIcon(
99
fill="none"
1010
xmlns="http://www.w3.org/2000/svg"
1111
>
12-
<rect width="36" height="36" rx="6" fill="#2E2E34" />
12+
<rect width="36" height="36" rx="6" fill="currentColor" />
1313
<path
1414
d="M17.1429 17.6429V12.5H18.8571V17.6429H24V19.3571H18.8571V24.5H17.1429V19.3571H12V17.6429H17.1429Z"
1515
fill="white"

src/theme.ts

Lines changed: 98 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { createTheme } from '@mui/material/styles';
22
import type { PaletteMode, Theme } from '@mui/material';
33
import { OPACITY } from './utils/style';
44
import Color from 'color';
5-
import { grey } from '@mui/material/colors';
65

76
export type WormholeConnectTheme = {
87
// "dark" or "light"
@@ -33,17 +32,12 @@ export type WormholeConnectTheme = {
3332

3433
type Color = { main: string };
3534

36-
type BackgroundType = {
37-
default: string;
38-
form?: string;
39-
};
40-
4135
export type InternalTheme = {
4236
mode: PaletteMode;
4337
primary: Color;
4438
secondary: Color;
4539
divider: string;
46-
background: BackgroundType;
40+
background: { default: string };
4741
text: {
4842
primary: string;
4943
secondary: string;
@@ -82,6 +76,16 @@ export type InternalTheme = {
8276
border: string;
8377
fillTreatment: boolean;
8478
};
79+
icon: {
80+
primary: string;
81+
secondary: string;
82+
};
83+
toggle: {
84+
background: string;
85+
text: string;
86+
active: string;
87+
activeText: string;
88+
};
8589
formContainer?: {
8690
background: string;
8791
border: string;
@@ -92,17 +96,16 @@ export type InternalTheme = {
9296

9397
export const light: InternalTheme = {
9498
mode: 'light',
95-
primary: { main: '#9892e6' },
99+
primary: { main: '#A89EFF' },
96100
secondary: { main: '#cccccc' },
97101
divider: '#a0a2a9',
98102
background: {
99103
default: 'transparent',
100-
form: '#ffffff',
101104
},
102105
text: {
103-
primary: grey[900],
104-
secondary: '#7d7d7d',
105-
tertiary: '#78787880',
106+
primary: '#3F3F46',
107+
secondary: '#71717B',
108+
tertiary: '#9F9FA9',
106109
accent: '#9891DA',
107110
},
108111
error: { main: '#f44336' },
@@ -112,33 +115,47 @@ export const light: InternalTheme = {
112115
success: { main: '#4caf50' },
113116
warning: { main: '#ff9800' },
114117
button: {
115-
primary: '#ffffff',
116-
primaryText: grey[900],
117-
disabled: '#c8cad1',
118-
disabledText: grey[800],
119-
action: '#F3A01E',
120-
actionText: '#000000',
121-
hover: '#b7b9c1',
118+
primary: '#A89EFF',
119+
primaryText: '#F9F9FB',
120+
disabled: '#F3F4F6',
121+
disabledText: '#99A1AF',
122+
action: '#A89EFF',
123+
actionText: '#F9F9FB',
124+
hover: '#A89EFF',
122125
},
123126
options: {
124127
hover: '#f9f9fb',
125128
select: '#F0F0F5',
126129
},
127130
card: {
128-
background: '#ffffff',
131+
background: '#F0F0F5',
129132
elevation: '10px 10px 30px 15px #CCD2E7',
130133
secondary: '#F0F0F5',
131134
},
132135
popover: {
133-
background: '#ffffff',
136+
background: '#FFFFFF',
134137
elevation: '10px 10px 30px 15px #CCD2E7',
135138
secondary: '#F0F0F5',
136139
},
137140
input: {
138-
background: '#f9f9f9',
139-
border: '#DEE0E3',
141+
background: '#F9F9FB',
142+
border: '#E8E6F0',
140143
fillTreatment: true,
141144
},
145+
icon: {
146+
primary: '#101828',
147+
secondary: '#99A1AF',
148+
},
149+
toggle: {
150+
background: '#E5E7EB',
151+
text: '#71717B',
152+
active: '#A89EFF',
153+
activeText: '#FFFFFF',
154+
},
155+
formContainer: {
156+
background: '#FBFAF9',
157+
border: '#E4E4E7',
158+
},
142159
font: '"Inter", sans-serif',
143160
logo: '#000000',
144161
};
@@ -151,12 +168,11 @@ export const dark: InternalTheme = {
151168
divider: '#ffffff' + OPACITY[20],
152169
background: {
153170
default: 'transparent',
154-
form: '#0E0D12',
155171
},
156172
text: {
157173
primary: '#ffffff',
158-
secondary: '#79859e',
159-
tertiary: 'rgba(255,255,255,0.5)',
174+
secondary: '#71717B',
175+
tertiary: '#52525C',
160176
accent: '#ffffff',
161177
},
162178
info: {
@@ -172,13 +188,13 @@ export const dark: InternalTheme = {
172188
main: '#F79009',
173189
},
174190
button: {
175-
primary: '#ffffff' + OPACITY[10],
176-
primaryText: '#ffffff',
177-
disabled: '#ffffff' + OPACITY[7],
178-
disabledText: '#ffffff' + OPACITY[40],
179-
action: '#ffffff',
180-
actionText: '#000000',
181-
hover: '#ffffff' + OPACITY[7],
191+
primary: '#AFA7F6',
192+
primaryText: '#12111A',
193+
disabled: '#3F3F46',
194+
disabledText: '#71717B',
195+
action: '#AFA7F6',
196+
actionText: '#12111A',
197+
hover: '#9891DA',
182198
},
183199
options: {
184200
hover: '#ffffff' + OPACITY[7],
@@ -195,10 +211,24 @@ export const dark: InternalTheme = {
195211
elevation: 'none',
196212
},
197213
input: {
198-
background: '#1B1A21',
199-
border: '#2B2A2E',
214+
background: '#18181B',
215+
border: '#3F3F46',
200216
fillTreatment: true,
201217
},
218+
icon: {
219+
primary: '#F9FAFB',
220+
secondary: '#6A7282',
221+
},
222+
toggle: {
223+
background: '#18181B',
224+
text: '#9F9FA9',
225+
active: '#3C3A50',
226+
activeText: '#F4F4F5',
227+
},
228+
formContainer: {
229+
background: '#0E0D12',
230+
border: '#333333',
231+
},
202232
font: '"Inter", sans-serif',
203233
logo: '#ffffff',
204234
};
@@ -229,6 +259,39 @@ export const generateTheme = (customTheme: WormholeConnectTheme): Theme => {
229259
theme.primary = {
230260
main: customTheme.primary,
231261
};
262+
const buttonPrimary = Color(customTheme.primary || theme.primary.main);
263+
let primaryText: string;
264+
let disabled: string;
265+
let disabledText: string;
266+
let action: string;
267+
let actionText: string;
268+
let hover: string;
269+
270+
if (buttonPrimary.isDark()) {
271+
primaryText = buttonPrimary.lightness(95).hex();
272+
disabled = buttonPrimary.alpha(0.5).hexa();
273+
disabledText = buttonPrimary.lightness(95).alpha(0.9).hexa();
274+
action = buttonPrimary.darken(0.15).hex();
275+
actionText = buttonPrimary.lightness(80).hex();
276+
hover = buttonPrimary.darken(0.05).hex();
277+
} else {
278+
primaryText = buttonPrimary.lightness(5).hex();
279+
disabled = buttonPrimary.alpha(0.5).hexa();
280+
disabledText = buttonPrimary.lightness(5).alpha(0.9).hexa();
281+
action = buttonPrimary.lighten(0.05).hex();
282+
actionText = buttonPrimary.lightness(0).hex();
283+
hover = buttonPrimary.lighten(0.05).hex();
284+
}
285+
286+
theme.button = {
287+
primary: buttonPrimary.hex(),
288+
primaryText,
289+
disabled,
290+
disabledText,
291+
action,
292+
actionText,
293+
hover,
294+
};
232295
}
233296
if (customTheme.secondary) {
234297
theme.secondary = {
@@ -251,40 +314,6 @@ export const generateTheme = (customTheme: WormholeConnectTheme): Theme => {
251314
main: customTheme.success,
252315
};
253316
}
254-
255-
const primary = Color(customTheme.primary || theme.primary.main);
256-
let primaryText: string;
257-
let disabled: string;
258-
let disabledText: string;
259-
let action: string;
260-
let actionText: string;
261-
let hover: string;
262-
263-
if (primary.isDark()) {
264-
primaryText = primary.lightness(95).hex();
265-
disabled = primary.alpha(0.5).hexa();
266-
disabledText = primary.lightness(95).alpha(0.9).hexa();
267-
action = primary.darken(0.15).hex();
268-
actionText = primary.lightness(80).hex();
269-
hover = primary.darken(0.05).hex();
270-
} else {
271-
primaryText = primary.lightness(5).hex();
272-
disabled = primary.alpha(0.5).hexa();
273-
disabledText = primary.lightness(5).alpha(0.9).hexa();
274-
action = primary.lighten(0.05).hex();
275-
actionText = primary.lightness(0).hex();
276-
hover = primary.lighten(0.05).hex();
277-
}
278-
279-
theme.button = {
280-
primary: primary.hex(),
281-
primaryText,
282-
disabled,
283-
disabledText,
284-
action,
285-
actionText,
286-
hover,
287-
};
288317
}
289318

290319
return createTheme({

0 commit comments

Comments
 (0)