Skip to content

Commit

Permalink
feat: add quote block according to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
buuhuu committed Jul 25, 2024
1 parent 89f71c9 commit b242dea
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
30 changes: 30 additions & 0 deletions blocks/quote/quote.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.block.quote {
background-color: #ccc;
padding: 0 0 24px;
display: flex;
flex-direction: column;
margin: 1rem 0;
}

.block.quote blockquote {
margin: 16px;
text-indent: 0;
}

.block.quote > div:last-child > div {
margin: 0 16px;
font-size: small;
font-style: italic;
position: relative;
}

.block.quote > div:last-child > div::after {
content: "";
display: block;
position: absolute;
left: 0;
bottom: -8px;
height: 5px;
width: 30px;
background-color: darkgray;
}
7 changes: 7 additions & 0 deletions blocks/quote/quote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function decorate(block) {
const [quoteWrapper] = block.children;

const blockquote = document.createElement('blockquote');
blockquote.textContent = quoteWrapper.textContent.trim();
quoteWrapper.replaceChildren(blockquote);
}
17 changes: 17 additions & 0 deletions component-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@
}
}
}
},
{
"title": "Quote",
"id": "quote",
"plugins": {
"xwalk": {
"page": {
"resourceType": "core/franklin/components/block/v1/block",
"template": {
"name": "Quote",
"model": "quote",
"quote": "<p>Think, McFly! Think!</p>",
"author": "Biff Tannen"
}
}
}
}
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion component-filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"title",
"hero",
"cards",
"columns"
"columns",
"quote"
]
},
{
Expand Down
19 changes: 19 additions & 0 deletions component-models.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,24 @@
"valueType": "string"
}
]
},
{
"id": "quote",
"fields": [
{
"component": "text-area",
"name": "quote",
"value": "",
"label": "Quote",
"valueType": "string"
},
{
"component": "text-input",
"valueType": "string",
"name": "author",
"label": "Author",
"value": ""
}
]
}
]

0 comments on commit b242dea

Please sign in to comment.