Skip to content

Commit 56bd0cb

Browse files
committed
feat: add dark theme styles
1 parent 40df1d9 commit 56bd0cb

File tree

8 files changed

+52
-17
lines changed

8 files changed

+52
-17
lines changed

examples/chain-template/components/common/Radio/Radio.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717

1818
.radioDark {
19-
border-color: #323a42;
19+
border-color: #6d7987;
2020
}
2121

2222
.radioDark:checked {

examples/chain-template/components/common/Radio/Radio.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export const Radio = ({
1919
onChange,
2020
}: RadioProps) => {
2121
const { theme } = useTheme();
22-
const color = checked ? '$purple600' : '$blackAlpha600';
22+
23+
const checkedColor = theme === 'light' ? '$purple600' : '$purple400';
24+
const textColor = checked ? checkedColor : '$blackAlpha600';
25+
const borderColor = checked ? checkedColor : '$blackAlpha200';
2326

2427
return (
2528
<Box
@@ -37,7 +40,7 @@ export const Radio = ({
3740
borderRadius="4px"
3841
borderWidth="1px"
3942
borderStyle="solid"
40-
borderColor={checked ? '$purple600' : '$blackAlpha200'}
43+
borderColor={borderColor}
4144
padding="10px"
4245
>
4346
<input
@@ -55,14 +58,14 @@ export const Radio = ({
5558
right: '6px',
5659
}}
5760
/>
58-
<Box color={color}>
61+
<Box color={textColor}>
5962
{typeof icon === 'string' ? (
60-
<Icon name={icon as IconName} color={color} size="$lg" />
63+
<Icon name={icon as IconName} color={textColor} size="$lg" />
6164
) : (
6265
icon
6366
)}
6467
</Box>
65-
<Text color={color} fontSize="14px" fontWeight="500">
68+
<Text color={textColor} fontSize="14px" fontWeight="500">
6669
{children}
6770
</Text>
6871
</Box>

examples/chain-template/components/contract/BackButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const BackButton = ({ onClick }: { onClick: () => void }) => {
1010
attributes={{ onClick }}
1111
>
1212
<Icon
13+
color="$text"
1314
name="arrowRightLine"
1415
attributes={{ transform: 'rotate(180deg)' }}
1516
/>

examples/chain-template/components/contract/InstantiateContract.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export const InstantiateContract = ({
114114
!canInstantiate ||
115115
!!adminInputErr;
116116

117+
const { isMobile } = useDetectBreakpoints();
118+
117119
if (txResult) {
118120
const infoItems: TxInfoItem[] = [
119121
{
@@ -174,8 +176,6 @@ export const InstantiateContract = ({
174176
);
175177
}
176178

177-
const { isMobile } = useDetectBreakpoints();
178-
179179
return (
180180
<Box
181181
display={show ? 'flex' : 'none'}

examples/chain-template/components/contract/WasmFileUploader.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
import Image from 'next/image';
22
import { useCallback, useMemo } from 'react';
3-
import { Box, Text } from '@interchain-ui/react';
3+
import {
4+
Box,
5+
Text,
6+
useTheme,
7+
useColorModeValue,
8+
ThemeVariant,
9+
} from '@interchain-ui/react';
410
import { HiOutlineTrash } from 'react-icons/hi';
511
import { useDropzone } from 'react-dropzone';
612

713
import { bytesToKb } from '@/utils';
814

915
const MAX_FILE_SIZE = 800_000;
1016

11-
const defaultFileInfo = {
17+
const getDefaultFileInfo = (theme: ThemeVariant) => ({
1218
image: {
13-
src: '/images/upload.svg',
19+
src: theme === 'light' ? '/images/upload.svg' : '/images/upload-dark.svg',
1420
alt: 'upload',
1521
width: 80,
1622
height: 48,
1723
},
1824
title: 'Upload or drag .wasm file here',
1925
description: `Max file size: ${bytesToKb(MAX_FILE_SIZE)}KB`,
20-
};
26+
});
2127

2228
type WasmFileUploaderProps = {
2329
file: File | null;
2430
setFile: (file: File | null) => void;
2531
};
2632

2733
export const WasmFileUploader = ({ file, setFile }: WasmFileUploaderProps) => {
34+
const { theme } = useTheme();
35+
2836
const onDrop = useCallback(
2937
(files: File[]) => {
3038
setFile(files[0]);
@@ -33,19 +41,22 @@ export const WasmFileUploader = ({ file, setFile }: WasmFileUploaderProps) => {
3341
);
3442

3543
const fileInfo = useMemo(() => {
36-
if (!file) return defaultFileInfo;
44+
if (!file) return getDefaultFileInfo(theme);
3745

3846
return {
3947
image: {
40-
src: '/images/contract-file.svg',
48+
src:
49+
theme === 'light'
50+
? '/images/contract-file.svg'
51+
: '/images/contract-file-dark.svg',
4152
alt: 'contract-file',
4253
width: 40,
4354
height: 54,
4455
},
4556
title: file.name,
4657
description: `File size: ${bytesToKb(file.size)}KB`,
4758
};
48-
}, [file]);
59+
}, [file, theme]);
4960

5061
const { getRootProps, getInputProps } = useDropzone({
5162
onDrop,
@@ -63,8 +74,8 @@ export const WasmFileUploader = ({ file, setFile }: WasmFileUploaderProps) => {
6374
borderRadius="8px"
6475
borderWidth="1px"
6576
borderStyle={file ? 'none' : 'dashed'}
66-
borderColor="$purple600"
67-
bg="$purple50"
77+
borderColor={useColorModeValue('$purple600', '$purple400')}
78+
bg={useColorModeValue('$purple50', '$purple900')}
6879
cursor={file ? 'auto' : 'pointer'}
6980
height="206px"
7081
position="relative"

examples/chain-template/config/theme.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const CustomTheme: Record<ThemeVariant, string> = {
66
};
77

88
export const lightColors: ThemeDef['vars']['colors'] = {
9+
purple900: '#322F3C',
910
purple600: '#7310FF',
1011
purple400: '#AB6FFF',
1112
purple200: '#E5D4FB',
@@ -42,6 +43,7 @@ export const lightColors: ThemeDef['vars']['colors'] = {
4243
};
4344

4445
export const darkColors: ThemeDef['vars']['colors'] = {
46+
purple900: '#322F3C',
4547
purple600: '#9042FE',
4648
purple400: '#AB6FFF',
4749
purple200: '#4D198F',
Lines changed: 14 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)