Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #38 from cagov/1.0.10
Browse files Browse the repository at this point in the history
1.0.10
  • Loading branch information
chachasikes authored Jun 24, 2021
2 parents 3f83d67 + 9369da6 commit 88bec75
Show file tree
Hide file tree
Showing 8 changed files with 747 additions and 72 deletions.
114 changes: 113 additions & 1 deletion blocks/accordion/editor.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,115 @@
cagov-accordion.prog-enhanced button[aria-expanded="true"] + .accordion-card-container {
.edit-post-visual-editor cagov-accordion.prog-enhanced button[aria-expanded="true"]+.accordion-card-container {
min-height: 100px;
}

/* accordion component specific classes */
.edit-post-visual-editor cagov-accordion ..edit-post-visual-editor cagov-accordion-card {
border-radius: .3rem !important;
margin-bottom: 0;
min-height: 3rem;
margin-top: .5rem;
border: solid 1px #ededef !important;
}

.edit-post-visual-editor cagov-accordion .accordion-card-container {
display: block;
overflow: hidden;
}

.edit-post-visual-editor cagov-accordion button.accordion-card-header {
display: flex;
justify-content: left;
align-items: center;
padding: 0 0 0 1rem;
background-clip: border-box;
background-color: #EDEDEF;
border: none;
position: relative;
width: 100%;
line-height: 3rem;
}

.edit-post-visual-editor cagov-accordion button.accordion-card-header *,
.edit-post-visual-editor cagov-accordion .accordion-title {
text-align: left;
margin-bottom: 0;
color: var(--primary-color, #064E66);
margin-right: auto;
width: 90%;
padding: 0 0.5rem 0 0 !important;
font-size: 1.125rem;
font-weight: bold;
}

.edit-post-visual-editor cagov-accordion.prog-enhanced .accordion-card-container {
height: 0px;
transition: height 0.3s ease;
}

.edit-post-visual-editor cagov-accordion.prog-enhanced .accordion-card-container .card-body {
padding-left: 1rem;
}

.edit-post-visual-editor cagov-accordion .collapsed {
display: block;
overflow: hidden;
visibility: hidden;
}

.edit-post-visual-editor .accordion-title h4,
.edit-post-visual-editor .accordion-title h3,
.edit-post-visual-editor .accordion-title h2 {
padding: 0 !important;
margin-top: 0 !important;
margin-bottom: 0 !important;
font-size: 1.2rem !important;
font-weight: 700;
color: var(--primary-color, #064E66);
text-align: left !important;
}

.edit-post-visual-editor button.accordion-card-header:hover {
background-color: var(--hover-color, #F9F9FA);
}

.edit-post-visual-editor button.accordion-card-header:hover .accordion-title {
text-decoration: underline;
}

.edit-post-visual-editor button.accordion-card-header:focus {
outline-offset: -2px;
}

.edit-post-visual-editor .accordion-icon svg line {
stroke-width: 4px;
}

.edit-post-visual-editor .prog-enhanced .accordion-alpha .plus-minus {
width: 2.125rem;
height: 2.125rem;
border: none;
overflow: hidden;
margin-left: 1rem;
color: var(--primary-color, #064E66);
align-self: flex-start;
}

.edit-post-visual-editor .prog-enhanced .accordion-alpha .plus-minus svg {
fill: var(--primary-color, #064E66);
width: 25px;
height: 25px;
}

.edit-post-visual-editor .prog-enhanced .accordion-alpha-open cagov-plus .accordion-icon {
display: none !important;
}

.edit-post-visual-editor .prog-enhanced .accordion-alpha-open cagov-minus .accordion-icon {
display: block !important;
}

@media only screen and (max-width: 767px) {
.edit-post-visual-editor .accordion-alpha-open+.accordion-card-container {
height: 100% !important;
}
}
42 changes: 22 additions & 20 deletions blocks/accordion/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
* Version: 1.1.0
* Author: California Office of Digital Innovation
* @package ca-design-system
* @depends https://github.com/cagov/design-system/tree/main/components/accordion
*/

defined( 'ABSPATH' ) || exit;
defined('ABSPATH') || exit;

/**
* Load all translations for our plugin from the MO file.
*/
add_action( 'init', 'cagov_accordion' );
add_action('init', 'cagov_accordion');

function cagov_accordion() {
load_plugin_textdomain( 'ca-design-system', false, basename( __DIR__ ) . '/languages' );
function cagov_accordion()
{
load_plugin_textdomain('ca-design-system', false, basename(__DIR__) . '/languages');
}

function cagov_accordion_dynamic_render_callback( $block_attributes, $content ) {
// print_r($block_attributes);
function cagov_accordion_dynamic_render_callback($block_attributes, $content)
{
$title = isset($block_attributes["title"]) ? $block_attributes["title"] : "";
return <<<EOT
<cagov-accordion>
Expand Down Expand Up @@ -49,32 +51,32 @@ function cagov_accordion_dynamic_render_callback( $block_attributes, $content )
*
* Passes translations to JavaScript.
*/
function ca_design_system_register_accordion() {
function ca_design_system_register_accordion()
{

if ( ! function_exists( 'register_block_type' ) ) {
if (!function_exists('register_block_type')) {
// Gutenberg is not active.
return;
}

wp_register_script(
'ca-design-system-accordion',
plugins_url( 'block.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ),
filemtime( plugin_dir_path( __FILE__ ) . 'block.js' ),
plugins_url('block.js', __FILE__),
array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor'),
filemtime(plugin_dir_path(__FILE__) . 'block.js'),
);

wp_register_style(
wp_register_style(
'ca-design-system-accordion-editor-style',
plugins_url( 'editor.css', __FILE__ ),
array( ),
filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' )
plugins_url('editor.css', __FILE__),
array(),
filemtime(plugin_dir_path(__FILE__) . 'editor.css')
);

register_block_type( 'ca-design-system/accordion', array(
'editor_style' => 'ca-design-system-accordion-editor-style',
register_block_type('ca-design-system/accordion', array(
'editor_style' => 'ca-design-system-accordion-editor-style',
'editor_script' => 'ca-design-system-accordion',
'render_callback' => 'cagov_accordion_dynamic_render_callback'
) );

));
}
add_action( 'init', 'ca_design_system_register_accordion' );
add_action('init', 'ca_design_system_register_accordion');
5 changes: 5 additions & 0 deletions blocks/card-grid/editor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* link underline not used in cannabis designs */

.edit-post-visual-editor a.cagov-card {
text-decoration: none;
}
41 changes: 25 additions & 16 deletions blocks/card-grid/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
* @package ca-design-system
*/

defined( 'ABSPATH' ) || exit;
defined('ABSPATH') || exit;

/**
* Load all translations for our plugin from the MO file.
*/
add_action( 'init', 'cagov_card_grid' );
add_action('init', 'cagov_card_grid');

function cagov_card_grid() {
load_plugin_textdomain( 'ca-design-system', false, basename( __DIR__ ) . '/languages' );
function cagov_card_grid()
{
load_plugin_textdomain('ca-design-system', false, basename(__DIR__) . '/languages');
}

/**
Expand All @@ -26,31 +27,39 @@ function cagov_card_grid() {
*
* Passes translations to JavaScript.
*/
function ca_design_system_register_card_grid() {
function ca_design_system_register_card_grid()
{

if ( ! function_exists( 'register_block_type' ) ) {
if (!function_exists('register_block_type')) {
// Gutenberg is not active.
return;
}

wp_register_script(
'ca-design-system-card-grid',
plugins_url( 'block.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'underscore' ),
filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )
plugins_url('block.js', __FILE__),
array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'underscore'),
filemtime(plugin_dir_path(__FILE__) . 'block.js')
);

wp_register_style(
'cagov-card-grid',
plugins_url( 'style.css', __FILE__ ),
array( ),
filemtime( plugin_dir_path( __FILE__ ) . 'style.css' )
plugins_url('style.css', __FILE__),
array(),
filemtime(plugin_dir_path(__FILE__) . 'style.css')
);

register_block_type( 'ca-design-system/card-grid', array(
wp_register_style(
'ca-design-system-accordion-editor-style',
plugins_url('editor.css', __FILE__),
array(),
filemtime(plugin_dir_path(__FILE__) . 'editor.css')
);

register_block_type('ca-design-system/card-grid', array(
'style' => 'cagov-card-grid',
'editor_style' => 'ca-design-system-accordion-editor-style',
'editor_script' => 'ca-design-system-card-grid',
) );

));
}
add_action( 'init', 'ca_design_system_register_card_grid' );
add_action('init', 'ca_design_system_register_card_grid');
Loading

0 comments on commit 88bec75

Please sign in to comment.