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-27: Add studio page #35

Merged
merged 6 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"vite": "5.4.0"
},
"dependencies": {
"@chakra-ui/icons": "2.1.1",
"@chakra-ui/react": "2.8.2",
"@emotion/react": "11.13.0",
"@emotion/styled": "11.13.0",
Expand Down
56 changes: 2 additions & 54 deletions frontend/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,9 @@
import reactLogo from '~/assets/img/react.svg';
import { Link, RouterOutlet } from '~/bundles/common/components/components.js';
import { AppRoute } from '~/bundles/common/enums/enums.js';
import {
useAppDispatch,
useAppSelector,
useEffect,
useLocation,
} from '~/bundles/common/hooks/hooks.js';
import { actions as userActions } from '~/bundles/users/store/users.js';
import { RouterOutlet } from '~/bundles/common/components/components.js';

const App: React.FC = () => {
const { pathname } = useLocation();
const dispatch = useAppDispatch();
const { users, dataStatus } = useAppSelector(({ users }) => ({
users: users.users,
dataStatus: users.dataStatus,
}));

const isRoot = pathname === AppRoute.ROOT;

useEffect(() => {
if (isRoot) {
void dispatch(userActions.loadAll());
}
}, [isRoot, dispatch]);

return (
<>
<img src={reactLogo} width="30" alt="logo" />

<ul>
<li>
<Link to={AppRoute.ROOT}>Root</Link>
</li>
<li>
<Link to={AppRoute.SIGN_IN}>Sign in</Link>
</li>
<li>
<Link to={AppRoute.SIGN_UP}>Sign up</Link>
</li>
</ul>
<p>Current path: {pathname}</p>

<div>
<RouterOutlet />
</div>
{isRoot && (
<>
<h2>Users:</h2>
<h3>Status: {dataStatus}</h3>
<ul>
{users.map((it) => (
<li key={it.id}>{it.email}</li>
))}
</ul>
</>
)}
<RouterOutlet />
</>
);
};
Expand Down
27 changes: 24 additions & 3 deletions frontend/src/bundles/common/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
import { Button as LibraryButton } from '@chakra-ui/react';
import {
type SystemStyleObject,
Button as LibraryButton,
} from '@chakra-ui/react';

type Properties = {
label: string;
type?: 'button' | 'submit';
variant?: string;
size?: 'md' | 'lg';
isDisabled?: boolean;
sx?: SystemStyleObject;
};

const Button: React.FC<Properties> = ({ type = 'button', label }) => (
<LibraryButton type={type} width="full">
const Button: React.FC<Properties> = ({
type = 'button',
label,
variant = 'solid',
size = 'md',
isDisabled = false,
sx = {},
}) => (
<LibraryButton
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that default parameters should be placed at the end. For example :
({
label,
type = 'button',
variant = 'solid',
size = 'md',
isDisabled = false,
sx = {},
})

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required props should go first

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

type={type}
w="full"
variant={variant}
size={size}
isDisabled={isDisabled}
sx={sx}
>
{label}
</LibraryButton>
);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/bundles/common/components/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ export { Link } from './link/link.js';
export { Loader } from './loader/loader.js';
export { Overlay } from './overlay/overlay.js';
export { RouterProvider } from './router-provider/router-provider.js';
export { DownloadIcon } from '@chakra-ui/icons';
export {
Box,
Circle,
ChakraProvider as ComponentsProvider,
Flex,
Heading,
IconButton,
Text,
VStack,
} from '@chakra-ui/react';
Expand Down
29 changes: 17 additions & 12 deletions frontend/src/bundles/common/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
import { Flex, Text } from '@chakra-ui/react';
import { Box, Flex, Text } from '@chakra-ui/react';

const Header = (): JSX.Element => {
type Properties = {
left?: React.ReactNode;
center?: React.ReactNode;
right?: React.ReactNode;
};

const Header: React.FC<Properties> = ({ left, center, right }) => {
return (
<Flex
as="header"
height="75px"
position="sticky"
top="0"
left="0"
width="100%"
width="full"
backgroundColor="background.900"
color="white"
boxShadow="md"
zIndex="1000"
padding="4"
marginBottom="20px"
alignItems="center"
justifyContent="space-between"
>
<Flex
width="full"
alignItems="center"
maxWidth="1440px"
justifyContent="space-between"
>
<Text fontSize="xl" fontWeight="lighter">
{left ?? (
// {/* TODO: Add logo */}
<Text fontSize="xl" fontWeight="lighter" color="white">
Logo
</Text>
</Flex>
)}
<Box>{center}</Box>
<Box>{right}</Box>
</Flex>
);
};
Expand Down
1 change: 1 addition & 0 deletions frontend/src/bundles/common/enums/app-route.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const AppRoute = {
ROOT: '/',
SIGN_IN: '/sign-in',
SIGN_UP: '/sign-up',
STUDIO: '/studio',
} as const;

export { AppRoute };
31 changes: 31 additions & 0 deletions frontend/src/bundles/studio/pages/studio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
Button,
DownloadIcon,
Header,
IconButton,
} from '~/bundles/common/components/components.js';

const Studio: React.FC = () => {
return (
<>
<Header
center={
<Button
variant="primaryOutlined"
label="Resize"
sx={{ width: '135px' }}
/>
}
right={
<IconButton
variant="primaryOutlined"
aria-label="Download"
icon={<DownloadIcon />}
/>
}
/>
</>
);
};

export { Studio };
13 changes: 13 additions & 0 deletions frontend/src/framework/theme/styles/components.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ const components = {
},
},
},
primaryOutlined: {
color: colors.background[300],
border: '1px solid',
borderColor: colors.background[300],
_hover: {
color: 'white',
bg: colors.background[300],
_disabled: {
color: colors.background[300],
bg: 'none',
},
},
},
ghostIcon: {
color: colors.white,
_hover: {
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
StoreProvider,
} from '~/bundles/common/components/components.js';
import { AppRoute } from '~/bundles/common/enums/enums.js';
import { Studio } from '~/bundles/studio/pages/studio.js';
import { store } from '~/framework/store/store.js';
import { theme } from '~/framework/theme/theme.js';

Expand All @@ -29,6 +30,10 @@ const routes = [
path: AppRoute.SIGN_UP,
element: <Auth />,
},
{
path: AppRoute.STUDIO,
element: <Studio />,
},
],
},
];
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading