Skip to content

Commit 77fbd80

Browse files
didimmovaadrianptrvsimeonoff
authored
Add chat theme to theming package (#490)
* feat(chat): add chat theme file * fix(chat): comment var name * feat(chat): add chat theme --------- Co-authored-by: Adrian Petrov <[email protected]> Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent 152ce59 commit 77fbd80

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

sass/themes/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@forward 'calendar/calendar-theme';
99
@forward 'card/card-theme';
1010
@forward 'carousel/carousel-theme';
11+
@forward 'chat/chat-theme';
1112
@forward 'checkbox/checkbox-theme';
1213
@forward 'chip/chip-theme';
1314
@forward 'column-actions/column-actions-theme';
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
@use 'sass:map';
2+
@use '../../config';
3+
@use '../../functions' as *;
4+
@use '../../schemas/' as *;
5+
@use '../../../utils/map' as *;
6+
@use '../../../color/functions' as *;
7+
@use '../../../elevations/' as *;
8+
9+
////
10+
/// @package theming
11+
/// @group themes
12+
/// @access public
13+
////
14+
15+
/// Chat Theme
16+
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
17+
/// @prop {Color} background [null] - The background color of the chat component.
18+
/// @prop {Color} header-background [null] - The background color of the chat header.
19+
/// @prop {Color} header-color [null] - The text color of the chat header.
20+
/// @prop {Color} header-border [null] - The color used for the chat header border.
21+
/// @prop {Color} message-background [null] - The background color of the sent message bubble.
22+
/// @prop {Color} message-color [null] - The text color of the chat messages.
23+
/// @prop {Color} message-actions-color [null] - The icon color of the chat message actions.
24+
/// @prop {Color} file-background [null] - The background color of the image message container.
25+
/// @prop {Color} file-icon-color [null] - The color of the attached file icon.
26+
/// @prop {Color} file-icon-accent-color [null] - The accent color of the attached file icon.
27+
/// @prop {Color} image-background [null] - The background color of the image message container.
28+
/// @prop {Color} image-border [null] - The border color of the image message container.
29+
/// @prop {Color} image-attachment-icon [null] - The color of the message attachment icon.
30+
/// @prop {Color} chat-input-border [null] - The border color of the chat input area.
31+
/// @prop {Color} progress-indicator-color [null] - The color of the progress indicator in the chat component.
32+
/// @prop {Color} code-background [null] - The background color of the code snippets in the chat component.
33+
/// @prop {Color} code-border [null] - The border color of the code snippets in the chat component.
34+
/// @requires $light-material-schema
35+
///
36+
/// @example scss Change background color
37+
/// $my-chat-theme: chat-theme($background: blue);
38+
/// // Pass the theme to the css-vars mixin
39+
/// @include css-vars($my-chat-theme);
40+
@function chat-theme(
41+
$schema: $light-material-schema,
42+
43+
$background: null,
44+
45+
$header-background: null,
46+
$header-color: null,
47+
$header-border: null,
48+
49+
$message-background: null,
50+
$message-color: null,
51+
$message-actions-color: null,
52+
53+
$file-background: null,
54+
$file-icon-color: null,
55+
$file-icon-accent-color: null,
56+
57+
$image-background: null,
58+
$image-border: null,
59+
$image-attachment-icon: null,
60+
61+
$chat-input-border: null,
62+
$progress-indicator-color: null,
63+
64+
$code-background: null,
65+
$code-border: null
66+
) {
67+
$name: #{config.variable-prefix() + '-' + 'chat'};
68+
$selector: #{config.element-prefix() + '-' + 'chat'};
69+
$chat-schema: ();
70+
71+
@if map.has-key($schema, 'chat') {
72+
$chat-schema: map.get($schema, 'chat');
73+
} @else {
74+
$chat-schema: $schema;
75+
}
76+
77+
$theme: digest-schema($chat-schema);
78+
$variant: map.get($theme, '_meta', 'theme');
79+
80+
@if not($header-color) and $header-background {
81+
$header-color: adaptive-contrast(var(--header-background));
82+
}
83+
84+
@if not($message-color) and $message-background {
85+
$message-color: adaptive-contrast(var(--message-background));
86+
}
87+
88+
@if not($message-actions-color) and $message-background {
89+
$message-actions-color: adaptive-contrast(var(--message-color));
90+
}
91+
92+
@return extend(
93+
$theme,
94+
(
95+
name: $name,
96+
selector: $selector,
97+
background: $background,
98+
99+
header-background: $header-background,
100+
header-color: $header-color,
101+
header-border: $header-border,
102+
103+
message-background: $message-background,
104+
message-color: $message-color,
105+
message-actions-color: $message-actions-color,
106+
107+
file-background: $file-background,
108+
file-icon-color: $file-icon-color,
109+
file-icon-accent-color: $file-icon-accent-color,
110+
111+
image-background: $image-background,
112+
image-border: $image-border,
113+
image-attachment-icon: $image-attachment-icon,
114+
115+
chat-input-border: $chat-input-border,
116+
progress-indicator-color: $progress-indicator-color,
117+
118+
code-background: $code-background,
119+
code-border: $code-border,
120+
)
121+
);
122+
}

0 commit comments

Comments
 (0)