소스 검색

add NodeViewTitle component

axolotle 3 년 전
부모
커밋
1a1c4875a1
2개의 변경된 파일74개의 추가작업 그리고 0개의 파일을 삭제
  1. 73 0
      src/components/nodes/NodeViewTitle.vue
  2. 1 0
      src/components/nodes/index.js

+ 73 - 0
src/components/nodes/NodeViewTitle.vue

@@ -0,0 +1,73 @@
+<template>
+  <component
+    :is="tag"
+    class="node-view-title"
+    :class="{ block }"
+  >
+    <component
+      :is="link ? 'a' : 'div'"
+      @click="onTitleClick(node)"
+      class="node-view-title-container"
+    >
+      <slot name="default" />
+      <strong>{{ toCommaList(node.authors) }}</strong>,
+      <span>
+        <span v-if="node.preTitle" v-html="trim(node.preTitle) + ', '" />
+        <em v-html="trim(node.title) || 'pas de titre ital'" />
+      </span>
+      <div v-if="edition && node.edition" class="edition">
+        {{ node.edition.map(ed => ed.name).join(' ') }}
+      </div>
+    </component>
+  </component>
+</template>
+
+<script>
+import { trim, toCommaList } from '@/helpers/common'
+
+
+export default {
+  name: 'NodeViewTitle',
+
+  props: {
+    node: { type: Object, required: true },
+    tag: { type: String, default: 'h6' },
+    link: { type: Boolean, default: false },
+    block: { type: Boolean, default: false },
+    edition: { type: Boolean, default: false }
+  },
+
+  data () {
+    return {
+    }
+  },
+
+  methods: {
+    trim,
+    toCommaList,
+
+    onTitleClick (node) {
+      if (this.link) {
+        this.$emit('open-node')
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.node-view-title {
+  font-weight: $font-weight-normal;
+
+  a {
+    text-decoration: none;
+    cursor: pointer;
+  }
+
+  &.block &-container {
+    > * {
+      display: block;
+    }
+  }
+}
+</style>

+ 1 - 0
src/components/nodes/index.js

@@ -1,4 +1,5 @@
 export { default as NodeViewChildList } from './NodeViewChildList'
+export { default as NodeViewTitle } from './NodeViewTitle'
 export { default as NodeViewHeaderRef } from './NodeViewHeaderRef'
 export { default as NodeViewHeaderProd } from './NodeViewHeaderProd'
 export { default as NodeViewBody } from './NodeViewBody'