-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial flip card block * Improvements for flip card * Added templateLock * Initial expandable content -block * Initial Revealable content -block * Changed icon to button * Little changes * Little changes to revealable content block * Changes to flipcard desing * Changes to style of expandable content -block * Changes to style of revealable content -block * Small changes to style of the flip card block * Small changes * Changes to margin * Seperated Inner card to back and front cards * Small changes to Revealable content -block * Little fixes --------- Co-authored-by: Maija Y <[email protected]>
- Loading branch information
Showing
34 changed files
with
1,096 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
services/cms/src/blocks/ExpandableContent/ExpandableContentEditor.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { BlockEditProps } from "@wordpress/blocks" | ||
import React from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import BlockPlaceholderWrapper from "../BlockPlaceholderWrapper" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["core/expandable-content-inner-block"] | ||
const ExpandableContentEditor: React.FC< | ||
React.PropsWithChildren<BlockEditProps<Record<string, never>>> | ||
> = ({ clientId }) => { | ||
const { t } = useTranslation() | ||
return ( | ||
<BlockPlaceholderWrapper | ||
id={clientId} | ||
title={t("expandable-content-placeholder")} | ||
explanation={t("expandable-content-explanation")} | ||
> | ||
<div> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} /> | ||
</div> | ||
</BlockPlaceholderWrapper> | ||
) | ||
} | ||
|
||
export default ExpandableContentEditor |
38 changes: 38 additions & 0 deletions
38
...locks/ExpandableContent/ExpandableContentInnerBlock/ExpandableContentInnerBlockEditor.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { css } from "@emotion/css" | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { BlockEditProps } from "@wordpress/blocks" | ||
import React from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import BlockPlaceholderWrapper from "../../BlockPlaceholderWrapper" | ||
|
||
import { ExpandableContentConfigurationProps } from "." | ||
|
||
import TextField from "@/shared-module/common/components/InputFields/TextField" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["core/heading", "core/paragraph", "core/image", "core/list"] | ||
const ExpandableContentInnerBlockEditor: React.FC< | ||
React.PropsWithChildren<BlockEditProps<ExpandableContentConfigurationProps>> | ||
> = ({ clientId, attributes, setAttributes }) => { | ||
const { t } = useTranslation() | ||
return ( | ||
<BlockPlaceholderWrapper | ||
id={clientId} | ||
title={"Expandable content"} | ||
explanation={"Expandable content"} | ||
> | ||
<TextField | ||
placeholder={t("label-title")} | ||
value={attributes.name} | ||
onChangeByValue={(value) => setAttributes({ name: value })} | ||
className={css` | ||
margin-bottom: 1rem !important; | ||
`} | ||
/> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} /> | ||
</BlockPlaceholderWrapper> | ||
) | ||
} | ||
|
||
export default ExpandableContentInnerBlockEditor |
12 changes: 12 additions & 0 deletions
12
.../blocks/ExpandableContent/ExpandableContentInnerBlock/ExpandableContentInnerBlockSave.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import React from "react" | ||
|
||
const ExpandableContentInnerBlockSave: React.FC<unknown> = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default ExpandableContentInnerBlockSave |
23 changes: 23 additions & 0 deletions
23
services/cms/src/blocks/ExpandableContent/ExpandableContentInnerBlock/index.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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "../../../utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
import ExpandableContentEditor from "./ExpandableContentInnerBlockEditor" | ||
import ExpandableContentSave from "./ExpandableContentInnerBlockSave" | ||
|
||
export interface ExpandableContentConfigurationProps { | ||
name: string | ||
} | ||
const ExpandableContentInnerBlockConfiguration: BlockConfiguration<ExpandableContentConfigurationProps> = | ||
{ | ||
title: "Expandable Content", | ||
description: "One or more heading that has expandable/collapsible content", | ||
category: MOOCFI_CATEGORY_SLUG, | ||
attributes: { name: { type: "string", default: "" } }, | ||
parent: ["moocfi/expandable-content"], | ||
edit: ExpandableContentEditor, | ||
save: ExpandableContentSave, | ||
} | ||
|
||
export default ExpandableContentInnerBlockConfiguration |
12 changes: 12 additions & 0 deletions
12
services/cms/src/blocks/ExpandableContent/ExpandableContentSave.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import React from "react" | ||
|
||
const ExpendableContentSave: React.FC<unknown> = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default ExpendableContentSave |
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,20 @@ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "../../utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
import ExpandableContentEditor from "./ExpandableContentEditor" | ||
import ExpandableContentSave from "./ExpandableContentSave" | ||
|
||
// eslint-disable-next-line i18next/no-literal-string | ||
const ExpandableContent = "ExpandableContent" | ||
|
||
const ExpandableContentConfiguration: BlockConfiguration = { | ||
title: ExpandableContent, | ||
description: ExpandableContent, | ||
category: MOOCFI_CATEGORY_SLUG, | ||
attributes: {}, | ||
edit: ExpandableContentEditor, | ||
save: ExpandableContentSave, | ||
} | ||
|
||
export default ExpandableContentConfiguration |
25 changes: 25 additions & 0 deletions
25
services/cms/src/blocks/FlipCard/BackFlipCard/BackFlipCardEditor.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { BlockEditProps } from "@wordpress/blocks" | ||
import React from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import BlockPlaceholderWrapper from "../../BlockPlaceholderWrapper" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["core/image", "core/paragraph", "core/heading", "core/list"] | ||
|
||
const BackFlipCardEditor: React.FC<BlockEditProps<Record<string, never>>> = ({ clientId }) => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<BlockPlaceholderWrapper | ||
id={clientId} | ||
title={t("back-card")} | ||
explanation={t("back-card-explanation")} | ||
> | ||
<div> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} templateLock={false} /> | ||
</div> | ||
</BlockPlaceholderWrapper> | ||
) | ||
} | ||
export default BackFlipCardEditor |
11 changes: 11 additions & 0 deletions
11
services/cms/src/blocks/FlipCard/BackFlipCard/BackFlipCardSave.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
|
||
const BackFlipCardSave: React.FC = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default BackFlipCardSave |
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,19 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import BackFlipCardEditor from "./BackFlipCardEditor" | ||
import InnerCardSave from "./BackFlipCardSave" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "@/utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
const BackFlipCardConfiguration: BlockConfiguration = { | ||
title: "Back Flip Card", | ||
description: "Back side for the flip card block", | ||
category: MOOCFI_CATEGORY_SLUG, | ||
parent: ["moocfi/flip-card"], | ||
attributes: {}, | ||
edit: BackFlipCardEditor, | ||
save: InnerCardSave, | ||
} | ||
|
||
export default BackFlipCardConfiguration |
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,44 @@ | ||
import { InnerBlocks, InspectorControls } from "@wordpress/block-editor" | ||
import { BlockEditProps, TemplateArray } from "@wordpress/blocks" | ||
import React from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import BlockPlaceholderWrapper from "../BlockPlaceholderWrapper" | ||
|
||
import { FlipCardAttributes } from "." | ||
|
||
import FlipBoxSizeCustomizer from "@/components/blocks/FlipCardSizeCustomizer" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["moocfi/front-card"] | ||
const INNER_BLOCKS_TEMPLATE: TemplateArray = [ | ||
["moocfi/front-card", {}], | ||
["moocfi/back-card", {}], | ||
] | ||
|
||
const FlipCardEditor: React.FC<React.PropsWithChildren<BlockEditProps<FlipCardAttributes>>> = ({ | ||
clientId, | ||
attributes, | ||
setAttributes, | ||
}) => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<BlockPlaceholderWrapper | ||
id={clientId} | ||
title={t("flip-card-placeholder")} | ||
explanation={t("flip-card-placeholder-explanation")} | ||
> | ||
<InspectorControls key="flip-card-settings"> | ||
<FlipBoxSizeCustomizer attributes={attributes} setAttributes={setAttributes} /> | ||
</InspectorControls> | ||
<div> | ||
<InnerBlocks | ||
allowedBlocks={ALLOWED_NESTED_BLOCKS} | ||
template={INNER_BLOCKS_TEMPLATE} | ||
templateLock="all" | ||
/> | ||
</div> | ||
</BlockPlaceholderWrapper> | ||
) | ||
} | ||
export default FlipCardEditor |
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,11 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
|
||
const FlipCardSave: React.FC = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default FlipCardSave |
25 changes: 25 additions & 0 deletions
25
services/cms/src/blocks/FlipCard/FrontFlipCard/FrontFlipCardEditor.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { BlockEditProps } from "@wordpress/blocks" | ||
import React from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import BlockPlaceholderWrapper from "../../BlockPlaceholderWrapper" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["core/image", "core/paragraph", "core/heading", "core/list"] | ||
|
||
const FrontFlipCardEditor: React.FC<BlockEditProps<Record<string, never>>> = ({ clientId }) => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<BlockPlaceholderWrapper | ||
id={clientId} | ||
title={t("front-card")} | ||
explanation={t("front-card-explanation")} | ||
> | ||
<div> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} templateLock={false} /> | ||
</div> | ||
</BlockPlaceholderWrapper> | ||
) | ||
} | ||
export default FrontFlipCardEditor |
11 changes: 11 additions & 0 deletions
11
services/cms/src/blocks/FlipCard/FrontFlipCard/FrontFlipCardSave.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
|
||
const FrontFlipCardSave: React.FC = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default FrontFlipCardSave |
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,19 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import FrontFlipCardEditor from "./FrontFlipCardEditor" | ||
import FrontFlipCardSave from "./FrontFlipCardSave" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "@/utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
const FrontFlipCardConfiguration: BlockConfiguration = { | ||
title: "Inner Card", | ||
description: "Front side for the flip card block", | ||
category: MOOCFI_CATEGORY_SLUG, | ||
parent: ["moocfi/flip-card"], | ||
attributes: {}, | ||
edit: FrontFlipCardEditor, | ||
save: FrontFlipCardSave, | ||
} | ||
|
||
export default FrontFlipCardConfiguration |
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,26 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import FlipCardEditor from "./FlipCardEditor" | ||
import FlipCardSave from "./FlipCardSave" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "@/utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
export interface FlipCardAttributes { | ||
size: string | ||
} | ||
const FlipCardConfiguration: BlockConfiguration<FlipCardAttributes> = { | ||
title: "Flip Card", | ||
description: "A two sided flip card that can be flipped by clicking the card", | ||
category: MOOCFI_CATEGORY_SLUG, | ||
attributes: { | ||
size: { | ||
type: "string", | ||
default: "xl", | ||
}, | ||
}, | ||
edit: FlipCardEditor, | ||
save: FlipCardSave, | ||
} | ||
|
||
export default FlipCardConfiguration |
32 changes: 32 additions & 0 deletions
32
services/cms/src/blocks/RevealableContent/RevealableContentEditor.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { BlockEditProps } from "@wordpress/blocks" | ||
import { t } from "i18next" | ||
import React from "react" | ||
|
||
import BlockPlaceholderWrapper from "../BlockPlaceholderWrapper" | ||
|
||
import { ConditionAttributes } from "." | ||
|
||
const ALLOWED_NESTED_BLOCKS = [ | ||
"core/heading", | ||
"core/paragraph", | ||
"core/image", | ||
"core/list", | ||
"moocfi/revealable-hidden-content", | ||
] | ||
|
||
const ConditionalBlockEditor: React.FC< | ||
React.PropsWithChildren<BlockEditProps<ConditionAttributes>> | ||
> = ({ clientId }) => { | ||
return ( | ||
<BlockPlaceholderWrapper | ||
id={clientId} | ||
title={t("revealable-content-placeholder")} | ||
explanation={t("revealable-content-explanation")} | ||
> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} /> | ||
</BlockPlaceholderWrapper> | ||
) | ||
} | ||
|
||
export default ConditionalBlockEditor |
11 changes: 11 additions & 0 deletions
11
services/cms/src/blocks/RevealableContent/RevealableContentSave.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
|
||
const RevealableContentSave: React.FC = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default RevealableContentSave |
Oops, something went wrong.