Skip to content

Commit

Permalink
Added textfile block (#653)
Browse files Browse the repository at this point in the history
* Added textfile block

* Create soft-jeans-listen.md

* Added package to textfile-block

* added package-lock

---------

Co-authored-by: Malavika Koppula <[email protected]>
  • Loading branch information
malavikakoppula and Malavika Koppula authored Aug 9, 2023
1 parent 8e5e2b9 commit 2b4eb36
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 0 deletions.
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"
}

0 comments on commit 2b4eb36

Please sign in to comment.