Browse Source

Refactor demos in docs

pull/1287/head
Artur Arseniev 8 years ago
parent
commit
fb33e58e83
  1. 18
      docs/.vuepress/components/DemoCustomPanels.vue
  2. 28
      docs/.vuepress/components/DemoLayers.vue
  3. 17
      docs/.vuepress/components/demos/DemoLayers.css
  4. 11
      docs/.vuepress/components/demos/utils.js
  5. 63
      docs/getting-started.md

18
docs/.vuepress/components/DemoCustomPanels.vue

@ -1,6 +1,8 @@
<template> <template>
<div> <div>
<div class="basic-panel" id="basic-panel3"></div> <div class="panel__top" id="panel__top3">
<div class="panel__basic-actions" id="panel__basic-actions3"></div>
</div>
<div class="gjs" id="gjs3"> <div class="gjs" id="gjs3">
<h1>Hello World Component!</h1> <h1>Hello World Component!</h1>
</div> </div>
@ -13,8 +15,11 @@ module.exports = {
mounted() { mounted() {
const utils = require('./demos/utils.js'); const utils = require('./demos/utils.js');
const editor3 = grapesjs.init(utils.gjsConfigPanels); const editor3 = grapesjs.init(utils.gjsConfigPanels);
editor3.Panels.addPanel(Object.assign({}, utils.customPanel, { editor3.Panels.addPanel(Object.assign({}, utils.panelTop, {
el: '#basic-panel3' el: '#panel__top3'
}));
editor3.Panels.addPanel(Object.assign({}, utils.panelBasicActions, {
el: '#panel__basic-actions3'
})); }));
window.editor3 = editor3; window.editor3 = editor3;
} }
@ -22,10 +27,15 @@ module.exports = {
</script> </script>
<style> <style>
.basic-panel { .panel__top {
padding: 0;
width: 100%; width: 100%;
display: flex; display: flex;
position: initial;
justify-content: center; justify-content: center;
justify-content: space-between;
}
.panel__basic-actions {
position: initial; position: initial;
} }
.content pre { .content pre {

28
docs/.vuepress/components/DemoLayers.vue

@ -1,6 +1,8 @@
<template> <template>
<div> <div>
<div class="basic-panel" id="basic-panel4"></div> <div class="panel__top" id="panel__top4">
<div class="panel__basic-actions" id="panel__basic-actions4"></div>
</div>
<div class="editor-row"> <div class="editor-row">
<div class="editor-canvas"> <div class="editor-canvas">
@ -8,7 +10,7 @@
<h1>Hello World Component!</h1> <h1>Hello World Component!</h1>
</div> </div>
</div> </div>
<div class="editor-sidebar" id="editor-sidebar"> <div class="panel__right" id="panel__right4">
<div id="layers-container"></div> <div id="layers-container"></div>
</div> </div>
</div> </div>
@ -22,26 +24,16 @@ module.exports = {
mounted() { mounted() {
const utils = require('./demos/utils.js'); const utils = require('./demos/utils.js');
const editor4 = grapesjs.init(utils.gjsConfigLayers); const editor4 = grapesjs.init(utils.gjsConfigLayers);
editor4.Panels.addPanel(Object.assign({}, utils.customPanel, { editor4.Panels.addPanel(Object.assign({}, utils.panelTop, {
el: '#basic-panel4' el: '#panel__top4'
}));
editor4.Panels.addPanel(Object.assign({}, utils.panelBasicActions, {
el: '#panel__basic-actions4'
})); }));
window.editor4 = editor4; window.editor4 = editor4;
} }
} }
</script> </script>
<style> <style src="./demos/DemoLayers.css">
.editor-row {
display: flex;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
}
.editor-canvas {
flex-grow: 1;
}
.editor-sidebar {
flex-basis: 230px;
position: relative;
}
</style> </style>

17
docs/.vuepress/components/demos/DemoLayers.css

@ -0,0 +1,17 @@
.editor-row {
display: flex;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
height: 300px;
}
.editor-canvas {
flex-grow: 1;
}
.panel__right {
flex-basis: 230px;
position: relative;
overflow-y: auto;
}

11
docs/.vuepress/components/demos/utils.js

@ -29,8 +29,9 @@ var blockManager = {
] ]
}; };
var customPanel = { var panelTop = { id: 'panel-top' };
id: 'custom-panel', var panelBasicActions = {
id: 'panel-basic',
buttons: [ buttons: [
{ {
id: 'visibility', id: 'visibility',
@ -61,9 +62,8 @@ var customPanel = {
} }
], ],
}; };
var panelSidebar = { var panelSidebar = {
el: '#editor-sidebar', el: '#panel__right4',
id: 'layers', id: 'layers',
// Make the panel resizable // Make the panel resizable
resizable: { resizable: {
@ -116,5 +116,6 @@ module.exports = {
gjsConfigBlocks, gjsConfigBlocks,
gjsConfigPanels, gjsConfigPanels,
gjsConfigLayers, gjsConfigLayers,
customPanel, panelTop,
panelBasicActions,
}; };

63
docs/getting-started.md

@ -35,7 +35,7 @@ With just the canvas you're already able to move, copy and delete components fro
## Add Blocks ## Add Blocks
The block in GrapesJS is just a reusable piece of HTML that you can drop in the canvas. A block can be an image, a button, or an entire section with videos, forms and iframes. Let's start from creating another container and append inside it few basic blocks which we can later use to build more complex structures. The block in GrapesJS is just a reusable piece of HTML that you can drop in the canvas. A block can be an image, a button, or an entire section with videos, forms and iframes. Let's start from creating another container and append inside it few basic blocks which we can later use to build more complex structures.
```html ```html{4}
<div id="gjs"> <div id="gjs">
... ...
</div> </div>
@ -144,18 +144,38 @@ myComponent.components('<div>New content</div>');
## Panels & Buttons ## Panels & Buttons
Now that we have a canvas and custom blocks let's see how to create a new custom panel with some buttons inside (using [Panels API](api/panels.html)) which trigger commands (the core one or custom). Now that we have a canvas and custom blocks let's see how to create a new custom panel with some buttons inside (using [Panels API](api/panels.html)) which trigger commands (the core one or custom).
```html ```html{1,2,3}
<div id="basic-panel"></div> <div class="panel__top">
<div class="panel__basic-actions"></div>
</div>
<div id="gjs"> <div id="gjs">
... ...
</div> </div>
<div id="blocks"></div> <div id="blocks"></div>
``` ```
```css
.panel__top {
padding: 0;
width: 100%;
display: flex;
position: initial;
justify-content: center;
justify-content: space-between;
}
.panel__basic-actions {
position: initial;
}
```
```js ```js
editor.Panels.addPanel({ editor.Panels.addPanel({
id: 'custom-panel', id: 'panel-top',
el: '#basic-panel', el: '.panel__top',
});
editor.Panels.addPanel({
id: 'basic-actions',
el: '.panel__basic-actions',
buttons: [ buttons: [
{ {
id: 'visibility', id: 'visibility',
@ -206,46 +226,33 @@ editor.on('abort:export-template', () => console.log('Command aborted'));
## Layers ## Layers
Another utility tool you might find useful when working with web elements is a layer manger. It's just a tree overview of the structure nodes and enables you to manage it easier. To enable it you just have to specify where you want to render it Another utility tool you might find useful when working with web elements is a layer manger. It's just a tree overview of the structure nodes and enables you to manage it easier. To enable it you just have to specify where you want to render it
```html ```html{4,5,6,7,8,9,10,11}
<div id="basic-panel"></div> <div class="panel__top">
<div class="panel__basic-actions"></div>
</div>
<div class="editor-row"> <div class="editor-row">
<div class="editor-canvas"> <div class="editor-canvas">
<div id="gjs">...</div> <div id="gjs">...</div>
</div> </div>
<div class="editor-sidebar"> <div class="panel__right">
<div id="layers-container"></div> <div class="layers-container"></div>
</div> </div>
</div> </div>
<div id="blocks"></div> <div id="blocks"></div>
``` ```
<<< @/docs/.vuepress/components/demos/DemoLayers.css
```css
.editor-row {
display: flex;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
}
.editor-canvas {
flex-grow: 1;
}
.editor-sidebar {
flex-basis: 230px;
position: relative;
}
```
```js ```js
const editor = grapesjs.init({ const editor = grapesjs.init({
// ... // ...
layerManager: { layerManager: {
appendTo: '#layers-container' appendTo: '.layers-container'
}, },
// We define a default panel as a sidebar to contain layers // We define a default panel as a sidebar to contain layers
panels: { panels: {
defaults: [{ defaults: [{
id: 'layers', id: 'layers',
el: '.editor-sidebar', el: '.panel__right',
// Make the panel resizable // Make the panel resizable
resizable: { resizable: {
maxDim: 350, maxDim: 350,
@ -268,7 +275,7 @@ const editor = grapesjs.init({
## Style Manager ## Style Manager
An important step in any web project is the style definition and with the built-in style manager module you're able to do it easily and quickly. An important step in any web project is the style definition and with the built-in style manager module you're able to do it easily and quickly.
The style manager is composed by style properties and grouped by sectors, so let's see how to define a basic set of them. The style manager is composed by style properties and are grouped by sectors, let's see how to define a basic set of them.
-- show how to render SM and show style for width, height, padding, Typography, shadows -- show how to render SM and show style for width, height, padding, Typography, shadows

Loading…
Cancel
Save