Skip to content

Commit

Permalink
fix: fixed color selector
Browse files Browse the repository at this point in the history
  • Loading branch information
SaraBianchi committed Aug 9, 2023
1 parent 978ff21 commit 974bf5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Block/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const Sidebar = ({ data, block, onChangeBlock }) => {
title={intl.formatMessage(messages.color)}
value={data.color || CC_PALETTE[0].name}
onChange={(id, value) => {
console.log('color', value);
onChangeBlock(block, {
...data,
[id]: value,
Expand Down
8 changes: 7 additions & 1 deletion src/Block/View.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { CC_PALETTE } from 'volto-comuni-chiamo/Block/colors';

const View = ({ data, properties, id, path }) => {
useEffect(() => {
const ccWidgetReportingConf = {
targetId: 'comunichiamo',
apiKey: data.keyWidget,
ui: {
primaryColor: data.colorWidget ?? data.color,
primaryColor: data.colorWidget ?? checkColor(data.color),
},
};
if (window && !window.hasOwnProperty('ccWidgetReportingConf')) {
Expand All @@ -25,6 +26,11 @@ const View = ({ data, properties, id, path }) => {
// };
}, [data]);

const checkColor = (color) => {
const colorSelect = CC_PALETTE.filter((el) => el.name === color);
return colorSelect[0].code;
};

return (
<>
<div className="block comuni-chiamo">
Expand Down

0 comments on commit 974bf5b

Please sign in to comment.