-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from ucsc/feature/verbiage
Feature/verbiage
- Loading branch information
Showing
11 changed files
with
114 additions
and
1,369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('wp-components', 'wp-element', 'wp-polyfill'), 'version' => 'f356208fedc09a50d3e7c0908cb65f6a'); | ||
<?php return array('dependencies' => array('wp-block-editor', 'wp-components', 'wp-element', 'wp-polyfill'), 'version' => '1a616c20ecf3577e268b6eb4094a8e38'); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
class Accordion | ||
{ | ||
function __construct() | ||
{ | ||
add_action('init', array($this, 'adminAssets')); | ||
} | ||
|
||
function adminAssets() | ||
{ | ||
wp_register_style( 'accordion', | ||
plugins_url('../src/components/Accordion/editor.css', __FILE__), | ||
array(), | ||
filemtime(plugin_dir_path(__FILE__) . '../src/components/Accordion/editor.css')); | ||
wp_enqueue_style( 'accordion'); | ||
|
||
register_block_type('ucscblocks/accordion', array( | ||
'editor_script' => 'ucscblocks', | ||
'render_callback' => array($this, 'theHTML') | ||
)); | ||
} | ||
|
||
function theHTML($attributes, $content) | ||
{ | ||
$open = ($attributes['openOnPageLoad'] === true) ? 'open' : ''; | ||
return '<details ' . $open . '> | ||
<summary>' . $attributes['title'] . '</summary>' | ||
. $content . | ||
'</details>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { InnerBlocks, useBlockProps, BlockControls, InspectorControls } from '@wordpress/block-editor'; | ||
import { Panel, PanelBody, CheckboxControl } from '@wordpress/components'; | ||
|
||
const Accordion = () => { | ||
wp.blocks.registerBlockType("ucscblocks/accordion", { | ||
title: "Accordion", | ||
icon: "menu", | ||
category: "common", | ||
attributes: { | ||
openOnPageLoad: { | ||
type: 'boolean', | ||
} | ||
}, | ||
edit: ({ setAttributes, attributes }) => { | ||
const blockProps = useBlockProps(); | ||
|
||
return ( | ||
<> | ||
<InspectorControls key="setting"> | ||
<Panel> | ||
<PanelBody> | ||
<CheckboxControl | ||
label="Open on page load" | ||
checked={attributes.openOnPageLoad} | ||
onChange={newValue => setAttributes({openOnPageLoad: newValue})} | ||
></CheckboxControl> | ||
</PanelBody> | ||
</Panel> | ||
</InspectorControls> | ||
<details className='ucsc-accordion' open="true" > | ||
<summary><input | ||
placeholder='Accordion Item Title' | ||
value={attributes.title} | ||
onKeyUp={event => { | ||
event.preventDefault(); | ||
}} | ||
onChange={e => setAttributes({title: e.target.value})} /></summary> | ||
<InnerBlocks /> | ||
</details> | ||
</> | ||
); | ||
}, | ||
save:() => { | ||
const blockProps = useBlockProps.save(); | ||
|
||
return ( | ||
<div { ...blockProps }> | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
}, | ||
}) | ||
} | ||
|
||
export default Accordion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.ucsc-accordion { | ||
border: 1px solid #aaa; | ||
border-radius: 4px; | ||
margin: .5em .5em 0; | ||
padding: .5em .5em 0; | ||
} | ||
|
||
.ucsc-accordion[open] summary { | ||
border-bottom: 1px solid #aaa; | ||
margin-bottom: .5em; | ||
} | ||
|
||
.ucsc-accordion summary input { | ||
border: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters