From aa280920905d3d3c40c35bc3757a005be8872107 Mon Sep 17 00:00:00 2001 From: zombieFox Date: Sat, 21 Aug 2021 09:19:10 +0100 Subject: [PATCH] clear bookmark rainbow --- src/component/bookmarkForm/index.js | 4 +- .../menuContent/themeSetting/index.js | 49 +++++++++++++------ src/component/theme/index.js | 16 ++++++ 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/component/bookmarkForm/index.js b/src/component/bookmarkForm/index.js index 6ec3b37d..0a66b2c9 100644 --- a/src/component/bookmarkForm/index.js +++ b/src/component/bookmarkForm/index.js @@ -386,7 +386,7 @@ export const BookmarkForm = function({ id: 'accent', labelText: 'Accent', srOnly: true, - defaultValue: JSON.parse(JSON.stringify(bookmarkDefault.accent.rgb)), + defaultValue: bookmarkDefault.accent.rgb, minMaxObject: bookmarkMinMax, action: () => { this.preview.update.style(bookmarkData); @@ -414,7 +414,7 @@ export const BookmarkForm = function({ id: 'color', labelText: 'Colour', srOnly: true, - defaultValue: JSON.parse(JSON.stringify(bookmarkDefault.color.rgb)), + defaultValue: bookmarkDefault.color.rgb, minMaxObject: bookmarkMinMax, action: () => { this.preview.update.style(bookmarkData); diff --git a/src/component/menuContent/themeSetting/index.js b/src/component/menuContent/themeSetting/index.js index 8464b705..fc45c880 100644 --- a/src/component/menuContent/themeSetting/index.js +++ b/src/component/menuContent/themeSetting/index.js @@ -1940,18 +1940,27 @@ themeSetting.bookmark = (parent) => { text: ['Bookmark border can also be changed when editing individual Bookmarks.', 'The colour of the Border is defined by the Accent which can also be changed when editing individual Bookmarks.'] }); - themeSetting.control.bookmark.item.rainbow = new Button({ - text: 'Apply unique accent to each', - style: ['line'], - func: () => { - theme.accent.rainbow.render(); - data.save(); - } - }); - - themeSetting.control.bookmark.item.rainbowHelper = new Control_helperText({ - text: ['Bookmark custom Accent can also be changed when editing individual Bookmarks.'] - }); + themeSetting.control.bookmark.item.rainbow = { + add: new Button({ + text: 'Add unique accent to each', + style: ['line'], + func: () => { + theme.accent.rainbow.render(); + data.save(); + } + }), + remove: new Button({ + text: 'Remove all unique accent', + style: ['line'], + func: () => { + theme.accent.rainbow.clear(); + data.save(); + } + }), + helper: new Control_helperText({ + text: ['Bookmark custom Accent can also be changed when editing individual Bookmarks.'] + }) + }; parent.appendChild( node('div', [ @@ -1969,8 +1978,20 @@ themeSetting.bookmark = (parent) => { themeSetting.control.bookmark.item.border.wrap(), themeSetting.control.bookmark.item.borderHelper.wrap(), node('hr'), - themeSetting.control.bookmark.item.rainbow.wrap(), - themeSetting.control.bookmark.item.rainbowHelper.wrap() + form.wrap({ + children: [ + form.inline({ + gap: 'small', + wrap: true, + equalGap: true, + children: [ + themeSetting.control.bookmark.item.rainbow.add.wrap(), + themeSetting.control.bookmark.item.rainbow.remove.wrap(), + ] + }) + ] + }), + themeSetting.control.bookmark.item.rainbow.helper.wrap() ]) ); diff --git a/src/component/theme/index.js b/src/component/theme/index.js index 96c59c3b..9b6c436d 100644 --- a/src/component/theme/index.js +++ b/src/component/theme/index.js @@ -3,6 +3,7 @@ import { data } from '../data'; import { appName } from '../appName'; import { toolbar } from '../toolbar'; import { bookmark } from '../bookmark'; +import { bookmarkDefault } from '../bookmarkDefault'; import { groupAndBookmark } from '../groupAndBookmark'; import { themeSetting } from '../menuContent/themeSetting'; @@ -201,6 +202,21 @@ theme.accent.rainbow = { groupAndBookmark.render(); + }, + clear: () => { + + bookmark.all.forEach((item, i) => { + + item.items.forEach((item, i) => { + + item.accent = JSON.parse(JSON.stringify(bookmarkDefault.accent)); + + }); + + }); + + groupAndBookmark.render(); + } };