Skip to content

Commit

Permalink
Merge b0b9421 into 9c71d2d
Browse files Browse the repository at this point in the history
  • Loading branch information
PatelUtkarsh committed Sep 1, 2021
2 parents 9c71d2d + b0b9421 commit 7e09ca3
Show file tree
Hide file tree
Showing 20 changed files with 443 additions and 8 deletions.
5 changes: 5 additions & 0 deletions plugin/assets/css/src/gsm/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@
text-align: left;
width: 105px;
}

& .mdc-button--offsite .mdc-button__icon {
transform: rotate(-140deg);
transform-origin: initial;
}
}
5 changes: 5 additions & 0 deletions plugin/assets/css/src/wizard/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@
& .material-wizard__card img {
width: 100%;
}

& .mdc-button--offsite .mdc-button__icon {
transform: rotate(-140deg);
transform-origin: initial;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './wizard';
export * from './overview';
export * from './customize';
export * from './updates';
export * from './learn';
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import Notice from '../../../wizard/components/notice';
import TabContext from '../../context';
import { ACTIONS } from '../../constants';
import { Wizard, Overview, Customize, Updates } from './content';
import { Wizard, Overview, Customize, Updates, Learn } from './content';

const Content = () => {
const { state, dispatch } = useContext( TabContext );
Expand Down Expand Up @@ -95,6 +95,7 @@ const Content = () => {
{ 'CUSTOMIZE' === activeTab && <Customize handleClick={ handleClick } /> }
{ 'OVERVIEW' === activeTab && <Overview handleClick={ handleClick } /> }
{ 'UPDATES' === activeTab && <Updates handleClick={ handleClick } /> }
{ 'LEARN' === activeTab && <Learn handleClick={ handleClick } /> }
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* WordPress dependencies
*/
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import Button from '../../../wizard/components/navigation/button';

export const LearnContent = ( { materialUrl, newsLetterUrl } ) => {
return (
<Fragment>
<p>
{ __(
'Learn about the concepts behind material Design',
'material-design'
) }
</p>

<div className="material-gsm__content-actions">
<Button
style="mdc-button--raised mdc-button--offsite"
text={ __( 'Visit material.io', 'material-design' ) }
trailingIcon="arrow_downward"
link={ materialUrl }
target="_blank"
/>
</div>

<p>
{ __(
'Sign up to get updates and news about material design via email',
'material-design'
) }
</p>

<div className="material-gsm__content-actions">
<Button
style="mdc-button--raised mdc-button--offsite"
text={ __( 'Subscribe to Newsletter', 'material-design' ) }
trailingIcon="arrow_downward"
link={ newsLetterUrl }
target="_blank"
/>
</div>
</Fragment>
);
};
41 changes: 41 additions & 0 deletions plugin/assets/src/getting-started/components/content/learn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* WordPress dependencies
*/
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import getConfig from '../../get-config';
import { LearnContent } from './learn-content';

export const Learn = () => {
return (
<Fragment>
<div className="material-gsm__content mdc-layout-grid__cell mdc-layout-grid__cell--span-9">
<h2 className="material-gsm__content-title mdc-typography--headline2">
{ __( 'Learn More about Material Design', 'material-design' ) }
</h2>
<LearnContent
materialUrl={ getConfig( 'materialUrl' ) }
newsLetterUrl={ getConfig( 'newsLetterUrl' ) }
/>

<div style={ { height: '20px' } }></div>
</div>
</Fragment>
);
};
12 changes: 10 additions & 2 deletions plugin/assets/src/getting-started/components/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ import Tab from './tab';
const Navigation = () => {
const { dispatch } = useContext( TabContext );

let activeTab = 'CUSTOMIZE';
const hash = document.location.hash
? document.location.hash.split( '#' )[ 1 ]
: 'false';
if ( TABS[ hash.toUpperCase() ] ) {
activeTab = hash.toUpperCase();
}

useEffect( () => {
// Change initial tab if content and theme are already installed.
if ( 'ok' === getConfig( 'themeStatus' ) ) {
dispatch( { type: ACTIONS.SET_THEME_OK } );
dispatch( { type: ACTIONS.GOTO_STEP, payload: { value: 'CUSTOMIZE' } } );
dispatch( { type: ACTIONS.GOTO_STEP, payload: { value: activeTab } } );
dispatch( {
type: ACTIONS.MARK_COMPLETE,
payload: { value: [ 'WIZARD' ] },
Expand All @@ -45,7 +53,7 @@ const Navigation = () => {

if ( 'ok' === getConfig( 'contentStatus' ) ) {
dispatch( { type: ACTIONS.SET_DEMO_OK } );
dispatch( { type: ACTIONS.GOTO_STEP, payload: { value: 'CUSTOMIZE' } } );
dispatch( { type: ACTIONS.GOTO_STEP, payload: { value: activeTab } } );
dispatch( {
type: ACTIONS.MARK_COMPLETE,
payload: {
Expand Down
1 change: 1 addition & 0 deletions plugin/assets/src/getting-started/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ export const TABS = {
CUSTOMIZE: __( 'Customize your Theme', 'material-design' ),
OVERVIEW: __( 'Build with Material Blocks', 'material-design' ),
UPDATES: __( 'Updates', 'material-design' ),
LEARN: __( 'Learn More', 'material-design' ),
};
1 change: 1 addition & 0 deletions plugin/assets/src/getting-started/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const tabs = Object.keys( TABS );
* Default state of the world
*
*/

const initialState = {
activeTab: 'CUSTOMIZE',
completed: [ 'WIZARD' ],
Expand Down
5 changes: 5 additions & 0 deletions plugin/assets/src/wizard/components/content/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { __ } from '@wordpress/i18n';
*/
import Card from './card';
import getConfig from '../../../admin/get-config';
import { LearnContent } from '../../../getting-started/components/content/learn-content';

/**
* Congrats and how we work screen
Expand All @@ -45,6 +46,10 @@ const Work = () => {
'material-design'
) }
</p>
<LearnContent
materialUrl={ getConfig( 'materialUrl' ) }
newsLetterUrl={ getConfig( 'newsLetterUrl' ) }
/>
</Card>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions plugin/assets/src/wizard/components/navigation/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ const Button = props => {
* @param {*} props Inherited props
*/
export const Link = props => {
const { style, text, leadingIcon, trailingIcon, link } = props;
const { style, text, leadingIcon, trailingIcon, link, target } = props;

return (
<a href={ link } className={ `mdc-button ${ style }` }>
<a href={ link } className={ `mdc-button ${ style }` } target={ target }>
{ leadingIcon && (
<i
className="material-icons mdc-button__icon leading-icon"
Expand Down
10 changes: 10 additions & 0 deletions plugin/php/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
*/
class Admin extends Module_Base {

const NEWSLETTER_URL = 'https://services.google.com/fb/forms/materialdesignnewsletter?utm_source=WordPress';

const MATERIAL_URL = 'https://material.io/design/material-theming/overview.html#material-theming';

/**
* Initiate the class and hooks.
*/
Expand Down Expand Up @@ -210,6 +214,8 @@ public function enqueue_assets() {
'redirect' => esc_url( admin_url( 'themes.php' ) ),
'themeStatus' => esc_html( $this->plugin->theme_status() ),
'contentStatus' => esc_html( $has_demo_content ? 'ok' : 'install' ),
'newsLetterUrl' => self::NEWSLETTER_URL,
'materialUrl' => self::MATERIAL_URL,
]
);

Expand All @@ -221,6 +227,8 @@ public function enqueue_assets() {
'nonce' => wp_create_nonce( 'wp_rest' ),
'themeStatus' => esc_html( $this->plugin->theme_status() ),
'assetsRestPath' => esc_url( $this->plugin->assets_rest_controller->get_base_path() ),
'newsLetterUrl' => self::NEWSLETTER_URL,
'materialUrl' => self::MATERIAL_URL,
]
);
}
Expand Down Expand Up @@ -262,6 +270,8 @@ public function enqueue_assets() {
'restPath' => esc_url( $this->plugin->onboarding_rest_controller->get_base_path() ),
'assetsRestPath' => esc_url( $this->plugin->assets_rest_controller->get_base_path() ),
'themeStatus' => esc_html( $this->plugin->theme_status() ),
'newsLetterUrl' => self::NEWSLETTER_URL,
'materialUrl' => self::MATERIAL_URL,
]
);
}
Expand Down
29 changes: 29 additions & 0 deletions plugin/php/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public function init() {
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_front_end_assets' ], 100 );
add_action( 'wp_head', [ $this, 'frontend_inline_css' ], 1 );
add_action( 'admin_head', [ $this, 'frontend_inline_css' ], 1 );
add_action( 'plugin_row_meta', [ $this, 'get_plugin_row_meta' ], 10, 2 );
}

/**
Expand Down Expand Up @@ -281,4 +282,32 @@ public function theme_status() {

return 'ok';
}

/**
* Updates the plugin row meta with links to review plugin and get support.
*
* @param string[]|mixed $meta An array of the plugin's metadata, including the version, author, author URI,
* and plugin URI.
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
*
* @return string[]|mixed Plugin row meta.
*/
public function get_plugin_row_meta( $meta, $plugin_file ) {
if ( plugin_basename( realpath( __DIR__ . '/../material-design.php' ) ) !== $plugin_file ) {
return $meta;
}
if ( ! is_array( $meta ) ) {
return $meta;
}
$redirect_to = 'admin.php?page=material-settings#learn';


$additional_meta = [
'<a href="' . esc_url( admin_url( $redirect_to ) ) . '" target="_blank" rel="noreferrer noopener">' . esc_html__( 'Learn more', 'material-design' ) . '</a>',
'<a href="https://wordpress.org/support/plugin/material-design/" target="_blank" rel="noreferrer noopener">' . esc_html__( 'Contact support', 'material-design' ) . '</a>',
'<a href="https://wordpress.org/support/plugin/material-design/reviews/#new-post" target="_blank" rel="noreferrer noopener">' . esc_html__( 'Leave review', 'material-design' ) . '</a>',
];

return array_merge( $meta, $additional_meta );
}
}
Loading

0 comments on commit 7e09ca3

Please sign in to comment.