Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement typing indicator theme-v2 #95 #130

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/theming/component-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ Defined in: [https://github.com/GetStream/stream-chat-css/blob/main/src/v2/style

Defined in: [https://github.com/GetStream/stream-chat-css/blob/main/src/v2/styles/Thread/Thread-theme.scss](https://github.com/GetStream/stream-chat-css/blob/main/src/v2/styles/Thread/Thread-theme.scss)

## Typing indicator

| Name | Description |
| --------------------------------------------------- | ------------------------------------------------------------- |
| `--str-chat__typing-indicator-font-family` | The font used in the component |
| `--str-chat__typing-indicator-color` | The text/icon color of the component |
| `--str-chat__typing-indicator-background-color` | The background color of the component |
| `--str-chat__typing-indicator-border-radius` | The border radius used for the borders of the component |
| `--str-chat__typing-indicator-border-block-start` | Top border of the component |
| `--str-chat__typing-indicator-border-block-end` | Bottom border of the component |
| `--str-chat__typing-indicator-border-inline-start` | Left (right in RTL layout) border of the component |
| `--str-chat__typing-indicator-border-inline-start` | Right (lrft in RTL layout) border of the component |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `--str-chat__typing-indicator-border-inline-start` | Right (lrft in RTL layout) border of the component |
| `--str-chat__typing-indicator-border-inline-end` | Right (left in RTL layout) border of the component |

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that is a copy-paste mistake copied a lot of times 😀, will take care of this everywhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this after the ongoing PRs merged into theming-v2

| `--str-chat__typing-indicator-box-shadow` | Box shadow applied to the component |
| `--str-chat__typing-indicator-dot-background-color` | Background color of the animated dots in the typing indicator |

Defined in: [https://github.com/GetStream/stream-chat-css/blob/main/src/v2/styles/TypingIndicator/TypingIndicator-theme.scss](https://github.com/GetStream/stream-chat-css/blob/main/src/v2/styles/TypingIndicator/TypingIndicator-theme.scss)

## Message

| Name | Description |
Expand Down
5 changes: 5 additions & 0 deletions src/v1/TypingIndicator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
opacity: 0.2;
}
}

.str-chat__typing-indicator__users {
margin-left: 8px;
color: var(--lighten-grey);
}
}

.dark.str-chat {
Expand Down
23 changes: 23 additions & 0 deletions src/v2/styles/TypingIndicator/TypingIndicator-layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@use '../utils';

.str-chat__typing-indicator {
padding: var(--str-chat__spacing-1_5);
display: flex;
justify-content: flex-start;
align-items: center;
column-gap: var(--str-chat__spacing-1);
position: absolute;
inset-block-end: 0;
inset-inline-start: 0;
inset-inline-end: 0;

.str-chat__typing-indicator__dots {
@include utils.flex-row-center;
column-gap: var(--str-chat__spacing-0_5);

.str-chat__typing-indicator__dot {
width: calc(var(--str-chat__spacing-px) * 4);
height: calc(var(--str-chat__spacing-px) * 4);
}
}
}
52 changes: 52 additions & 0 deletions src/v2/styles/TypingIndicator/TypingIndicator-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@use '../utils';

.str-chat {
--str-chat__typing-indicator-font-family: var(--str-chat__font-family);
--str-chat__typing-indicator-border-radius: none;
--str-chat__typing-indicator-color: var(--str-chat__text-low-emphasis-color);
--str-chat__typing-indicator-background-color: var(--str-chat__overlay-color);
--str-chat__typing-indicator-border-block-start: none;
--str-chat__typing-indicator-border-block-end: none;
--str-chat__typing-indicator-border-inline-start: none;
--str-chat__typing-indicator-border-inline-end: none;
--str-chat__typing-indicator-box-shadow: none;
--str-chat__typing-indicator-dot-background-color: var(--str-chat__text-color);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--str-chat__typing-indicator-dot-background-color: var(--str-chat__text-color);
--str-chat__typing-indicator__dot-background-color: var(--str-chat__text-color);

Nitpick: I'm not sure how closely BEM is followed across other files but, I think dot represents an element. This just caught my eye :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theme-v2 for CSS variables we use camel-case after the str-chat__ prefix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think BEM is just for class names, but I'm happy to be corrected. Let's stick to snake-case for CSS variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, our CSS class names are not 100% consistent, it's mostly BEM, but there are exceptions, the only consistent part is the str-chat__ prefix.

Copy link
Collaborator Author

@szuperaz szuperaz Jun 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#135 created an issue to create some lint rules to check class and variable names

}

.str-chat__typing-indicator {
@include utils.component-layer-overrides('typing-indicator');

.str-chat__typing-indicator__dots {
.str-chat__typing-indicator__dot {
border-radius: 999px;
animation: dotFlashing 1s infinite alternate;
background-color: var(--str-chat__typing-indicator-dot-background-color);

&:nth-child(1) {
animation-delay: 0s;
}

&:nth-child(2) {
animation-delay: 0.5s;
}

&:nth-child(3) {
animation-delay: 1s;
}

@keyframes dotFlashing {
0% {
opacity: 1;
}

50% {
opacity: 0.6;
}

100% {
opacity: 0.2;
}
}
}
}
}
1 change: 1 addition & 0 deletions src/v2/styles/index.layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
@use 'Modal/Modal-layout';
@use 'Thread/Thread-layout';
@use 'Tooltip/Tooltip-layout';
@use 'TypingIndicator/TypingIndicator-layout';
1 change: 1 addition & 0 deletions src/v2/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
@use 'Modal/Modal-theme';
@use 'Thread/Thread-theme';
@use 'Tooltip/Tooltip-theme';
@use 'TypingIndicator/TypingIndicator-theme';