-
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.
feat: wip DynamicZoneBlock style, opened state, header
- Loading branch information
Quentin Le Caignec
committed
Aug 20, 2024
1 parent
f5777e1
commit f1f7958
Showing
8 changed files
with
127 additions
and
45 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
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
69 changes: 52 additions & 17 deletions
69
packages/haring-react/src/Form/DynamicZone/DynamicZone.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
10 changes: 8 additions & 2 deletions
10
packages/haring-react/src/Form/DynamicZone/DynamicZoneBlock/DynamicZoneBlock.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 |
---|---|---|
@@ -1,4 +1,10 @@ | ||
.container { | ||
/* WIP */ | ||
border: 1px red dashed; | ||
} | ||
|
||
.header { | ||
cursor: pointer; | ||
|
||
&:hover { | ||
filter: contrast(40%); | ||
} | ||
} |
49 changes: 37 additions & 12 deletions
49
packages/haring-react/src/Form/DynamicZone/DynamicZoneBlock/DynamicZoneBlock.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 |
---|---|---|
@@ -1,26 +1,51 @@ | ||
import type { ContainerProps } from '@mantine/core'; | ||
import type { CardProps, CardSectionProps } from '@mantine/core'; | ||
import type { ReactElement, ReactNode } from 'react'; | ||
|
||
import { Container } from '@mantine/core'; | ||
import { Card, Collapse, Container, Group } from '@mantine/core'; | ||
import { CaretDown, CaretUp } from '@phosphor-icons/react'; | ||
|
||
import classes from './DynamicZoneBlock.module.css'; | ||
|
||
export interface IDynamicZoneBlockProps { | ||
export interface IDynamicZoneBlockProps extends CardProps { | ||
cardSectionProps?: CardSectionProps; | ||
children: ReactNode; | ||
containerProps?: ContainerProps; | ||
onToggle: (opened: boolean) => void; | ||
opened: boolean; | ||
} | ||
|
||
export function DynamicZoneBlock(props: IDynamicZoneBlockProps): ReactElement { | ||
const { children, containerProps } = props; | ||
const { cardSectionProps, children, onToggle, opened, ...cardProps } = props; | ||
return ( | ||
<Container | ||
<Card | ||
bg="white" | ||
className={classes.container} | ||
fluid | ||
m={0} | ||
p={10} | ||
{...containerProps} | ||
radius="md" | ||
shadow="sm" | ||
withBorder | ||
{...cardProps} | ||
> | ||
{children} | ||
</Container> | ||
<Card.Section | ||
className={classes.header} | ||
p="sm" | ||
withBorder={opened} | ||
{...cardSectionProps} | ||
onClick={() => onToggle(!opened)} | ||
role="button" | ||
> | ||
<Group justify="space-between"> | ||
<Group> | ||
<span>icon</span> | ||
<span>title</span> | ||
</Group> | ||
{opened ? <CaretDown /> : <CaretUp />} | ||
</Group> | ||
</Card.Section> | ||
<Collapse {...cardSectionProps} in={opened}> | ||
<Container fluid p="xs"> | ||
{children} | ||
</Container> | ||
</Collapse> | ||
<Card.Section p={0} {...cardSectionProps} /> | ||
</Card> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface IBaseBlock extends Record<string, unknown> { | ||
id: string; | ||
opened: boolean; | ||
} |
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 +1,2 @@ | ||
export * from './thumbnail'; | ||
export * from './dynamic-zone'; |