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 author to QuoteBlock. Fixes #1037 #1173

Merged
merged 1 commit into from
May 16, 2020
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
6 changes: 3 additions & 3 deletions core/Piranha.Manager/assets/dist/css/full.min.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions core/Piranha.Manager/assets/dist/css/slim.min.css

Large diffs are not rendered by default.

1,726 changes: 1,117 additions & 609 deletions core/Piranha.Manager/assets/dist/js/piranha-deps-dev.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,726 changes: 1,117 additions & 609 deletions core/Piranha.Manager/assets/dist/js/piranha-deps.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/Piranha.Manager/assets/dist/js/piranha-deps.min.js

Large diffs are not rendered by default.

45 changes: 38 additions & 7 deletions core/Piranha.Manager/assets/dist/js/piranha.contentedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,19 @@ Vue.component("missing-block", {
});
Vue.component("quote-block", {
props: ["uid", "model"],
data: function () {
return {
placeholder: {
body: "",
author: ""
}
};
},
methods: {
onBlur: function (e) {
onAuthorBlur: function (e) {
this.model.author.value = e.target.innerText;
},
onBodyBlur: function (e) {
this.model.body.value = e.target.innerText; // Tell parent that title has been updated

var title = this.model.body.value.replace(/(<([^>]+)>)/ig, "");
Expand All @@ -513,12 +524,32 @@ Vue.component("quote-block", {
});
}
},
computed: {
isEmpty: function () {
return piranha.utils.isEmptyText(this.model.body.value);
}
},
template: "\n<div class=\"block-body\" :class=\"{ empty: isEmpty }\">\n <i class=\"fas fa-quote-right quote\"></i>\n <p class=\"lead\" contenteditable=\"true\" spellcheck=\"false\" v-html=\"model.body.value\" v-on:blur=\"onBlur\"></p>\n</div>\n"
created: function () {
var quotes = [{
author: "Nelson Mandela",
body: "The greatest glory in living lies not in never falling, but in rising every time we fall."
}, {
author: "Walt Disney",
body: "The way to get started is to quit talking and begin doing."
}, {
author: "Eleanor Roosevelt",
body: "The future belongs to those who believe in the beauty of their dreams."
}, {
author: "John Lennon",
body: "Life is what happens when you're busy making other plans."
}, {
author: "Audrey Hepburn",
body: "Nothing is impossible, the word itself says, 'I'm possible!'"
}, {
author: "Mark Twain",
body: "Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do."
}, {
author: "Maya Angelou",
body: "You will face many defeats in life, but never let yourself be defeated."
}];
this.placeholder = quotes[Math.floor(Math.random() * quotes.length)];
},
template: "\n<div class=\"block-body\">\n <blockquote class=\"blockquote\">\n <p contenteditable=\"true\" class=\"blockquote-body\" v-html=\"model.body.value\" v-on:blur=\"onBodyBlur\" :data-placeholder=\"placeholder.body\"></p>\n <footer contenteditable=\"true\" class=\"blockquote-footer\" v-html=\"model.author.value\" v-on:blur=\"onAuthorBlur\" :data-placeholder=\"placeholder.author\"></footer>\n </blockquote>\n</div>\n"
});
Vue.component("separator-block", {
props: ["model"],
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
<template>
<div class="block-body" :class="{ empty: isEmpty }">
<i class="fas fa-quote-right quote"></i>
<p class="lead" contenteditable="true" spellcheck="false" v-html="model.body.value" v-on:blur="onBlur"></p>
<div class="block-body">
<blockquote class="blockquote">
<p contenteditable="true" class="blockquote-body" v-html="model.body.value" v-on:blur="onBodyBlur" :data-placeholder="placeholder.body"></p>
<footer contenteditable="true" class="blockquote-footer" v-html="model.author.value" v-on:blur="onAuthorBlur" :data-placeholder="placeholder.author"></footer>
</blockquote>
</div>
</template>

<script>
export default {
props: ["uid", "model"],
data: function () {
return {
placeholder: {
body: "",
author: ""
}
}
},
methods: {
onBlur: function (e) {
onAuthorBlur: function (e) {
this.model.author.value = e.target.innerText;
},
onBodyBlur: function (e) {
this.model.body.value = e.target.innerText;

// Tell parent that title has been updated
Expand All @@ -24,10 +37,39 @@ export default {
});
}
},
computed: {
isEmpty: function () {
return piranha.utils.isEmptyText(this.model.body.value);
}
created: function () {
var quotes = [
{
author: "Nelson Mandela",
body: "The greatest glory in living lies not in never falling, but in rising every time we fall."
},
{
author: "Walt Disney",
body: "The way to get started is to quit talking and begin doing."
},
{
author: "Eleanor Roosevelt",
body: "The future belongs to those who believe in the beauty of their dreams."
},
{
author: "John Lennon",
body: "Life is what happens when you're busy making other plans."
},
{
author: "Audrey Hepburn",
body: "Nothing is impossible, the word itself says, 'I'm possible!'"
},
{
author: "Mark Twain",
body: "Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do."
},
{
author: "Maya Angelou",
body: "You will face many defeats in life, but never let yourself be defeated."
},
];

this.placeholder = quotes[Math.floor(Math.random() * quotes.length)];
}
}
</script>
39 changes: 16 additions & 23 deletions core/Piranha.Manager/assets/src/scss/inc/_blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -203,31 +203,24 @@
}

.quote-block {
.empty:not(:focus-within) {
background: $gray-100 url("../img/empty-text.png") no-repeat 50% 50%;
height: 8rem;
}

p {
color: $gray-600;
height: 100%;
min-height: 2rem;
font-family: "Open Sans", serif;
font-size: 1.4rem;
margin-left: 4.5rem;
}
.blockquote {
*[contenteditable] {
cursor: text;
padding: .5rem;
}

.quote {
display: none;
color: $gray-500;
float: left;
font-size: 2rem;
padding: .25rem 1rem;
}
*[data-placeholder]:empty {
&:after {
content: attr(data-placeholder);
color: $gray-500;
}
}

:not(.empty), :focus-within {
.quote {
display: inline;
.blockquote-body {
font-family: "Open Sans", serif;
font-size: 1.4rem;
margin-bottom: 0;
color: $gray-600;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions core/Piranha/Extend/Blocks/QuoteBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ namespace Piranha.Extend.Blocks
[BlockType(Name = "Quote", Category = "Content", Icon = "fas fa-quote-right", Component = "quote-block")]
public class QuoteBlock : Block, ISearchable
{
/// <summary>
/// Gets/sets the author
/// </summary>
public StringField Author { get; set; }

/// <summary>
/// Gets/sets the text body.
/// </summary>
Expand Down
8 changes: 6 additions & 2 deletions examples/MvcWeb/Views/Cms/DisplayTemplates/QuoteBlock.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
@model Piranha.Extend.Blocks.QuoteBlock

<div class="block">
<blockquote>
@Model.Body
<blockquote class="blockquote">
<p>@Model.Body</p>
@if (!string.IsNullOrEmpty(Model.Author))
{
<footer class="blockquote-footer">@Model.Author</footer>
}
</blockquote>
</div>
8 changes: 6 additions & 2 deletions examples/RazorWeb/Pages/DisplayTemplates/QuoteBlock.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
@model Piranha.Extend.Blocks.QuoteBlock

<div class="block">
<blockquote>
@Model.Body
<blockquote class="blockquote">
<p>@Model.Body</p>
@if (!string.IsNullOrEmpty(Model.Author))
{
<footer class="blockquote-footer">@Model.Author</footer>
}
</blockquote>
</div>