1 | # DaVanMonet
|
2 | [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
|
3 | [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
|
4 | [![Build Status](https://travis-ci.com/wezz/DaVanMonet.svg?branch=dev)](https://travis-ci.com/wezz/DaVanMonet)
|
5 | [![Next Version](https://img.shields.io/npm/v/davanmonet/next.svg)](https://www.npmjs.com/package/davanmonet)
|
6 | [![Stable Version](https://img.shields.io/npm/v/davanmonet/latest.svg)](https://www.npmjs.com/package/davanmonet)
|
7 |
|
8 | A Pattern Library system that compiles SASS/LESS to CSS and gives preview of Markdown documentation
|
9 |
|
10 | ## Getting Started
|
11 | You can use this project in two ways, either clone the repository and work in it directly, or use it as a grunt task.
|
12 |
|
13 | ### Clone
|
14 | Clone this repository and run the following commands in the base directory (we use npm as an example but recommend you use [yarn](https://yarnpkg.com/en/))
|
15 |
|
16 | #### Using NPM
|
17 | ```shell
|
18 | npm install
|
19 | ```
|
20 |
|
21 | ### Install DvM as a package
|
22 | #### Installation
|
23 | ```shell
|
24 | npm install davanmonet --save-dev
|
25 | ```
|
26 | #### Configuration
|
27 | In your package.json
|
28 | ```js
|
29 | "config": {
|
30 | "configFile": "./configs/projectoptions.yml"
|
31 | },
|
32 | ```
|
33 |
|
34 | #### Run as NPM scripts
|
35 | In your package.json
|
36 | ```js
|
37 | "scripts": {
|
38 | "dev": "node node_modules/davanmonet/dvm-build/dev-server.js"
|
39 | },
|
40 | ```
|
41 |
|
42 | Then simply start the project in development mode:
|
43 | ```shell
|
44 | npm run dev
|
45 | ```
|
46 |
|
47 | ## Writing documentation
|
48 | Documentation is written in [Markdown](https://daringfireball.net/projects/markdown/).
|
49 | A page visible on the website can consist of multiple markdown files. They will be automatically combined if they have the same component id (See primary.md and secondary.md in the button folder).
|
50 |
|
51 | To create a component preview, wrap a code segment with _:::componentpreview_
|
52 | If a component has multiple states just add more code segments with a headline above the code to name the state. See the example documentation in this project
|
53 |
|
54 | ## Iframes
|
55 | In some cases, the built-in preview frame might not work for you. In that case you can create a static HTML-file instead, and display it using an iframe. Use this markdown to cerate an iframe: _:::iframe(url/to/your-file.html)_
|
56 |
|
57 | If you include the client script for [iFrame Resizer](https://github.com/davidjbradshaw/iframe-resizer) in the document in the iframe, it will automatically resize itself to fit the content. You can also specify the height in the markdown, like this: _:::iframe(url/to/your-file.html,600)_. Width will always be 100%.
|
58 |
|
59 | ## Configuration file (JSON or YAML)
|
60 | Default configuration resides in /configs/projectoptions.yml
|
61 | It can be a JSON file as well. Just specify the correct path to the options file in your gruntfile configuration.
|
62 |
|
63 |
|
64 | ### Directories
|
65 | You can change where the system will put compiled css and where your source files are located
|
66 |
|
67 | ### Index Options
|
68 | The system will create an index of all the documentation (also used by the preview), this will specify where that index is saved and what metadata to add to the index.
|
69 |
|
70 | For keys to index we recommend relying only on strings. If a index key is not present in the documentation metadata it will not be included per documentation file.
|
71 |
|
72 | The one exception of this is the key "private". If it is present in the configuration we will always cast it to a boolean.
|
73 |
|
74 | ### Compilation
|
75 | Add target files here. These can be anything that Webpack can understand. By default Less, Sass and JS (es6) is supported, but you can add more loaders to Webbpack for other languages.
|
76 |
|
77 | The option compileIndividualFiles will create one less file per source files.
|
78 |
|
79 | ### Env
|
80 | Settings for ports etc
|
81 |
|
82 | ### Structure
|
83 | Add folders that should be included in the less/sass/index compilation.
|
84 | If this is left empty, all folders in your specified src directory will be included.
|
85 |
|
86 | ### User configuration (JSON or YAML)
|
87 | The options "userconfig" takes a string with a path to additional configuration for a specific user. This file should not be checked in. And the application will run even if the file is not present.
|
88 | The content of the file will extend the existing options for the project.
|
89 | This makes it possible for developers to choose which port to run the dev environment on
|
90 |
|
91 | ## On Site Preview
|
92 | In order to use On Site Preview, onSitePreview.js need to be loaded on the target site, like this:
|
93 | ```html
|
94 | <script src="http://localhost:9001/ospClient.js"></script>
|
95 | ```
|
96 | ### Config
|
97 | Below is an example config snippet for On Site Preview.
|
98 |
|
99 | The "onsitepreview" object should be at the root level of the configuration tree, preferrably in the user config file (user-conf.json).
|
100 |
|
101 | ```js
|
102 | "onsitepreview":
|
103 | {
|
104 | "components":
|
105 | [
|
106 | {
|
107 | "guid": "31495b40-9492-40e4-86e3-1e06bfc40171", // Required. GUID of the compontent
|
108 | "hook": "#SomeElement > div > p", // Required. Selector at which the component will be injected
|
109 | "state": 0, // Optional. State index. 0 will be the first state that is defined. Defaults to 0.
|
110 | "inject_pos": "after", // Optional. Specifies where it will be injected in relation to the selector. Before, after, append or prepend. Defaults to after.
|
111 | "wrapper": "<p class='preview'></p>", // Optional. The component will be wrapped in this tag if specified.
|
112 | "extra_css": ".preview .some-component { position: absolute; width: 100%; }" // Optional. This CSS will be injected in the page in addition to the component.
|
113 | }
|
114 | ]
|
115 | }
|
116 | ```
|
117 |
|
118 | ## Usage
|
119 |
|
120 |
|
121 | ### Deployment
|
122 | ```shell
|
123 | npm run build
|
124 | ```
|
125 | Compiles the project into the Dist folder. The build will generate three folders.
|
126 | 1. *Indexes* contains information about what documentation is contained in the project
|
127 | 2. *Package* contains the compiled css and the source ready to be published as a npm package
|
128 | 3. *Web* contains everything you need to deploy a pattern library website on IIS (or Apache).
|
129 |
|
130 | ### Development
|
131 | ```shell
|
132 | npm run dev
|
133 | ```
|
134 | This will create the css and start a webserver so you can preview your work
|