-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
141 additions
and
8 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
32 changes: 32 additions & 0 deletions
32
frontend/src/components/PagingButton/PagingButton.stories.tsx
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import PagingButton from './PagingButton'; | ||
|
||
const meta: Meta<typeof PagingButton> = { | ||
title: 'PagingButton', | ||
component: PagingButton, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof PagingButton>; | ||
|
||
export const Default: Story = { | ||
render: () => ( | ||
<div> | ||
<PagingButton page={1} isActive={false} onClick={() => {}} />, | ||
<PagingButton page={2} isActive={false} onClick={() => {}} />, | ||
<PagingButton page={3} isActive={false} onClick={() => {}} />, | ||
</div> | ||
), | ||
}; | ||
|
||
export const Active: Story = { | ||
render: () => ( | ||
<div> | ||
<PagingButton page={1} isActive={true} onClick={() => {}} />, | ||
<PagingButton page={2} isActive={true} onClick={() => {}} />, | ||
<PagingButton page={3} isActive={true} onClick={() => {}} />, | ||
</div> | ||
), | ||
}; |
28 changes: 28 additions & 0 deletions
28
frontend/src/components/PagingButton/PagingButton.style.ts
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import { theme } from '../../style/theme'; | ||
|
||
export const StyledPagingButton = styled.button` | ||
cursor: pointer; | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
margin: 0 0.25rem; | ||
color: ${theme.color.light.secondary_500}; | ||
background: none; | ||
border: none; | ||
:disabled { | ||
background-color: ${theme.color.light.primary_800}; | ||
span { | ||
color: ${theme.color.light.white}; | ||
} | ||
} | ||
:not(:disabled):hover span { | ||
color: ${theme.color.light.secondary_700}; | ||
} | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Text } from '@/components'; | ||
import { theme } from '@/style/theme'; | ||
import * as S from './PagingButton.style'; | ||
|
||
interface PagingButtonProps { | ||
page: number; | ||
isActive: boolean; | ||
onClick: (page: number) => void; | ||
} | ||
|
||
const PagingButton = ({ page, isActive, onClick }: PagingButtonProps) => ( | ||
<S.StyledPagingButton disabled={isActive} onClick={() => onClick(page)}> | ||
<Text.Medium color={theme.color.light.secondary_500}>{page}</Text.Medium> | ||
</S.StyledPagingButton> | ||
); | ||
|
||
export default PagingButton; |
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
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,15 +1,18 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { keepPreviousData, useQuery } from '@tanstack/react-query'; | ||
|
||
import { QUERY_KEY, getTemplateList } from '@/api'; | ||
import type { TemplateListResponse } from '@/types'; | ||
|
||
interface UseTemplateListQueryProps { | ||
interface Props { | ||
categoryId?: number; | ||
tagId?: number; | ||
page?: number; | ||
pageSize?: number; | ||
} | ||
|
||
export const useTemplateListQuery = ({ categoryId, tagId }: UseTemplateListQueryProps) => | ||
export const useTemplateListQuery = ({ categoryId, tagId, page = 1, pageSize = 20 }: Props) => | ||
useQuery<TemplateListResponse, Error>({ | ||
queryKey: [QUERY_KEY.TEMPLATE_LIST, categoryId, tagId], | ||
queryFn: () => getTemplateList(categoryId, tagId), | ||
queryKey: [QUERY_KEY.TEMPLATE_LIST, categoryId, tagId, page, pageSize], | ||
queryFn: () => getTemplateList(categoryId, tagId, page, pageSize), | ||
placeholderData: keepPreviousData, | ||
}); |
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,2 +1,3 @@ | ||
export { formatRelativeTime } from './formatRelativeTime'; | ||
export { getLanguageByFilename } from './getLanguageByFileName'; | ||
export { scroll } from './scroll'; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const top = () => { | ||
window.scrollTo({ | ||
top: 0, | ||
behavior: 'smooth', | ||
}); | ||
}; | ||
|
||
export const scroll = { | ||
top, | ||
}; |