From 3a8bcc4b713671da7e0a581f1ee211bd14dda3f2 Mon Sep 17 00:00:00 2001 From: James Ray Date: Thu, 22 Aug 2024 04:43:56 -0700 Subject: [PATCH 1/3] Rich Table Block --- .../src/scss/components/_BlockRichTable.scss | 62 +++++++++++ .../BlockRichTable/BlockRichTable.stories.js | 62 +++++++++++ .../BlockRichTable/BlockRichTable.vue | 100 ++++++++++++++++++ .../BlockStreamfield/BlockStreamfield.vue | 11 ++ 4 files changed, 235 insertions(+) create mode 100644 packages/common/src/scss/components/_BlockRichTable.scss create mode 100644 packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js create mode 100644 packages/vue/src/components/BlockRichTable/BlockRichTable.vue diff --git a/packages/common/src/scss/components/_BlockRichTable.scss b/packages/common/src/scss/components/_BlockRichTable.scss new file mode 100644 index 00000000..3982d691 --- /dev/null +++ b/packages/common/src/scss/components/_BlockRichTable.scss @@ -0,0 +1,62 @@ +// needed to @extend .BlockText +@import '@explorer-1/common/src/scss/components/BlockText'; + +.BlockRichTable { + table { + @apply border-gray-light-mid border-t border-b border-collapse w-full; + } + + thead { + @apply bg-jpl-blue-darker; + } + + th { + @apply p-3 lg:p-5 border-gray-light-mid border-b font-secondary uppercase text-base leading-tight tracking-wider text-white text-left font-normal; + } + + tbody { + @apply text-gray-dark; + } + + tbody tr { + @apply table-row bg-white border-t border-gray-light-mid; + } + + td { + @apply p-3 lg:p-5; + } + + .rich_text, + .link { + @extend .BlockText; + } + // Below selectors are extra-specific to ensure they take priority over the @extend-ed .BlockText styles. + td.rich_text p { + @apply mb-4; + } + + td.rich_text ol { + @apply pl-6 mb-4; + } + + td.rich_text ul { + @apply pl-6 mb-4 list-disc; + + li { + @apply p-0; + } + + li::before { + @apply hidden; + } + } + + td.rich_text ul li, + td.rich_text ol li { + @apply my-1; + } + + td.rich_text hr { + @apply my-4; + } +} diff --git a/packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js b/packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js new file mode 100644 index 00000000..98894bf9 --- /dev/null +++ b/packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js @@ -0,0 +1,62 @@ +import BlockRichTable from './BlockRichTable.vue' + +export default { + title: 'Components/Blocks/BlockRichTable', + component: BlockRichTable, + excludeStories: /.*Data$/ +} + +export const BlockRichTableData = { + blockType: 'RichTableBlock', + table: `{ "data": { + "page": { + "body": [ + { + "blockType": "RichTableBlock", + "tableCaption": "table caption", + "tableContent": { + "tableBody": [ + [ + { + "blockType": "CharBlock", + "value": "plain text render" + } + ], + [ + { + "blockType": "RichTextBlock", + "value": "

richtext render

" + } + ], + [ + { + "blockType": "ImageBlock", + "image": { + "caption": "These JPL interns worked on the development and testing of the hardware and software for CADRE, NASA’s upcoming lunar technology demonstration.", + "url": "https://placekitten.com/400/300" + } + } + ] + ], + "tableHead": [ + [ + { + "text": "Column Heading Text" + } + ] + ] + } + } + ], + "breadcrumb": null + } + } + }` +} + +export const BaseStory = { + name: 'BlockRichTable', + args: { + data: BlockRichTableData + } +} diff --git a/packages/vue/src/components/BlockRichTable/BlockRichTable.vue b/packages/vue/src/components/BlockRichTable/BlockRichTable.vue new file mode 100644 index 00000000..faf83a5a --- /dev/null +++ b/packages/vue/src/components/BlockRichTable/BlockRichTable.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue b/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue index 6175bc23..8941a4c0 100644 --- a/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue +++ b/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue @@ -184,6 +184,15 @@ + + + + Date: Wed, 28 Aug 2024 04:16:14 -0700 Subject: [PATCH 2/3] WIP richTableBlock --- .../src/scss/components/_BlockRichTable.scss | 4 -- .../BlockRichTable/BlockRichTable.stories.js | 38 +++++++++++------- .../BlockRichTable/BlockRichTable.vue | 40 +++++++++++++------ 3 files changed, 50 insertions(+), 32 deletions(-) diff --git a/packages/common/src/scss/components/_BlockRichTable.scss b/packages/common/src/scss/components/_BlockRichTable.scss index 3982d691..43160953 100644 --- a/packages/common/src/scss/components/_BlockRichTable.scss +++ b/packages/common/src/scss/components/_BlockRichTable.scss @@ -22,10 +22,6 @@ @apply table-row bg-white border-t border-gray-light-mid; } - td { - @apply p-3 lg:p-5; - } - .rich_text, .link { @extend .BlockText; diff --git a/packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js b/packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js index 98894bf9..2eeeb8d6 100644 --- a/packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js +++ b/packages/vue/src/components/BlockRichTable/BlockRichTable.stories.js @@ -15,33 +15,41 @@ export const BlockRichTableData = { "blockType": "RichTableBlock", "tableCaption": "table caption", "tableContent": { - "tableBody": [ + "tableHead": [ [ { - "blockType": "CharBlock", - "value": "plain text render" - } - ], - [ + "text": "1. Learn why we study geology on Earth and other planets" + }, { - "blockType": "RichTextBlock", - "value": "

richtext render

" + "text": "1. Learn why we study geology on Earth and other planets" } - ], + ] + ], + "tableBody": [ [ { "blockType": "ImageBlock", "image": { - "caption": "These JPL interns worked on the development and testing of the hardware and software for CADRE, NASA’s upcoming lunar technology demonstration.", - "url": "https://placekitten.com/400/300" + "caption": "NASA astronaut Kate Rubins uses a hand lens to observe the minerals present in a rock while taking part in the European Space Agency's PANGAEA geology training. Image credit: ESA–A. Romeo", + "url": "https://imagecache.jpl.nasa.gov/images/edu/activities/ediblerocks_learn_main-640x350.jpg" + } + }, + { + "blockType": "ImageBlock", + "image": { + "caption": "NASA astronaut Kate Rubins uses a hand lens to observe the minerals present in a rock while taking part in the European Space Agency's PANGAEA geology training. Image credit: ESA–A. Romeo", + "url": "https://imagecache.jpl.nasa.gov/images/edu/activities/ediblerocks_learn_main-640x350.jpg" } } - ] - ], - "tableHead": [ + ], [ { - "text": "Column Heading Text" + "blockType": "CharBlock", + "value": "Geologists are scientists who study a planet's solid features, like soil, rocks, and minerals. There are all kinds of rocks and minerals that make up our planet – as well as the Moon, Mars, and other rocky worlds. By studying these features, we can learn more about how rocky worlds form and change over time." + }, + { + "blockType": "CharBlock", + "value": "Geologists are scientists who study a planet's solid features, like soil, rocks, and minerals. There are all kinds of rocks and minerals that make up our planet – as well as the Moon, Mars, and other rocky worlds. By studying these features, we can learn more about how rocky worlds form and change over time." } ] ] diff --git a/packages/vue/src/components/BlockRichTable/BlockRichTable.vue b/packages/vue/src/components/BlockRichTable/BlockRichTable.vue index faf83a5a..0ef42ff4 100644 --- a/packages/vue/src/components/BlockRichTable/BlockRichTable.vue +++ b/packages/vue/src/components/BlockRichTable/BlockRichTable.vue @@ -1,6 +1,8 @@ @@ -42,13 +21,13 @@ export default defineComponent({ diff --git a/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue b/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue index 472cea4c..a3749340 100644 --- a/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue +++ b/packages/vue/src/components/BlockStreamfield/BlockStreamfield.vue @@ -188,7 +188,7 @@ indent="col-3" class="lg:mb-18 mb-10" > - +