Skip to content

Commit

Permalink
Fix wrong color for paste card in light theme
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Jan 3, 2024
1 parent 4d82783 commit aab1987
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions web/ui/src/YBFeed/Components/YBPasteCardComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState,useEffect } from 'react'

import { useParams } from 'react-router-dom'

import { Textarea, Paper, Center } from '@mantine/core';
import { Textarea, Paper, Center, useComputedColorScheme, useMantineTheme } from '@mantine/core';
import { useForm } from '@mantine/form';

import './YBPasteCardComponent.css'
Expand All @@ -13,9 +13,14 @@ interface YBPasteCardComponentProps {
}

export function YBPasteCardComponent(props:YBPasteCardComponentProps) {
const theme = useMantineTheme()
const [isActive,setActive] = useState(false)
const [isMobile, setIsMobile] = useState(false)
const {feed} = useParams()
const colorScheme = useComputedColorScheme('light');
const [activeColor,setActiveColor] = useState(theme.colors.gray[1])
const [inactiveColor,setInactiveColor] = useState(theme.colors.gray[2])

const form = useForm({
initialValues: {
text: '',
Expand Down Expand Up @@ -89,9 +94,20 @@ export function YBPasteCardComponent(props:YBPasteCardComponentProps) {
};
}, []);

useEffect(() => {
if (colorScheme === 'light') {
setActiveColor(theme.colors.gray[2])
setInactiveColor(theme.colors.gray[1])
}
else {
setActiveColor(theme.colors.gray[8])
setInactiveColor(theme.colors.gray[9])
}
},[colorScheme,theme.colors.gray])

return (
<Paper shadow="xs" p="sm" mb="1em" mt="2em" withBorder tabIndex={0} onPaste={handleOnPaste}
style={{backgroundColor:(isActive)?"var(--mantine-color-gray-9)":"var(--mantine-color-gray-10)"}}
style={{backgroundColor:(isActive)?activeColor:inactiveColor}}
onFocus={() => setActive(true)} onBlur={() => setActive(false)}
>
<Center>
Expand Down

0 comments on commit aab1987

Please sign in to comment.