Upload files to "/"
This commit is contained in:
parent
e38ea7c238
commit
af0fb62893
4 changed files with 201 additions and 0 deletions
102
block.js
Normal file
102
block.js
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
const el = wp.element.createElement;
|
||||
const { registerBlockType } = wp.blocks;
|
||||
const { RichText, InnerBlocks } = wp.blockEditor;
|
||||
|
||||
// COMPANY
|
||||
registerBlockType('cv/company', {
|
||||
title: 'Company (CV)',
|
||||
icon: 'building',
|
||||
category: 'layout',
|
||||
|
||||
attributes: {
|
||||
name: { type: 'string', default: '' },
|
||||
dates: { type: 'string', default: '' }
|
||||
},
|
||||
|
||||
edit: ({ attributes, setAttributes }) =>
|
||||
el('div', { className: 'cv-company' },
|
||||
|
||||
el(RichText, {
|
||||
tagName: 'div',
|
||||
className: 'cv-company-name',
|
||||
placeholder: 'Company Name',
|
||||
value: attributes.name,
|
||||
onChange: val => setAttributes({ name: val })
|
||||
}),
|
||||
|
||||
el(RichText, {
|
||||
tagName: 'div',
|
||||
className: 'cv-company-dates',
|
||||
placeholder: 'Years (e.g. 2020 - 2024)',
|
||||
value: attributes.dates,
|
||||
onChange: val => setAttributes({ dates: val })
|
||||
}),
|
||||
|
||||
el(InnerBlocks, {
|
||||
allowedBlocks: ['cv/position'],
|
||||
template: [['cv/position']]
|
||||
})
|
||||
),
|
||||
|
||||
save: ({ attributes }) =>
|
||||
el('div', { className: 'cv-company' },
|
||||
el('div', { className: 'cv-company-name' }, el('strong', null, attributes.name)),
|
||||
el('div', { className: 'cv-company-dates' }, attributes.dates),
|
||||
el(InnerBlocks.Content, null)
|
||||
)
|
||||
});
|
||||
|
||||
// POSITION
|
||||
registerBlockType('cv/position', {
|
||||
title: 'Position (CV)',
|
||||
icon: 'id',
|
||||
parent: ['cv/company'],
|
||||
category: 'layout',
|
||||
|
||||
attributes: {
|
||||
title: { type: 'string', default: '' },
|
||||
department: { type: 'string', default: '' },
|
||||
dates: { type: 'string', default: '' }
|
||||
},
|
||||
|
||||
edit: ({ attributes, setAttributes }) =>
|
||||
el('div', { className: 'cv-position' },
|
||||
|
||||
el(RichText, {
|
||||
tagName: 'div',
|
||||
className: 'cv-position-title',
|
||||
placeholder: 'Job Title',
|
||||
value: attributes.title,
|
||||
onChange: val => setAttributes({ title: val })
|
||||
}),
|
||||
|
||||
el(RichText, {
|
||||
tagName: 'div',
|
||||
className: 'cv-position-department',
|
||||
placeholder: 'Department',
|
||||
value: attributes.department,
|
||||
onChange: val => setAttributes({ department: val })
|
||||
}),
|
||||
|
||||
el(RichText, {
|
||||
tagName: 'div',
|
||||
className: 'cv-position-dates',
|
||||
placeholder: 'Period',
|
||||
value: attributes.dates,
|
||||
onChange: val => setAttributes({ dates: val })
|
||||
}),
|
||||
|
||||
el(InnerBlocks, {
|
||||
allowedBlocks: ['core/list'],
|
||||
template: [['core/list']]
|
||||
})
|
||||
),
|
||||
|
||||
save: ({ attributes }) =>
|
||||
el('div', { className: 'cv-position' },
|
||||
el('div', { className: 'cv-position-title' }, el('strong', null, attributes.title)),
|
||||
el('div', { className: 'cv-position-department' }, attributes.department),
|
||||
el('div', { className: 'cv-position-dates' }, attributes.dates),
|
||||
el(InnerBlocks.Content, null)
|
||||
)
|
||||
});
|
||||
50
cv-experience-block-v1.php
Normal file
50
cv-experience-block-v1.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Plugin Name: CV Experience Blocks
|
||||
* Description: Adds Gutenberg CV Experience blocks (Company + Positions)
|
||||
* Version: 1.0.0
|
||||
* Author: Andreas Andersen (Ansico)
|
||||
* Author URI: https://ansico.dk/Ansico
|
||||
* Plugin URI: https://ansico.dk/Ansico/CV-Experience-Blocks
|
||||
* License: GPL3 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
function cv_v1_register_blocks() {
|
||||
|
||||
wp_register_script(
|
||||
'cv-v1-blocks',
|
||||
plugins_url('block.js', __FILE__),
|
||||
array('wp-blocks','wp-element','wp-block-editor','wp-components'),
|
||||
filemtime(plugin_dir_path(__FILE__) . 'block.js')
|
||||
);
|
||||
|
||||
wp_register_style(
|
||||
'cv-v1-style',
|
||||
plugins_url('style.css', __FILE__),
|
||||
array(),
|
||||
filemtime(plugin_dir_path(__FILE__) . 'style.css')
|
||||
);
|
||||
|
||||
wp_register_style(
|
||||
'cv-v1-editor',
|
||||
plugins_url('editor.css', __FILE__),
|
||||
array('wp-edit-blocks'),
|
||||
filemtime(plugin_dir_path(__FILE__) . 'editor.css')
|
||||
);
|
||||
|
||||
register_block_type('cv/company', [
|
||||
'editor_script' => 'cv-v1-blocks',
|
||||
'style' => 'cv-v1-style',
|
||||
'editor_style' => 'cv-v1-editor',
|
||||
]);
|
||||
|
||||
register_block_type('cv/position', [
|
||||
'editor_script' => 'cv-v1-blocks',
|
||||
'style' => 'cv-v1-style',
|
||||
'editor_style' => 'cv-v1-editor',
|
||||
]);
|
||||
}
|
||||
add_action('init', 'cv_v1_register_blocks');
|
||||
9
editor.css
Normal file
9
editor.css
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
.cv-company {
|
||||
border-left: 4px solid #2271b1;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.cv-position {
|
||||
border-left: 2px solid #ddd;
|
||||
padding-left: 10px;
|
||||
}
|
||||
40
style.css
Normal file
40
style.css
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
.cv-company {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.cv-company-name {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.cv-company-dates {
|
||||
color: #666;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
/* tighter spacing fix */
|
||||
.cv-position-dates {
|
||||
color: #777;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.cv-position .wp-block-list {
|
||||
margin-top: 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.cv-position p {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.cv-position {
|
||||
margin-left: 24px;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.cv-position-title {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cv-position-department {
|
||||
font-style: italic;
|
||||
}
|
||||
Loading…
Reference in a new issue