Skip to content

Commit f692686

Browse files
Tweak: improve changelog appearance [TMZ-928] (#543) (#544)
1 parent 3d32073 commit f692686

File tree

6 files changed

+72
-35
lines changed

6 files changed

+72
-35
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
node_modules/
33
.sass-cache/
44
build/**
5-
assets/
5+
# Only ignore root-level assets directory (build output), not module assets (source files)
6+
/assets/
67
hello-elementor/
78
elementor-hello-theme/
89
log/
@@ -13,7 +14,6 @@ Thumbs.db
1314
*.log
1415
*.map
1516
yarn.lock
16-
assets/js/
1717
*.zip
1818
.npmrc
1919
.env
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Dialog from '@elementor/ui/Dialog';
2+
import DialogContent from '@elementor/ui/DialogContent';
3+
import DialogHeader from '@elementor/ui/DialogHeader';
4+
import Typography from '@elementor/ui/Typography';
5+
import { __ } from '@wordpress/i18n';
6+
import Stack from '@elementor/ui/Stack';
7+
import Update from './update';
8+
import Divider from '@elementor/ui/Divider';
9+
import { PlusIcon } from './plus-icon';
10+
import { Fragment } from 'react';
11+
12+
export const ChangelogDialog = ( { open, onClose, whatsNew } ) => {
13+
return (
14+
<Dialog
15+
open={ open }
16+
onClose={ onClose }
17+
maxWidth="sm"
18+
fullWidth
19+
>
20+
<DialogHeader
21+
onClose={ onClose }
22+
variant="outlined"
23+
logo={ <PlusIcon /> }
24+
>
25+
<Typography variant="overline" sx={ { textTransform: 'uppercase', fontWeight: 400, color: 'text.primary' } }>
26+
{ __( 'Changelog', 'hello-elementor' ) }
27+
</Typography>
28+
</DialogHeader>
29+
30+
<DialogContent sx={ { p: 0 } }>
31+
<Stack direction={ 'column' } >
32+
{ whatsNew.map( ( item, index ) => {
33+
return (
34+
<Fragment key={ item.id } >
35+
<Update { ...item } />
36+
{ index !== whatsNew.length - 1 && <Divider /> }
37+
</Fragment>
38+
);
39+
} ) }
40+
</Stack>
41+
</DialogContent>
42+
</Dialog>
43+
);
44+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SvgIcon from '@elementor/ui/SvgIcon';
2+
import { ReactComponent as Icon } from '../../../images/plus.svg';
3+
4+
export const PlusIcon = ( props ) => {
5+
return (
6+
<SvgIcon viewBox="0 0 24 24" { ...props }>
7+
<Icon />
8+
</SvgIcon>
9+
);
10+
};

modules/admin-home/assets/js/components/settings/settings-page.js

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import Paper from '@elementor/ui/Paper';
1818
import { styled } from '@elementor/ui/styles';
1919
import Link from '@elementor/ui/Link';
2020
import Stack from '@elementor/ui/Stack';
21-
import Modal from '@elementor/ui/Modal';
22-
import Update from './update';
21+
import { ChangelogDialog } from './changelog';
2322

2423
const Notices = () => {
2524
const notices = useSelect(
@@ -75,19 +74,6 @@ const StyledTabs = styled( Tabs )( () => ( {
7574
},
7675
} ) );
7776

78-
const style = {
79-
position: 'absolute',
80-
top: '50%',
81-
left: '50%',
82-
transform: 'translate(-50%, -50%)',
83-
bgcolor: 'background.paper',
84-
border: '1px solid #000',
85-
boxShadow: 24,
86-
p: 2,
87-
maxHeight: '80vh',
88-
overflowY: 'auto',
89-
};
90-
9177
export const SettingsPage = () => {
9278
const { whatsNew } = useSettingsContext();
9379
const { getTabsProps, getTabProps, getTabPanelProps } = useTabs( 'one' );
@@ -131,19 +117,7 @@ export const SettingsPage = () => {
131117
<TabPanel { ...getTabPanelProps( 'three' ) }><Theme /></TabPanel>
132118
</Box>
133119
</Paper>
134-
<Modal
135-
open={ open }
136-
onClose={ handleClose }
137-
aria-labelledby="modal-modal-title"
138-
aria-describedby="modal-modal-description"
139-
>
140-
<Box sx={ style }>
141-
<Typography variant={ 'h4' }>{ __( 'Changelog', 'hello-plus' ) }</Typography>
142-
<Stack direction={ 'column' } gap={ 1 } sx={ { mt: 2 } }>
143-
{ whatsNew.map( ( item ) => <Update key={ item.id } { ...item } /> ) }
144-
</Stack>
145-
</Box>
146-
</Modal>
120+
<ChangelogDialog open={ open } onClose={ handleClose } whatsNew={ whatsNew } />
147121
</>
148122
);
149123
};
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
import Stack from '@elementor/ui/Stack';
1+
import Box from '@elementor/ui/Box';
22
import Typography from '@elementor/ui/Typography';
3+
import { useMemo } from 'react';
34

45
export default function Update( { title, description } ) {
6+
const descriptionToShow = useMemo( () => {
7+
const parser = new DOMParser();
8+
const doc = parser.parseFromString( description, 'text/html' );
9+
const listItems = doc.querySelectorAll( 'li' );
10+
const extractedContent = Array.from( listItems ).map( ( item ) => item.textContent.trim() );
11+
return extractedContent.join( '\n' );
12+
}, [ description ] );
513
return (
6-
<Stack direction={ 'column' } gap={ 2 }>
7-
<Typography variant={ 'h6' }>{ title }</Typography>
8-
<div dangerouslySetInnerHTML={ { __html: description } } />
9-
</Stack>
14+
<Box sx={ { py: 2, px: 3 } }>
15+
<Typography variant={ 'subtitle1' } sx={ { pb: 0.75 } }>{ title }</Typography>
16+
<Typography variant={ 'body2' } sx={ { whiteSpace: 'pre-line' } }>{ descriptionToShow }</Typography>
17+
</Box>
1018
);
1119
}

0 commit comments

Comments
 (0)