From eb391a4305021451837f88fdf51fe3820c2374e5 Mon Sep 17 00:00:00 2001 From: Maija <51128208+Maijjay@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:12:20 +0300 Subject: [PATCH] bug fix for hero section (#1159) * bug fix for hero section * small fixes * moved herosection components to course material --------- Co-authored-by: Maija Y --- .../blocks/HeroSection/HeroSectionEditor.tsx | 4 +++- .../CourseChapterGridBlock/ChapterGrid.tsx | 2 +- .../moocfi/HeroSectionBlock.tsx | 3 +-- .../moocfi/LandingPageHeroSectionBlock.tsx | 4 +--- .../src/components/HeroSection.tsx | 19 +++++++++++----- .../src/components/LandingPageHeroSection.tsx | 15 ++++++++----- shared-module/stories/HeroSection.stories.tsx | 22 ------------------- 7 files changed, 28 insertions(+), 41 deletions(-) rename {shared-module => services/course-material}/src/components/HeroSection.tsx (85%) rename {shared-module => services/course-material}/src/components/LandingPageHeroSection.tsx (86%) delete mode 100644 shared-module/stories/HeroSection.stories.tsx diff --git a/services/cms/src/blocks/HeroSection/HeroSectionEditor.tsx b/services/cms/src/blocks/HeroSection/HeroSectionEditor.tsx index e145e1c088db..f5bd08bab0f9 100644 --- a/services/cms/src/blocks/HeroSection/HeroSectionEditor.tsx +++ b/services/cms/src/blocks/HeroSection/HeroSectionEditor.tsx @@ -75,7 +75,9 @@ const HeroSectionEditor: React.FC< `} tagName="h2" value={title} - onChange={(value: string) => setAttributes({ title: value })} + onChange={(value) => { + setAttributes({ title: value }) + }} placeholder={"Hero section title..."} /> >> = ( props, ) => { diff --git a/services/course-material/src/components/ContentRenderer/moocfi/LandingPageHeroSectionBlock.tsx b/services/course-material/src/components/ContentRenderer/moocfi/LandingPageHeroSectionBlock.tsx index 6ceadde5c5f5..2a39b14bd370 100644 --- a/services/course-material/src/components/ContentRenderer/moocfi/LandingPageHeroSectionBlock.tsx +++ b/services/course-material/src/components/ContentRenderer/moocfi/LandingPageHeroSectionBlock.tsx @@ -2,10 +2,8 @@ import React from "react" import { BlockRendererProps, blockToRendererMap } from ".." import BreakFromCentered from "../../../shared-module/components/Centering/BreakFromCentered" -import LandingPageHeroSection, { - LandingPageHeroSectionProps, -} from "../../../shared-module/components/LandingPageHeroSection" import withErrorBoundary from "../../../shared-module/utils/withErrorBoundary" +import LandingPageHeroSection, { LandingPageHeroSectionProps } from "../../LandingPageHeroSection" import DefaultBlock from "../DefaultBlock" const LandingPageHeroSectionBlock: React.FC< diff --git a/shared-module/src/components/HeroSection.tsx b/services/course-material/src/components/HeroSection.tsx similarity index 85% rename from shared-module/src/components/HeroSection.tsx rename to services/course-material/src/components/HeroSection.tsx index bf75226cd14d..678f7a6a3eef 100644 --- a/shared-module/src/components/HeroSection.tsx +++ b/services/course-material/src/components/HeroSection.tsx @@ -1,10 +1,13 @@ import { css } from "@emotion/css" import styled from "@emotion/styled" -import React from "react" +import React, { useContext } from "react" -import { baseTheme, headingFont } from "../styles" -import { respondToOrLarger } from "../styles/respond" -import { INCLUDE_THIS_HEADING_IN_HEADINGS_NAVIGATION_CLASS } from "../utils/constants" +import { GlossaryContext } from "../contexts/GlossaryContext" +import { respondToOrLarger } from "../shared-module//styles/respond" +import { baseTheme, headingFont } from "../shared-module/styles" +import { INCLUDE_THIS_HEADING_IN_HEADINGS_NAVIGATION_CLASS } from "../shared-module/utils/constants" + +import { parseText } from "./ContentRenderer/util/textParsing" interface TextBoxProps { fontColor?: string @@ -92,6 +95,7 @@ const HeroSection: React.FC {label} -

{title}

- {subtitle} +

+ ) diff --git a/shared-module/src/components/LandingPageHeroSection.tsx b/services/course-material/src/components/LandingPageHeroSection.tsx similarity index 86% rename from shared-module/src/components/LandingPageHeroSection.tsx rename to services/course-material/src/components/LandingPageHeroSection.tsx index d6e2a0caf149..270fac52fd56 100644 --- a/shared-module/src/components/LandingPageHeroSection.tsx +++ b/services/course-material/src/components/LandingPageHeroSection.tsx @@ -1,13 +1,15 @@ import { css } from "@emotion/css" import styled from "@emotion/styled" -import React from "react" +import React, { useContext } from "react" import { useTranslation } from "react-i18next" -import DefaultSVG from "../img/hero-default-bg-image.svg" -import { baseTheme } from "../styles" -import { respondToOrLarger } from "../styles/respond" +import { GlossaryContext } from "../contexts/GlossaryContext" +import Button from "../shared-module/components/Button" +import DefaultSVG from "../shared-module/img/hero-default-bg-image.svg" +import { baseTheme } from "../shared-module/styles" +import { respondToOrLarger } from "../shared-module/styles/respond" -import Button from "./Button" +import { parseText } from "./ContentRenderer/util/textParsing" export const CHAPTER_GRID_SCROLLING_DESTINATION_CLASSNAME_DOES_NOT_AFFECT_STYLING = "chapter-grid-scrolling-destination" @@ -87,6 +89,7 @@ const LandingPageHeroSection: React.FC< React.PropsWithChildren> > = ({ title, children, backgroundImage, backgroundColor, backgroundRepeatX, fontColor }) => { const { t } = useTranslation() + const { terms } = useContext(GlossaryContext) return (
{backgroundImage === undefined && } -

{title}

+

{children}