Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added textfile block #653

Merged
merged 4 commits into from
Aug 9, 2023
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
5 changes: 5 additions & 0 deletions .changeset/soft-jeans-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

---

Added textfile block
4 changes: 4 additions & 0 deletions blocks/textfile-block/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
19 changes: 19 additions & 0 deletions blocks/textfile-block/features/textfile/text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import PropTypes from 'fusion:prop-types'
import Consumer from 'fusion:consumer'

export function Textfile({ customFields }){
const { Text = "" } = customFields || {};
return Text;
};

Textfile.label = "Text File – Arc Block";

Textfile.icon = "notes-paper-text";

Textfile.propTypes = {
customFields: PropTypes.shape({
// eslint-disable-next-line react/no-typos
Text: PropTypes.richtext,
}),
}
export default Consumer(Textfile)
17 changes: 17 additions & 0 deletions blocks/textfile-block/features/textfile/text.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import TextFile from "./text";

const simple = "User-agent: *\nAllow: /\n\nSitemap: http://www.example.com/sitemap.xml";

it('should render the simple text', () => {
const textFile = TextFile({
customFields: {
Text: simple
},
})
expect(textFile).toMatchSnapshot()
})

it('should not render anything when no data is given', () => {
const textFile = TextFile({})
expect(textFile).toMatchSnapshot()
})
5 changes: 5 additions & 0 deletions blocks/textfile-block/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const base = require("../../jest/jest.config.base");

module.exports = {
...base,
};
46 changes: 46 additions & 0 deletions blocks/textfile-block/package-lock.json

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

27 changes: 27 additions & 0 deletions blocks/textfile-block/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@wpmedia/textfile-block",
"version": "0.0.1",
"description": "Fusion News Theme text file block",
"license": "CC-BY-NC-ND-4.0",
"main": "index.js",
"files": [
"features"
],
"publishConfig": {
"registry": "https://npm.pkg.github.com/",
"access": "public"
},
"repository": {
"type": "git",
"url": "ssh://[email protected]/WPMedia/feed-components.git",
"directory": "blocks/textfile-block"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"lint": "eslint --ext js --ext jsx features"
},
"devDependencies": {
"prop-types": "^15.7.2"
},
"gitHead": "83fb8d6685958d85ddbfcfbf01d9a5c864cd6c95"
}
Loading