Started doing an Image component for inline text

This commit is contained in:
2023-09-03 19:45:19 +02:00
parent bfeeb71312
commit 4f5d822e11
5 changed files with 42 additions and 27 deletions

View File

@@ -10,11 +10,9 @@ import inlineComponents, { richTextTemplates } from "../inline/inline-definition
export const Content: PageBlockFunction<PageBlocksContent> = ({ data }) => {
return (
<Section color={ data.color }>
<Section>
<Container
className={ `prose prose-lg ${
data.color === "primary" ? "prose-primary" : "dark:prose-dark"
}` }
className={ "prose prose-lg" }
data-tina-field={ tinaField(data, "body") }
size="large"
width="medium"
@@ -42,16 +40,6 @@ export const contentBlockSchema: Template = {
name: "body",
templates: richTextTemplates,
isBody: true
},
{
type: "string",
label: "Color",
name: "color",
options: [
{ label: "Default", value: "default" },
{ label: "Tint", value: "tint" },
{ label: "Primary", value: "primary" }
]
}
]
};

View File

@@ -1,14 +1,29 @@
import { TinaMarkdown, TinaMarkdownContent } from "tinacms/dist/rich-text";
import { Template } from "tinacms";
import { anchoringSchema } from "../util/anchoring";
import { TinaMarkdownContent } from "tinacms/dist/rich-text";
import { RichTextTemplate } from "@tinacms/schema-tools";
enum imageSize {
small = "small",
medium = "medium",
large = "large"
}
enum imageDecorations {
default = "default",
noStyle = "no-style"
}
enum imagePosition {
left = "left",
middle = "middle",
right = "right"
}
export interface ImageProps {
children: TinaMarkdownContent;
size: "small" | "medium" | "large";
size: imageSize;
imageUrl: string,
decorations: string,
position: "left" | "middle" | "right"
decorations: imageDecorations,
position: imagePosition
}
const Image = (props: ImageProps) => (
@@ -17,21 +32,27 @@ const Image = (props: ImageProps) => (
</div>);
export const imageSchema: RichTextTemplate = {
name: "image",
name: "Image",
label: "Image",
inline: true,
ui: {
defaultItem: {
size: Object.values(imageSize)[0],
decorations: Object.values(imageDecorations)[0]
}
},
fields: [
{
name: "size",
label: "Size",
type: "string",
options: ["small", "medium", "large"]
options: Object.values(imageSize)
},
{
name: "position",
label: "Position",
type: "string",
options: ["left", "middle", "right"]
options: Object.values(imagePosition)
},
{
name: "imageUrl",
@@ -41,7 +62,8 @@ export const imageSchema: RichTextTemplate = {
{
name: "decorations",
label: "Decorations",
type: "string"
type: "string",
options: Object.values(imageDecorations)
}
] };

View File

@@ -9,8 +9,9 @@ blocks:
text: Découvrez-en plus !
linkTo: main-page
_template: carousel
- body: |
aezaeaezae<DateTime format="iso" />dzds
- body: >
aezaeaezae<DateTime format="iso" />dzd <Image size="small" position="left"
imageUrl="/uploads/etoile.jpg" decorations="default" />
_template: content
- headline: Welcome to the Tina Starter
text: >
@@ -85,6 +86,10 @@ url: home

BIN
public/uploads/etoile.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

File diff suppressed because one or more lines are too long