Skip to content

Commit

Permalink
fix: minor color stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachakra16 committed Mar 28, 2023
1 parent a2199fd commit 783def8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 17 deletions.
24 changes: 24 additions & 0 deletions app/modules/Collection/Context/LocalCollectionContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type LocalCollectionContextType = {
};
currentPage: string;
setCurrentPage: React.Dispatch<React.SetStateAction<string>>;
colorMapping: {
[key: string]: string;
};
};

export const LocalCollectionContext = createContext<LocalCollectionContextType>(
Expand Down Expand Up @@ -92,6 +95,9 @@ export function useProviderLocalCollection() {
[key: string]: string;
}
);
const [colorMapping, setColorMapping] = useState(
{} as { [key: string]: string }
);

const [currentPage, setCurrentPage] = useState("start");

Expand Down Expand Up @@ -146,6 +152,23 @@ export function useProviderLocalCollection() {
});
setFieldNeedsAttention(fieldsThatNeedAttention);
setReasonFieldNeedsAttention(reasonFieldNeedsAttention);

let colorMapping = {};
Object.entries(localCollection.properties || {}).forEach(([key, value]) => {
if (["singleSelect", "multiSelect"].includes(value.type)) {
if (value.options && value.options.length > 0) {
const colorMap = value.options.reduce((acc, option) => {
if (option.color) acc[option.value] = option.color;
return acc;
}, {} as { [key: string]: string });
colorMapping = {
...colorMapping,
...(colorMap || {}),
};
}
}
});
setColorMapping(colorMapping);
}, [localCollection.properties]);

useEffect(() => {
Expand Down Expand Up @@ -249,6 +272,7 @@ export function useProviderLocalCollection() {
getIfFieldNeedsAttention,
currentPage,
setCurrentPage,
colorMapping,
};
}

Expand Down
7 changes: 0 additions & 7 deletions app/modules/CollectionProject/CardDrawer/CardOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ export default function CardOptions({
}}
onClick={() => {
setIsOpen(false);

if (!circle?.snapshot?.id) {
toast.error(
"Please integrate your Snapshot in the Governance Center first"
);
return;
}
setDiscordThreadModal(true);
}}
>
Expand Down
1 change: 1 addition & 0 deletions app/modules/CollectionProject/CardDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default function CardDrawer({ handleClose, defaultValue }: Props) {
res = await updateCollectionDataGuarded(collection.id, slug, update);
if (!res) {
updateCollection(tempColl);
return;
}
if (res.id) {
updateCollection(res);
Expand Down
22 changes: 17 additions & 5 deletions app/modules/CollectionProject/KanbanView/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export default function Column({
setDefaultValue,
cardIds,
}: Props) {
const { localCollection: collection, updateCollection } =
useLocalCollection();
const {
localCollection: collection,
updateCollection,
colorMapping,
} = useLocalCollection();
const { getMemberDetails } = useModalOptions();

const [columnName, setColumnName] = useState(column.label);
Expand Down Expand Up @@ -158,8 +161,17 @@ export default function Column({
if (property.type === "singleSelect") {
return (
<Box key={propertyId}>
{/* <Text weight="semiBold">{property.name}</Text> */}
<Text variant="label">{value.label}</Text>
<Stack direction="horizontal" wrap space="1">
{" "}
<CustomTag
key={propertyId}
mode={mode}
borderCol={colorMapping[value.value]}
>
{/* <Text weight="semiBold">{property.name}</Text> */}
<Text variant="label">{value.label}</Text>
</CustomTag>
</Stack>
</Box>
);
}
Expand All @@ -172,7 +184,7 @@ export default function Column({
<CustomTag
key={value.value}
mode={mode}
borderCol={value.color}
borderCol={colorMapping[value.value]}
>
<Text>{value.label}</Text>
</CustomTag>
Expand Down
22 changes: 17 additions & 5 deletions app/modules/CollectionProject/ListView/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export default function Column({
setDefaultValue,
cardIds,
}: Props) {
const { localCollection: collection, updateCollection } =
useLocalCollection();
const {
localCollection: collection,
updateCollection,
colorMapping,
} = useLocalCollection();
const { getMemberDetails } = useModalOptions();
const [columnName, setColumnName] = useState(column.label);
const { mode } = useTheme();
Expand Down Expand Up @@ -155,8 +158,17 @@ export default function Column({
if (property.type === "singleSelect") {
return (
<Box key={propertyId}>
{/* <Text weight="semiBold">{property.name}</Text> */}
<Text variant="label">{value.label}</Text>
<Stack direction="horizontal" wrap space="1">
{" "}
<CustomTag
key={propertyId}
mode={mode}
borderCol={colorMapping[value.value]}
>
{/* <Text weight="semiBold">{property.name}</Text> */}
<Text variant="label">{value.label}</Text>
</CustomTag>
</Stack>
</Box>
);
}
Expand All @@ -169,7 +181,7 @@ export default function Column({
<CustomTag
key={value.value}
mode={mode}
borderCol={value.color}
borderCol={colorMapping[value.value]}
>
<Text> {value.label}</Text>
</CustomTag>
Expand Down

0 comments on commit 783def8

Please sign in to comment.