generated from chiffre-io/template-library
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add dark mode support for cards
- Loading branch information
Showing
3 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,47 @@ | ||
import React from 'react' | ||
import Box, { BoxProps } from '@chakra-ui/core/dist/Box' | ||
import PseudoBox, { PseudoBoxProps } from '@chakra-ui/core/dist/PseudoBox' | ||
import Flex, { FlexProps } from '@chakra-ui/core/dist/Flex' | ||
import Stack, { StackProps } from '@chakra-ui/core/dist/Stack' | ||
import { useColorMode } from '@chakra-ui/core/dist/ColorModeProvider' | ||
|
||
// -- | ||
|
||
const baseProps: BoxProps = { | ||
export const cardBackgroundColors = { | ||
light: 'white', | ||
dark: 'gray.900', | ||
} | ||
|
||
export const cardProps: PseudoBoxProps = { | ||
p: 4, | ||
borderRadius: 4, | ||
bg: 'white', | ||
shadow: 'md', | ||
} | ||
|
||
export interface CardProps extends BoxProps {} | ||
export interface CardProps extends PseudoBoxProps {} | ||
|
||
export const Card: React.FC<CardProps> = ({ ...props }) => { | ||
return <Box {...baseProps} {...props} /> | ||
const { colorMode } = useColorMode() | ||
return ( | ||
<PseudoBox {...cardProps} bg={cardBackgroundColors[colorMode]} {...props} /> | ||
) | ||
} | ||
|
||
// -- | ||
|
||
export interface FlexCardProps extends FlexProps {} | ||
|
||
export const FlexCard: React.FC<FlexCardProps> = ({ ...props }) => { | ||
return <Flex {...baseProps} {...props} /> | ||
const { colorMode } = useColorMode() | ||
return <Flex {...cardProps} bg={cardBackgroundColors[colorMode]} {...props} /> | ||
} | ||
|
||
// -- | ||
|
||
export interface StackCardProps extends StackProps {} | ||
|
||
export const StackCard: React.FC<StackCardProps> = ({ ...props }) => { | ||
return <Stack {...baseProps} {...props} /> | ||
const { colorMode } = useColorMode() | ||
return ( | ||
<Stack {...cardProps} bg={cardBackgroundColors[colorMode]} {...props} /> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters