-
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.
Remove textAlign prop from HeadingBlock and move it to StandaloneHeadingBlock so the text align setting will only be visible where it is used.
- Loading branch information
Showing
19 changed files
with
182 additions
and
80 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
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,31 @@ | ||
import { BlockCategory, createCompositeBlock, createCompositeBlockSelectField } from "@comet/blocks-admin"; | ||
import { StandaloneHeadingBlockData } from "@src/blocks.generated"; | ||
import { HeadingBlock } from "@src/common/blocks/HeadingBlock"; | ||
import * as React from "react"; | ||
import { FormattedMessage } from "react-intl"; | ||
|
||
export const StandaloneHeadingBlock = createCompositeBlock( | ||
{ | ||
name: "StandaloneHeading", | ||
displayName: <FormattedMessage id="standaloneHeading.displayName" defaultMessage="Heading" />, | ||
blocks: { | ||
heading: { | ||
block: HeadingBlock, | ||
}, | ||
textAlignment: { | ||
block: createCompositeBlockSelectField<StandaloneHeadingBlockData["textAlignment"]>({ | ||
defaultValue: "left", | ||
options: [ | ||
{ value: "left", label: <FormattedMessage id="standaloneHeading.textAlignment.left" defaultMessage="left" /> }, | ||
{ value: "center", label: <FormattedMessage id="standaloneHeading.textAlignment.center" defaultMessage="center" /> }, | ||
], | ||
fieldProps: { label: <FormattedMessage id="standaloneHeading.textAlignment" defaultMessage="Text alignment" />, fullWidth: true }, | ||
}), | ||
}, | ||
}, | ||
}, | ||
(block) => { | ||
block.category = BlockCategory.TextAndContent; | ||
return block; | ||
}, | ||
); |
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
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
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
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,43 @@ | ||
import { | ||
BlockData, | ||
BlockDataInterface, | ||
BlockField, | ||
BlockInput, | ||
ChildBlock, | ||
ChildBlockInput, | ||
createBlock, | ||
ExtractBlockInput, | ||
inputToData, | ||
} from "@comet/blocks-api"; | ||
import { HeadingBlock } from "@src/common/blocks/heading.block"; | ||
import { IsEnum } from "class-validator"; | ||
|
||
enum TextAlignment { | ||
left = "left", | ||
center = "center", | ||
} | ||
|
||
class StandaloneHeadingBlockData extends BlockData { | ||
@ChildBlock(HeadingBlock) | ||
heading: BlockDataInterface; | ||
|
||
@BlockField({ type: "enum", enum: TextAlignment }) | ||
textAlignment: TextAlignment; | ||
} | ||
|
||
class StandaloneHeadingBlockInput extends BlockInput { | ||
@ChildBlockInput(HeadingBlock) | ||
heading: ExtractBlockInput<typeof HeadingBlock>; | ||
|
||
@IsEnum(TextAlignment) | ||
@BlockField({ type: "enum", enum: TextAlignment }) | ||
textAlignment: TextAlignment; | ||
|
||
transformToBlockData(): StandaloneHeadingBlockData { | ||
return inputToData(StandaloneHeadingBlockData, this); | ||
} | ||
} | ||
|
||
export const StandaloneHeadingBlock = createBlock(StandaloneHeadingBlockData, StandaloneHeadingBlockInput, { | ||
name: "StandaloneHeading", | ||
}); |
Oops, something went wrong.