Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OV-418: Add delete background #420

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import {
Flex,
SimpleGrid,
Tab,
TabList,
TabPanel,
TabPanels,
Tabs,
Text,
} from '~/bundles/common/components/components.js';
import { useAppDispatch, useCallback } from '~/bundles/common/hooks/hooks.js';
// TODO: Make endpoint for this
import backgroundColors from '~/bundles/studio/data/bg-colors.json';
import backgroundImages from '~/bundles/studio/data/bg-images.json';
import { actions as studioActions } from '~/bundles/studio/store/studio.js';

import { ColorCard, ImageCard } from './components/components.js';
import styles from './styles.module.css';

const BackgroundsContent: React.FC = () => {
const dispatch = useAppDispatch();
const handleRemoveBackground = useCallback((): void => {
dispatch(studioActions.removeBackgroundFromScene());
}, [dispatch]);

return (
<>
<Tabs>
Expand All @@ -24,6 +34,14 @@ const BackgroundsContent: React.FC = () => {
<TabPanels>
<TabPanel>
<SimpleGrid columns={2} spacingX="13px" spacingY="10px">
<Flex
className={styles['none-item']}
height="100px"
onClick={handleRemoveBackground}
>
<Text variant="body1">None</Text>
</Flex>

{backgroundImages.map((imageSource, index) => (
<ImageCard
key={index}
Expand All @@ -34,6 +52,14 @@ const BackgroundsContent: React.FC = () => {
</TabPanel>
<TabPanel>
<SimpleGrid columns={3} spacingX="13px" spacingY="10px">
<Flex
className={styles['none-item']}
height="80px"
onClick={handleRemoveBackground}
>
<Text variant="body1">None</Text>
</Flex>

{backgroundColors.map((color, index) => (
<ColorCard key={index} color={color} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Box } from '~/bundles/common/components/components.js';
import { useAppDispatch, useCallback } from '~/bundles/common/hooks/hooks.js';
import { actions as studioActions } from '~/bundles/studio/store/studio.js';

import styles from './styles.module.css';

type Properties = {
color: string;
};
Expand All @@ -20,8 +22,8 @@ const ColorCard: React.FC<Properties> = ({ color }) => {

return (
<Box
className={styles['color-item']}
backgroundColor={color}
height="80px"
onClick={handleColorClick}
></Box>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@
transition: all 0.3s ease;
}

.color-item {
border-radius: 7px;
height: 80px;
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';
cursor: pointer;
}

.color-item:hover {
border-color: var(--chakra-colors-brand-secondary-300);
cursor: pointer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.none-item {
background-color: var(--chakra-colors-background-700);
border-radius: 7px;
border-width: 1px;
border-color: transparent;
transition: all 0.3s ease;
align-items: center;
justify-content: center;
}

.none-item:hover {
background-color: var(--chakra-colors-background-600);
border-color: var(--chakra-colors-brand-secondary-300);
cursor: pointer;
}
17 changes: 17 additions & 0 deletions frontend/src/bundles/studio/store/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,23 @@ const { reducer, actions, name } = createSlice({
};
});
},
removeBackgroundFromScene(state) {
const selectedItem = state.ui.selectedItem;
if (!selectedItem || selectedItem.type !== RowNames.SCENE) {
return;
}

state.scenes = state.scenes.map((scene) => {
if (scene.id !== selectedItem.id) {
return scene;
}

return {
...scene,
background: {},
};
});
},
setMenuActiveItem(
state,
action: PayloadAction<ValueOf<typeof MenuItems> | null>,
Expand Down
Loading