From 4bfd6b409ad444355247b2df8bd64e96dc42106a Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 27 Aug 2022 19:27:23 +0200 Subject: [PATCH] Update component --- README.md | 3 +- src/index.ts | 89 ++++++++++++++-------------------------------------- 2 files changed, 26 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index bdaedbc..51d8ac6 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,12 @@ Simple countdown component for GrapesJS Editor ## Summary -* Plugin name: `gjs-component-countdown` +* Plugin name: `grapesjs-component-countdown` * Components: `countdown` * Blocks: `countdown` +* Switched the plugin name from `gjs-component-countdown` to `grapesjs-component-countdown` * Added `id` * Removed `blocks` and `labelCountdownCategory` options in favor of `block`. * Removed `defaultStyle` options in favor of `style`. diff --git a/src/index.ts b/src/index.ts index 7ebf424..2b5f85c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -182,6 +182,7 @@ const plugin: grapesjs.Plugin = (editor, opts = {}) => { model: { defaults: { startfrom: options.startTime, + classes: [pfx], endText: options.endText, droppable: false, script: coundownScript, @@ -217,74 +218,32 @@ const plugin: grapesjs.Plugin = (editor, opts = {}) => { `, + styles: ` + .${pfx} { + text-align: center; + } + + .${pfx}-block { + display: inline-block; + margin: 0 10px; + padding: 10px; + } + + .${pfx}-digit { + font-size: 5rem; + } + + .${pfx}-endtext { + font-size: 5rem; + } + + .${pfx}-cont { + display: inline-block; + } + `, }, }, - view: { - init() { - // this.listenTo(this.model, 'change:startfrom change:endText', this.updateScript); - const comps = this.model.get('components'); - - // // Add a basic countdown template if it's not yet initialized - // if (comps && !comps?.length) { - // comps.reset(); - // comps.add(` - // - //
- //
- //
${c.labelDays}
- //
- //
- //
- //
${c.labelHours}
- //
- //
- //
- //
${c.labelMinutes}
- //
- //
- //
- //
${c.labelSeconds}
- //
- //
- // - // `); - // } - - } - }, }); - - /** -const pfx = c.countdownClsPfx; -`` - */ - - // Add components - // loadComponents(editor, options); }; export default plugin; \ No newline at end of file