Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve app responsiveness on mobile screen #1382

Merged
merged 20 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a31d72c
sync fontColor and backgroundColor of HeroSectionEditor with defaults
george-misan Feb 4, 2025
451892d
refactor HeroSectionEditor to use useEffect
george-misan Feb 4, 2025
a82fb0c
refactor code
george-misan Feb 4, 2025
29cbd6a
[mobile-responsiveness]: update Chapter Card Grid styles
george-misan Feb 5, 2025
2d647d1
[mobile-responsiveness]: update padding in Learning Objectives block
george-misan Feb 5, 2025
9acee5c
[mobile-responsiveness]: update color of TopLevelPage block
george-misan Feb 5, 2025
6062399
[mobile-responsiveness]: dynamically add padding-left to breadcrumbs
george-misan Feb 5, 2025
e729cb9
[mobile-responsiveness]: dynamically add padding to AsideBlock and In…
george-misan Feb 5, 2025
2521718
[mobile-responsiveness]: update padding for QuoteBlock
george-misan Feb 5, 2025
207428b
[mobile-responsiveness]: update padding for HightligtBox
george-misan Feb 5, 2025
d032278
[mobile-responsiveness]: update padding for InstructionBox
george-misan Feb 5, 2025
9d4f7ae
[mobile-responsiveness]: fix chapter-progress ui bug
george-misan Feb 5, 2025
d005afa
[mobile-responsiveness]: update pages-in-chapter heading
george-misan Feb 5, 2025
fe4c5eb
[mobile-responsiveness]: update highlightItem border color to be a sh…
george-misan Feb 5, 2025
2bf5e53
[mobile-responsiveness]: add padding to Highlight container
george-misan Feb 5, 2025
0ab83b9
[mobile-responsiveness]: update NextSectionLink when next course is l…
george-misan Feb 5, 2025
b12913e
remove trailing 0 from HighlightItem when value is 0
george-misan Feb 5, 2025
e599c3a
remove unused import
george-misan Feb 5, 2025
a7c6e99
update snapshot test
george-misan Feb 5, 2025
427cd12
convert px to rem
george-misan Feb 6, 2025
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
15 changes: 13 additions & 2 deletions services/cms/src/blocks/HeroSection/HeroSectionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { css } from "@emotion/css"
import { InspectorControls, RichText } from "@wordpress/block-editor"
import { BlockEditProps } from "@wordpress/blocks"
import React, { useContext } from "react"
import React, { useContext, useEffect } from "react"

import BackgroundAndColorCustomizer from "../../components/blocks/BackgroundAndColorCustomizer"
import PageContext from "../../contexts/PageContext"
Expand Down Expand Up @@ -33,6 +33,17 @@ const HeroSectionEditor: React.FC<

const backgroundVerticalAlignment = alignBottom ? "bottom" : "center"

const WHITE = "#FFFFFF"

useEffect(() => {
if (!attributes.fontColor) {
setAttributes({ fontColor: baseTheme.colors.gray[700] })
}
if (!attributes.backgroundColor) {
setAttributes({ backgroundColor: WHITE })
}
}, [attributes.backgroundColor, attributes.fontColor, setAttributes])

return (
<BlockWrapper id={clientId}>
<InspectorControls key="settings">
Expand All @@ -52,7 +63,7 @@ const HeroSectionEditor: React.FC<
padding: 7.5em 1em;
margin-bottom: 3rem;

background-color: ${backgroundColor ? backgroundColor : baseTheme.colors.green["200"]};
background-color: ${backgroundColor};
position: relative;

&::after {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ const DEFAULT_BACKGROUND_COLORS = [
{ color: baseTheme.colors.blue[100], name: "lightblue" },
]

const DEFAULT_FONT_COLORS = [
{ color: baseTheme.colors.gray[700], name: "gray-1" },
{ color: baseTheme.colors.gray[600], name: "gray-2" },
{ color: baseTheme.colors.gray[500], name: "gray-3" },
]

const WHITE = "#FFFFFF"
const GRAY = baseTheme.colors.gray[700]

const ALLOWED_MIMETYPES_FOR_UPLOAD = ["image/svg+xml"]

Expand Down Expand Up @@ -108,10 +115,10 @@ const BackgroundAndColorCustomizer: React.FC<
>
<ColorPalette
disableCustomColors={false}
value={attributes.fontColor ?? WHITE}
value={attributes.fontColor ?? GRAY}
onChange={(fontColor) => setAttributes({ fontColor })}
clearable={false}
colors={DEFAULT_BACKGROUND_COLORS}
colors={DEFAULT_FONT_COLORS}
/>
</Placeholder>
<CheckBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GlossaryContext } from "../../../../../contexts/GlossaryContext"
import InnerBlocks from "../../../util/InnerBlocks"
import { parseText } from "../../../util/textParsing"

import { respondToOrLarger } from "@/shared-module/common/styles/respond"
george-misan marked this conversation as resolved.
Show resolved Hide resolved
import withErrorBoundary from "@/shared-module/common/utils/withErrorBoundary"

interface ExtraAttributes {
Expand All @@ -18,7 +19,7 @@ const QuoteBlock: React.FC<BlockRendererProps<QuoteAttributes & ExtraAttributes>
const { terms } = useContext(GlossaryContext)

const styleLeftDefault = css`
padding: 0.5rem 2rem;
padding: 0.4rem 1rem;
margin: 2.5rem 0;
max-width: 100%;
border-left: 7px solid #bdc7d1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from "react"
import { BlockRendererProps } from ".."
import InnerBlocks from "../util/InnerBlocks"

import { respondToOrLarger } from "@/shared-module/common/styles/respond"
import withErrorBoundary from "@/shared-module/common/utils/withErrorBoundary"

interface AsideBlockProps {
Expand All @@ -17,11 +18,15 @@ const AsideBLock: React.FC<React.PropsWithChildren<BlockRendererProps<AsideBlock
return (
<div
className={css`
padding: 2rem;
padding: 0rem 0.8rem;
border-top: 0.4rem solid ${props.data.attributes.separatorColor};
border-bottom: 0.4rem solid ${props.data.attributes.separatorColor};
background: ${props.data.attributes.backgroundColor};

${respondToOrLarger.md} {
padding: 1rem 2rem;
}

h1,
h2,
h3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ const HightlightBlock: React.FC<
<>
<div
className={css`
padding: 1rem 1.5rem;
background-color: #fafbfb;
margin: 1rem 0;
border: 1px solid #e2e4e6;
padding: 1rem 0rem;

${respondToOrLarger.md} {
padding: 1rem 1.5rem;
}
`}
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import InnerBlocks from "../util/InnerBlocks"

import BreakFromCentered from "@/shared-module/common/components/Centering/BreakFromCentered"
import Centered from "@/shared-module/common/components/Centering/Centered"
import { respondToOrLarger } from "@/shared-module/common/styles/respond"
import withErrorBoundary from "@/shared-module/common/utils/withErrorBoundary"

interface InfoBoxBlockAttributes {
Expand All @@ -20,8 +21,12 @@ const InfoBoxBlock: React.FC<
<BreakFromCentered sidebar={false}>
<div
className={css`
${!props.data.attributes.noPadding && `padding: 3rem;`}
padding: 1rem 0;
background-color: ${props.data.attributes.backgroundColor};

${respondToOrLarger.md} {
${!props.data.attributes.noPadding && ` padding: 3rem;`}
}
`}
>
<Centered variant="narrow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@ const InstructionBlock: React.FC<
<>
<div
className={css`
padding: 1rem 1.5rem;
padding: 1rem 0rem;
background-color: #f2f7fc;
margin: 1rem 0;
border: 2px ${baseTheme.colors.purple[300]} dashed;
${respondToOrLarger.md} {
padding: 1rem 1.5rem;
}
`}
>
<div
className={css`
max-width: 48rem;
margin-left: auto;
margin-right: auto;
padding: 0rem 1.375rem;
padding: 0rem 1rem;

${respondToOrLarger.md} {
padding: 0rem 1.375rem;
}

span {
font-size: 18px;
Expand All @@ -40,9 +47,6 @@ const InstructionBlock: React.FC<
font-size: 20px;
}
}
${respondToOrLarger.md} {
padding: 0rem;
}
`}
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import withErrorBoundary from "@/shared-module/common/utils/withErrorBoundary"
const Wrapper = styled.div`
margin: 2rem auto;
background: #f0f5f5;
padding: 1.5rem 2.2rem;
padding: 0.5rem 1.5rem;

${respondToOrLarger.md} {
padding: 1.5rem 2.2rem;
}
height: auto;
`
const Header = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion services/course-material/src/components/HeroSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const HeroSection: React.FC<React.PropsWithChildren<React.PropsWithChildren<Card
margin-bottom: 3rem;
/** There should not be empty space before the hero section, so we'll undo the default block margin **/
margin-top: -${COURSE_MATERIAL_DEFAULT_BLOCK_MARGIN_REM}rem;
background-color: ${backgroundColor ? backgroundColor : baseTheme.colors.green["200"]};
background-color: ${backgroundColor};
george-misan marked this conversation as resolved.
Show resolved Hide resolved
position: relative;

&::after {
Expand Down
7 changes: 7 additions & 0 deletions shared-module/packages/common/src/components/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import styled from "@emotion/styled"
import Link from "next/link"
import { useTranslation } from "react-i18next"

import { respondToOrLarger } from "../styles/respond"

const StyledBreadcrumb = styled.div`
font-size: 1rem;
margin: 0;
Expand All @@ -14,6 +16,11 @@ const StyledBreadcrumb = styled.div`
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
padding-left: 0;

${respondToOrLarger.md} {
padding-left: 2rem;
}
}

.group {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ const CardContentWrapper = styled.div`
z-index: 20;
color: #fff;
font-weight: 500;
line-height: 100%;
font-size: clamp(28px, 2.7rem, 46px);
line-height: 110%;
font-size: 1.875rem;

${respondToOrLarger.lg} {
font-size: clamp(28px, 2.7rem, 46px);
}
}

span {
Expand Down
10 changes: 5 additions & 5 deletions shared-module/packages/common/src/components/TopLevelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import styled from "@emotion/styled"
import Link from "next/link"
import React from "react"

import { primaryFont } from "../styles"
import { baseTheme, primaryFont } from "../styles"
import { respondToOrLarger } from "../styles/respond"

// eslint-disable-next-line i18next/no-literal-string
const Content = styled.div`
margin: 0 auto;
max-width: 100%;
background: #ecf3f2;
background: rgb(242, 245, 247);
display: flex;
height: auto;
align-items: center;
Expand All @@ -25,14 +25,14 @@ const Content = styled.div`
transition: filter 0.2s;
filter: brightness(100%) contrast(100%);
&:hover {
filter: brightness(92%) contrast(110%);
background-color: rgb(235, 239, 242);
}

h3 {
font-family: ${primaryFont};
font-size: 22px;
font-weight: 400;
color: #065853;
color: #1a2333;
}

span {
Expand Down Expand Up @@ -80,7 +80,7 @@ const TopLevelPage: React.FC<React.PropsWithChildren<React.PropsWithChildren<Top
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56.957 49" className="right-arrow">
<path
d="M32.466,0,29.321,3.146l19.123,19.11H0v4.475H48.444L29.321,45.854,32.466,49l24.49-24.506Z"
fill="#44827E"
fill="#1a2333"
/>
</svg>
</Content>
Expand Down
Loading