Skip to content

Commit

Permalink
Add support for tab containers (#1023)
Browse files Browse the repository at this point in the history
Uses https://github.com/pskordilakis/vuepress-tabs.

Closes openhab/website#183.

Update dependencies.

Signed-off-by: Yannick Schaus <github@schaus.net>
ghys authored Aug 9, 2019
1 parent 456b53d commit 85c3431
Showing 5 changed files with 2,537 additions and 1,708 deletions.
16 changes: 10 additions & 6 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ const DocsSidebarNavigation = require('./docs-sidebar.js')
const fs = require ('fs-extra')
const path = require('path')
// const CopyWebpackPlugin = require('copy-webpack-plugin')
const vuepressTabs = require('vuepress-tabs')

const HighlightDsl = require('./highlight-dsl')
const HighlightRules = require('./highlight-rules')
@@ -30,9 +31,17 @@ module.exports = {
],
markdown: {
config: (md) => {
vuepressTabs(md)
md.options.linkify = true
const highlight = md.options.highlight
md.options.highlight = (str, lang) => {
if (!Prism.languages.dsl || !Prism.languages.rules) {
Prism.languages.dsl = HighlightDsl
Prism.languages.rules = HighlightRules
}

if (['nginx', 'bash', 'python', 'js', 'javascript', 'groovy'].indexOf(lang) >= 0) return highlight(str, lang)

/* Simple heuristics to detect rules & other openHAB DSL code snippets and override the language */
if (str.match(/\b(?:Color|Contact|Dimmer|Group|Number|Player|Rollershutter|Switch|Location|Frame|Default|Text|Group|Selection|Setpoint|Slider|Colorpicker|Chart|Webview|Mapview|Image|Video|Item|Thing|Bridge|Time|Type|Sitemap|sitemap)\b/)) {
lang = 'dsl'
@@ -44,7 +53,7 @@ module.exports = {
str.match(/received update/) || str.match(/changed.*(?:from|to)/) || str.match(/Channel.*triggered/) ||
str.match(/\bval\b/) || str.match(/\bvar\b/) /* <-- dangerous! */) {

if (lang !== 'nginx' && lang !== 'shell') lang = 'rules'
lang = 'rules'
}
if (lang === 'shell' || lang === 'sh' || lang === 'shell_session') lang = 'bash'
if (lang === 'conf') lang = 'dsl'
@@ -54,11 +63,6 @@ module.exports = {
// console.log(str)
// }

if (!Prism.languages.dsl || !Prism.languages.rules) {
Prism.languages.dsl = HighlightDsl
Prism.languages.rules = HighlightRules
}

return highlight(str, lang)
}
}
10 changes: 10 additions & 0 deletions .vuepress/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Tabs from 'vue-tabs-component'

export default ({
Vue, // the version of Vue being used in the VuePress app
options, // the options for the root Vue instance
router, // the router instance for the app
siteData // site metadata
}) => {
Vue.use(Tabs)
}
48 changes: 48 additions & 0 deletions .vuepress/style.styl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@require '~vuepress-tabs/dist/themes/default.styl'

.navbar:not(.headroom--top):not(.transparent)
box-shadow rgba(10%,10%,10%,25%) 0 0 10px
background-color rgba(98%, 98%, 99%, 0.9) // linear-gradient(180deg,hsla(0,0%,100%,.3),hsla(0,0%,100%,.3) 95%,rgba(0,0,0,.05) 99%,rgba(0,0,0,.04))
@@ -105,3 +107,49 @@ a[href*='.openhab.org'] .outbound

.custom-block.tip
border-color #2196f3 !important

/* Tweaks for vuepress-tabs */

.vuepress-tabs
.tabs-component
.tabs-component-tab.is-active .tabs-component-tab-a
color black
.tabs-component-panel
margin-top -8.4rem
padding-top 8.4rem

@media (min-width: 700px)
.vuepress-tabs
.tabs-component-tab
border solid 1px #bbb
&.is-active
border-bottom solid 1px #fff
z-index 2
transform translateY(0)
.tabs-component-panels
border solid 1px #bbb

@media (max-width: 699px)
.vuepress-tabs
.tabs-component-tabs
border 0
align-items center
display flex
justify-content flex-start
margin-bottom -2px
padding-left -1rem
.tabs-component-tab
background-color #fff
border solid 1px #bbb
border-radius 3px 3px 0 0
margin-right .25em
transition transform .3s ease
&.is-active
border-bottom solid 1px #fff
z-index 2
transform translateY(0)
.tabs-component-panels
background-color #fff
border-top solid 1px #bbb
padding-top 0
margin-top 1px
Loading

0 comments on commit 85c3431

Please sign in to comment.