You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 lines
8.2 KiB

  1. <template lang="pug">
  2. v-app(v-scroll='upBtnScroll', :dark='darkMode')
  3. nav-header
  4. v-navigation-drawer(
  5. :class='darkMode ? `grey darken-3` : `primary`'
  6. dark
  7. app
  8. clipped
  9. mobile-break-point='600'
  10. :temporary='$vuetify.breakpoint.mdAndDown'
  11. v-model='navShown'
  12. )
  13. vue-scroll(:ops='scrollStyle')
  14. nav-sidebar(:color='darkMode ? `grey darken-3` : `primary`')
  15. slot(name='sidebar')
  16. v-fab-transition
  17. v-btn(
  18. fab
  19. color='primary'
  20. fixed
  21. bottom
  22. left
  23. small
  24. @click='navShown = !navShown'
  25. v-if='$vuetify.breakpoint.mdAndDown'
  26. v-show='!navShown'
  27. )
  28. v-icon menu
  29. v-content
  30. template(v-if='path !== `home`')
  31. v-toolbar(:color='darkMode ? `grey darken-4-d3` : `grey lighten-3`', flat, dense)
  32. v-btn.pl-0(v-if='$vuetify.breakpoint.xsOnly', flat, @click='toggleNavigation')
  33. v-icon(color='grey darken-2', left) menu
  34. span Navigation
  35. v-breadcrumbs.breadcrumbs-nav.pl-0(
  36. v-else
  37. :items='breadcrumbs'
  38. divider='/'
  39. )
  40. template(slot='item', slot-scope='props')
  41. v-icon(v-if='props.item.path === "/"', small) home
  42. v-btn.ma-0(v-else, :href='props.item.path', small, flat) {{props.item.name}}
  43. template(v-if='!isPublished')
  44. v-spacer
  45. .caption.red--text Unpublished
  46. status-indicator.ml-3(negative, pulse)
  47. v-divider
  48. v-layout(row)
  49. v-flex(xs12, lg9, xl10)
  50. v-toolbar(:color='darkMode ? `grey darken-4` : `grey lighten-4`', flat, :height='90')
  51. div
  52. .headline.grey--text(:class='darkMode ? `text-lighten-2` : `text--darken-3`') {{title}}
  53. .caption.grey--text.text--darken-1 {{description}}
  54. v-divider
  55. .contents(ref='container')
  56. slot(name='contents')
  57. v-flex(lg3, xl2, fill-height, v-if='$vuetify.breakpoint.lgAndUp')
  58. v-toolbar(:color='darkMode ? `grey darken-4` : `grey lighten-4`', flat, :height='90')
  59. div
  60. .caption.grey--text.text--lighten-1 Last edited by
  61. .body-2.grey--text(:class='darkMode ? `` : `text--darken-3`') {{ authorName }}
  62. .caption.grey--text.text--darken-1 {{ updatedAt | moment('calendar') }}
  63. v-spacer
  64. v-tooltip(left)
  65. v-btn.btn-animate-edit(icon, slot='activator', :href='"/e/" + path')
  66. v-icon(color='grey') edit
  67. span Edit Page
  68. v-divider
  69. template(v-if='toc.length')
  70. v-list.grey.pb-3(dense, :class='darkMode ? `darken-3-d3` : `lighten-3`')
  71. v-subheader.pl-4(:class='darkMode ? `blue--text text--lighten-1` : `primary--text`') Table of contents
  72. template(v-for='(tocItem, tocIdx) in toc')
  73. v-list-tile(@click='$vuetify.goTo(tocItem.anchor, scrollOpts)')
  74. v-icon(color='grey') arrow_right
  75. v-list-tile-title.pl-3 {{tocItem.title}}
  76. v-divider.ml-4(v-if='tocIdx < toc.length - 1 || tocItem.children.length')
  77. template(v-for='tocSubItem in tocItem.children')
  78. v-list-tile(@click='$vuetify.goTo(tocSubItem.anchor, scrollOpts)')
  79. v-icon.pl-3(color='grey lighten-1') arrow_right
  80. v-list-tile-title.pl-3.caption {{tocSubItem.title}}
  81. v-divider(inset, v-if='tocIdx < toc.length - 1')
  82. v-divider
  83. v-list.grey(dense, :class='darkMode ? `darken-3` : `lighten-4`')
  84. v-subheader.pl-4.yellow--text.text--darken-4 Rating
  85. .text-xs-center
  86. v-rating(
  87. v-model='rating'
  88. color='yellow darken-3'
  89. background-color='grey lighten-1'
  90. half-increments
  91. hover
  92. )
  93. .pb-2.caption.grey--text 5 votes
  94. v-divider
  95. template(v-if='tags.length')
  96. v-list.grey(dense, :class='darkMode ? `darken-3-d3` : `lighten-3`')
  97. v-subheader.pl-4.teal--text Tags
  98. template(v-for='(tag, idx) in tags')
  99. v-list-tile(:href='`/t/` + tag.slug')
  100. v-list-tile-avatar: v-icon(color='teal') label
  101. v-list-tile-title {{tag.title}}
  102. v-divider(inset, v-if='idx < tags.length - 1')
  103. v-divider
  104. v-toolbar(:color='darkMode ? `grey darken-3` : `grey lighten-4`', flat, dense)
  105. v-spacer
  106. v-tooltip(bottom)
  107. v-btn(icon, slot='activator'): v-icon(color='grey') bookmark
  108. span Bookmark
  109. v-tooltip(bottom)
  110. v-btn(icon, slot='activator'): v-icon(color='grey') share
  111. span Share
  112. v-tooltip(bottom)
  113. v-btn(icon, slot='activator'): v-icon(color='grey') print
  114. span Print Format
  115. v-spacer
  116. nav-footer
  117. v-fab-transition
  118. v-btn(v-if='upBtnShown', fab, fixed, bottom, right, small, @click='$vuetify.goTo(0, scrollOpts)', color='primary')
  119. v-icon arrow_upward
  120. </template>
  121. <script>
  122. import { StatusIndicator } from 'vue-status-indicator'
  123. import Prism from '@/libs/prism/prism.js'
  124. import { get } from 'vuex-pathify'
  125. export default {
  126. components: {
  127. StatusIndicator
  128. },
  129. props: {
  130. locale: {
  131. type: String,
  132. default: 'en'
  133. },
  134. path: {
  135. type: String,
  136. default: 'home'
  137. },
  138. title: {
  139. type: String,
  140. default: 'Untitled Page'
  141. },
  142. description: {
  143. type: String,
  144. default: ''
  145. },
  146. createdAt: {
  147. type: String,
  148. default: ''
  149. },
  150. updatedAt: {
  151. type: String,
  152. default: ''
  153. },
  154. tags: {
  155. type: Array,
  156. default: () => ([])
  157. },
  158. authorName: {
  159. type: String,
  160. default: 'Unknown'
  161. },
  162. authorId: {
  163. type: Number,
  164. default: 0
  165. },
  166. isPublished: {
  167. type: Boolean,
  168. default: false
  169. },
  170. toc: {
  171. type: Array,
  172. default: () => []
  173. }
  174. },
  175. data() {
  176. return {
  177. navShown: false,
  178. navExpanded: false,
  179. upBtnShown: false,
  180. scrollOpts: {
  181. duration: 1500,
  182. offset: -75,
  183. easing: 'easeInOutCubic'
  184. },
  185. breadcrumbs: [
  186. { path: '/', name: 'Home' },
  187. { path: '/' + this.path, name: 'Breadcrumb' },
  188. { path: '/' + this.path, name: 'Coming soon' }
  189. ],
  190. scrollStyle: {
  191. vuescroll: {},
  192. scrollPanel: {
  193. initialScrollX: 0.01, // fix scrollbar not disappearing on load
  194. scrollingX: false,
  195. speed: 50
  196. },
  197. rail: {
  198. gutterOfEnds: '2px'
  199. },
  200. bar: {
  201. onlyShowBarOnScroll: false,
  202. background: '#42A5F5',
  203. hoverStyle: {
  204. background: '#64B5F6'
  205. }
  206. }
  207. }
  208. }
  209. },
  210. computed: {
  211. darkMode: get('site/dark'),
  212. rating: {
  213. get () {
  214. return 3.5
  215. },
  216. set (val) {
  217. }
  218. }
  219. },
  220. created() {
  221. this.$store.commit('page/SET_AUTHOR_ID', this.authorId)
  222. this.$store.commit('page/SET_AUTHOR_NAME', this.authorName)
  223. this.$store.commit('page/SET_CREATED_AT', this.createdAt)
  224. this.$store.commit('page/SET_DESCRIPTION', this.description)
  225. this.$store.commit('page/SET_IS_PUBLISHED', this.isPublished)
  226. this.$store.commit('page/SET_LOCALE', this.locale)
  227. this.$store.commit('page/SET_PATH', this.path)
  228. this.$store.commit('page/SET_TAGS', this.tags)
  229. this.$store.commit('page/SET_TITLE', this.title)
  230. this.$store.commit('page/SET_UPDATED_AT', this.updatedAt)
  231. this.$store.commit('page/SET_MODE', 'view')
  232. },
  233. mounted () {
  234. Prism.highlightAllUnder(this.$refs.container)
  235. this.navShown = this.$vuetify.breakpoint.smAndUp
  236. },
  237. methods: {
  238. toggleNavigation () {
  239. this.navOpen = !this.navOpen
  240. },
  241. upBtnScroll () {
  242. const scrollOffset = window.pageYOffset || document.documentElement.scrollTop
  243. this.upBtnShown = scrollOffset > window.innerHeight * 0.33
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="scss">
  249. .breadcrumbs-nav {
  250. .v-btn {
  251. min-width: 0;
  252. &__content {
  253. text-transform: none;
  254. }
  255. }
  256. .v-breadcrumbs__divider:nth-child(2n) {
  257. padding: 0 6px;
  258. }
  259. .v-breadcrumbs__divider:nth-child(2) {
  260. padding: 0 6px 0 12px;
  261. }
  262. }
  263. </style>