Skip to content
Merged
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
81 changes: 75 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,53 @@ It is the state of the tree in the network that we call "in transit".
These abstract helper types define special types a [Parent](#parent) can use as
[children][term-child].

### `BodyBlock`
### FormattingBlock

```ts
type BodyBlock =
type FormattingBlock =
| Paragraph
| Heading
| List
| Blockquote
| ThematicBreak
| Text
```

`FormattingBlock` nodes contains only text-structured blocks used for formatting textual content.

### `StoryBlock`

```ts
type StoryBlock =
| ImageSet
| Flourish
| BigNumber
| CustomCodeComponent
| Layout
| List
| Blockquote
| Pullquote
| ScrollyBlock
| ThematicBreak
| Table
| Recommended
| RecommendedList
| Tweet
| Video
| YoutubeVideo
| Text
| Timeline
| ImagePair
| InNumbers
| Definition
| InfoBox
| InfoPair
```

`StoryBlock` nodes are things that can be inserted into an article body.

### BodyBlock

```ts
type BodyBlock =
| FormattingBlock
| StoryBlock
```

`BodyBlock` nodes are the only things that are valid as the top level of a `Body`.
Expand Down Expand Up @@ -850,6 +870,55 @@ interface InNumbers extends Parent {
}
```

### Card

```ts
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>
/**
* A card describes a subject with images and text
*/
interface Card extends Parent {
type: "card"
/** The title of this card */
title?: string
children: CardChildren[]
}
```

### InfoBox

```ts
/**
* Allowed layout widths for an InfoBox.
*/
type InfoBoxLayoutWidth = Extract<LayoutWidth, "in-line" | "inset-left">
/**
* An info box describes a subject via a single card
*/
interface InfoBox extends Parent {
type: "info-box"
/** The layout width supported by this node */
layoutWidth: InfoBoxLayoutWidth
children: [Card]
}
```

### InfoPair

```ts
/**
* InfoPair provides exactly two cards.
*/
interface InfoPair extends Parent {
type: "info-pair"
/** The title of the info pair */
title?: string
children: [Card, Card]
}
```

## License

This software is published by the Financial Times under the [MIT licence](mit).
Expand Down
152 changes: 148 additions & 4 deletions content-tree.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export declare namespace ContentTree {
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition;
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type BodyBlock = FormattingBlock | StoryBlock;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
interface Node {
Expand Down Expand Up @@ -325,8 +327,44 @@ export declare namespace ContentTree {
title?: string;
children: [Definition, Definition, Definition];
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
/**
* A card describes a subject with images and text
*/
interface Card extends Parent {
type: "card";
/** The title of this card */
title?: string;
children: CardChildren[];
}
/**
* Allowed layout widths for an InfoBox.
*/
type InfoBoxLayoutWidth = Extract<LayoutWidth, "in-line" | "inset-left">;
/**
* An info box describes a subject via a single card
*/
interface InfoBox extends Parent {
type: "info-box";
/** The layout width supported by this node */
layoutWidth: InfoBoxLayoutWidth;
children: [Card];
}
/**
* InfoPair provides exactly two cards.
*/
interface InfoPair extends Parent {
type: "info-pair";
/** The title of the info pair */
title?: string;
children: [Card, Card];
}
namespace full {
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition;
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type BodyBlock = FormattingBlock | StoryBlock;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
interface Node {
Expand Down Expand Up @@ -652,9 +690,45 @@ export declare namespace ContentTree {
title?: string;
children: [Definition, Definition, Definition];
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
/**
* A card describes a subject with images and text
*/
interface Card extends Parent {
type: "card";
/** The title of this card */
title?: string;
children: CardChildren[];
}
/**
* Allowed layout widths for an InfoBox.
*/
type InfoBoxLayoutWidth = Extract<LayoutWidth, "in-line" | "inset-left">;
/**
* An info box describes a subject via a single card
*/
interface InfoBox extends Parent {
type: "info-box";
/** The layout width supported by this node */
layoutWidth: InfoBoxLayoutWidth;
children: [Card];
}
/**
* InfoPair provides exactly two cards.
*/
interface InfoPair extends Parent {
type: "info-pair";
/** The title of the info pair */
title?: string;
children: [Card, Card];
}
}
namespace transit {
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition;
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type BodyBlock = FormattingBlock | StoryBlock;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
interface Node {
Expand Down Expand Up @@ -965,9 +1039,45 @@ export declare namespace ContentTree {
title?: string;
children: [Definition, Definition, Definition];
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
/**
* A card describes a subject with images and text
*/
interface Card extends Parent {
type: "card";
/** The title of this card */
title?: string;
children: CardChildren[];
}
/**
* Allowed layout widths for an InfoBox.
*/
type InfoBoxLayoutWidth = Extract<LayoutWidth, "in-line" | "inset-left">;
/**
* An info box describes a subject via a single card
*/
interface InfoBox extends Parent {
type: "info-box";
/** The layout width supported by this node */
layoutWidth: InfoBoxLayoutWidth;
children: [Card];
}
/**
* InfoPair provides exactly two cards.
*/
interface InfoPair extends Parent {
type: "info-pair";
/** The title of the info pair */
title?: string;
children: [Card, Card];
}
}
namespace loose {
type BodyBlock = Paragraph | Heading | ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | List | Blockquote | Pullquote | ScrollyBlock | ThematicBreak | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Text | Timeline | ImagePair | InNumbers | Definition;
type FormattingBlock = Paragraph | Heading | List | Blockquote | ThematicBreak | Text;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type BodyBlock = FormattingBlock | StoryBlock;
type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width";
type Phrasing = Text | Break | Strong | Emphasis | Strikethrough | Link;
interface Node {
Expand Down Expand Up @@ -1293,5 +1403,39 @@ export declare namespace ContentTree {
title?: string;
children: [Definition, Definition, Definition];
}
/** Allowed children for a card
*/
type CardChildren = ImageSet | Exclude<FormattingBlock, Heading>;
/**
* A card describes a subject with images and text
*/
interface Card extends Parent {
type: "card";
/** The title of this card */
title?: string;
children: CardChildren[];
}
/**
* Allowed layout widths for an InfoBox.
*/
type InfoBoxLayoutWidth = Extract<LayoutWidth, "in-line" | "inset-left">;
/**
* An info box describes a subject via a single card
*/
interface InfoBox extends Parent {
type: "info-box";
/** The layout width supported by this node */
layoutWidth: InfoBoxLayoutWidth;
children: [Card];
}
/**
* InfoPair provides exactly two cards.
*/
interface InfoPair extends Parent {
type: "info-pair";
/** The title of the info pair */
title?: string;
children: [Card, Card];
}
}
}
Loading
Loading