Skip to content

Commit f577a66

Browse files
Tweak: Settings page (#334)
1 parent 815aca0 commit f577a66

File tree

8 files changed

+35
-311
lines changed

8 files changed

+35
-311
lines changed

assets/dev/js/admin/hello-admin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import './hello-admin.scss';
22
import { render } from '@wordpress/element';
3-
import { MainPage } from './pages/main-page.js';
3+
import { SettingsPage } from './pages/settings-page.js';
44

55
const App = () => {
6-
return <MainPage />;
6+
return <SettingsPage />;
77
};
88

99
document.addEventListener( 'DOMContentLoaded', () => {

assets/dev/js/admin/pages/panels/head-cleanup.js

-88
This file was deleted.

assets/dev/js/admin/pages/panels/scripts-styles.js

-67
This file was deleted.

assets/dev/js/admin/pages/main-page.js renamed to assets/dev/js/admin/pages/settings-page.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { dispatch, useDispatch, useSelect } from '@wordpress/data';
44
import { __ } from '@wordpress/i18n';
55
import api from '@wordpress/api';
66
import { Button, Panel, Placeholder, Spinner, SnackbarList } from '@wordpress/components';
7-
import { SETTINGS } from './settings.js';
8-
import { PanelThemeFeatures } from './panels/theme-features.js';
9-
import { PanelHeadCleanup } from './panels/head-cleanup.js';
10-
import { PanelScriptsStyles } from './panels/scripts-styles.js';
7+
import { SettingsPanel } from './../panels/settings-panel.js';
118

129
const Notices = () => {
1310
const notices = useSelect(
@@ -29,7 +26,15 @@ const Notices = () => {
2926
);
3027
};
3128

32-
export const MainPage = () => {
29+
const SETTINGS = {
30+
DESCRIPTION_META_TAG: '_description_meta_tag',
31+
SKIP_LINK: '_skip_link',
32+
PAGE_TITLE: '_page_title',
33+
HELLO_STYLE: '_hello_style',
34+
HELLO_THEME: '_hello_theme',
35+
};
36+
37+
export const SettingsPage = () => {
3338
const [ hasLoaded, setHasLoaded ] = useState( false );
3439
const [ settingsData, setSettingsData ] = useState( {} );
3540

@@ -115,11 +120,7 @@ export const MainPage = () => {
115120
<div className="hello_elementor__main">
116121
<Panel>
117122

118-
<PanelThemeFeatures { ...{ settingsData, updateSettings } } />
119-
120-
<PanelHeadCleanup { ...{ settingsData, updateSettings } } />
121-
122-
<PanelScriptsStyles { ...{ settingsData, updateSettings } } />
123+
<SettingsPanel { ...{ SETTINGS, settingsData, updateSettings } } />
123124

124125
<Button isPrimary onClick={ saveSettings }>
125126
{ __( 'Save Settings', 'hello-elementor' ) }

assets/dev/js/admin/pages/settings.js

-24
This file was deleted.

assets/dev/js/admin/pages/panels/theme-features.js renamed to assets/dev/js/admin/panels/settings-panel.js

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { __ } from '@wordpress/i18n';
2-
import { SETTINGS } from '../settings.js';
3-
import { PanelBody, ToggleControl } from '@wordpress/components';
2+
import { PanelBody, ToggleControl, Notice, Dashicon } from '@wordpress/components';
43

5-
export const PanelThemeFeatures = ( { settingsData, updateSettings } ) => {
4+
export const SettingsPanel = ( { SETTINGS, settingsData, updateSettings } ) => {
65
const protocol = window.location.protocol || 'https:';
76
const hostname = window.location.hostname || 'example.com';
87
const prefix = protocol + '//' + hostname;
98

109
return (
11-
<PanelBody title={ __( 'Hello Theme Features', 'hello-elementor' ) } >
10+
<PanelBody title={ __( 'Hello Theme Settings', 'hello-elementor' ) } >
11+
12+
<Notice status="warning" isDismissible="false">
13+
<Dashicon icon="flag" />
14+
{ __( 'Be cautious, disabling some of the following options may break your website.', 'hello-elementor' ) }
15+
</Notice>
1216

1317
<ToggleControl
1418
label={ __( 'Disable description meta tag', 'hello-elementor' ) }
@@ -35,12 +39,20 @@ export const PanelThemeFeatures = ( { settingsData, updateSettings } ) => {
3539
<code className="code-example"> &lt;header class=&quot;page-header&quot;&gt; &lt;h1 class=&quot;entry-title&quot;&gt; Post title &lt;/h1&gt; &lt;/header&gt; </code>
3640

3741
<ToggleControl
38-
label={ __( 'Disable WordPress sitemap', 'hello-elementor' ) }
39-
help={ __( 'Remove the WordPress sitemap that contains the site pages.', 'hello-elementor' ) }
40-
checked={ !! settingsData[ SETTINGS.WP_SITEMAP ] || false }
41-
onChange={ ( value ) => updateSettings( SETTINGS.WP_SITEMAP, value ) }
42+
label={ __( 'Unregister Hello style.css', 'hello-elementor' ) }
43+
help={ __( "Disable Hello theme's style.css file which contains CSS reset rules for unified cross-browser view.", 'hello-elementor' ) }
44+
checked={ !! settingsData[ SETTINGS.HELLO_STYLE ] || false }
45+
onChange={ ( value ) => updateSettings( SETTINGS.HELLO_STYLE, value ) }
46+
/>
47+
<code className="code-example"> &lt;link rel=&quot;stylesheet&quot; href=&quot;{ prefix }/wp-content/themes/hello-elementor/style.min.css&quot; /&gt; </code>
48+
49+
<ToggleControl
50+
label={ __( 'Unregister Hello theme.css', 'hello-elementor' ) }
51+
help={ __( "Disable Hello theme's theme.css file which contains CSS rules that style WordPress elements.", 'hello-elementor' ) }
52+
checked={ !! settingsData[ SETTINGS.HELLO_THEME ] || false }
53+
onChange={ ( value ) => updateSettings( SETTINGS.HELLO_THEME, value ) }
4254
/>
43-
<code className="code-example"> &lt;link rel=&quot;sitemap&quot; href=&quot;{ prefix }/wp-sitemap.xml&quot; /&gt; </code>
55+
<code className="code-example"> &lt;link rel=&quot;stylesheet&quot; href=&quot;{ prefix }/wp-content/themes/hello-elementor/theme.min.css&quot; /&gt; </code>
4456

4557
</PanelBody>
4658
);

0 commit comments

Comments
 (0)