Skip to content

Commit b57278c

Browse files
emeaguiarravichdev
authored andcommitted
Merge branch 'feature/534-settings-page' of github.com:material-components/material-design-for-wordpress into feature/534-settings-page
2 parents 4f8ab6f + 3011d23 commit b57278c

File tree

17 files changed

+420
-71
lines changed

17 files changed

+420
-71
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@wordpress/components": "9.4.0",
6060
"@wordpress/compose": "3.12.0",
6161
"@wordpress/data": "4.14.2",
62-
"@wordpress/date": "^3.13.1",
62+
"@wordpress/date": "3.13.1",
6363
"@wordpress/dom": "2.8.0",
6464
"@wordpress/dom-ready": "2.8.0",
6565
"@wordpress/e2e-test-utils": "4.16.0",

plugin/assets/css/src/settings/base.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
margin-top: 0;
4747
}
4848

49+
& h2 {
50+
margin-top: 32px;
51+
}
52+
4953
& p {
5054
font-size: 16px;
5155
margin: 0;
@@ -63,4 +67,16 @@
6367
text-align: left;
6468
width: 105px;
6569
}
70+
71+
& .material-settings__message {
72+
align-items: center;
73+
color: var(--material-design-settings-error-color);
74+
display: flex;
75+
}
76+
77+
& .material-settings__message-text {
78+
font-size: 16px;
79+
font-weight: 500;
80+
margin-left: 10px;
81+
}
6682
}

plugin/assets/fonts/google-fonts.json

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,14 +436,24 @@
436436
},
437437
"Archivo": {
438438
"variants": [
439+
"100",
440+
"200",
441+
"300",
439442
"regular",
440-
"italic",
441443
"500",
442-
"500italic",
443444
"600",
444-
"600italic",
445445
"700",
446-
"700italic"
446+
"800",
447+
"900",
448+
"100italic",
449+
"200italic",
450+
"300italic",
451+
"italic",
452+
"500italic",
453+
"600italic",
454+
"700italic",
455+
"800italic",
456+
"900italic"
447457
],
448458
"category": "sans-serif"
449459
},
@@ -545,12 +555,12 @@
545555
"Asap": {
546556
"variants": [
547557
"regular",
548-
"italic",
549558
"500",
550-
"500italic",
551559
"600",
552-
"600italic",
553560
"700",
561+
"italic",
562+
"500italic",
563+
"600italic",
554564
"700italic"
555565
],
556566
"category": "sans-serif"
@@ -1340,7 +1350,11 @@
13401350
"regular",
13411351
"500",
13421352
"600",
1343-
"700"
1353+
"700",
1354+
"italic",
1355+
"500italic",
1356+
"600italic",
1357+
"700italic"
13441358
],
13451359
"category": "serif"
13461360
},
@@ -2209,6 +2223,12 @@
22092223
],
22102224
"category": "handwriting"
22112225
},
2226+
"Dela Gothic One": {
2227+
"variants": [
2228+
"regular"
2229+
],
2230+
"category": "display"
2231+
},
22122232
"Delius": {
22132233
"variants": [
22142234
"regular"
@@ -4172,6 +4192,14 @@
41724192
],
41734193
"category": "sans-serif"
41744194
},
4195+
"Kiwi Maru": {
4196+
"variants": [
4197+
"300",
4198+
"regular",
4199+
"500"
4200+
],
4201+
"category": "serif"
4202+
},
41754203
"Knewave": {
41764204
"variants": [
41774205
"regular"
@@ -4448,6 +4476,18 @@
44484476
],
44494477
"category": "display"
44504478
},
4479+
"Lexend": {
4480+
"variants": [
4481+
"100",
4482+
"300",
4483+
"regular",
4484+
"500",
4485+
"600",
4486+
"700",
4487+
"800"
4488+
],
4489+
"category": "sans-serif"
4490+
},
44514491
"Lexend Deca": {
44524492
"variants": [
44534493
"regular"
@@ -5529,6 +5569,12 @@
55295569
],
55305570
"category": "display"
55315571
},
5572+
"New Tegomin": {
5573+
"variants": [
5574+
"regular"
5575+
],
5576+
"category": "serif"
5577+
},
55325578
"News Cycle": {
55335579
"variants": [
55345580
"regular",
@@ -8167,6 +8213,12 @@
81678213
],
81688214
"category": "display"
81698215
},
8216+
"Train One": {
8217+
"variants": [
8218+
"regular"
8219+
],
8220+
"category": "display"
8221+
},
81708222
"Trirong": {
81718223
"variants": [
81728224
"100",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* WordPress dependencies
19+
*/
20+
import { useContext } from '@wordpress/element';
21+
22+
/**
23+
* Internal dependencies
24+
*/
25+
import SettingsContext from '../context';
26+
27+
const Errors = () => {
28+
const { state } = useContext( SettingsContext );
29+
30+
return Object.keys( state.errors ).map( key => (
31+
<div
32+
key={ key }
33+
className="material-settings__message material-settings__message--error"
34+
>
35+
<i
36+
className="material-icons mdc-button__icon leading-icon"
37+
aria-hidden="true"
38+
>
39+
error
40+
</i>
41+
<span className="material-settings__message-text">
42+
{ state.errors[ key ] }
43+
</span>
44+
</div>
45+
) );
46+
};
47+
48+
export default Errors;

plugin/assets/src/settings/components/integrations/api.js

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
/**
218
* WordPress dependencies
319
*/
@@ -19,24 +35,47 @@ const Api = () => {
1935
const [ isLoading, setIsLoading ] = useState( false );
2036
const isApiOk = 'ok' === state.apiStatus;
2137

38+
const dispatchError = error =>
39+
dispatch( {
40+
type: ACTIONS.ADD_ERROR,
41+
payload: { id: 'api_error', error },
42+
} );
43+
2244
const removeApiKey = () => {
2345
setIsLoading( true );
2446
setApi( '' );
2547

26-
setApiKey( api ).then( () => {
27-
setIsLoading( false );
28-
dispatch( { type: ACTIONS.REMOVE_API_KEY } );
29-
} );
48+
setApiKey( api )
49+
.then( () => {
50+
setIsLoading( false );
51+
dispatch( { type: ACTIONS.REMOVE_API_KEY } );
52+
} )
53+
.catch( error => {
54+
dispatchError( error.message );
55+
console.error( error );
56+
setIsLoading( false );
57+
} );
3058
};
3159

3260
const activateApiKey = () => {
3361
setIsLoading( true );
3462

35-
setApiKey( api ).then( () => {
36-
setIsLoading( false );
37-
dispatch( { type: ACTIONS.ADD_API_KEY } );
38-
setApi( '' );
39-
} );
63+
setApiKey( api )
64+
.then( response => {
65+
setIsLoading( false );
66+
dispatch( {
67+
type: ACTIONS.ADD_API_KEY,
68+
payload: {
69+
lastUpdated: response.lastUpdated,
70+
},
71+
} );
72+
setApi( '' );
73+
} )
74+
.catch( error => {
75+
dispatchError( error.message );
76+
console.error( error );
77+
setIsLoading( false );
78+
} );
4079
};
4180

4281
const handleSubmit = event => {
@@ -51,7 +90,7 @@ const Api = () => {
5190
{ ! isApiOk && (
5291
<TextControl
5392
className="material-settings__api-input mdc-layout-grid__cell"
54-
value={ api }
93+
value={ api || '' }
5594
placeholder={ __( 'Google API Key', 'material-design' ) }
5695
onChange={ value => {
5796
setApi( value );

plugin/assets/src/settings/components/integrations/index.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
/**
218
* External dependencies
319
*/
@@ -34,11 +50,11 @@ const Integrations = () => {
3450
'Integrate %s and %s to get the most out of the Material Theme.',
3551
'material-design'
3652
),
37-
`<a href="https://fonts.google.com/">${ __(
53+
`<a href="https://fonts.google.com/" target="_blank" rel="noopener noreferrer">${ __(
3854
'Google Fonts',
3955
'material-design'
4056
) }</a>`,
41-
`<a href="https://material.io/resources/icons/?style=baseline">${ __(
57+
`<a href="https://material.io/resources/icons/?style=baseline" target="_blank" rel="noopener noreferrer">${ __(
4258
'Material icons',
4359
'material-design'
4460
) }</a>`
@@ -78,7 +94,7 @@ const Integrations = () => {
7894
'To use Google Fonts in Material Theme, please activate your %s and enable updates',
7995
'material-design'
8096
),
81-
`<a href="https://developers.google.com/fonts/docs/developer_api#APIKey">${ __(
97+
`<a href="https://developers.google.com/fonts/docs/developer_api#APIKey" target="_blank" rel="noopener noreferrer">${ __(
8298
'Google API Key',
8399
'material-design'
84100
) }</a>`

plugin/assets/src/settings/components/integrations/switch.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
/**
218
* External dependencies
319
*/

0 commit comments

Comments
 (0)