Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings screen updates #4998

Merged
merged 100 commits into from Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
a23e0b4
Remove settings screen markup
johnwatkins0 Jul 6, 2020
a9e3d07
Refactor PHP classes for dependecy injection, update tests, setup adm…
johnwatkins0 Jul 6, 2020
9974b5c
Fix tests
johnwatkins0 Jul 6, 2020
0eea9d5
Welcome section
johnwatkins0 Jul 6, 2020
5192f62
Merge branch 'feature/4974-remove-close-on-finish-screen' into featur…
johnwatkins0 Jul 6, 2020
398ef55
Settings screen parts
johnwatkins0 Jul 6, 2020
c0d28d0
Merge branch 'feature/4974-remove-close-on-finish-screen' into featur…
johnwatkins0 Jul 6, 2020
4288269
Start on supported templates component
johnwatkins0 Jul 6, 2020
209222d
Merge remote-tracking branch 'origin/develop' into feature/4704-setti…
johnwatkins0 Jul 6, 2020
b9a3aa1
Complete working settings screen without tests or reader themes
johnwatkins0 Jul 7, 2020
aa32c6f
PHPUnit tests
johnwatkins0 Jul 7, 2020
ce2ad8b
Rename test class
johnwatkins0 Jul 7, 2020
fe68e6b
Update e2e tests with minor fixes
johnwatkins0 Jul 7, 2020
336f684
Merge remote-tracking branch 'origin/develop' into feature/4704-setti…
johnwatkins0 Jul 7, 2020
a16b9cf
Integrate reader theme seleection on settings page
johnwatkins0 Jul 7, 2020
fdba128
Resolve minor issues
johnwatkins0 Jul 7, 2020
4ed8e50
Linting fixes
johnwatkins0 Jul 7, 2020
e19f4c1
Improve tests
johnwatkins0 Jul 7, 2020
cdb8a17
Add tests and fix static analysis
johnwatkins0 Jul 7, 2020
316ef14
Test fixes
johnwatkins0 Jul 7, 2020
2e29ad8
Fix phpcs issue
johnwatkins0 Jul 7, 2020
d5b4ece
Copy update
johnwatkins0 Jul 7, 2020
ec2d557
Test fixes and style updates
johnwatkins0 Jul 7, 2020
8aaadd9
Move menu item last and update styles
johnwatkins0 Jul 7, 2020
ddf8c99
Fix lint issue
johnwatkins0 Jul 7, 2020
d689092
Handle mode notices on the FE instead of BE
johnwatkins0 Jul 7, 2020
fe463ee
Fix a failing PHPunit test
johnwatkins0 Jul 7, 2020
dfcc896
Options page: improve handling of submit button disabled state
johnwatkins0 Jul 8, 2020
4274149
Show notices based on whether plugin was configured rather than wheth…
johnwatkins0 Jul 8, 2020
5c0aa8e
Settings screen: minor JS updates
johnwatkins0 Jul 8, 2020
2e996ba
E2E test fix
johnwatkins0 Jul 8, 2020
2990917
Style updates based on design review
johnwatkins0 Jul 8, 2020
d47b163
Don't open wizard link in new tab
johnwatkins0 Jul 8, 2020
4ac1b0f
Merge remote-tracking branch 'origin/develop' into feature/4704-setti…
johnwatkins0 Jul 8, 2020
b05ffe6
Resolve additional conflicts with reader theme branch
johnwatkins0 Jul 8, 2020
b646856
Remove unneeded eslint ignore
johnwatkins0 Jul 8, 2020
480e393
Remove old options menu class and notice that was moved to JS
johnwatkins0 Jul 8, 2020
1c81777
Add needed use statements
johnwatkins0 Jul 8, 2020
d00b249
Move effect into onboarding wizard screen component
johnwatkins0 Jul 8, 2020
94545ca
Use temporary string to help tests pass
johnwatkins0 Jul 8, 2020
83c2e01
Static analysis fixes
johnwatkins0 Jul 8, 2020
4f7987d
Fix mock filename
johnwatkins0 Jul 8, 2020
4d36455
Refine mode recommendation notices on AMP settings screen
johnwatkins0 Jul 9, 2020
da1977f
Settings screen: set max height on reader themes
johnwatkins0 Jul 9, 2020
c6f0fd7
Docblock fix
johnwatkins0 Jul 9, 2020
b26e031
Default fetching options to false
johnwatkins0 Jul 9, 2020
3dde065
Only pass currently active theme notice to components that need it
johnwatkins0 Jul 9, 2020
af5ab7b
Merge branch 'feature/4704-settings-screen-updates' of https://github…
johnwatkins0 Jul 9, 2020
f554e0e
Make relative import briefer
johnwatkins0 Jul 9, 2020
df0f693
Merge branch 'feature/4704-settings-screen-updates' of https://github…
johnwatkins0 Jul 9, 2020
151636d
Remove unneeded defaultProps
johnwatkins0 Jul 9, 2020
79d4e15
Update description and for details prop
johnwatkins0 Jul 9, 2020
6facd83
Combine padding CSS rules
johnwatkins0 Jul 9, 2020
8dae204
Small PHP comment fixes
johnwatkins0 Jul 9, 2020
d6adb14
Undo debug code
johnwatkins0 Jul 9, 2020
376078b
Move reader mode override component
johnwatkins0 Jul 9, 2020
375d63b
Add @todo above CSS var block
johnwatkins0 Jul 9, 2020
5c5e452
Make GoogleFonts class conditional
johnwatkins0 Jul 9, 2020
c695a2e
Move ReaderThemes into DI architecture and minor improvements
johnwatkins0 Jul 9, 2020
51a9ddb
Rename phpunit group
johnwatkins0 Jul 9, 2020
4881c2d
Remove check for "all" theme support declared in theme
johnwatkins0 Jul 9, 2020
de82214
Text updates
johnwatkins0 Jul 9, 2020
6e83093
Update theme_support_args
johnwatkins0 Jul 9, 2020
1d7c2e3
Settings screen: show notices even if plugin is configured
johnwatkins0 Jul 9, 2020
c8cdcd0
Remove obsolete imports
johnwatkins0 Jul 9, 2020
2856055
Test fixes
johnwatkins0 Jul 9, 2020
1fdce43
Linting fies
johnwatkins0 Jul 9, 2020
2bc546c
Update test file with new class name
johnwatkins0 Jul 9, 2020
796a896
Cast filter result as array
johnwatkins0 Jul 9, 2020
6fa5132
PHPStan fixes
johnwatkins0 Jul 9, 2020
576b46e
Merge remote-tracking branch 'origin/develop' into feature/4704-setti…
johnwatkins0 Jul 9, 2020
a85667c
Update two more instances of changed class name
johnwatkins0 Jul 9, 2020
966e796
Minor CSS updates from design feedback
johnwatkins0 Jul 9, 2020
604cf0d
Update class dependencies in PHPUnit instances
johnwatkins0 Jul 9, 2020
f3c4148
Change HTMLElement to ElementName because the former exists globally
johnwatkins0 Jul 9, 2020
1334179
Settings page: enhance conditional UI logic around supported template…
johnwatkins0 Jul 9, 2020
4fb339b
Remove available_callback check and notice
johnwatkins0 Jul 9, 2020
f45910b
Improve readability around mobile redirection visibility
johnwatkins0 Jul 9, 2020
d9bab74
Increase width of status column in plugin suppression table
johnwatkins0 Jul 9, 2020
e8bc432
Add todo indicating Plugin Suppression will be handled over REST in t…
johnwatkins0 Jul 9, 2020
e464cc2
Supported templates visibility updates
johnwatkins0 Jul 9, 2020
b8316bb
Merge branch 'feature/4704-settings-screen-updates' of https://github…
johnwatkins0 Jul 9, 2020
c55bdd9
Remove unnecessary default option provided via filter elsewhere
johnwatkins0 Jul 9, 2020
4661ccb
Change ElementName to elementName and lint fixes
johnwatkins0 Jul 9, 2020
c39c00b
Merge branch 'feature/4704-settings-screen-updates' of https://github…
johnwatkins0 Jul 9, 2020
3618745
Restore ElementName
johnwatkins0 Jul 9, 2020
81b9a88
Change registration action for GoogleFonts class
johnwatkins0 Jul 9, 2020
b40767e
Comment formatting fix
johnwatkins0 Jul 9, 2020
281c354
Rename reader-mode-override.js
johnwatkins0 Jul 9, 2020
c3d1d15
Remove redundant isset check
johnwatkins0 Jul 9, 2020
55e26b9
Escaping and minor updates to OptionsMenu.php
johnwatkins0 Jul 9, 2020
aaa6109
Make details prop a string instead of a node
johnwatkins0 Jul 9, 2020
3505976
Merge branch 'feature/4704-settings-screen-updates' of https://github…
johnwatkins0 Jul 9, 2020
6f0a9c8
Add escaping to menu strings
johnwatkins0 Jul 9, 2020
330f2c3
Remove unused variable
johnwatkins0 Jul 9, 2020
dc61532
Restore supported templates fieldset without obsolete wrapper
johnwatkins0 Jul 9, 2020
f6c407c
Settings page CSS updates and test fixes
johnwatkins0 Jul 9, 2020
fea953b
Remove dead code and update translator comment formatting
westonruter Jul 9, 2020
e6ac291
Open ecosystem page in a new window
westonruter Jul 9, 2020
f717920
Improve formatting of active theme notice
westonruter Jul 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -57,7 +57,7 @@
"react/no-unused-prop-types": "error",
"react/self-closing-comp": "error",
"import/no-unresolved": [ "error", {
"ignore": [ "jquery", "amp-block-editor-data", "amp-setup" ]
"ignore": [ "jquery", "amp-block-editor-data", "amp-settings" ]
} ],
"import/order": [ "error", { "groups": [ "builtin", [ "external", "unknown" ], "internal", "parent", "sibling", "index" ] } ],
"jsdoc/check-indentation": "error",
Expand Down
Expand Up @@ -73,7 +73,7 @@ function getNoticeIcon( type ) {
* @param {string} props.size The notice size.
* @param {string} props.type The notice type.
*/
export function AMPNotice( { children, className, size, type } ) {
export function AMPNotice( { children, className, size = NOTICE_SIZE_LARGE, type = NOTICE_TYPE_INFO } ) {
const noticeIcon = getNoticeIcon( type );

const classNames = [
Expand All @@ -98,6 +98,6 @@ export function AMPNotice( { children, className, size, type } ) {
AMPNotice.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
size: PropTypes.oneOf( [ NOTICE_SIZE_LARGE, NOTICE_SIZE_SMALL ] ).isRequired,
type: PropTypes.oneOf( [ NOTICE_TYPE_INFO, NOTICE_TYPE_SUCCESS, NOTICE_TYPE_WARNING ] ).isRequired,
size: PropTypes.oneOf( [ NOTICE_SIZE_LARGE, NOTICE_SIZE_SMALL ] ),
type: PropTypes.oneOf( [ NOTICE_TYPE_INFO, NOTICE_TYPE_SUCCESS, NOTICE_TYPE_WARNING ] ),
};
Expand Up @@ -5,11 +5,21 @@
line-height: 1.85;
}

.amp-notice p {
font-size: 13px;
}

.amp-notice__body {
flex-grow: 1;
text-align: left;
}

.amp-notice__body .components-panel__body-toggle,
.amp-notice__body .components-panel__body-toggle:focus:not(:disabled) {
color: var(--black);
outline: none;
}

.amp-notice--success {
background-color: #ecfef1;
}
Expand All @@ -23,6 +33,7 @@
}

.amp-notice--small {
line-height: 1.5;
padding: 0.5rem 1rem 0.5rem 0.5rem;
}

Expand Down
Expand Up @@ -46,6 +46,17 @@ describe( 'AMPNotice', () => {
} );

it( 'has correct classes', () => {
act( () => {
render(
<AMPNotice>
{ 'children' }
</AMPNotice>,
container,
);
} );

expect( container.querySelector( 'div' ).getAttribute( 'class' ) ).toBe( 'amp-notice amp-notice--info amp-notice--large' );

act( () => {
render(
<AMPNotice type={ NOTICE_TYPE_SUCCESS } size={ NOTICE_SIZE_LARGE } className="my-cool-class">
Expand Down
51 changes: 51 additions & 0 deletions assets/src/components/amp-setting-toggle/index.js
@@ -0,0 +1,51 @@
/**
* External dependencies
*/
import PropTypes from 'prop-types';

/**
* WordPress dependencies
*/
import { ToggleControl } from '@wordpress/components';

/**
* Internal dependencies
*/
import './style.css';

/**
* Styled toggle control.
*
* @param {Object} props Component props.
* @param {boolean} props.checked Whether the toggle is on.
* @param {Function} props.onChange Change handler.
* @param {?string} props.text Toggle text.
* @param {string} props.title Toggle title.
*/
export function AMPSettingToggle( { checked, onChange, text, title } ) {
return (
<div className="amp-setting-toggle">
<ToggleControl
checked={ checked }
label={ (
<div className="amp-setting-toggle__label-text">
<h3>
{ title }
</h3>
{ text && (
<p>
{ text }
</p> ) }
</div>
) }
onChange={ onChange }
/>
</div>
);
}
AMPSettingToggle.propTypes = {
checked: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired,
text: PropTypes.string,
title: PropTypes.string.isRequired,
};
44 changes: 44 additions & 0 deletions assets/src/components/amp-setting-toggle/style.css
@@ -0,0 +1,44 @@
/**
* AMP setting toggle component.
*/
.amp-setting-toggle__label-text h3 {
font-weight: 700;
font-size: 1.25rem;
margin-bottom: 1rem;
margin-top: 0;
}

.amp-setting-toggle__label-text p:last-child {
margin-bottom: 0;
}

.amp-setting-toggle .components-toggle-control .components-base-control__field .components-toggle-control__label {
display: flex;
flex-wrap: wrap;
}

.amp-setting-toggle__illustration {
padding-bottom: 1.5rem;

@media screen and (min-width: 783px) {
padding: 0 1.5rem;
}
}

.amp .amp-setting-toggle .components-form-toggle {
margin-bottom: 2.25rem;
margin-right: 2.25rem;
}

.amp-setting-toggle .components-toggle-control .components-base-control__field {
align-items: baseline;
margin-bottom: 0;
}

.amp-setting-toggle .components-form-toggle.is-checked .components-form-toggle__track {
background-color: var(--brand);
}

.amp-setting-toggle .components-form-toggle__input:focus + .components-form-toggle__track {
box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--brand);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions assets/src/components/amp-setting-toggle/test/index.js
@@ -0,0 +1,69 @@
/**
* External dependencies
*/
import { act } from 'react-dom/test-utils';
import { create } from 'react-test-renderer';

/**
* WordPress dependencies
*/
import { render } from '@wordpress/element';

/**
* Internal dependencies
*/
import { AMPSettingToggle } from '../';

let container;

describe( 'AMPSettingToggle', () => {
beforeEach( () => {
container = document.createElement( 'div' );
document.body.appendChild( container );
} );

afterEach( () => {
document.body.removeChild( container );
container = null;
} );

it( 'matches snapshots', () => {
let wrapper = create(
<AMPSettingToggle checked={ true } onChange={ () => null } text={ 'My text' } title={ 'My title' } />,
);
expect( wrapper.toJSON() ).toMatchSnapshot();

wrapper = create(
<AMPSettingToggle checked={ false } onChange={ () => null } title={ 'My title' } />,
);
expect( wrapper.toJSON() ).toMatchSnapshot();
} );

it( 'has correct elements and text', () => {
act( () => {
render(
<AMPSettingToggle title="My title" onChange={ () => null } checked={ false }>
{ 'children' }
</AMPSettingToggle>,
container,
);
} );

expect( container.querySelector( 'h3' ).textContent ).toBe( 'My title' );
expect( container.querySelector( 'p' ) ).toBeNull();
expect( container.querySelector( 'input:checked' ) ).toBeNull();

act( () => {
render(
<AMPSettingToggle title="My title" onChange={ () => null } checked={ true } text="My text">
{ 'children' }
</AMPSettingToggle>,
container,
);
} );

expect( container.querySelector( 'h3' ).textContent ).toBe( 'My title' );
expect( container.querySelector( 'p' ).textContent ).toBe( 'My text' );
expect( container.querySelector( 'input:checked' ) ).not.toBeNull();
} );
} );