Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
868 changes: 868 additions & 0 deletions build/blocks-manifest.php

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions build/ranking-card/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "unityblocks/ranking-card",
"version": "1.0.0",
"title": "Ranking Card",
"category": "unityblocks",
"keywords": [
"unityblocks",
"ranking",
"card"
],
"icon": "index-card",
"description": "A UDS default design - ranking card with an interactive show more.",
"supports": {
"html": false,
"align": [
"wide",
"full"
]
},
"textdomain": "unityblocks",
"viewScript": [
"file:./frontend.js",
"unityblocks-ranking-card-view-script"
],
"editorScript": "file:./index.js",
"attributes": {
"imageSize": {
"type": "string",
"enum": [
"small",
"large"
],
"default": "large"
},
"image": {
"type": "string",
"default": ""
},
"imageAlt": {
"type": "string",
"default": ""
},
"heading": {
"type": "string",
"default": ""
},
"body": {
"type": "string",
"default": ""
},
"readMoreLink": {
"type": "string",
"default": ""
},
"citation": {
"type": "string",
"default": ""
}
}
}
1 change: 1 addition & 0 deletions build/ranking-card/frontend.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-element'), 'version' => '2a9df455ff2087287c12');
1 change: 1 addition & 0 deletions build/ranking-card/frontend.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/ranking-card/index.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '8ac4cf5d85f777a13cd1');
1 change: 1 addition & 0 deletions build/ranking-card/index.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unityblocks",
"version": "2.6.0",
"version": "3.0.0",
"description": "UnityBlocks is a suite of page building content blocks for the ASU Web Standards Unity (UDS) WordPress theme.",
"author": "ASU KE Web Services",
"license": "GPL-2.0-or-later",
Expand All @@ -16,6 +16,7 @@
"main": "build/index.js",
"scripts": {
"build": "wp-scripts build",
"manifest": "wp-scripts build-blocks-manifest",
"format": "wp-scripts format",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
Expand All @@ -27,6 +28,7 @@
"@asu/component-carousel": "^1.2.1",
"@asu/component-events": "^3.0.1",
"@asu/components-core": "^3.1.0",
"@asu/unity-react-core": "^1.3.0",
"@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-regular-svg-icons": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0",
Expand Down
49 changes: 49 additions & 0 deletions src/ranking-card/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "unityblocks/ranking-card",
"version": "1.0.0",
"title": "Ranking Card",
"category": "unityblocks",
"keywords": ["unityblocks", "ranking", "card"],
"icon": "index-card",
"description": "A UDS default design - ranking card with an interactive show more.",
"supports": {
"html": false,
"align": ["wide", "full"]
},
"textdomain": "unityblocks",
"viewScript": ["file:./frontend.js", "unityblocks-ranking-card-view-script"],
"editorScript": "file:./index.js",
"attributes": {
"imageSize": {
"type": "string",
"enum": ["small", "large"],
"default": "large"
},
"image": {
"type": "string",
"default": ""
},
"imageAlt": {
"type": "string",
"default": ""
},
"heading": {
"type": "string",
"default": ""
},
"body": {
"type": "string",
"default": ""
},
"readMoreLink": {
"type": "string",
"default": ""
},
"citation": {
"type": "string",
"default": ""
}
}
}
75 changes: 75 additions & 0 deletions src/ranking-card/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Retrieves the translation of text.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-i18n/
*/
import { __ } from "@wordpress/i18n";

/**
* React hook that is used to mark the block wrapper element.
* It provides all the necessary props like the class name.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops
*/
import { useBlockProps } from "@wordpress/block-editor";

/**
* External dependencies
*/
import { RankingCard } from "@asu/unity-react-core/dist/esm/components/RankingCard.es";

/**
* Internal dependencies
*/
import Inspector from "./inspector";

/**
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
* Those files can contain any CSS code that gets applied to the editor.
*
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css
*/
// import "./editor.scss";

/**
* The edit function describes the structure of your block in the context of the
* editor. This represents what the editor will render when the block is used.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit
*
* @return {WPElement} Element to render.
*/
const Edit = (props) => {
const {
attributes: {
imageSize,
image,
imageAlt,
heading,
body,
readMoreLink,
citation,
},
} = props;

const args = {
imageSize,
image,
imageAlt,
heading,
body,
readMoreLink,
citation,
};

return (
<>
<Inspector {...props} />
<div {...useBlockProps()}>
<RankingCard key={imageSize} {...args} />
</div>
</>
);
};

export default Edit;
29 changes: 29 additions & 0 deletions src/ranking-card/frontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { render } = wp.element;

import { RankingCard } from "@asu/unity-react-core/dist/esm/components/RankingCard.es";

// It is possible to load multiple ranking cards onto a page.
// Load each DOM element on page using the Gutenberg-generated class for the Ranking Card block
const cards = document.querySelectorAll(".wp-block-unityblocks-ranking-card");

cards.forEach((rankingCard) => {
const imageSize = rankingCard.dataset.imagesize;
const image = rankingCard.dataset.image;
const imageAlt = rankingCard.dataset.imagealt;
const heading = rankingCard.dataset.heading;
const body = rankingCard.dataset.body;
const readMoreLink = rankingCard.dataset.readmorelink;
const citation = rankingCard.dataset.citation;

const props = {
imageSize,
image,
imageAlt,
heading,
body,
readMoreLink,
citation,
};

render(<RankingCard {...props} />, rankingCard);
});
40 changes: 40 additions & 0 deletions src/ranking-card/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Registers a new block provided a unique name and an object defining its behavior.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
*/
import { registerBlockType } from "@wordpress/blocks";

/**
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
* All files containing `style` keyword are bundled together. The code used
* gets applied both to the front of your site and to the editor.
*
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css
*/
// import "./style.scss";

/**
* Internal dependencies
*/
import edit from "./edit";
import metadata from "./block.json";
import save from "./save";

/**
* Every block starts by registering a new block type definition.
*
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
*/
registerBlockType(metadata.name, {
/**
* @see ./edit.js
*/
edit,

/**
* @see ./save.js
*/
save,
example: () => {},
});
Loading
Loading