Skip to content

Commit

Permalink
Rename file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jffng committed Mar 30, 2023
1 parent 6efb440 commit b86a1f1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
4 changes: 2 additions & 2 deletions admin/class-create-block-theme-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public function __construct() {
}

function create_block_theme_enqueue() {
$asset_file = include( plugin_dir_path( dirname( __FILE__ ) ) . 'build/editor.asset.php' );
$asset_file = include( plugin_dir_path( dirname( __FILE__ ) ) . 'build/plugin-sidebar.asset.php' );

wp_register_script(
'create-block-theme-slot-fill',
plugins_url( 'build/editor.js', dirname( __FILE__ ) ),
plugins_url( 'build/plugin-sidebar.js', dirname( __FILE__ ) ),
$asset_file['dependencies'],
$asset_file['version']
);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"simple-git": "^3.14.1"
},
"scripts": {
"build": "wp-scripts build src/index.js src/editor.js",
"build": "wp-scripts build src/index.js src/plugin-sidebar.js",
"format": "wp-scripts format",
"lint:css": "wp-scripts lint-style",
"lint:css:fix": "npm run lint:css -- --fix",
Expand All @@ -47,7 +47,7 @@
"lint:php": "composer run-script lint",
"lint:php:fix": "composer run-script format",
"packages-update": "wp-scripts packages-update",
"start": "wp-scripts start src/index.js src/editor.js",
"start": "wp-scripts start src/index.js src/plugin-sidebar.js",
"update-version": "node update-version-and-changelog.js",
"prepare": "husky install"
},
Expand Down
39 changes: 26 additions & 13 deletions src/editor.js → src/plugin-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
import {
Button,
__experimentalVStack as VStack,
__experimentalSpacer as Spacer,
__experimentalSpacer as Spacer,
__experimentalText as Text,
__experimentalHeading as Heading,
PanelBody,
Expand Down Expand Up @@ -50,19 +50,21 @@ const ExportTheme = () => {

async function exportTheme() {
try {
const response = await apiFetch(fetchOptions);
const response = await apiFetch( fetchOptions );
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const url = URL.createObjectURL( blob );
window.location.href = url;
} catch (error) {
} catch ( error ) {
const errorMessage =
error.message && error.code !== 'unknown_error'
? error.message
: __('An error occurred while attempting to export the theme.');
createErrorNotice(errorMessage, { type: 'snackbar' });
: __(
'An error occurred while attempting to export the theme.'
);
createErrorNotice( errorMessage, { type: 'snackbar' } );
}
}

exportTheme();
};

Expand All @@ -72,11 +74,11 @@ const ExportTheme = () => {
<VStack>
<Text variant="muted">
{ __(
"Export your theme with updated templates and styles.",
'Export your theme with updated templates and styles.',
'create-block-theme'
) }
</Text>
<Spacer/>
<Spacer />
<TextControl
label={ __( 'Theme name', 'create-block-theme' ) }
value={ theme.name }
Expand Down Expand Up @@ -130,12 +132,23 @@ const ExportTheme = () => {
) }
/>
</VStack>
<Spacer/>
<Button variant="secondary" disabled={ ! theme.name } onClick={ handleSubmit }>
<Spacer />
<Button
variant="secondary"
disabled={ ! theme.name }
onClick={ handleSubmit }
>
{ __( 'Export', 'create-block-theme' ) }
</Button>
<Spacer/>
{ ! theme.name && (<Text variant="muted">{ __( 'Theme name is required for export.', 'create-block-theme' ) }</Text>)}
<Spacer />
{ ! theme.name && (
<Text variant="muted">
{ __(
'Theme name is required for export.',
'create-block-theme'
) }
</Text>
) }
</PanelBody>
);
};
Expand Down

0 comments on commit b86a1f1

Please sign in to comment.