Skip to content

Commit

Permalink
[READY] TNO-2987: Rearragne View Content Header (#2244)
Browse files Browse the repository at this point in the history
* tno-2896

* cleanup

* fixes
  • Loading branch information
jdtoombs authored Sep 3, 2024
1 parent 33fe820 commit f52609b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 42 deletions.
5 changes: 0 additions & 5 deletions app/subscriber/src/components/section/PageSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { navbarOptions } from 'components/navbar/NavbarItems';
import { ContentActionBar } from 'components/tool-bar';
import { useLocation } from 'react-router-dom';
import { IContentModel, Row } from 'tno-core';

Expand Down Expand Up @@ -54,10 +53,6 @@ export const PageSection: React.FC<IPageSectionProps> = ({
onKeyDownCapture={onKeyDownCapture}
{...rest}
>
{/* TODO: This component is polluting the generic implementation. It should be a separate component which include content related functionality */}
{includeContentActions && !!activeContent && (
<ContentActionBar className="content-actions" content={activeContent} viewingContent />
)}
{header && (
<Row className="page-section-title">
{includeHeaderIcon && icon && <div className="page-icon">{icon}</div>}
Expand Down
11 changes: 11 additions & 0 deletions app/subscriber/src/components/section/styled/PageSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ export const PageSection = styled.div<{ $ignoreMinWidth?: boolean; $ignoreLastCh
align-self: stretch;
min-width: ${(props) => (props.$ignoreMinWidth ? 'unset' : 'fit-content')};
.back-button {
margin-right: 1rem;
&:hover {
cursor: pointer;
}
}
.content-headline {
margin-bottom: 0.25rem;
}
@media (min-width: 500px) {
margin: 0 0.75rem 0.75rem 0.75rem;
}
Expand Down
27 changes: 2 additions & 25 deletions app/subscriber/src/components/tool-bar/ContentActionBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ShareMenu } from 'components/share-menu';
import React, { useState } from 'react';
import { FaArrowUpRightFromSquare } from 'react-icons/fa6';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
import { Tooltip } from 'react-tooltip';
import { useLookup, useSettings } from 'store/hooks';
import { useAppStore } from 'store/slices';
import { Checkbox, Claim, IContentModel, Row, Settings, Show } from 'tno-core';
Expand Down Expand Up @@ -41,15 +39,13 @@ export const ContentActionBar: React.FC<IContentActionBarProps> = ({
className,
content,
viewingContent,
onBack,
onSelectAll,
isSelectAllChecked,
onClear,
onReset,
removeFolderItem,
disableAddToFolder,
}) => {
const navigate = useNavigate();
const [{ frontPageImagesMediaTypeId, settings, isReady }] = useLookup();
const { editorUrl } = useSettings();
const [{ userInfo }] = useAppStore();
Expand Down Expand Up @@ -79,26 +75,7 @@ export const ContentActionBar: React.FC<IContentActionBarProps> = ({
}, [frontPageImagesMediaTypeId, settings, isReady, content]);

return (
<styled.ContentActionBar className={className}>
<Show visible={viewingContent}>
<div className="action left-side-items" onClick={() => (onBack ? onBack() : navigate(-1))}>
<img
className="back-button"
src={'/assets/back-button.svg'}
alt="Back"
data-tooltip-id="back-button"
/>
<Tooltip
clickable={false}
className="back-tooltip"
classNameArrow="back-tooltip-arrow"
id="back-button"
place="top"
noArrow={false}
content="Back"
/>
</div>
</Show>
<styled.ContentActionBar viewingContent={viewingContent} className={className}>
<Show visible={!!onSelectAll}>
<Row className="select-all">
<div className="check-area">
Expand All @@ -113,7 +90,7 @@ export const ContentActionBar: React.FC<IContentActionBarProps> = ({
<div className="arrow" />
</Show>
{showActionsItems && (
<div className="right-side-items">
<div className="content-buttons">
<Row>
{onReset && <ResetFilters onReset={onReset} />}
<ShareMenu content={content} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import { Row } from 'tno-core';

export const ContentActionBar = styled(Row)`
export const ContentActionBar = styled(Row)<{ viewingContent?: boolean }>`
&.search {
.check-area {
margin-left: 1em;
Expand Down Expand Up @@ -43,8 +43,9 @@ export const ContentActionBar = styled(Row)`
}
}
.right-side-items {
.content-buttons {
color: ${(props) => props.theme.css.btnBkPrimary};
width: ${(props) => (props.viewingContent ? '100%' : 'auto')};
@media (max-width: 768px) {
span {
display: none;
Expand All @@ -53,13 +54,13 @@ export const ContentActionBar = styled(Row)`
animation: fade-in 0.5s linear;
}
.editor-button {
margin-left: auto;
display: flex;
svg {
height: 12px;
width: 12px;
}
align-items: center;
margin-right: 1em;
svg {
margin-right: 0.25em;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ export const ViewContent: React.FC<IViewContentProps> = ({ setActiveContent, act
//Remove HTML tags, square brackets and line breaks before comparison.
const cleanString = (str: string | undefined) => str?.replace(/<[^>]*>?|\[|\]|\n/gm, '').trim();

const formattedHeadline = React.useMemo(
() => formatSearch(content?.headline ?? '', filter),
[content?.headline, filter],
);
const formattedBody = React.useMemo(
() => formatSearch(content?.body?.replace(/\n+/g, '<br><br>') ?? '', filter),
[content?.body, filter],
Expand All @@ -294,7 +290,6 @@ export const ViewContent: React.FC<IViewContentProps> = ({ setActiveContent, act

return (
<styled.ViewContent className={`${!!popout && 'popout'}`}>
<div className="headline">{formattedHeadline}</div>
<Bar className="info-bar" vanilla>
<Show visible={!!content?.byline}>
<div className="byline">{`BY ${content?.byline}`}</div>
Expand Down Expand Up @@ -324,6 +319,7 @@ export const ViewContent: React.FC<IViewContentProps> = ({ setActiveContent, act
)}
</Row>
</Bar>
{!!content && <ContentActionBar className="actions" content={[content]} viewingContent />}
<Show visible={!!avStream && isAV}>
<Row justifyContent="center">
<Show visible={isProcessing}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ export const ViewContent = styled.div`
}
}
.info-bar {
/* negative margins to bypass parent padding (PageSection) */
margin-left: -1.25em;
margin-right: -1.25em;
padding-left: 1.25em;
padding-right: 1.25em;
font-size: 0.9rem;
Expand Down
24 changes: 23 additions & 1 deletion app/subscriber/src/features/landing/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import { MyMinister } from 'features/my-minister/MyMinister';
import { MyProducts } from 'features/my-products';
import { MySearches } from 'features/my-searches';
import { PressGallery } from 'features/press-gallery';
import { formatSearch } from 'features/search-page/utils';
import { MyMinisterSettings } from 'features/settings';
import { TodaysCommentary } from 'features/todays-commentary';
import { TodaysFrontPages } from 'features/todays-front-pages';
import { TopStories } from 'features/top-stories';
import React from 'react';
import { useParams } from 'react-router-dom';
import { useNavigate, useParams } from 'react-router-dom';
import { useContent } from 'store/hooks';
import useMobile from 'store/hooks/app/useMobile';
import { Col, IContentModel, Row, Show } from 'tno-core';

Expand All @@ -33,7 +35,13 @@ export const Landing: React.FC = () => {
const [activeItem, setActiveItem] = React.useState<INavbarOptionItem | undefined>(
NavbarOptions.home,
);
const [
{
search: { filter },
},
] = useContent();
const isMobile = useMobile();
const navigate = useNavigate();
/* active content will be stored from this context in order to inject into subsequent components */
const [activeContent, setActiveContent] = React.useState<IContentModel[]>();
const [isFullScreen, setIsFullScreen] = React.useState(false);
Expand Down Expand Up @@ -89,6 +97,20 @@ export const Landing: React.FC = () => {
? 'Settings | My Minister'
: activeItem?.label}
</Show>
<Show visible={!activeItem && !!activeContent}>
<Row>
<img
className="back-button"
src={'/assets/back-button.svg'}
alt="Back"
data-tooltip-id="back-button"
onClick={() => navigate(-1)}
/>
<span className="content-headline">
{activeContent && formatSearch(activeContent[0].headline, filter)}
</span>
</Row>
</Show>
{!!activeItem?.reduxFilterStore && (
<>
<FilterOptions filterStoreName={activeItem?.reduxFilterStore} />
Expand Down

0 comments on commit f52609b

Please sign in to comment.