-
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 #451 from BinaryStudioAcademy/task/OV-421-add-temp…
…lates-menu OV-421: Add templates menu
- Loading branch information
Showing
40 changed files
with
513 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { templateErrorMessage } from './template-error-message.enum.js'; | ||
export { templateApiPath } from './templates-api-path.enum.js'; | ||
export { TemplateApiPath } from 'shared'; |
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
2 changes: 1 addition & 1 deletion
2
...omponents/video-menu/components/menu-content/backgrounds-content/components/components.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { ColorCard } from './color-card.js'; | ||
export { ImageCard } from './image-card.js'; | ||
export { BackgroundImageCard } from './image-card.js'; |
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
1 change: 1 addition & 0 deletions
1
...src/bundles/studio/components/video-menu/components/menu-content/components/components.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 @@ | ||
export { ImageCard } from './image-card/image-card.js'; |
23 changes: 23 additions & 0 deletions
23
...studio/components/video-menu/components/menu-content/components/image-card/image-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,23 @@ | ||
import { Box, Image } from '~/bundles/common/components/components.js'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
type Properties = { | ||
imageSource: string; | ||
onClick?: () => void; | ||
}; | ||
|
||
const ImageCard: React.FC<Properties> = ({ imageSource, onClick }) => { | ||
return ( | ||
<Box className={styles['image-item']} onClick={onClick}> | ||
<Image | ||
src={imageSource} | ||
objectFit="contain" | ||
width="100%" | ||
height="100%" | ||
></Image> | ||
</Box> | ||
); | ||
}; | ||
|
||
export { ImageCard }; |
14 changes: 14 additions & 0 deletions
14
...dio/components/video-menu/components/menu-content/components/image-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 @@ | ||
.image-item { | ||
height: 100px; | ||
background-color: var(--chakra-colors-background-700); | ||
border-radius: 7px; | ||
border-width: 1px; | ||
border-color: transparent; | ||
transition: all 0.3s ease; | ||
} | ||
|
||
.image-item:hover { | ||
background-color: var(--chakra-colors-background-600); | ||
border-color: var(--chakra-colors-brand-secondary-300); | ||
cursor: pointer; | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/bundles/studio/components/video-menu/components/menu-content/content.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { AvatarsContent } from './avatars-content/avatars-content.js'; | ||
export { BackgroundsContent } from './backgrounds-content/backgrounds-content.js'; | ||
export { ScriptContent } from './script-content/script-content.js'; | ||
export { TemplatesContent } from './templates-content/templates-content.js'; |
1 change: 1 addition & 0 deletions
1
.../components/video-menu/components/menu-content/templates-content/components/components.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 @@ | ||
export { TemplateCard } from './template-card.js'; |
22 changes: 22 additions & 0 deletions
22
...ponents/video-menu/components/menu-content/templates-content/components/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,22 @@ | ||
import { useAppDispatch, useCallback } from '~/bundles/common/hooks/hooks.js'; | ||
import { ImageCard } from '~/bundles/studio/components/video-menu/components/menu-content/components/components.js'; | ||
import { actions as studioActions } from '~/bundles/studio/store/studio.js'; | ||
import { type Template } from '~/bundles/studio/types/types.js'; | ||
|
||
type Properties = { | ||
template: Template; | ||
}; | ||
|
||
const TemplateCard: React.FC<Properties> = ({ template }) => { | ||
const dispatch = useAppDispatch(); | ||
|
||
const handleClick = useCallback((): void => { | ||
void dispatch(studioActions.loadTemplate(template)); | ||
}, [dispatch, template]); | ||
|
||
return ( | ||
<ImageCard imageSource={template.previewUrl} onClick={handleClick} /> | ||
); | ||
}; | ||
|
||
export { TemplateCard }; |
86 changes: 86 additions & 0 deletions
86
...dio/components/video-menu/components/menu-content/templates-content/templates-content.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,86 @@ | ||
import { | ||
Box, | ||
Loader, | ||
SimpleGrid, | ||
Tab, | ||
TabList, | ||
TabPanel, | ||
TabPanels, | ||
Tabs, | ||
Text, | ||
} from '~/bundles/common/components/components.js'; | ||
import { EMPTY_VALUE } from '~/bundles/common/constants/constants.js'; | ||
import { DataStatus } from '~/bundles/common/enums/data-status.enum.js'; | ||
import { | ||
useAppDispatch, | ||
useAppSelector, | ||
useEffect, | ||
} from '~/bundles/common/hooks/hooks.js'; | ||
import { actions as studioActions } from '~/bundles/studio/store/studio.js'; | ||
|
||
import { TemplateCard } from './components/components.js'; | ||
|
||
const TemplatesContent: React.FC = () => { | ||
const dispatch = useAppDispatch(); | ||
|
||
const { templates, dataStatus } = useAppSelector(({ studio }) => studio); | ||
|
||
useEffect(() => { | ||
if (templates.public.length === EMPTY_VALUE) { | ||
void dispatch(studioActions.loadPublicTemplates()); | ||
} | ||
if (!templates.isUserLoaded) { | ||
void dispatch(studioActions.loadUserTemplates()); | ||
} | ||
}, [dispatch, templates]); | ||
|
||
return ( | ||
<Tabs> | ||
<TabList> | ||
<Tab>Templates</Tab> | ||
<Tab>My templates</Tab> | ||
</TabList> | ||
|
||
{dataStatus === DataStatus.PENDING ? ( | ||
<Box mt="100px"> | ||
<Loader /> | ||
</Box> | ||
) : ( | ||
<TabPanels> | ||
<TabPanel> | ||
<SimpleGrid columns={2} spacingX="13px" spacingY="10px"> | ||
{templates.public.map((template) => ( | ||
<TemplateCard | ||
key={template.id} | ||
template={template} | ||
/> | ||
))} | ||
</SimpleGrid> | ||
</TabPanel> | ||
<TabPanel> | ||
{templates.user.length > EMPTY_VALUE ? ( | ||
<SimpleGrid | ||
columns={2} | ||
spacingX="13px" | ||
spacingY="10px" | ||
> | ||
{templates.user.map((template) => ( | ||
<TemplateCard | ||
key={template.id} | ||
template={template} | ||
/> | ||
))} | ||
</SimpleGrid> | ||
) : ( | ||
<Text color="typography.600" variant="body1"> | ||
You have no templates yet. | ||
</Text> | ||
)} | ||
</TabPanel> | ||
</TabPanels> | ||
)} | ||
</Tabs> | ||
); | ||
}; | ||
|
||
export { TemplatesContent }; |
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
3 changes: 3 additions & 0 deletions
3
frontend/src/bundles/studio/constants/template-save-failed-notification-id.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,3 @@ | ||
const TEMPLATE_SAVE_FAILED_NOTOFICATION_ID = 'template-save-failed'; | ||
|
||
export { TEMPLATE_SAVE_FAILED_NOTOFICATION_ID }; |
3 changes: 3 additions & 0 deletions
3
frontend/src/bundles/studio/constants/template-save-notification-id.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,3 @@ | ||
const TEMPLATE_SAVE_NOTOFICATION_ID = 'template-save'; | ||
|
||
export { TEMPLATE_SAVE_NOTOFICATION_ID }; |
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
Oops, something went wrong.