Skip to content

Commit

Permalink
[WEB-1424] chore: page and view logo implementation, and emoji/icon p…
Browse files Browse the repository at this point in the history
…icker improvement (#4583)

* chore: added logo_props

* chore: logo props in cycles, views and modules

* chore: emoji icon picker types updated

* chore: info icon added to plane ui package

* chore: icon color adjust helper function added

* style: icon picker ui improvement and default color options updated

* chore: update page logo action added in store

* chore: emoji code to unicode helper function added

* chore: common logo renderer component added

* chore: app header project logo updated

* chore: project logo updated across platform

* chore: page logo picker added

* chore: control link component improvement

* chore: list item improvement

* chore: emoji picker component updated

* chore: space app and package logo prop type updated

* chore: migration

* chore: logo added to project view

* chore: page logo picker added in create modal and breadcrumbs

* chore: view logo picker added in create modal and updated breadcrumbs

* fix: build error

* chore: AIO docker images for preview deployments (#4605)

* fix: adding single docker base file

* action added

* fix action

* dockerfile.base modified

* action fix

* dockerfile

* fix: base aio dockerfile

* fix: dockerfile.base

* fix: dockerfile base

* fix: modified folder structure

* fix: action

* fix: dockerfile

* fix: dockerfile.base

* fix: supervisor file name changed

* fix: base dockerfile updated

* fix dockerfile base

* fix: base dockerfile

* fix: docker files

* fix: base dockerfile

* update base image

* modified docker aio base

* aio base modified to debian-12-slim

* fixes

* finalize the dockerfiles with volume exposure

* modified the aio build and dockerfile

* fix: codacy suggestions implemented

* fix: codacy fix

* update aio build action

---------

Co-authored-by: sriram veeraghanta <[email protected]>

* fix: merge conflict

* chore: lucide react added to planu ui package

* chore: new emoji picker component added with lucid icon and code refactor

* chore: logo component updated

* chore: emoji picker updated for pages and views

---------

Co-authored-by: NarayanBavisetti <[email protected]>
Co-authored-by: Manish Gupta <[email protected]>
Co-authored-by: sriram veeraghanta <[email protected]>
  • Loading branch information
4 people committed May 31, 2024
1 parent ddf1cf8 commit 5381868
Show file tree
Hide file tree
Showing 64 changed files with 1,411 additions and 301 deletions.
1 change: 1 addition & 0 deletions apiserver/plane/app/serializers/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Meta:
"external_source",
"external_id",
"progress_snapshot",
"logo_props",
# meta fields
"is_favorite",
"total_issues",
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/app/serializers/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class Meta:
"sort_order",
"external_source",
"external_id",
"logo_props",
# computed fields
"is_favorite",
"total_issues",
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/app/serializers/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Meta:
"created_by",
"updated_by",
"view_props",
"logo_props",
]
read_only_fields = [
"workspace",
Expand Down
5 changes: 5 additions & 0 deletions apiserver/plane/app/views/cycle/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def list(self, request, slug, project_id):
"external_source",
"external_id",
"progress_snapshot",
"logo_props",
# meta fields
"is_favorite",
"total_issues",
Expand Down Expand Up @@ -356,6 +357,7 @@ def list(self, request, slug, project_id):
"external_source",
"external_id",
"progress_snapshot",
"logo_props",
# meta fields
"is_favorite",
"total_issues",
Expand Down Expand Up @@ -403,6 +405,7 @@ def create(self, request, slug, project_id):
"external_source",
"external_id",
"progress_snapshot",
"logo_props",
# meta fields
"is_favorite",
"cancelled_issues",
Expand Down Expand Up @@ -496,6 +499,7 @@ def partial_update(self, request, slug, project_id, pk):
"external_source",
"external_id",
"progress_snapshot",
"logo_props",
# meta fields
"is_favorite",
"total_issues",
Expand Down Expand Up @@ -556,6 +560,7 @@ def retrieve(self, request, slug, project_id, pk):
"external_id",
"progress_snapshot",
"sub_issues",
"logo_props",
# meta fields
"is_favorite",
"total_issues",
Expand Down
3 changes: 3 additions & 0 deletions apiserver/plane/app/views/module/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def create(self, request, slug, project_id):
"sort_order",
"external_source",
"external_id",
"logo_props",
# computed fields
"is_favorite",
"cancelled_issues",
Expand Down Expand Up @@ -281,6 +282,7 @@ def list(self, request, slug, project_id):
"sort_order",
"external_source",
"external_id",
"logo_props",
# computed fields
"total_issues",
"is_favorite",
Expand Down Expand Up @@ -465,6 +467,7 @@ def partial_update(self, request, slug, project_id, pk):
"sort_order",
"external_source",
"external_id",
"logo_props",
# computed fields
"is_favorite",
"cancelled_issues",
Expand Down
12 changes: 12 additions & 0 deletions packages/types/src/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@ export type TPaginationInfo = {
per_page?: number;
total_results: number;
};

export type TLogoProps = {
in_use: "emoji" | "icon";
emoji?: {
value?: string;
url?: string;
};
icon?: {
name?: string;
color?: string;
};
};
2 changes: 2 additions & 0 deletions packages/types/src/pages.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TLogoProps } from "./common";
import { EPageAccess } from "./enums";

export type TPage = {
Expand All @@ -17,6 +18,7 @@ export type TPage = {
updated_at: Date | undefined;
updated_by: string | undefined;
workspace: string | undefined;
logo_props: TLogoProps | undefined;
};

// page filters
Expand Down
15 changes: 2 additions & 13 deletions packages/types/src/project/projects.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,10 @@ import type {
IUserMemberLite,
IWorkspace,
IWorkspaceLite,
TLogoProps,
TStateGroups,
} from "..";

export type TProjectLogoProps = {
in_use: "emoji" | "icon";
emoji?: {
value?: string;
url?: string;
};
icon?: {
name?: string;
color?: string;
};
};

export interface IProject {
archive_in: number;
archived_at: string | null;
Expand All @@ -46,7 +35,7 @@ export interface IProject {
is_deployed: boolean;
is_favorite: boolean;
is_member: boolean;
logo_props: TProjectLogoProps;
logo_props: TLogoProps;
member_role: EUserProjectRoles | null;
members: IProjectMemberLite[];
name: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/views.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TLogoProps } from "./common";
import {
IIssueDisplayFilterOptions,
IIssueDisplayProperties,
Expand All @@ -21,4 +22,5 @@ export interface IProjectView {
query_data: IIssueFilterOptions;
project: string;
workspace: string;
logo_props: TLogoProps | undefined;
}
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@popperjs/core": "^2.11.8",
"clsx": "^2.0.0",
"emoji-picker-react": "^4.5.16",
"lucide-react": "^0.379.0",
"react-color": "^2.19.3",
"react-dom": "^18.2.0",
"react-popper": "^2.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/control-link/control-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";

export type TControlLink = React.AnchorHTMLAttributes<HTMLAnchorElement> & {
href: string;
onClick: () => void;
onClick: (event: React.MouseEvent<HTMLAnchorElement>) => void;
children: React.ReactNode;
target?: string;
disabled?: boolean;
Expand All @@ -17,7 +17,7 @@ export const ControlLink = React.forwardRef<HTMLAnchorElement, TControlLink>((pr
const clickCondition = (event.metaKey || event.ctrlKey) && event.button === LEFT_CLICK_EVENT_CODE;
if (!clickCondition) {
event.preventDefault();
onClick();
onClick(event);
}
};

Expand Down
100 changes: 100 additions & 0 deletions packages/ui/src/emoji/emoji-icon-helper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { Placement } from "@popperjs/core";
import { EmojiClickData, Theme } from "emoji-picker-react";

export enum EmojiIconPickerTypes {
EMOJI = "emoji",
ICON = "icon",
}

export const TABS_LIST = [
{
key: EmojiIconPickerTypes.EMOJI,
title: "Emojis",
},
{
key: EmojiIconPickerTypes.ICON,
title: "Icons",
},
];

export type TChangeHandlerProps =
| {
type: EmojiIconPickerTypes.EMOJI;
value: EmojiClickData;
}
| {
type: EmojiIconPickerTypes.ICON;
value: {
name: string;
color: string;
};
};

export type TCustomEmojiPicker = {
isOpen: boolean;
handleToggle: (value: boolean) => void;
buttonClassName?: string;
className?: string;
closeOnSelect?: boolean;
defaultIconColor?: string;
defaultOpen?: EmojiIconPickerTypes;
disabled?: boolean;
dropdownClassName?: string;
label: React.ReactNode;
onChange: (value: TChangeHandlerProps) => void;
placement?: Placement;
searchPlaceholder?: string;
theme?: Theme;
iconType?: "material" | "lucide";
};

export const DEFAULT_COLORS = ["#95999f", "#6d7b8a", "#5e6ad2", "#02b5ed", "#02b55c", "#f2be02", "#e57a00", "#f38e82"];

export type TIconsListProps = {
defaultColor: string;
onChange: (val: { name: string; color: string }) => void;
};

/**
* Adjusts the given hex color to ensure it has enough contrast.
* @param {string} hex - The hex color code input by the user.
* @returns {string} - The adjusted hex color code.
*/
export const adjustColorForContrast = (hex: string): string => {
// Ensure hex color is valid
if (!/^#([0-9A-F]{3}){1,2}$/i.test(hex)) {
throw new Error("Invalid hex color code");
}

// Convert hex to RGB
let r = 0,
g = 0,
b = 0;
if (hex.length === 4) {
r = parseInt(hex[1] + hex[1], 16);
g = parseInt(hex[2] + hex[2], 16);
b = parseInt(hex[3] + hex[3], 16);
} else if (hex.length === 7) {
r = parseInt(hex[1] + hex[2], 16);
g = parseInt(hex[3] + hex[4], 16);
b = parseInt(hex[5] + hex[6], 16);
}

// Calculate luminance
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;

// If the color is too light, darken it
if (luminance > 0.5) {
r = Math.max(0, r - 50);
g = Math.max(0, g - 50);
b = Math.max(0, b - 50);
}

// Convert RGB back to hex
const toHex = (value: number): string => {
const hex = value.toString(16);
return hex.length === 1 ? "0" + hex : hex;
};

return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
};
Loading

0 comments on commit 5381868

Please sign in to comment.