Skip to content

Commit

Permalink
Merge pull request #13 from artf/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
artf authored Aug 29, 2022
2 parents 1b6cde4 + 36bc20b commit 0bda33b
Show file tree
Hide file tree
Showing 13 changed files with 4,203 additions and 5,377 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
private/
node_modules/
dist/
.eslintrc
*.log
_index.html
70 changes: 49 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,89 @@ Simple countdown component for GrapesJS Editor

## Summary

* Plugin name: `gjs-component-countdown`
* Plugin name: `grapesjs-component-countdown`
* Components: `countdown`
* Blocks: `countdown`





## Options

* `blocks` Which blocks to add, default: `['countdown']` (all)
* `defaultStyle` Add default style to blocks, default: true
* `startTime` Default start time, eg. '2018-01-25 00:00', default: ''
* `endText` Text to show when the countdown is ended, default: 'EXPIRED'
* `dateInputType` Date input type, eg, 'date', 'datetime-local', default: 'date'
* `countdownClsPfx` Countdown class prefix, default: 'countdown'
* `labelCountdown` Countdown label, default 'Countdown'
* `labelCountdownCategory` Countdown category label, default 'Extra'
* `labelDays` Days label text used in component, default 'days'
* `labelHours` Hours label text used in component, default 'hours'
* `labelMinutes` Minutes label text used in component, default 'minutes'
* `labelSeconds` Seconds label text used in component, default 'seconds'
| Option | Description | Default |
|-|-|-
| `id` | The ID used to create the block and component. | `countdown` |
| `label` | The label used for the block and the component. | `Countdown` |
| `block` | Object to extend the default block, eg. `{ label: 'Countdown', category: 'Extra', ... }`. Pass a falsy value to avoid adding the block. | `{}` |
| `props` | Object to extend the default component properties., eg. `{ name: 'Countdown', droppable: false, ... }`. | `{}` |
| `style` | Custom CSS styles for the component. This will replace the default one. | `''` |
| `styleAdditional` | Additional CSS styles for the component. These will be appended to the default one. | `''` |
| `startTime` | Default start time, eg. `2030-01-25 00:00`. | `''` |
| `endText` | Text to show when the countdown is ended. | `'EXPIRED'` |
| `dateInputType` | Date input type, eg. `date`, `datetime-local` | `'date'` |
| `labelDays` | Days label text used in component. | `'days'` |
| `labelHours` | Hours label text used in component. | `'hours'` |
| `labelMinutes` | Minutes label text used in component. | `'minutes'` |
| `labelSeconds` | Seconds label text used in component. | `'seconds'` |
| `classPrefix` | Countdown component class prefix. | `'countdown'` |





## Download

* `npm i grapesjs-component-countdown` or `yarn add grapesjs-component-countdown`
* CDN
* `https://unpkg.com/grapesjs-component-countdown`
* NPM
* `npm i grapesjs-component-countdown`
* GIT
* `git clone https://github.com/artf/grapesjs-component-countdown.git`






## Usage

Directly in the browser
```html
<link href="path/to/grapes.min.css" rel="stylesheet"/>
<script src="path/to/grapes.min.js"></script>
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="path/to/grapesjs-component-countdown.min.js"></script>

<div id="gjs"></div>

<script type="text/javascript">
var editor = grapesjs.init({
container : '#gjs',
plugins: ['gjs-component-countdown'],
// ...
plugins: ['grapesjs-component-countdown'],
pluginsOpts: {
'gjs-component-countdown': {/* ...options */}
'grapesjs-component-countdown': { /* options */ }
}
});
</script>
```

Modern javascript
```js
import grapesjs from 'grapesjs';
import pluginCountdown from 'grapesjs-component-countdown';

const editor = grapesjs.init({
container : '#gjs',
// ...
plugins: [pluginCountdown],
pluginsOpts: {
[pluginCountdown]: { /* options */ }
}
// or
plugins: [
editor => pluginCountdown(editor, { /* options */ }),
],
});
```




Expand Down
2 changes: 0 additions & 2 deletions dist/grapesjs-component-countdown.min.js

This file was deleted.

24 changes: 12 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>GrapesJS Countdown Plugin</title>
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="dist/grapesjs-component-countdown.min.js"></script>
<style>
body, html {
height: 100%;
Expand All @@ -16,17 +15,18 @@
<body>
<div id="gjs" style="height:0px; overflow:hidden"></div>
<script type="text/javascript">
var editor = grapesjs.init({
height: '100%',
noticeOnUnload: 0,
storageManager:{autoload: 0},
container : '#gjs',
fromElement: true,

plugins: ['gjs-component-countdown'],
pluginsOpts: {
'gjs-component-countdown': {}
}
setTimeout(() => {
window.editor = grapesjs.init({
height: '100%',
noticeOnUnload: false,
storageManager: false,
container : '#gjs',
fromElement: true,
plugins: ['grapesjs-component-countdown'],
pluginsOpts: {
'grapesjs-component-countdown': {}
}
});
});
</script>
</body>
Expand Down
Loading

0 comments on commit 0bda33b

Please sign in to comment.