Skip to content

Commit

Permalink
feat(#7): add Code paragraph
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Mar 1, 2022
1 parent a020ad2 commit 1e9cff7
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
uuid: a1ec81f8-796e-47db-9928-8ebc78ce7a6d
langcode: en
status: true
dependencies:
config:
- field.field.paragraph.code.field_code
- field.field.paragraph.code.field_title
- paragraphs.paragraphs_type.code
id: paragraph.code.default
targetEntityType: paragraph
bundle: code
mode: default
content:
field_code:
type: string_textarea
weight: 1
region: content
settings:
rows: 5
placeholder: ''
third_party_settings: { }
field_title:
type: string_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
layout_paragraphs_fields:
weight: -200
region: content
settings: { }
third_party_settings: { }
hidden:
created: true
status: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
uuid: c68fa08a-6112-4fbd-863d-53ccf1a2b412
langcode: en
status: true
dependencies:
config:
- field.field.paragraph.code.field_code
- field.field.paragraph.code.field_title
- paragraphs.paragraphs_type.code
id: paragraph.code.default
targetEntityType: paragraph
bundle: code
mode: default
content:
field_code:
type: basic_string
label: hidden
settings: { }
third_party_settings: { }
weight: 1
region: content
field_title:
type: string
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 0
region: content
hidden: { }
5 changes: 5 additions & 0 deletions drupal/config/sync/field.field.node.article.field_content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- node.type.article
- paragraphs.paragraphs_type.card
- paragraphs.paragraphs_type.card_group
- paragraphs.paragraphs_type.code
- paragraphs.paragraphs_type.jumbotron
- paragraphs.paragraphs_type.link
- paragraphs.paragraphs_type.media
Expand Down Expand Up @@ -36,6 +37,7 @@ settings:
link: link
media: media
section: section
code: code
repository: repository
negate: 0
target_bundles_drag_drop:
Expand All @@ -45,6 +47,9 @@ settings:
card_group:
weight: -19
enabled: true
code:
weight: 15
enabled: true
entity_reference:
weight: -18
enabled: false
Expand Down
19 changes: 19 additions & 0 deletions drupal/config/sync/field.field.paragraph.code.field_code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
uuid: 15f252c4-198a-4c82-af93-7c5fbc56f471
langcode: en
status: true
dependencies:
config:
- field.storage.paragraph.field_code
- paragraphs.paragraphs_type.code
id: paragraph.code.field_code
field_name: field_code
entity_type: paragraph
bundle: code
label: Code
description: ''
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string_long
19 changes: 19 additions & 0 deletions drupal/config/sync/field.field.paragraph.code.field_title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
uuid: e8b07de4-46e1-4419-8752-c595172110b3
langcode: en
status: true
dependencies:
config:
- field.storage.paragraph.field_title
- paragraphs.paragraphs_type.code
id: paragraph.code.field_title
field_name: field_title
entity_type: paragraph
bundle: code
label: 'File name'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
19 changes: 19 additions & 0 deletions drupal/config/sync/field.storage.paragraph.field_code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
uuid: 117fcc66-180a-4801-8c1b-3fe9ad77f704
langcode: en
status: true
dependencies:
module:
- paragraphs
id: paragraph.field_code
field_name: field_code
entity_type: paragraph
type: string_long
settings:
case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
23 changes: 23 additions & 0 deletions drupal/config/sync/paragraphs.paragraphs_type.code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
uuid: e3c6ec6e-d8b4-42fa-a788-41ab19196fc9
langcode: en
status: true
dependencies:
module:
- entity_display_mode
- paragraphs_ee
- paragraphs_library
third_party_settings:
paragraphs_library:
allow_library_conversion: true
paragraphs_ee:
paragraphs_categories:
basics: basics
entity_display_mode:
display_configuration:
field_name: ''
id: code
label: Code
icon_uuid: null
icon_default: null
description: ''
behavior_plugins: { }
1 change: 1 addition & 0 deletions drupal/config/sync/user.role.anonymous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ permissions:
- 'view media'
- 'view paragraph content card'
- 'view paragraph content card_group'
- 'view paragraph content code'
- 'view paragraph content entity_reference'
- 'view paragraph content jumbotron'
- 'view paragraph content link'
Expand Down
1 change: 1 addition & 0 deletions drupal/config/sync/user.role.authenticated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ permissions:
- 'view media'
- 'view paragraph content card'
- 'view paragraph content card_group'
- 'view paragraph content code'
- 'view paragraph content entity_reference'
- 'view paragraph content jumbotron'
- 'view paragraph content link'
Expand Down
3 changes: 3 additions & 0 deletions drupal/config/sync/user.role.author.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ permissions:
- 'create page content'
- 'create paragraph content card'
- 'create paragraph content card_group'
- 'create paragraph content code'
- 'create paragraph content entity_reference'
- 'create paragraph content jumbotron'
- 'create paragraph content link'
Expand All @@ -64,6 +65,7 @@ permissions:
- 'create video media'
- 'delete paragraph content card'
- 'delete paragraph content card_group'
- 'delete paragraph content code'
- 'delete paragraph content entity_reference'
- 'delete paragraph content jumbotron'
- 'delete paragraph content link'
Expand Down Expand Up @@ -94,6 +96,7 @@ permissions:
- 'update content translations'
- 'update paragraph content card'
- 'update paragraph content card_group'
- 'update paragraph content code'
- 'update paragraph content entity_reference'
- 'update paragraph content jumbotron'
- 'update paragraph content link'
Expand Down
29 changes: 29 additions & 0 deletions nuxt/components/druxt/entity/paragraph/code/Default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div class="mockup-code mx-4 my-8">
<pre
v-if="filename"
class="mb-4"
data-prefix="#"
><code v-text="filename" /></pre>

<pre
v-for="(line, lineNumber) of code"
:key="lineNumber"
:data-prefix="lineNumber"
><!--
--><code v-text="line" /><!--
--></pre>
</div>
</template>

<script>
import { DruxtEntityMixin } from 'druxt-entity'
export default {
mixins: [DruxtEntityMixin],
computed: {
code: ({ entity }) => entity.attributes.field_code.split('\n'),
filename: ({ entity }) => entity.attributes.field_title,
},
}
</script>

0 comments on commit 1e9cff7

Please sign in to comment.