Skip to content
Open
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
4 changes: 2 additions & 2 deletions backend/api/project/models/project.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"blocks": {
"type": "dynamiczone",
"components": [
"project.title-block",
"project.blockquote-block",
"project.image-block",
"project.paragraph-block"
"project.paragraph-block",
"project.list-block"
],
"pluginOptions": {
"i18n": {
Expand Down
13 changes: 13 additions & 0 deletions backend/components/blocks/list-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"collectionName": "components_blocks_list_items",
"info": {
"name": "listItem",
"icon": "ban"
},
"options": {},
"attributes": {
"text": {
"type": "string"
}
}
}
15 changes: 15 additions & 0 deletions backend/components/project/list-block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"collectionName": "components_project_list_blocks",
"info": {
"name": "listBlock",
"icon": "list-ul"
},
"options": {},
"attributes": {
"items": {
"type": "component",
"repeatable": true,
"component": "blocks.list-item"
}
}
}
13 changes: 0 additions & 13 deletions backend/components/project/title-block.json

This file was deleted.

57 changes: 57 additions & 0 deletions frontend/features/project/blocks/ListBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from "react";
import {
Block,
BlockComponentProps,
BlocksControls,
InlineBlocks,
} from "react-tinacms-inline";

import { Box } from "@chakra-ui/react";
import { listItemBlock } from "./ListItemBlock";

export type ListBlockData = BlockTemplateData<
"listBlock",
{
id: string;
items: {
text: Nullable<string>[];
};
}
>;

export default function ListBlock() {
return (
<Box
as="ul"
w={{ base: "full", md: "container.md" }}
lineHeight="1.8em"
mt="12"
mx="auto"
mb="0"
pl="5"
fontFamily="Europa, sans-serif"
boxSizing="border-box"
>
<InlineBlocks name="items" blocks={{ listItem: listItemBlock }} />
</Box>
);
}

function BlockComponent({ index, data }: BlockComponentProps) {
return (
<BlocksControls index={index} focusRing={{ offset: 0 }} insetControls>
<ListBlock {...data} />
</BlocksControls>
);
}

export const listBlock: Block = {
Component: BlockComponent,
template: {
label: "List block",
defaultItem: {
blocks: [],
},
fields: [],
},
};
44 changes: 44 additions & 0 deletions frontend/features/project/blocks/ListItemBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from "react";
import {
Block,
BlockComponentProps,
BlocksControls,
InlineText,
} from "react-tinacms-inline";

import { Box } from "@chakra-ui/react";

export type ListItemBlockData = BlockTemplateData<
"listItemBlock",
{
id: string;
text: string;
}
>;

export default function ListItemBlock() {
return (
<Box as="li" mb="1">
<InlineText name="text" />
</Box>
);
}

function BlockComponent({ index, data }: BlockComponentProps) {
return (
<BlocksControls index={index} focusRing={{ offset: 0 }} insetControls>
<ListItemBlock {...data} />
</BlocksControls>
);
}

export const listItemBlock: Block = {
Component: BlockComponent,
template: {
label: "List item block",
defaultItem: {
text: "Default item text",
},
fields: [],
},
};
Loading