Skip to content

Commit

Permalink
Add show more collapsible title
Browse files Browse the repository at this point in the history
  • Loading branch information
osamasayed committed Feb 29, 2024
1 parent 1e77e36 commit 3974c51
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"language": "Language",
"languages": "Languages",
"learn-more": "Learn more",
"show-more": "Show more",
"learning-plans": "Learning Plans",
"less": "Less",
"loading": "Loading",
Expand Down
18 changes: 16 additions & 2 deletions src/components/RamadanActivity/ReadMoreCollapsible/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ export enum Section {
INSPIRING_READING = 'inspiring_reading',
}

export enum TitleType {
SHOW_MORE = 'show_more',
LEARN_MORE = 'learn_more',
}

type Props = {
children: React.ReactNode;
section: Section;
titleType?: TitleType;
};

const ReadMoreCollapsible: React.FC<Props> = ({ children, section }) => {
const ReadMoreCollapsible: React.FC<Props> = ({
children,
section,
titleType = TitleType.LEARN_MORE,
}) => {
const { t } = useTranslation('common');

const onCollapseOpenChange = (isCollapseOpen: boolean) => {
Expand All @@ -39,7 +49,11 @@ const ReadMoreCollapsible: React.FC<Props> = ({ children, section }) => {
<Collapsible
direction={CollapsibleDirection.Right}
onOpenChange={(isCollapseOpen) => onCollapseOpenChange(isCollapseOpen)}
title={<span className={styles.title}>{t('learn-more')}</span>}
title={
<span className={styles.title}>
{t(titleType === TitleType.LEARN_MORE ? 'learn-more' : 'show-more')}
</span>
}
prefix={<ChevronDownIcon />}
shouldRotatePrefixOnToggle
>
Expand Down
10 changes: 8 additions & 2 deletions src/pages/ramadan-activities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import NextSeoWrapper from '@/components/NextSeoWrapper';
import PageContainer from '@/components/PageContainer';
import Hero from '@/components/RamadanActivity/Hero';
import InlineLink from '@/components/RamadanActivity/InlineLink';
import ReadMoreCollapsible, { Section } from '@/components/RamadanActivity/ReadMoreCollapsible';
import ReadMoreCollapsible, {
Section,
TitleType,
} from '@/components/RamadanActivity/ReadMoreCollapsible';
import Button, { ButtonVariant } from '@/dls/Button/Button';
import styles from '@/pages/contentPage.module.scss';
import { logButtonClick } from '@/utils/eventLogger';
Expand Down Expand Up @@ -338,7 +341,10 @@ const RamadanActivitiesPage: NextPage = (): JSX.Element => {
/>
</li>
</ul>
<ReadMoreCollapsible section={Section.INSPIRING_READING}>
<ReadMoreCollapsible
section={Section.INSPIRING_READING}
titleType={TitleType.SHOW_MORE}
>
<ul>
<li>
<InlineLink
Expand Down

0 comments on commit 3974c51

Please sign in to comment.