-
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.
* WIP * Add Author InnerBlock * Add Author InnerBlock * update AuthorBlock * + responsiveness to AUthorBlock * remove unused import * update AuthorEditor style * update AuthorEditor style * add page containing AuthorBlock to seed_courses.rs * + test for Author block * add test * add missing comma * update snapshot * update snapshot * WIP * WIP * Add broken example code * update author in seed_course * remove unused import * add assets * remove unused code * update seed_courses * Show block name in the default block * update seed_courses * update snapshots * run cargo-fmt * Close browser contexts * update snapshot * Misc fixes --------- Co-authored-by: Henrik Nygren <[email protected]>
- Loading branch information
1 parent
e1f3b53
commit 4ce6cce
Showing
31 changed files
with
433 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { css } from "@emotion/css" | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { BlockEditProps, Template } from "@wordpress/blocks" | ||
import React from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import { baseTheme, headingFont } from "../../shared-module/styles" | ||
import BlockWrapper from "../BlockWrapper" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["moocfi/author-inner-block"] | ||
const AUTHOR_BLOCK_TEMPLATE: Template[] = [["moocfi/author-inner-block"]] | ||
const AuthorEditor: React.FC<React.PropsWithChildren<BlockEditProps<Record<string, never>>>> = ({ | ||
clientId, | ||
}) => { | ||
const { t } = useTranslation() | ||
return ( | ||
<BlockWrapper id={clientId}> | ||
<div> | ||
<div | ||
className={css` | ||
padding: 1rem; | ||
background: ${baseTheme.colors.clear[100]}; | ||
text-align: center; | ||
font-family: ${headingFont}; | ||
`} | ||
> | ||
<h4>{t("authors-block")}</h4> | ||
<span | ||
className={css` | ||
color: ${baseTheme.colors.gray[600]}; | ||
text-align: center; | ||
font-weight: 500; | ||
display: inline-block; | ||
margin-bottom: 1.4rem; | ||
font-family: ${headingFont}; | ||
`} | ||
> | ||
{t("authors-block-description")} | ||
</span> | ||
|
||
<div> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} template={AUTHOR_BLOCK_TEMPLATE} /> | ||
</div> | ||
</div> | ||
</div> | ||
</BlockWrapper> | ||
) | ||
} | ||
|
||
export default AuthorEditor |
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 AuthorSave: React.FC<unknown> = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default AuthorSave |
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,18 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "../../utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
import AuthorEditor from "./AuthorEditor" | ||
import AuthorSave from "./AuthorSave" | ||
|
||
const AuthorConfiguration: BlockConfiguration = { | ||
title: "Authors", | ||
description: "Author Section", | ||
category: MOOCFI_CATEGORY_SLUG, | ||
attributes: {}, | ||
edit: AuthorEditor, | ||
save: AuthorSave, | ||
} | ||
|
||
export default AuthorConfiguration |
57 changes: 57 additions & 0 deletions
57
services/cms/src/blocks/AuthorInnerBlock/AuthorInnerBlockEditor.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,57 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { BlockEditProps, Template } from "@wordpress/blocks" | ||
import React from "react" | ||
|
||
import BlockWrapper from "../BlockWrapper" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["core/image", "core/paragraph"] | ||
const AUTHOR_BLOCK_TEMPLATE: Template[] = [ | ||
[ | ||
"core/columns", | ||
{ isStackedOnMobile: true }, | ||
[ | ||
[ | ||
"core/column", | ||
{}, | ||
[ | ||
[ | ||
"core/image", | ||
{ | ||
level: 2, | ||
textAlign: "left", | ||
anchor: "author-photo", | ||
}, | ||
], | ||
], | ||
], | ||
[ | ||
"core/column", | ||
{}, | ||
[ | ||
[ | ||
"core/paragraph", | ||
{ | ||
content: "Insert author's bio text...", | ||
placeholder: "Insert author's bio text...", | ||
align: "left", | ||
}, | ||
], | ||
], | ||
], | ||
], | ||
], | ||
] | ||
|
||
const AuthorEditor: React.FC<React.PropsWithChildren<BlockEditProps<Record<string, never>>>> = ({ | ||
clientId, | ||
}) => { | ||
return ( | ||
<BlockWrapper id={clientId}> | ||
<div> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} template={AUTHOR_BLOCK_TEMPLATE} /> | ||
</div> | ||
</BlockWrapper> | ||
) | ||
} | ||
|
||
export default AuthorEditor |
11 changes: 11 additions & 0 deletions
11
services/cms/src/blocks/AuthorInnerBlock/AuthorInnerBlockSave.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 AuthorInnerBlockSave: React.FC<unknown> = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default AuthorInnerBlockSave |
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,18 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "../../utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
import AuthorInnerBlockEditor from "./AuthorInnerBlockEditor" | ||
import AuthorInnerBlockSave from "./AuthorInnerBlockSave" | ||
|
||
const AuthorInnerBlockConfiguration: BlockConfiguration = { | ||
title: "AuthorInnerBlock", | ||
description: "Author InnerBlock", | ||
category: MOOCFI_CATEGORY_SLUG, | ||
attributes: {}, | ||
edit: AuthorInnerBlockEditor, | ||
save: AuthorInnerBlockSave, | ||
} | ||
|
||
export default AuthorInnerBlockConfiguration |
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
15 changes: 14 additions & 1 deletion
15
services/course-material/src/components/ContentRenderer/DefaultBlock.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 |
---|---|---|
@@ -1,12 +1,25 @@ | ||
import { css } from "@emotion/css" | ||
|
||
import { BlockAttributes } from "../../../types/GutenbergBlockAttributes" | ||
import { baseTheme } from "../../shared-module/styles" | ||
import withErrorBoundary from "../../shared-module/utils/withErrorBoundary" | ||
|
||
import { BlockRendererProps } from "." | ||
|
||
const DefaultBlock: React.FC<React.PropsWithChildren<BlockRendererProps<BlockAttributes>>> = ({ | ||
data, | ||
}) => { | ||
return <pre>{JSON.stringify(data, undefined, 2)}</pre> | ||
return ( | ||
<div | ||
className={css` | ||
padding: 1rem; | ||
border: 1px solid ${baseTheme.colors.gray[400]}; | ||
`} | ||
> | ||
<b>{data.name}</b> | ||
<pre>{JSON.stringify(data, undefined, 2)}</pre> | ||
</div> | ||
) | ||
} | ||
|
||
export default withErrorBoundary(DefaultBlock) |
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
73 changes: 73 additions & 0 deletions
73
services/course-material/src/components/ContentRenderer/moocfi/AuthorBlock.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,73 @@ | ||
import styled from "@emotion/styled" | ||
import { t } from "i18next" | ||
import React from "react" | ||
|
||
import { BlockRendererProps } from ".." | ||
import { baseTheme } from "../../../shared-module/styles" | ||
import withErrorBoundary from "../../../shared-module/utils/withErrorBoundary" | ||
import InnerBlocks from "../util/InnerBlocks" | ||
|
||
interface InfoBoxBlockAttributes { | ||
backgroundColor: string | ||
} | ||
|
||
const Wrapper = styled.div` | ||
background: #f7f8f9; | ||
padding: 2rem 2rem 1rem 2rem; | ||
margin-bottom: 1rem; | ||
h3 { | ||
color: ${baseTheme.colors.gray[700]}; | ||
padding-bottom: 0.5rem; | ||
border-bottom: 2px solid #edf0f2; | ||
font-weight: 600; | ||
font-size: 22px; | ||
margin-bottom: 1.4rem; | ||
} | ||
/*Overwrite InnerBlock Component styles*/ | ||
figure { | ||
margin: 0; | ||
img { | ||
margin: 0; | ||
width: 250px; | ||
height: 223px; | ||
object-fit: cover; | ||
} | ||
} | ||
div { | ||
margin-left: 0; | ||
} | ||
div.course-material-block > div > div:nth-child(2) { | ||
margin-bottom: 1.4rem !important; | ||
} | ||
div.course-material-block > div > div > div > div:nth-child(1) { | ||
max-width: 250px !important; | ||
} | ||
p { | ||
margin: 0; | ||
font-size: 16px; | ||
font-weight: 400; | ||
color: ${baseTheme.colors.gray[600]}; | ||
} | ||
` | ||
|
||
const AuthorBlock: React.FC<React.PropsWithChildren<BlockRendererProps<InfoBoxBlockAttributes>>> = ( | ||
props, | ||
) => { | ||
return ( | ||
<Wrapper> | ||
<h3>{t("author")}</h3> | ||
<div> | ||
<InnerBlocks parentBlockProps={props} /> | ||
</div> | ||
</Wrapper> | ||
) | ||
} | ||
|
||
export default withErrorBoundary(AuthorBlock) |
21 changes: 21 additions & 0 deletions
21
services/course-material/src/components/ContentRenderer/moocfi/AuthorInnerBlock.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,21 @@ | ||
import React from "react" | ||
|
||
import { BlockRendererProps } from ".." | ||
import withErrorBoundary from "../../../shared-module/utils/withErrorBoundary" | ||
import InnerBlocks from "../util/InnerBlocks" | ||
|
||
interface InfoBoxBlockAttributes { | ||
backgroundColor: string | ||
} | ||
|
||
const AuthorInnerBlock: React.FC< | ||
React.PropsWithChildren<BlockRendererProps<InfoBoxBlockAttributes>> | ||
> = (props) => { | ||
return ( | ||
<div> | ||
<InnerBlocks parentBlockProps={props} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default withErrorBoundary(AuthorInnerBlock) |
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
Binary file added
BIN
+47.6 KB
services/headless-lms/server/src/programs/seed/data/lilo-and-stitch.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.