From 026c81ff9e1a682f22da007924e461ca2e5ae3c4 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Mon, 19 Sep 2022 17:53:43 +0300 Subject: [PATCH] [SSE mobile] Fix Bug 59094 --- .../lib/component/ThemeColorPalette.jsx | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/apps/common/mobile/lib/component/ThemeColorPalette.jsx b/apps/common/mobile/lib/component/ThemeColorPalette.jsx index 3c53ff558..814c0e899 100644 --- a/apps/common/mobile/lib/component/ThemeColorPalette.jsx +++ b/apps/common/mobile/lib/component/ThemeColorPalette.jsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'; const ThemeColors = ({ themeColors, onColorClick, curColor, isTypeColors, isTypeCustomColors }) => { return (
- {themeColors.map((row, rowIndex) => { + {themeColors?.length && themeColors.map((row, rowIndex) => { return(
{row.map((effect, index) => { @@ -27,7 +27,7 @@ const ThemeColors = ({ themeColors, onColorClick, curColor, isTypeColors, isType const StandartColors = ({ options, standartColors, onColorClick, curColor }) => { return (
- {standartColors.map((color, index) => { + {standartColors?.length && standartColors.map((color, index) => { return( index === 0 && options.transparent ? const CustomColors = ({ options, customColors, isTypeColors, onColorClick, curColor }) => { const colors = customColors.length > 0 ? customColors : []; const emptyItems = []; + if (colors.length < options.customcolors) { for (let i = colors.length; i < options.customcolors; i++) { emptyItems.push( - {colors && colors.length > 0 && colors.map((color, index) => { + {colors?.length && colors.map((color, index) => { return( { const themeColors = []; const effectColors = Common.Utils.ThemeColor.getEffectColors(); let row = -1; - effectColors.forEach((effect, index) => { - if (0 == index % options.themecolors) { - themeColors.push([]); - row++; - } - themeColors[row].push(effect); - }); + + if(effectColors?.length) { + effectColors.forEach((effect, index) => { + if (0 == index % options.themecolors) { + themeColors.push([]); + row++; + } + themeColors[row].push(effect); + }); + } + const standartColors = Common.Utils.ThemeColor.getStandartColors(); - let isTypeColors = standartColors.some( value => value === curColor ); + let isTypeColors = standartColors?.length && standartColors.some( value => value === curColor ); // custom color let customColors = props.customColors; + if (customColors.length < 1) { customColors = localStorage.getItem('mobile-custom-colors'); customColors = customColors ? customColors.toLowerCase().split(',') : []; @@ -142,14 +148,18 @@ const CustomColorPicker = props => { }; let currentColor = props.currentColor; + if (props.autoColor) { currentColor = rgb2hex(props.autoColor); } + if (currentColor === 'transparent' || !currentColor) { currentColor = 'ffffff'; } + const countDynamicColors = props.countdynamiccolors || 10; const [stateColor, setColor] = useState(`#${currentColor}`); + useEffect(() => { if (document.getElementsByClassName('color-picker-wheel').length < 1) { const colorPicker = f7.colorPicker.create({ @@ -165,6 +175,7 @@ const CustomColorPicker = props => { }); } }); + const addNewColor = (color) => { let colors = localStorage.getItem('mobile-custom-colors'); colors = colors ? colors.split(',') : []; @@ -173,7 +184,8 @@ const CustomColorPicker = props => { localStorage.setItem('mobile-custom-colors', colors.join().toLowerCase()); props.onAddNewColor && props.onAddNewColor(colors, newColor); }; - return( + + return (