Skip to content

Commit

Permalink
style: 다크모드 스타일 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kangju2000 committed Oct 22, 2023
1 parent 449d350 commit 89c3fce
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 28 deletions.
4 changes: 4 additions & 0 deletions src/components/ActivityItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const ActivityItem = ({ activity }: Props) => {
href={`https://cyber.gachon.ac.kr/mod/${
activity.type === 'assignment' ? 'assign' : 'vod'
}/view.php?id=${activity.id}`}
_hover={{
_light: { color: 'blue.600' },
_dark: { color: 'blue.300' },
}}
>
<CardBody display="flex" alignItems="center" justifyContent="space-between" px="16px">
<Flex align="center" gap="8px">
Expand Down
88 changes: 64 additions & 24 deletions src/components/ContentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import {
TabPanels,
Tabs,
Text,
useColorMode,
} from '@chakra-ui/react'
import { ko } from 'date-fns/locale'
import { useState } from 'react'

import ActivityItem from './ActivityItem'
import { RefreshIcon } from './Icons'
Expand All @@ -32,29 +34,27 @@ type Props = {
}

const ContentModal = ({ isOpen, onClose }: Props) => {
const { colorMode, toggleColorMode } = useColorMode()

const [selectedCourseId, setSelectedCourseId] = useState('-1')
const {
data: { courseList, activityList, updateAt },
pos,
refetch,
isLoading,
} = useGetContents({ enabled: isOpen, local: false })
} = useGetContents({ enabled: isOpen, local: true })

console.log(isLoading, pos, activityList)
console.log(courseList, activityList)

return (
<Modal isCentered isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent minW="750px" h="500px" borderRadius="8px">
<ModalHeader
display="flex"
alignItems="center"
minH="60px"
px="24px"
color="gray.700"
fontSize="large"
fontWeight="700"
>
Gachon Tools
<ModalHeader display="flex" alignItems="center" minH="60px" px="24px">
<Text fontSize="18px" fontWeight="700">
Gachon Tools
</Text>
<button onClick={toggleColorMode}>{colorMode === 'light' ? '🌙' : '🌞'}</button>
<ModalCloseButton
size="lg"
top="16px"
Expand All @@ -71,10 +71,36 @@ const ContentModal = ({ isOpen, onClose }: Props) => {
</ModalHeader>
<Divider m="0" />
<ModalBody display="flex" p="0" overflow="hidden">
<Stack spacing="16px" w="200px" p="24px" bg="gray.200" overflowY="scroll"></Stack>
<Stack spacing="16px" w="200px" p="24px" overflowY="scroll">
{courseList.map(course => (
<Text
key={course.id}
fontSize="14px"
fontWeight={selectedCourseId === course.id ? '600' : '400'}
_light={{ color: selectedCourseId === course.id ? 'blue.600' : 'gray.600' }}
_dark={{ color: selectedCourseId === course.id ? 'blue.400' : 'gray.400' }}
_hover={{
_light: { color: 'blue.600' },
_dark: { color: 'blue.400' },
}}
cursor="pointer"
onClick={() => setSelectedCourseId(course.id)}
>
{course.title}
</Text>
))}
</Stack>
<Divider orientation="vertical" m="0" />
<Box flex="1" overflowY="scroll" px="24px" h="100%">
<Tabs>
<TabList position="sticky" top="0" zIndex="1" bg="white" pt="16px">
<TabList
position="sticky"
top="0"
zIndex="1"
_light={{ bg: 'white' }}
_dark={{ bg: 'gray.700' }}
pt="16px"
>
<Tab
fontSize="14px"
borderRadius="none"
Expand Down Expand Up @@ -105,11 +131,14 @@ const ContentModal = ({ isOpen, onClose }: Props) => {
<LoadingProgress pos={pos} />
) : (
<Stack spacing="16px">
{filteredActivities(activityList, '-1', '진행중인 과제', false).map(
activity => (
<ActivityItem key={activity.id} activity={activity} />
),
)}
{filteredActivities(
activityList,
selectedCourseId,
'진행중인 과제',
false,
).map(activity => (
<ActivityItem key={activity.id} activity={activity} />
))}
</Stack>
)}
</TabPanel>
Expand All @@ -118,9 +147,11 @@ const ContentModal = ({ isOpen, onClose }: Props) => {
<LoadingProgress pos={pos} />
) : (
<Stack spacing="16px">
{activityList.map(activity => (
<ActivityItem key={activity.id} activity={activity} />
))}
{filteredActivities(activityList, selectedCourseId, '모든 과제', false).map(
activity => (
<ActivityItem key={activity.id} activity={activity} />
),
)}
</Stack>
)}
</TabPanel>
Expand All @@ -130,10 +161,19 @@ const ContentModal = ({ isOpen, onClose }: Props) => {
</ModalBody>
<Divider m="0" />
<ModalFooter h="60px" px="24px">
<Text fontSize="12px" color="gray.600" mr="4px">
<Text
fontSize="12px"
_light={{ color: 'gray.500' }}
_dark={{ color: 'gray.400' }}
mr="4px"
>
{isLoading ? '불러오는 중...' : `${foramtDate(ko, updateAt)} 업데이트`}
</Text>
<RefreshIcon color="gray.600" onClick={refetch} />
<RefreshIcon
_light={{ color: 'gray.500' }}
_dark={{ color: 'gray.400' }}
onClick={refetch}
/>
</ModalFooter>
</ModalContent>
</Modal>
Expand Down
10 changes: 7 additions & 3 deletions src/components/LoadingProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ type Props = {
const LoadingProgress = ({ pos }: Props) => {
return (
<Box w="100%" mt="100px">
<Flex justify="space-between">
<Text>과제를 불러오는 중입니다.</Text>
<Text>{pos}%</Text>
<Flex justify="space-between" mb="4px">
<Text fontSize="12px" _light={{ color: 'gray.500' }} _dark={{ color: 'gray.400' }}>
과제를 불러오는 중입니다.
</Text>
<Text fontSize="12px" _light={{ color: 'gray.500' }} _dark={{ color: 'gray.400' }}>
{pos}%
</Text>
</Flex>
<Progress
value={pos}
Expand Down
8 changes: 7 additions & 1 deletion src/pages/content/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChakraProvider, extendTheme } from '@chakra-ui/react'
import { ChakraProvider, extendTheme, type ThemeConfig } from '@chakra-ui/react'
import * as Sentry from '@sentry/react'
import { createRoot } from 'react-dom/client'

Expand Down Expand Up @@ -31,7 +31,13 @@ const modal = document.createElement('div')
modal.id = 'modal'
document.body.append(modal)

const config: ThemeConfig = {
initialColorMode: 'system',
useSystemColorMode: true,
}

const theme = extendTheme({
config,
components: {
Text: {
baseStyle: {
Expand Down

0 comments on commit 89c3fce

Please sign in to comment.