mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-01 18:20:28 +00:00
Update prototype page
This commit is contained in:
@@ -3,7 +3,7 @@ import { useHistory, useParams } from 'react-router-dom';
|
|||||||
import { useLazyQuery, useReactiveVar } from '@apollo/client';
|
import { useLazyQuery, useReactiveVar } from '@apollo/client';
|
||||||
import { Redirect } from 'react-router';
|
import { Redirect } from 'react-router';
|
||||||
import { roleVar } from '../../graphql/state';
|
import { roleVar } from '../../graphql/state';
|
||||||
import { Empty, ArrowLeft } from '../../assets';
|
import { Empty, ArrowLeft, Edit, Check } from '../../assets';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Text,
|
Text,
|
||||||
@@ -19,12 +19,14 @@ import {
|
|||||||
TemplateOutput,
|
TemplateOutput,
|
||||||
} from '../../graphql/types';
|
} from '../../graphql/types';
|
||||||
import { GET_TEMPLATE_BY_ID } from '../../graphql/template.api';
|
import { GET_TEMPLATE_BY_ID } from '../../graphql/template.api';
|
||||||
|
import { theme } from '../../themes';
|
||||||
|
|
||||||
const Prototype = () => {
|
const Prototype = () => {
|
||||||
const role = useReactiveVar(roleVar);
|
const role = useReactiveVar(roleVar);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const [template, setTemplate] = useState<TemplateOutput>();
|
const [template, setTemplate] = useState<TemplateOutput>();
|
||||||
|
const [editing, setEditing] = useState<boolean>(false);
|
||||||
|
|
||||||
const [getTemplate, { loading: templateLoading }] = useLazyQuery<
|
const [getTemplate, { loading: templateLoading }] = useLazyQuery<
|
||||||
GetTemplateByIdQuery,
|
GetTemplateByIdQuery,
|
||||||
@@ -49,7 +51,7 @@ const Prototype = () => {
|
|||||||
{!templateLoading ? (
|
{!templateLoading ? (
|
||||||
<>
|
<>
|
||||||
{template ? (
|
{template ? (
|
||||||
<Wrapper>
|
<Wrapper color={role}>
|
||||||
<Box padding='35px 45px 0px 120px'>
|
<Box padding='35px 45px 0px 120px'>
|
||||||
<Box
|
<Box
|
||||||
display='flex'
|
display='flex'
|
||||||
@@ -85,23 +87,55 @@ const Prototype = () => {
|
|||||||
<Box
|
<Box
|
||||||
display='grid'
|
display='grid'
|
||||||
gridTemplateColumns='repeat(2, auto)'
|
gridTemplateColumns='repeat(2, auto)'
|
||||||
rowGap='20px'
|
rowGap='100px'
|
||||||
alignItems='stretch'
|
alignItems='stretch'
|
||||||
justifyContent='center'
|
|
||||||
background='#F9FAFA'
|
background='#F9FAFA'
|
||||||
boxShadow='1px 1px 10px rgba(50, 59, 105, 0.25)'
|
boxShadow='1px 1px 10px rgba(50, 59, 105, 0.25)'
|
||||||
borderRadius='10px'
|
borderRadius='10px'
|
||||||
padding='30px 60px'
|
padding='30px 120px'
|
||||||
|
position='relative'
|
||||||
>
|
>
|
||||||
{template.features.map((feature) => {
|
{template.features.map((feature, index) => {
|
||||||
if (
|
if (
|
||||||
feature.featureType === 'frontend' ||
|
feature.featureType === 'frontend' ||
|
||||||
feature.featureType === 'fullstack'
|
feature.featureType === 'fullstack'
|
||||||
) {
|
) {
|
||||||
return <FrontendFeatureCard feature={feature} />;
|
return (
|
||||||
|
<FrontendFeatureCard
|
||||||
|
feature={feature}
|
||||||
|
key={feature.id}
|
||||||
|
className={
|
||||||
|
index === 0 || index % 2 === 0
|
||||||
|
? 'frontend-feature-even'
|
||||||
|
: 'frontend-feature-odd'
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
})}
|
})}
|
||||||
|
<Box
|
||||||
|
position='absolute'
|
||||||
|
top='30px'
|
||||||
|
right='30px'
|
||||||
|
width='35px'
|
||||||
|
height='35px'
|
||||||
|
padding='10px'
|
||||||
|
borderRadius='10px'
|
||||||
|
background={
|
||||||
|
!editing
|
||||||
|
? theme.colors.white.main
|
||||||
|
: theme.colors[role].main
|
||||||
|
}
|
||||||
|
boxShadow='1px 1px 5px rgba(50, 59, 105, 0.25)'
|
||||||
|
display='flex'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
cursor='pointer'
|
||||||
|
onClick={() => setEditing(!editing)}
|
||||||
|
>
|
||||||
|
{!editing ? <Edit /> : <Check />}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
@@ -126,7 +160,12 @@ const Prototype = () => {
|
|||||||
feature.featureType === 'backend' ||
|
feature.featureType === 'backend' ||
|
||||||
feature.featureType === 'fullstack'
|
feature.featureType === 'fullstack'
|
||||||
) {
|
) {
|
||||||
return <BackendFeatureCard feature={feature} />;
|
return (
|
||||||
|
<BackendFeatureCard
|
||||||
|
feature={feature}
|
||||||
|
key={feature.id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -9,4 +9,21 @@ export const Wrapper = styled.div<WrapperProps>`
|
|||||||
fill: ${({ theme, color }) =>
|
fill: ${({ theme, color }) =>
|
||||||
color ? theme.colors[color].main : theme.colors.client.main};
|
color ? theme.colors[color].main : theme.colors.client.main};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.frontend-feature-odd {
|
||||||
|
justify-self: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frontend-feature-even {
|
||||||
|
justify-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frontend-feature-even,
|
||||||
|
.frontend-feature-odd {
|
||||||
|
&:hover {
|
||||||
|
border: 2px solid
|
||||||
|
${({ theme, color }) =>
|
||||||
|
color ? theme.colors[color].main : theme.colors.client.main};
|
||||||
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user