|
| 1 | +<template> |
| 2 | + <div class="row mb-5"> |
| 3 | + <div :class="styleData.h2ColClass"> |
| 4 | + <h2>Themes</h2> |
| 5 | + </div> |
| 6 | + |
| 7 | + <div class="col-12"> |
| 8 | + <p> |
| 9 | + There are a few options for theming the code block. Using the components |
| 10 | + built in method allows you to be able to dynamically change the theme |
| 11 | + easily. If you choose, you can also use your own custom theme. |
| 12 | + </p> |
| 13 | + |
| 14 | + <p> |
| 15 | + The first way is to use one of the two custom themes |
| 16 | + (<code>neon-bunny</code>, |
| 17 | + <code>neon-bunny-carrot</code>) built into the component that are based |
| 18 | + off of my own VSCode |
| 19 | + <a :href="links.neonBunnyTheme" target="_blank">Neon Bunny Theme</a>. |
| 20 | + </p> |
| 21 | + |
| 22 | + <CodeBlock |
| 23 | + :code="bunnyThemeExample" |
| 24 | + label="Using the Neon Bunny Themes" |
| 25 | + lang="html" |
| 26 | + :theme="selectedTheme" |
| 27 | + /> |
| 28 | + |
| 29 | + <p> |
| 30 | + Another other is to use the main |
| 31 | + <a :href="links.prism" target="_blank">PrismJS</a> themes. If you use |
| 32 | + the component to load the theme, you just need to set the |
| 33 | + <a href="#props-theme-option">theme</a> prop to the desired theme. When |
| 34 | + you load it this way, the component will use a <code>fetch</code> call |
| 35 | + to load them themes from the |
| 36 | + <a :href="links.jsDelivrPrism" target="_blank">jsDelivr CDN</a>. |
| 37 | + Fetching the PrismJS themes from a CDN was the best method I could |
| 38 | + figure out at this time to dynamically load the themes, while making it |
| 39 | + easier for you to use them. You can also link to another CDN of your |
| 40 | + choice. |
| 41 | + </p> |
| 42 | + |
| 43 | + <CodeBlock |
| 44 | + :code="themePropExample" |
| 45 | + label="Using the theme prop" |
| 46 | + lang="html" |
| 47 | + :theme="selectedTheme" |
| 48 | + /> |
| 49 | + |
| 50 | + <p> |
| 51 | + You can also load the themes the traditional way of importing them |
| 52 | + directly from the PrismJS package in <code>node_modules</code>. Themes |
| 53 | + from their |
| 54 | + <a :href="links.prismThemes" target="_blank">Prism themes</a> |
| 55 | + repository can be used this way as well (not build into the component). |
| 56 | + </p> |
| 57 | + |
| 58 | + <CodeBlock |
| 59 | + :code="importJsExample" |
| 60 | + label="Using import (javascript)" |
| 61 | + lang="html" |
| 62 | + :theme="selectedTheme" |
| 63 | + /> |
| 64 | + |
| 65 | + <p>Alternatively you can import the theme into your css/sass/scss.</p> |
| 66 | + |
| 67 | + <CodeBlock |
| 68 | + :code="importCssExample" |
| 69 | + label="Using import (css/sass/scss)" |
| 70 | + lang="html" |
| 71 | + :theme="selectedTheme" |
| 72 | + /> |
| 73 | + </div> |
| 74 | + </div> |
| 75 | +</template> |
| 76 | + |
| 77 | +<script setup> |
| 78 | +import { inject } from 'vue'; |
| 79 | +
|
| 80 | +const links = inject('links'); |
| 81 | +const styleData = inject('styleData'); |
| 82 | +const selectedTheme = inject('selectedTheme'); |
| 83 | +
|
| 84 | +const bunnyThemeExample = `<CodeBlock |
| 85 | + :code="myCode" |
| 86 | + label="Neon Bunny Theme" |
| 87 | + lang="html" |
| 88 | + theme="neon-bunny" |
| 89 | +/> |
| 90 | +
|
| 91 | +<CodeBlock |
| 92 | + :code="myCode" |
| 93 | + label="Neon Bunny Carrot Theme" |
| 94 | + lang="html" |
| 95 | + theme="neon-bunny-carrot" |
| 96 | +/>`; |
| 97 | +
|
| 98 | +const themePropExample = `<CodeBlock |
| 99 | + :code="myCode" |
| 100 | + label="Build in Theming" |
| 101 | + lang="html" |
| 102 | + theme="coy" |
| 103 | +/>`; |
| 104 | +
|
| 105 | +const importJsExample = `<script setup> |
| 106 | + import 'prismjs/themes/prism-coy.css'; |
| 107 | +<\/script>`; |
| 108 | +
|
| 109 | +const importCssExample = `<style> |
| 110 | + @import 'prismjs/themes/prism-coy.css'; |
| 111 | +<\/style>`; |
| 112 | +</script>; |
0 commit comments