@caweb/cli 1.3.13 → 1.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/blocks/update-block.js +1 -7
- package/configs/webpack.config.js +1 -1
- package/package.json +1 -1
- package/template/block/frontend.js.mustache +5 -0
- package/template/block/render.php.mustache +15 -0
- package/template/index.cjs +5 -2
- package/template/plugin/$slug.php.mustache +1 -49
- package/template/assets/css/popover.css +0 -80
- package/template/assets/js/popover.js +0 -30
- package/template/plugin/core/cdec-api.php.mustache +0 -44
- package/template/plugin/inc/renderer.php.mustache +0 -25
|
@@ -44,9 +44,6 @@ export default async function updateBlock({
|
|
|
44
44
|
// make tmp directory
|
|
45
45
|
fs.ensureDir( `${slug}.tmp`);
|
|
46
46
|
|
|
47
|
-
// move inc directory to tmp directory
|
|
48
|
-
fs.copySync(`${slug}/inc/`, `${slug}.tmp/inc/`);
|
|
49
|
-
|
|
50
47
|
// move src directory to tmp directory
|
|
51
48
|
fs.copySync(`${slug}/src/`, `${slug}.tmp/src/`);
|
|
52
49
|
|
|
@@ -62,9 +59,6 @@ export default async function updateBlock({
|
|
|
62
59
|
// Recreate the block.
|
|
63
60
|
await createBlock({spinner, debug, slug});
|
|
64
61
|
|
|
65
|
-
// move inc directory back to block directory
|
|
66
|
-
fs.copySync(`${slug}.tmp/inc/`, `${slug}/inc/` );
|
|
67
|
-
|
|
68
62
|
// move src directory back to block directory
|
|
69
63
|
fs.copySync(`${slug}.tmp/src/`, `${slug}/src/`);
|
|
70
64
|
|
|
@@ -73,7 +67,7 @@ export default async function updateBlock({
|
|
|
73
67
|
let newPkg = JSON.parse( fs.readFileSync(path.join(slug, 'package.json')) )
|
|
74
68
|
|
|
75
69
|
/**
|
|
76
|
-
*
|
|
70
|
+
* package.json changes
|
|
77
71
|
* @since 1.3.0 Gulp is no longer used.
|
|
78
72
|
*/
|
|
79
73
|
if( oldPkg.version < '1.3.0' ){
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* {{title}} Dynamic Renderer Functions
|
|
4
|
+
*
|
|
5
|
+
* @package {{namespace}}
|
|
6
|
+
*
|
|
7
|
+
* @see https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/creating-dynamic-blocks/
|
|
8
|
+
*
|
|
9
|
+
* @param array $attributes Block attributes.
|
|
10
|
+
* @param string $content Block content.
|
|
11
|
+
* @param WP_Block_Type $block Current Block Type.
|
|
12
|
+
*/
|
|
13
|
+
?>
|
|
14
|
+
|
|
15
|
+
<p>Render Block Output</p>
|
package/template/index.cjs
CHANGED
|
@@ -13,14 +13,13 @@ const blockSlugTitle = capitalCase( blockSlug );
|
|
|
13
13
|
const customScripts = {};
|
|
14
14
|
|
|
15
15
|
const npmDependencies = [
|
|
16
|
-
'@wordpress/icons@9.
|
|
16
|
+
'@wordpress/icons@9.45.0'
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
const npmDevDependencies = [
|
|
20
20
|
'@wordpress/scripts@27.6.0'
|
|
21
21
|
];
|
|
22
22
|
|
|
23
|
-
// assetsPath: join( __dirname, 'assets' ),
|
|
24
23
|
module.exports = {
|
|
25
24
|
pluginTemplatesPath: join( __dirname, 'plugin' ),
|
|
26
25
|
blockTemplatesPath: join( __dirname, 'block' ),
|
|
@@ -47,4 +46,8 @@ module.exports = {
|
|
|
47
46
|
npmDependencies: npmDependencies,
|
|
48
47
|
npmDevDependencies: npmDevDependencies,
|
|
49
48
|
},
|
|
49
|
+
customBlockJSON: {
|
|
50
|
+
viewScript: "file:./frontend.js",
|
|
51
|
+
render: "file:./render.php"
|
|
52
|
+
}
|
|
50
53
|
};
|
|
@@ -44,11 +44,6 @@ foreach ( glob( __DIR__ . '/core/*.php' ) as $file ) {
|
|
|
44
44
|
require_once $file;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// Include {{title}} Functionality.
|
|
48
|
-
foreach ( glob( __DIR__ . '/inc/*.php' ) as $file ) {
|
|
49
|
-
require_once $file;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
/**
|
|
53
48
|
* Plugin API/Action Reference
|
|
54
49
|
* Actions Run During a Typical Request
|
|
@@ -56,7 +51,6 @@ foreach ( glob( __DIR__ . '/inc/*.php' ) as $file ) {
|
|
|
56
51
|
* @link https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request
|
|
57
52
|
*/
|
|
58
53
|
add_action( 'init', 'cagov_design_system_{{slugSnakeCase}}_init' );
|
|
59
|
-
add_action( 'wp_enqueue_scripts', 'cagov_design_system_{{slugSnakeCase}}_wp_enqueue_scripts' );
|
|
60
54
|
|
|
61
55
|
if ( ! function_exists( 'cagov_design_system_{{slugSnakeCase}}_init' ) ) {
|
|
62
56
|
/**
|
|
@@ -71,12 +65,6 @@ if ( ! function_exists( 'cagov_design_system_{{slugSnakeCase}}_init' ) ) {
|
|
|
71
65
|
function cagov_design_system_{{slugSnakeCase}}_init() {
|
|
72
66
|
global $pagenow;
|
|
73
67
|
|
|
74
|
-
if ( ! function_exists( 'get_plugin_data' ) ) {
|
|
75
|
-
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
$version = get_plugin_data( __FILE__ )['Version'];
|
|
79
|
-
|
|
80
68
|
/**
|
|
81
69
|
* Enqueues the default ThickBox js and css. (if not on the login page or customizer page)
|
|
82
70
|
*
|
|
@@ -86,16 +74,6 @@ if ( ! function_exists( 'cagov_design_system_{{slugSnakeCase}}_init' ) ) {
|
|
|
86
74
|
add_thickbox();
|
|
87
75
|
}
|
|
88
76
|
|
|
89
|
-
// if editing a page/post register compiled Gutenberg Block bundles.
|
|
90
|
-
if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ), true ) ) {
|
|
91
|
-
|
|
92
|
-
wp_enqueue_style( 'cagov-design-system-{{slug}}', cagov_design_system_{{slugSnakeCase}}_get_min_file( '/css/{{slug}}.css' ), array(), $version );
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
$block_args = array(
|
|
96
|
-
'render_callback' => 'cagov_design_system_{{slugSnakeCase}}_block_renderer',
|
|
97
|
-
);
|
|
98
|
-
|
|
99
77
|
/**
|
|
100
78
|
* Registers the block using the metadata loaded from the `block.json` file.
|
|
101
79
|
* Behind the scenes, it registers also all assets so they can be enqueued
|
|
@@ -103,33 +81,7 @@ if ( ! function_exists( 'cagov_design_system_{{slugSnakeCase}}_init' ) ) {
|
|
|
103
81
|
*
|
|
104
82
|
* @see https://developer.wordpress.org/reference/functions/register_block_type/
|
|
105
83
|
*/
|
|
106
|
-
register_block_type( __DIR__ . '/build'
|
|
84
|
+
register_block_type( __DIR__ . '/build' );
|
|
107
85
|
}
|
|
108
86
|
}
|
|
109
87
|
|
|
110
|
-
if ( ! function_exists( 'cagov_design_system_{{slugSnakeCase}}_wp_enqueue_scripts' ) ) {
|
|
111
|
-
/**
|
|
112
|
-
* Register {{title}} scripts/styles
|
|
113
|
-
*
|
|
114
|
-
* Fires when scripts and styles are enqueued.
|
|
115
|
-
*
|
|
116
|
-
* @category add_action( 'wp_enqueue_scripts', 'cagov_design_system_{{slugSnakeCase}}_wp_enqueue_scripts' );
|
|
117
|
-
* @link https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/
|
|
118
|
-
*
|
|
119
|
-
* @return void
|
|
120
|
-
*/
|
|
121
|
-
function cagov_design_system_{{slugSnakeCase}}_wp_enqueue_scripts() {
|
|
122
|
-
|
|
123
|
-
if ( ! function_exists( 'get_plugin_data' ) ) {
|
|
124
|
-
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
$version = get_plugin_data( __FILE__ )['Version'];
|
|
128
|
-
|
|
129
|
-
// Register compiled Gutenberg Block bundles.
|
|
130
|
-
wp_enqueue_script( 'cagov-design-system-{{slug}}', cagov_design_system_{{slugSnakeCase}}_get_min_file( '/js/{{slug}}.js', 'js' ), array(), $version, true );
|
|
131
|
-
|
|
132
|
-
wp_enqueue_style( 'cagov-design-system-{{slug}}', cagov_design_system_{{slugSnakeCase}}_get_min_file( '/css/{{slug}}.css' ), array(), $version );
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
.popover-content {
|
|
3
|
-
position: absolute;
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: column-reverse;
|
|
6
|
-
row-gap: .5rem;
|
|
7
|
-
left: -10000px;
|
|
8
|
-
top: auto;
|
|
9
|
-
width: 1px;
|
|
10
|
-
height: 1px;
|
|
11
|
-
background-color: white;
|
|
12
|
-
padding: 1rem;
|
|
13
|
-
z-index: 100;
|
|
14
|
-
outline: 0;
|
|
15
|
-
border-radius: .5rem;
|
|
16
|
-
overflow: visible;
|
|
17
|
-
pointer-events: none;
|
|
18
|
-
--shadow-color: 220 3% 15%;
|
|
19
|
-
--shadow-strength: 1%;
|
|
20
|
-
box-shadow: 5px 7px 15px grey;
|
|
21
|
-
}
|
|
22
|
-
.popover-content:focus {
|
|
23
|
-
outline: 2px solid var(--highlight-color, #fec02f);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.popover-container {
|
|
27
|
-
position: relative;
|
|
28
|
-
width: fit-content;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.popover-content::before {
|
|
32
|
-
content: '';
|
|
33
|
-
position: absolute;
|
|
34
|
-
width: 1rem;
|
|
35
|
-
height: 1rem;
|
|
36
|
-
left: 0;
|
|
37
|
-
top: 50%;
|
|
38
|
-
background-color: white;
|
|
39
|
-
transform: translate(-50%, -50%) rotate(45deg);
|
|
40
|
-
}
|
|
41
|
-
.popover-revealed {
|
|
42
|
-
width: max-content;
|
|
43
|
-
height: max-content;
|
|
44
|
-
left: var(--x);
|
|
45
|
-
top: var(--y);
|
|
46
|
-
transform: translateY(-50%);
|
|
47
|
-
}
|
|
48
|
-
@media screen and (max-width: 950px) {
|
|
49
|
-
.popover-content::before {
|
|
50
|
-
content: none;
|
|
51
|
-
}
|
|
52
|
-
.popover-revealed {
|
|
53
|
-
left: calc(50% + var(--x-offset-m, 0%));
|
|
54
|
-
transform: translate(-50%, 0);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.popover-legend {
|
|
59
|
-
display: flex;
|
|
60
|
-
flex-direction: row;
|
|
61
|
-
gap: .75rem;
|
|
62
|
-
align-items: flex-start;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.popover-legend svg {
|
|
66
|
-
height: 1.5em;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.popover-revealed p {
|
|
70
|
-
font-weight: 400;
|
|
71
|
-
font-size: 1em;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.popover-header {
|
|
75
|
-
margin: 0;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.popover-stat {
|
|
79
|
-
margin: 0 0 .5rem 0;
|
|
80
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
jQuery( document ).ready( function ( $ ) { // eslint-disable-line
|
|
2
|
-
$( document ).on( 'mouseover', '.popover', function ( ele ) {
|
|
3
|
-
togglePopover( ele.currentTarget.id );
|
|
4
|
-
} );
|
|
5
|
-
|
|
6
|
-
$( document ).on( 'mouseout', '.popover', function ( ele ) {
|
|
7
|
-
togglePopover( ele.currentTarget.id, false );
|
|
8
|
-
} );
|
|
9
|
-
|
|
10
|
-
function togglePopover( id, popin = true ) {
|
|
11
|
-
if ( undefined !== id ) {
|
|
12
|
-
const current = $( '#' + id );
|
|
13
|
-
const popver = $( '#' + id + '-popover' );
|
|
14
|
-
|
|
15
|
-
if ( popin ) {
|
|
16
|
-
current.addClass( 'highlighted' );
|
|
17
|
-
|
|
18
|
-
if ( undefined !== popver ) {
|
|
19
|
-
$( popver ).addClass( 'popover-revealed' );
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
current.removeClass( 'highlighted' );
|
|
23
|
-
|
|
24
|
-
if ( undefined !== popver ) {
|
|
25
|
-
$( popver ).removeClass( 'popover-revealed' );
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
} );
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* {{title}} CDEC REST API
|
|
4
|
-
*
|
|
5
|
-
* @see https://cdec.water.ca.gov/resapp/
|
|
6
|
-
*
|
|
7
|
-
* @package cagov-design-system
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
if ( ! function_exists( 'cagov_design_system_cdec_reservoir_conditions_api' ) ) {
|
|
11
|
-
/**
|
|
12
|
-
* Retrieve data from the CDEC Reservoir API
|
|
13
|
-
*
|
|
14
|
-
* @see https://cdec.water.ca.gov/resapp/service/res/conditions
|
|
15
|
-
* @param string $station_id Major reservoirs station that were recommended by CDEC.
|
|
16
|
-
* @return string
|
|
17
|
-
*/
|
|
18
|
-
function cagov_design_system_cdec_reservoir_conditions_api( $station_id = '' ) {
|
|
19
|
-
$result = 'No Results';
|
|
20
|
-
|
|
21
|
-
if ( empty( $station_id ) ) {
|
|
22
|
-
return $result;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
$date = gmdate( 'Y-m-d' );
|
|
26
|
-
|
|
27
|
-
$url = "https://cdec.water.ca.gov/resapp/service/res/conditions?date=$date&stationIds=$station_id";
|
|
28
|
-
|
|
29
|
-
$args = array(
|
|
30
|
-
'headers' => array(
|
|
31
|
-
'Content-Type' => 'application/json',
|
|
32
|
-
),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
$response = wp_remote_get( $url, $args );
|
|
36
|
-
|
|
37
|
-
if ( 200 === wp_remote_retrieve_response_code( $response ) ) {
|
|
38
|
-
$result = wp_remote_retrieve_body( $response );
|
|
39
|
-
|
|
40
|
-
return json_decode( $result, true )[0];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* {{title}} Dynamic Renderer Functions
|
|
4
|
-
*
|
|
5
|
-
* @package {{namespace}}
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
if ( ! function_exists( 'cagov_design_system_{{slugSnakeCase}}_block_renderer' ) ) {
|
|
9
|
-
/**
|
|
10
|
-
* Dynamic Renderer for {{title}} Block
|
|
11
|
-
*
|
|
12
|
-
* @see https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/creating-dynamic-blocks/
|
|
13
|
-
*
|
|
14
|
-
* @param array $attributes Block attributes.
|
|
15
|
-
* @param string $content Block content.
|
|
16
|
-
* @param WP_Block_Type $block Current Block Type.
|
|
17
|
-
* @return string Rendered block type output.
|
|
18
|
-
*/
|
|
19
|
-
function cagov_design_system_{{slugSnakeCase}}_block_renderer( $attributes, $content, $block ) {
|
|
20
|
-
|
|
21
|
-
$output = sprintf( '<p>Render Block Output</p>' );
|
|
22
|
-
|
|
23
|
-
return $output;
|
|
24
|
-
}
|
|
25
|
-
}
|