Skip to content

Commit

Permalink
Add background color selection to text box as well
Browse files Browse the repository at this point in the history
  • Loading branch information
raimohanska committed Sep 18, 2023
1 parent 76f0508 commit 593d68b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
6 changes: 3 additions & 3 deletions common/src/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export type Note = TextItemProperties & {
color: Color
shape: NoteShape | undefined
}
export type Text = TextItemProperties & { type: typeof ITEM_TYPES.TEXT }
export type Text = TextItemProperties & { type: typeof ITEM_TYPES.TEXT; color: Color }
export type Image = ItemProperties & { type: typeof ITEM_TYPES.IMAGE; assetId: string; src?: string }
export type Video = ItemProperties & { type: typeof ITEM_TYPES.VIDEO; assetId: string; src?: string }
export type Container = TextItemProperties & { type: typeof ITEM_TYPES.CONTAINER; color: Color }
Expand Down Expand Up @@ -380,7 +380,7 @@ export function newText(
height: number = 2,
z: number = 0,
): Text {
return { id: uuid.v4(), type: "text", text, x, y, width, height, z }
return { id: uuid.v4(), type: "text", text, x, y, width, height, z, color: "none" }
}

export function newContainer(
Expand Down Expand Up @@ -433,7 +433,7 @@ export function isSameUser(a: EventUserInfo, b: EventUserInfo) {
}

export function isColoredItem(i: Item): i is ColoredItem {
return i.type === "note" || i.type === "container"
return i.type === "note" || i.type === "container" || i.type === "text"
}

export function isShapedItem(i: Item): i is ShapedItem {
Expand Down
3 changes: 3 additions & 0 deletions common/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ function migrateItem(item: Item, migratedItems: Item[], boardItems: Record<strin

// Force type, width and height for all items
let fixedItem = { type: type || "note", width: width || 5, height: height || 5, z: z || 0, ...rest } as Item
if (fixedItem.type === "text") {
fixedItem.color ??= "none"
}
if (fixedItem.type === "container") {
let container = fixedItem as Container & { items?: string[] }
// Force container to have text
Expand Down
18 changes: 8 additions & 10 deletions frontend/src/board/ItemView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,14 @@ export const ItemView = ({
}
})}
>
{type !== "text" && (
<span
className={L.view(shape, (s) => "shape " + s)}
style={L.view(item, (i) => {
return {
background: getItemBackground(i),
}
})}
/>
)}
<span
className={L.view(shape, (s) => "shape " + s)}
style={L.view(item, (i) => {
return {
background: getItemBackground(i),
}
})}
/>

{(type === "note" || type === "text" || type === "container") && (
<TextView item={item as L.Property<TextItem>} />
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/style/board.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@
}
}

&.color-ffffff00 {
&.color-ffffff00,
&.color-none {
> .shape {
box-shadow: none;
border: 1px dashed #00000040;
Expand Down Expand Up @@ -192,6 +193,13 @@
box-shadow: none;
align-items: flex-start;
justify-content: flex-start;

&.color-ffffff00,
&.color-none {
> .shape {
border: none;
}
}
}

.item .editable {
Expand Down

0 comments on commit 593d68b

Please sign in to comment.