Skip to content

Commit

Permalink
feat: add dark theme styles
Browse files Browse the repository at this point in the history
  • Loading branch information
marslavish committed Sep 22, 2024
1 parent 40df1d9 commit 56bd0cb
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}

.radioDark {
border-color: #323a42;
border-color: #6d7987;
}

.radioDark:checked {
Expand Down
13 changes: 8 additions & 5 deletions examples/chain-template/components/common/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const Radio = ({
onChange,
}: RadioProps) => {
const { theme } = useTheme();
const color = checked ? '$purple600' : '$blackAlpha600';

const checkedColor = theme === 'light' ? '$purple600' : '$purple400';
const textColor = checked ? checkedColor : '$blackAlpha600';
const borderColor = checked ? checkedColor : '$blackAlpha200';

return (
<Box
Expand All @@ -37,7 +40,7 @@ export const Radio = ({
borderRadius="4px"
borderWidth="1px"
borderStyle="solid"
borderColor={checked ? '$purple600' : '$blackAlpha200'}
borderColor={borderColor}
padding="10px"
>
<input
Expand All @@ -55,14 +58,14 @@ export const Radio = ({
right: '6px',
}}
/>
<Box color={color}>
<Box color={textColor}>
{typeof icon === 'string' ? (
<Icon name={icon as IconName} color={color} size="$lg" />
<Icon name={icon as IconName} color={textColor} size="$lg" />
) : (
icon
)}
</Box>
<Text color={color} fontSize="14px" fontWeight="500">
<Text color={textColor} fontSize="14px" fontWeight="500">
{children}
</Text>
</Box>
Expand Down
1 change: 1 addition & 0 deletions examples/chain-template/components/contract/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const BackButton = ({ onClick }: { onClick: () => void }) => {
attributes={{ onClick }}
>
<Icon
color="$text"
name="arrowRightLine"
attributes={{ transform: 'rotate(180deg)' }}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export const InstantiateContract = ({
!canInstantiate ||
!!adminInputErr;

const { isMobile } = useDetectBreakpoints();

if (txResult) {
const infoItems: TxInfoItem[] = [
{
Expand Down Expand Up @@ -174,8 +176,6 @@ export const InstantiateContract = ({
);
}

const { isMobile } = useDetectBreakpoints();

return (
<Box
display={show ? 'flex' : 'none'}
Expand Down
29 changes: 20 additions & 9 deletions examples/chain-template/components/contract/WasmFileUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
import Image from 'next/image';
import { useCallback, useMemo } from 'react';
import { Box, Text } from '@interchain-ui/react';
import {
Box,
Text,
useTheme,
useColorModeValue,
ThemeVariant,
} from '@interchain-ui/react';
import { HiOutlineTrash } from 'react-icons/hi';
import { useDropzone } from 'react-dropzone';

import { bytesToKb } from '@/utils';

const MAX_FILE_SIZE = 800_000;

const defaultFileInfo = {
const getDefaultFileInfo = (theme: ThemeVariant) => ({
image: {
src: '/images/upload.svg',
src: theme === 'light' ? '/images/upload.svg' : '/images/upload-dark.svg',
alt: 'upload',
width: 80,
height: 48,
},
title: 'Upload or drag .wasm file here',
description: `Max file size: ${bytesToKb(MAX_FILE_SIZE)}KB`,
};
});

type WasmFileUploaderProps = {
file: File | null;
setFile: (file: File | null) => void;
};

export const WasmFileUploader = ({ file, setFile }: WasmFileUploaderProps) => {
const { theme } = useTheme();

const onDrop = useCallback(
(files: File[]) => {
setFile(files[0]);
Expand All @@ -33,19 +41,22 @@ export const WasmFileUploader = ({ file, setFile }: WasmFileUploaderProps) => {
);

const fileInfo = useMemo(() => {
if (!file) return defaultFileInfo;
if (!file) return getDefaultFileInfo(theme);

return {
image: {
src: '/images/contract-file.svg',
src:
theme === 'light'
? '/images/contract-file.svg'
: '/images/contract-file-dark.svg',
alt: 'contract-file',
width: 40,
height: 54,
},
title: file.name,
description: `File size: ${bytesToKb(file.size)}KB`,
};
}, [file]);
}, [file, theme]);

const { getRootProps, getInputProps } = useDropzone({
onDrop,
Expand All @@ -63,8 +74,8 @@ export const WasmFileUploader = ({ file, setFile }: WasmFileUploaderProps) => {
borderRadius="8px"
borderWidth="1px"
borderStyle={file ? 'none' : 'dashed'}
borderColor="$purple600"
bg="$purple50"
borderColor={useColorModeValue('$purple600', '$purple400')}
bg={useColorModeValue('$purple50', '$purple900')}
cursor={file ? 'auto' : 'pointer'}
height="206px"
position="relative"
Expand Down
2 changes: 2 additions & 0 deletions examples/chain-template/config/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const CustomTheme: Record<ThemeVariant, string> = {
};

export const lightColors: ThemeDef['vars']['colors'] = {
purple900: '#322F3C',
purple600: '#7310FF',
purple400: '#AB6FFF',
purple200: '#E5D4FB',
Expand Down Expand Up @@ -42,6 +43,7 @@ export const lightColors: ThemeDef['vars']['colors'] = {
};

export const darkColors: ThemeDef['vars']['colors'] = {
purple900: '#322F3C',
purple600: '#9042FE',
purple400: '#AB6FFF',
purple200: '#4D198F',
Expand Down
14 changes: 14 additions & 0 deletions examples/chain-template/public/images/contract-file-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions examples/chain-template/public/images/upload-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 56bd0cb

Please sign in to comment.