From 0bf91d2bed343856864a5d0c0893b4ff02f9b808 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Tue, 27 Nov 2018 12:52:46 +1100 Subject: [PATCH] Added some markup to the Articles --- public/blog/Blog.jsx | 4 +-- public/objects/content/Content.jsx | 44 +++++++++++++++++++++++ public/objects/content/box/ContentBox.jsx | 6 ++-- public/objects/typography/Heading.jsx | 7 ++-- public/objects/typography/Paragraph.jsx | 5 ++- public/pages/blog/article/ArticlePage.jsx | 9 +++-- 6 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 public/objects/content/Content.jsx diff --git a/public/blog/Blog.jsx b/public/blog/Blog.jsx index 4bab102..ae16764 100644 --- a/public/blog/Blog.jsx +++ b/public/blog/Blog.jsx @@ -27,9 +27,9 @@ import { get } from '@public/api/api'; const TestBlogArticle = id => { return { id, handle: 'test-blog-article', title: 'My Title', - image: 'photo.jpg', + image: 'blogs/dombot-redevelopment/banner.jpg', shortDescription: "Some short description that goes here too so let's write.", - description: "This is my longer example description lorem ipsum dolor sit amet." + description: "This is my longer example description lorem ipsum dolor sit amet.\nNewline\n\nNew Paragraph\n\nhttps://hyperlink.com" } }; diff --git a/public/objects/content/Content.jsx b/public/objects/content/Content.jsx new file mode 100644 index 0000000..dc40f7b --- /dev/null +++ b/public/objects/content/Content.jsx @@ -0,0 +1,44 @@ +// Copyright (c) 2018 Dominic Masters +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import React, { Fragment } from 'react'; +import { Paragraph } from './../typography/Typography'; + +const DoLine = content => { + //TODO: Support things like hyperlinks etc. + return { content } +}; + +const DoNewline = content => { DoLine(content) }
; +const DoParagraph = content => DoNewline(e)) } />; + +export default props => { + let { content, children } = props; + content = content || children || ""; + + return ( + + { content.split('\n\n').map(e => DoParagraph(e)) } + + ); +}; diff --git a/public/objects/content/box/ContentBox.jsx b/public/objects/content/box/ContentBox.jsx index 50dc282..942235e 100644 --- a/public/objects/content/box/ContentBox.jsx +++ b/public/objects/content/box/ContentBox.jsx @@ -23,17 +23,19 @@ import React from 'react'; +import Content from './../Content'; import Styles from './ContentBox.scss'; export default (props) => { let newProps = {...props}; - let { className, box } = props; + let { className, box, content } = props; - delete newProps.box; + ["box","content"].forEach(e => delete newProps[e]); let clazz = "o-content-box"; if(box) clazz += " is-box" if(className) clazz += ` ${className}`; + if(content) newProps.children = return
; }; diff --git a/public/objects/typography/Heading.jsx b/public/objects/typography/Heading.jsx index 6331388..7ec9b42 100644 --- a/public/objects/typography/Heading.jsx +++ b/public/objects/typography/Heading.jsx @@ -23,7 +23,7 @@ import React from 'react'; -const Heading = (props) => { +const Heading = props => { let { level, size, className } = props; level = level || 1; @@ -33,8 +33,8 @@ const Heading = (props) => { let clazz = `o-heading o-heading--${size}`; if(className) clazz += ` ${className}`; return ; -} -export default Heading; +}; + const Heading1 = (props) => { return ; }; const Heading2 = (props) => { return ; }; @@ -43,6 +43,7 @@ const Heading4 = (props) => { return ; }; const Heading5 = (props) => { return ; }; const Heading6 = (props) => { return ; }; +export default Heading; export { Heading1, Heading2, Heading3, Heading4, Heading5, Heading6 }; diff --git a/public/objects/typography/Paragraph.jsx b/public/objects/typography/Paragraph.jsx index 2476ea6..89afc88 100644 --- a/public/objects/typography/Paragraph.jsx +++ b/public/objects/typography/Paragraph.jsx @@ -23,7 +23,6 @@ import React from 'react'; -export default (props) => { - let { className } = props; - return

; +export default props => { + return

; }; diff --git a/public/pages/blog/article/ArticlePage.jsx b/public/pages/blog/article/ArticlePage.jsx index 1877d7c..f9b275e 100644 --- a/public/pages/blog/article/ArticlePage.jsx +++ b/public/pages/blog/article/ArticlePage.jsx @@ -70,11 +70,10 @@ export default withArticleTemplate(withLanguage(props => {

{/* Description */} - - - { article.description || article.shortDescription } - - + );