-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ability to set styling for history and message loading
- Loading branch information
1 parent
dcd328b
commit 8ecbd15
Showing
9 changed files
with
91 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {MessageStyles} from '../../types/messages'; | ||
import {CustomStyle} from '../../types/styles'; | ||
|
||
export class LoadingStyle { | ||
private static colorToHex(color: string) { | ||
const dummyElement = document.createElement('div'); | ||
dummyElement.style.color = color; | ||
document.body.appendChild(dummyElement); | ||
const computedColor = window.getComputedStyle(dummyElement).color; | ||
const hex = (computedColor.match(/\d+/g) as string[]) | ||
.map((value) => parseInt(value).toString(16).padStart(2, '0')) | ||
.join(''); | ||
return `#${hex}`; | ||
} | ||
|
||
public static setDots(bubbleElement: HTMLElement, messageStyles?: MessageStyles) { | ||
if (messageStyles?.loading?.message?.bubble?.color) { | ||
const color = LoadingStyle.colorToHex(messageStyles.loading.message.bubble.color); | ||
bubbleElement.style.setProperty('--loading-message-color', color); | ||
bubbleElement.style.setProperty('--loading-message-color-fade', `${color}33`); | ||
} else { | ||
bubbleElement.style.setProperty('--loading-message-color', '#848484'); | ||
bubbleElement.style.setProperty('--loading-message-color-fade', '#55555533'); | ||
} | ||
} | ||
|
||
public static setRing(bubbleElement: HTMLElement, style: CustomStyle) { | ||
const {color, width, height, margin, border} = style; | ||
if (color) { | ||
const hexColor = LoadingStyle.colorToHex(color); | ||
bubbleElement.style.setProperty('--loading-history-color', hexColor); | ||
} else { | ||
bubbleElement.style.setProperty('--loading-history-color', '#dbdbdb'); | ||
} | ||
bubbleElement.style.setProperty('--loading-history-height', height || '57px'); | ||
bubbleElement.style.setProperty('--loading-history-width', width || '57px'); | ||
bubbleElement.style.setProperty('--loading-history-margin', margin || '7px'); | ||
bubbleElement.style.setProperty('--loading-history-border', border || '5px'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
component/src/views/chat/messages/loadingMessageDotsStyle.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters