-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #440 from BinaryStudioAcademy/task/OV-405-create-t…
…emplates-page OV-405: Create templates page
- Loading branch information
Showing
22 changed files
with
471 additions
and
5 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
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { CreationsSection } from './creations-section/creations-section.js'; | ||
export { TemplatesSection } from './templates-section/templates-section.js'; |
67 changes: 67 additions & 0 deletions
67
frontend/src/bundles/template/components/creations-section/creations-section.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,67 @@ | ||
import { | ||
Box, | ||
Button, | ||
Flex, | ||
Heading, | ||
} from '~/bundles/common/components/components.js'; | ||
import { Circles, Dots } from '~/bundles/my-avatar/components/components.js'; | ||
import { type Template } from '~/bundles/template/types/types.js'; | ||
|
||
import { TemplateCard } from '../template-card/template-card.js'; | ||
import styles from './styles.module.css'; | ||
|
||
//TODO: Change with the backend information | ||
const templates: Template[] = []; | ||
|
||
type Properties = { | ||
onClick: () => void; | ||
}; | ||
|
||
const CreationsSection: React.FC<Properties> = ({ onClick }) => { | ||
return ( | ||
<Box padding="17px 0"> | ||
<Flex alignItems="center" marginBottom="9px"> | ||
<Heading color="typography.900" variant="H3" marginRight="11px"> | ||
Recent Creations | ||
</Heading> | ||
</Flex> | ||
|
||
{templates.length > 0 ? ( | ||
<Box className={styles['horizontal']}> | ||
{templates.map(({ id, ...template }) => ( | ||
<Box | ||
key={id} | ||
flex="0 0 auto" | ||
marginRight="20px" | ||
width="250px" | ||
> | ||
<TemplateCard {...template} /> | ||
</Box> | ||
))} | ||
</Box> | ||
) : ( | ||
<Flex | ||
bg="white" | ||
h="140px" | ||
borderRadius="lg" | ||
justify="center" | ||
align="center" | ||
overflow="hidden" | ||
maxWidth="340px" | ||
> | ||
<Box w={{ base: '222px', sm: '222px' }} position="relative"> | ||
<Circles /> | ||
<Dots /> | ||
<Button | ||
label="Create Your First Template" | ||
variant="outlined" | ||
onClick={onClick} | ||
/> | ||
</Box> | ||
</Flex> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export { CreationsSection }; |
6 changes: 6 additions & 0 deletions
6
frontend/src/bundles/template/components/creations-section/styles.module.css
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,6 @@ | ||
.horizontal { | ||
display: flex; | ||
overflow-x: auto; | ||
scrollbar-width: thin; | ||
scrollbar-color: #c1c1c1 #f1f1f1; | ||
} |
14 changes: 14 additions & 0 deletions
14
frontend/src/bundles/template/components/template-card/styles.module.css
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,14 @@ | ||
.play-button { | ||
position: absolute; | ||
background-color: white; | ||
top: 5px; | ||
right: 5px; | ||
} | ||
|
||
.preview-image { | ||
border-radius: 5px; | ||
height: 100%; | ||
width: 100%; | ||
object-fit: cover; | ||
object-position: top; | ||
} |
107 changes: 107 additions & 0 deletions
107
frontend/src/bundles/template/components/template-card/template-card.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,107 @@ | ||
import { | ||
Badge, | ||
Box, | ||
Icon, | ||
IconButton, | ||
Image, | ||
Text, | ||
} from '~/bundles/common/components/components.js'; | ||
import { useCallback, useState } from '~/bundles/common/hooks/hooks.js'; | ||
import { IconName } from '~/bundles/common/icons/icons.js'; | ||
import { PlayerModal } from '~/bundles/home/components/player-modal/player-modal.js'; | ||
import { DeleteWarning } from '~/bundles/home/components/video-card/components/delete-warning.js'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
type Properties = { | ||
name: string; | ||
url: string | null; | ||
previewUrl: string; | ||
}; | ||
|
||
const TemplateCard: React.FC<Properties> = ({ name, url, previewUrl }) => { | ||
const [isVideoModalOpen, setIsVideoModalOpen] = useState(false); | ||
const [isWarningModalOpen, setIsWarningModalOpen] = useState(false); | ||
|
||
const handleIconClick = useCallback(() => { | ||
if (url) { | ||
return setIsVideoModalOpen(true); | ||
} | ||
}, [url]); | ||
|
||
const handleVideoModalClose = useCallback(() => { | ||
setIsVideoModalOpen(false); | ||
}, []); | ||
|
||
const handleWarningModalClose = useCallback(() => { | ||
setIsWarningModalOpen(false); | ||
}, []); | ||
|
||
const handleDelete = useCallback(() => { | ||
handleWarningModalClose(); | ||
}, [handleWarningModalClose]); | ||
|
||
return ( | ||
<Box borderRadius="8px" bg="white" padding="7px"> | ||
<Box | ||
position="relative" | ||
role="group" | ||
height="115px" | ||
overflow="hidden" | ||
> | ||
<Image | ||
src={previewUrl} | ||
alt="Video preview" | ||
className={styles['preview-image']} | ||
/> | ||
|
||
<IconButton | ||
size="xs" | ||
aria-label={url ? 'Play video' : 'Edit video'} | ||
_groupHover={{ opacity: 1 }} | ||
onClick={handleIconClick} | ||
className={styles['play-button']} | ||
icon={ | ||
<Icon | ||
as={url ? IconName.PLAY : IconName.PEN} | ||
color="background.600" | ||
/> | ||
} | ||
/> | ||
</Box> | ||
|
||
<Box padding="7px 10px 5px 5px"> | ||
<Text variant="button" color="typography.900"> | ||
{name} | ||
</Text> | ||
</Box> | ||
|
||
<Badge | ||
color="typography.900" | ||
textTransform="none" | ||
bg="background.300" | ||
fontWeight="400" | ||
padding="0 8px" | ||
borderRadius="24px" | ||
> | ||
Advertisement | ||
</Badge> | ||
|
||
{url && ( | ||
<PlayerModal | ||
videoUrl={url} | ||
isOpen={isVideoModalOpen} | ||
onClose={handleVideoModalClose} | ||
/> | ||
)} | ||
|
||
<DeleteWarning | ||
isOpen={isWarningModalOpen} | ||
onClose={handleWarningModalClose} | ||
onDelete={handleDelete} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
export { TemplateCard }; |
7 changes: 7 additions & 0 deletions
7
frontend/src/bundles/template/components/templates-section/constants.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,7 @@ | ||
const DEFAULT_TEMPLATE_PAYLOAD = { | ||
category: '', | ||
search: '', | ||
format: '', | ||
}; | ||
|
||
export { DEFAULT_TEMPLATE_PAYLOAD }; |
11 changes: 11 additions & 0 deletions
11
frontend/src/bundles/template/components/templates-section/styles.module.css
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,11 @@ | ||
.button { | ||
width: 100%; | ||
border-radius: 20px; | ||
background-color: #f6f5fa; | ||
color: #6b6b6b; | ||
} | ||
|
||
.button.selected { | ||
background-color: white; | ||
color: #4a4a4a; | ||
} |
Oops, something went wrong.