Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Apr 25, 2024
1 parent 84cbe6c commit 861a037
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
39 changes: 21 additions & 18 deletions src/apps/news/AppNews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import NextImage from 'next/image';
import TimeAgo from 'react-timeago';

import { AspectRatio, Box, Button, Card, CardContent, CardOverflow, Container, Grid, IconButton, Typography } from '@mui/joy';
import { AspectRatio, Box, Button, Card, CardContent, CardOverflow, Container, Grid, Typography } from '@mui/joy';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import LaunchIcon from '@mui/icons-material/Launch';

Expand All @@ -17,7 +17,8 @@ import { beamNewsCallout } from './beam.data';


// number of news items to show by default, before the expander
const DEFAULT_NEWS_COUNT = 4;
const NEWS_INITIAL_COUNT = 3;
const NEWS_LOAD_STEP = 2;


export const newsRoadmapCallout =
Expand Down Expand Up @@ -54,12 +55,15 @@ export const newsRoadmapCallout =

export function AppNews() {
// state
const [lastNewsIdx, setLastNewsIdx] = React.useState<number>(DEFAULT_NEWS_COUNT - 1);
const [lastNewsIdx, setLastNewsIdx] = React.useState<number>(NEWS_INITIAL_COUNT - 1);

// news selection
const news = NewsItems.filter((_, idx) => idx <= lastNewsIdx);
const firstNews = news[0] ?? null;

// show expander
const canExpand = news.length < NewsItems.length;

return (

<Box sx={{
Expand Down Expand Up @@ -103,8 +107,6 @@ export function AppNews() {
<Container disableGutters maxWidth='sm'>
{news?.map((ni, idx) => {
// const firstCard = idx === 0;
const hasCardAfter = news.length < NewsItems.length;
const showExpander = hasCardAfter && (idx === news.length - 1);
const addPadding = false; //!firstCard; // || showExpander;
return <React.Fragment key={idx}>

Expand Down Expand Up @@ -150,19 +152,6 @@ export function AppNews() {
</ul>
)}

{showExpander && (
<IconButton
variant='solid'
onClick={() => setLastNewsIdx(idx + 1)}
sx={{
position: 'absolute', right: 0, bottom: 0, mr: -1, mb: -1,
// backgroundColor: 'background.surface',
borderRadius: '50%',
}}
>
<ExpandMoreIcon />
</IconButton>
)}
</CardContent>

{!!ni.versionCoverImage && (
Expand All @@ -181,6 +170,7 @@ export function AppNews() {
</AspectRatio>
</CardOverflow>
)}

</Card>

{/* Inject the roadmap item here*/}
Expand All @@ -192,6 +182,19 @@ export function AppNews() {

</React.Fragment>;
})}

{canExpand && (
<Button
fullWidth
variant='soft'
color='neutral'
onClick={() => setLastNewsIdx(index => index + NEWS_LOAD_STEP)}
endDecorator={<ExpandMoreIcon />}
>
Load Previous News
</Button>
)}

</Container>

{/*<Typography sx={{ textAlign: 'center' }}>*/}
Expand Down
8 changes: 4 additions & 4 deletions src/modules/blocks/BlocksRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Diff as TextDiff } from '@sanity/diff-match-patch';

import type { SxProps } from '@mui/joy/styles/types';
import { Box, Button, Tooltip, Typography } from '@mui/joy';
import UnfoldLessRoundedIcon from '@mui/icons-material/UnfoldLessRounded';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';

import type { DMessage } from '~/common/state/store-chats';
import { ContentScaling, lineHeightChatTextMd, themeScalingMap } from '~/common/app.theme';
Expand Down Expand Up @@ -220,9 +220,9 @@ export const BlocksRenderer = React.forwardRef<HTMLDivElement, BlocksRendererPro
)}

{isTextCollapsed ? (
<Box sx={{ textAlign: 'right' }}><Button variant='soft' size='sm' onClick={handleTextUncollapse} startDecorator={<UnfoldMoreRoundedIcon />} sx={{ minWidth: 100, mt: 0.5 }}>Expand</Button></Box>
<Box sx={{ textAlign: 'right' }}><Button variant='soft' size='sm' onClick={handleTextUncollapse} startDecorator={<ExpandMoreIcon />} sx={{ minWidth: 120 }}>Expand</Button></Box>
) : forceUserExpanded && (
<Box sx={{ textAlign: 'right' }}><Button variant='soft' size='sm' onClick={handleTextCollapse} startDecorator={<UnfoldLessRoundedIcon />} sx={{ minWidth: 100, mt: 0.5 }}>Collapse</Button></Box>
<Box sx={{ textAlign: 'right' }}><Button variant='soft' size='sm' onClick={handleTextCollapse} startDecorator={<ExpandLessIcon />} sx={{ minWidth: 120 }}>Collapse</Button></Box>
)}

{/* import VisibilityIcon from '@mui/icons-material/Visibility'; */}
Expand Down

0 comments on commit 861a037

Please sign in to comment.