Skip to content

Commit

Permalink
refactor: update position prop in Step component
Browse files Browse the repository at this point in the history
  • Loading branch information
kleberbaum committed Jul 25, 2024
1 parent 73c4615 commit aa3c77d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 100 deletions.
163 changes: 64 additions & 99 deletions src/pages/recipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ import {
chakra
} from '@chakra-ui/react'
import {Field, connectBlock, useSectionBlockContext} from 'jaen'
import {FC} from 'react'
import {FC, useEffect, useState} from 'react'
import {Interface} from 'readline'
// import {CONTAINER_MAX_WIDTH} from '../../../../constant/sizes'
// import Shape1 from '../../../../common/assets/shapes/shape1.inline.svg'

interface IStepProps {
isLeft: boolean
position: number
}

interface IStepSectionProps {}
Expand All @@ -57,75 +58,41 @@ interface IStepsProps {
about: string
}

const Step: FC<IStepProps> = ({isLeft}) => {
const Step: React.FC<IStepProps> = ({ isLeft, position }) => {
// const [step, setStep] = useState<number>(position);

// useEffect(() => {
// setStep(position);
// }, [position]);

return (
<>
<Flex
justify={{md: isLeft ? 'left' : 'right'}}
justify={{ md: isLeft ? 'left' : 'right' }}
py="8"
display={{base: 'none', md: 'flex'}}>
display={{ base: 'none', md: 'flex' }}>
<Flex
align="center"
flexDir={{md: isLeft ? 'row' : 'row-reverse'}}
flexDir={{ md: isLeft ? 'row' : 'row-reverse' }}
flexGrow="1"
gap="8"
maxW="71.875rem"
justify="space-between">
<VStack flex="1">
<Grid placeItems="center" pos="relative">
{/* <Image src="/images/about_us/profile_bg.svg" /> */}
{/* <chakra.svg
as={Shape1}
sx={{
'#Selection': {
fill: '#f6f8fa'
}
}}
w="30rem"
maxW="100%"
h="auto"
pb="1rem"
transform="rotate(190deg)"
/> */}
{/* <Image src={image} pos="absolute" boxShadow="dark" w="80%" borderRadius="full" /> */}
<AspectRatio
ratio={1}
pos="absolute"
boxShadow="dark"
overflow="hidden"
isolation="isolate"
w="75%"
bg="white"
borderRadius="full">
<Field.Image name="image" />
</AspectRatio>
<Field.Image name="image" />
</Grid>
{/* <Heading size="h3015" fontWeight="semibold">
{name}
</Heading> */}
{/* <Field.Text
name="name"
as={Heading}
size="h3015"
fontWeight="semibold"
//textAlign={{ base: isLeft ? 'left' : 'right' }}
//fontWeight="semibold"
defaultValue={'Name'}
/> */}
</VStack>
<Stack flex="1" borderLeft={"5px solid"} borderColor="brand.900" p="8">
{/* <Heading color="brand.900" size="h4015" fontWeight="semibold">
{qoute}
</Heading> */}
<Field.Text
name="title"
as={Heading}
color="brand.900"
size="24"
fontWeight="semibold"
textAlign={'left'}
//fontWeight="semibold"
defaultValue={'Step 1'}
defaultValue={'Schritt ' + position}
isDisabled
/>
<Field.Text
name="lead"
Expand All @@ -137,52 +104,50 @@ const Step: FC<IStepProps> = ({isLeft}) => {
/>
<Field.Text
name="content"
//fontWeight="semibold"
color="gray.900"
textAlign={'left'}
//fontWeight="semibold"
defaultValue={'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'}
/>
</Stack>
</Flex>
</Flex>
</>
)
}
);
};

export const StepsSection = connectBlock(
() => {
const blockContext = useSectionBlockContext()
const position = blockContext!.position + 1
const blockContext = useSectionBlockContext()
const position = blockContext!.position + 1

console.log('position', blockContext)
console.log('position', blockContext)

return (
<Box
pos={'relative'}
pt={
position % 2 === 0
? {
base: '20',
md: '32'
return (
<Box
pos={'relative'}
pt={
position % 2 === 0
? {
base: '20',
md: '32'
}
: {
base: '8',
md: '12'
}
}
: {
base: '8',
md: '12'
}
}
pb={{
base: '12',
md: '20'
}}
//bgImage={blockContext!.position % 2 !== 0 ? '/images/about_us/thread1.svg' : undefined}
bgImage={{
md: position % 3 === 0 ? '/images/about_us/side_shape.svg' : undefined
}}
bgRepeat="no-repeat"
bgPos="right -8rem bottom 0"
bgSize="20rem">
{/* <Box
pb={{
base: '12',
md: '20'
}}
//bgImage={blockContext!.position % 2 !== 0 ? '/images/about_us/thread1.svg' : undefined}
bgImage={{
md: position % 3 === 0 ? '/images/about_us/side_shape.svg' : undefined
}}
bgRepeat="no-repeat"
bgPos="right -8rem bottom 0"
bgSize="20rem">
{/* <Box
top={position % 5 !== 0 ? { base: '-20', md: '-32' } : '0'}
right={"0"}
h={"100%"}
Expand All @@ -199,27 +164,27 @@ export const StepsSection = connectBlock(
bgPos={position % 5 !== 0 ? "0 -20px" : "0"}
bgSize="contain"
> */}
<Box
top={{base: '-20', md: '-32'}}
right={'0'}
h={'100%'}
w={'100%'}
bgImage={
position % 2 === 0 ? '/images/about_us/thread1.svg' : undefined
}
bgRepeat="no-repeat"
bgPos={'0 -20px'}
bgSize="contain"
pointerEvents="none"></Box>
<Container maxW={'8xl'}>
<Step isLeft={blockContext!.position % 2 === 0} />
</Container>
</Box>
)
<Box
top={{ base: '-20', md: '-32' }}
right={'0'}
h={'100%'}
w={'100%'}
bgImage={
position % 2 === 0 ? '/images/about_us/thread1.svg' : undefined
}
bgRepeat="no-repeat"
bgPos={'0 -20px'}
bgSize="contain"
pointerEvents="none"></Box>
<Container maxW={'8xl'}>
<Step isLeft={blockContext!.position % 2 === 0} position={blockContext!.position} />
</Container>
</Box>
)
},
{
name: 'StepsSection',
label: 'Step'
name: 'StepsSection',
label: 'Step'
}
)

Expand Down
2 changes: 1 addition & 1 deletion src/templates/RecipePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const StepsSection = connectBlock(
bgSize="contain"
pointerEvents="none"></Box>
<Container maxW={'8xl'}>
<Step isLeft={blockContext!.position % 2 === 0} position={position} />
<Step isLeft={blockContext!.position % 2 === 0} position={blockContext!.position} />
</Container>
</Box>
)
Expand Down

0 comments on commit aa3c77d

Please sign in to comment.