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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDA-4503 (Add federated green theme for notifications 馃煝) #2114

Merged
merged 2 commits into from
Mar 26, 2024
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
1 change: 1 addition & 0 deletions src/app/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ if (isDevEnv) {
'string',
'1234-5678-910',
);
systemPreferences.setUserDefault('devToolsEnabled', 'boolean', true);
}
logger.info(`init: Setting user data path to`, devDataPath);
app.setPath('userData', devDataPath);
Expand Down
1 change: 1 addition & 0 deletions src/common/api-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export interface INotificationData {
hasIgnore?: boolean;
hasReply?: boolean;
hasMention?: boolean;
isFederatedEnabled?: boolean;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ <h3>Notifications:</h3>
<div class="input-container">
<label for="isExternal">External</label>
<input type="checkbox" id="isExternal" />
<label for="isFederatedEnabled">isFederatedEnabled</label>
<input type="checkbox" id="isFederatedEnabled" />
</div>
<div class="input-container">
<label for="isUpdated">Is updated</label>
Expand Down Expand Up @@ -624,6 +626,8 @@ <h3>Call Notification Input</h3>
var imageUrl = document.getElementById('image').value;
var shouldFlash = document.getElementById('flash').checked;
var isExternal = document.getElementById('isExternal').checked;
var isFederatedEnabled =
document.getElementById('isFederatedEnabled').checked;
var isUpdated = document.getElementById('isUpdated').checked;
var hasMention = document.getElementById('hasMention').checked;
var shouldStick = document.getElementById('sticky').checked;
Expand All @@ -646,6 +650,7 @@ <h3>Call Notification Input</h3>
color: color,
sticky: shouldStick,
isExternal: isExternal,
isFederatedEnabled: isFederatedEnabled,
isUpdated,
theme: theme,
data: {
Expand Down Expand Up @@ -710,6 +715,8 @@ <h3>Call Notification Input</h3>
var imageUrl = document.getElementById('image').value;
var shouldFlash = document.getElementById('flash').checked;
var isExternal = document.getElementById('isExternal').checked;
var isFederatedEnabled =
document.getElementById('isFederatedEnabled').checked;
var color = document.getElementById('color').value;
var company = document.getElementById('company').value;
num++;
Expand All @@ -723,6 +730,7 @@ <h3>Call Notification Input</h3>
color: color,
flash: shouldFlash,
isExternal: isExternal,
isFederatedEnabled: isFederatedEnabled,
theme: theme,
data: {
hello: `Notification with id ${num} clicked')`,
Expand Down
13 changes: 12 additions & 1 deletion src/renderer/components/call-notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface ICallNotificationState {
theme: Theme;
isPrimaryTextOverflowing: boolean;
isSecondaryTextOverflowing: boolean;
isFederatedEnabled: boolean;
}

type mouseEventButton =
Expand Down Expand Up @@ -76,6 +77,7 @@ export default class CallNotification extends React.Component<
theme: '',
isPrimaryTextOverflowing: false,
isSecondaryTextOverflowing: false,
isFederatedEnabled: false,
};
this.state = { ...this.defaultState };
this.updateState = this.updateState.bind(this);
Expand Down Expand Up @@ -118,6 +120,7 @@ export default class CallNotification extends React.Component<
icon,
isPrimaryTextOverflowing,
isSecondaryTextOverflowing,
isFederatedEnabled,
} = this.state;

let themeClassName;
Expand All @@ -129,12 +132,20 @@ export default class CallNotification extends React.Component<
themeClassName =
color && color.match(whiteColorRegExp) ? Themes.LIGHT : Themes.DARK;
}
const themeColors = getThemeColors(theme, flash, isExternal, false, color);
const themeColors = getThemeColors(
theme,
flash,
isExternal,
false,
color,
isFederatedEnabled,
);
const customCssClasses = getContainerCssClasses(
theme,
flash,
isExternal,
false,
isFederatedEnabled,
);
let containerCssClass = `container ${themeClassName} `;
customCssClasses.push(isMac ? 'mac' : 'windows');
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/components/notification-comp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface INotificationState {
isInputHidden: boolean;
containerHeight: number;
canSendMessage: boolean;
isFederatedEnabled?: boolean;
}

type mouseEventButton =
Expand Down Expand Up @@ -84,6 +85,7 @@ export default class NotificationComp extends React.Component<
hasMention: false,
containerHeight: CONTAINER_HEIGHT,
canSendMessage: false,
isFederatedEnabled: false,
};
this.updateState = this.updateState.bind(this);
this.onInputChange = this.onInputChange.bind(this);
Expand Down Expand Up @@ -123,6 +125,7 @@ export default class NotificationComp extends React.Component<
containerHeight,
flash,
icon,
isFederatedEnabled,
} = this.state;
let themeClassName;
if (theme) {
Expand All @@ -139,6 +142,7 @@ export default class NotificationComp extends React.Component<
isExternal,
hasMention,
color,
isFederatedEnabled,
);
const closeImgFilePath = `../renderer/assets/close-icon-${themeClassName}.svg`;
let containerCssClass = `container ${themeClassName} `;
Expand All @@ -147,6 +151,7 @@ export default class NotificationComp extends React.Component<
flash,
isExternal,
hasMention,
isFederatedEnabled,
);
containerCssClass += customCssClasses.join(' ');
return (
Expand Down
33 changes: 31 additions & 2 deletions src/renderer/notification-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,18 @@ export const getContainerCssClasses = (
flash,
isExternal,
hasMention,
isFederatedEnabled = false,
): string[] => {
const customClasses: string[] = [];
if (flash && theme) {
if (isExternal) {
if (isFederatedEnabled) {
customClasses.push('federated-border');
if (hasMention) {
customClasses.push(`${theme}-federated-mention-flashing`);
} else {
customClasses.push(`${theme}-federated-flashing`);
}
} else if (isExternal) {
customClasses.push('external-border');
if (hasMention) {
customClasses.push(`${theme}-ext-mention-flashing`);
Expand Down Expand Up @@ -131,13 +139,32 @@ export const getThemeColors = (
isExternal,
hasMention,
color,
isFederatedEnabled = false,
): { [key: string]: string } => {
const currentColors =
theme === Themes.DARK ? { ...Colors.dark } : { ...Colors.light };
const externalFlashingBackgroundColor =
theme === Themes.DARK ? '#70511f' : '#f6e5a6';

const federatedFlashingBackgroundColor =
theme === Themes.DARK ? '#32602F' : '#D6EBD5';
if (flash && theme) {
if (isExternal) {
if (isFederatedEnabled) {
if (!hasMention) {
currentColors.notificationBorderColor = '#65C862';
currentColors.notificationBackgroundColor =
federatedFlashingBackgroundColor;
if (isCustomColor(color)) {
currentColors.notificationBorderColor = getThemedCustomBorderColor(
theme,
color,
);
currentColors.notificationBackgroundColor = color;
}
} else {
currentColors.notificationBorderColor = '#65C862';
}
} else if (isExternal) {
if (!hasMention) {
currentColors.notificationBorderColor = '#F7CA3B';
currentColors.notificationBackgroundColor =
Expand Down Expand Up @@ -179,6 +206,8 @@ export const getThemeColors = (
theme,
color,
);
} else if (isFederatedEnabled) {
currentColors.notificationBorderColor = '#65C862';
} else if (isExternal) {
currentColors.notificationBorderColor = '#F7CA3B';
}
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class Notification extends NotificationHandler {
hasIgnore,
hasReply,
hasMention,
isFederatedEnabled,
} = data;
notificationWindow.webContents.send('notification-data', {
title,
Expand All @@ -295,6 +296,7 @@ class Notification extends NotificationHandler {
hasIgnore,
hasReply,
hasMention,
isFederatedEnabled,
});
notificationWindow.showInactive();
}
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/styles/call-notification.less
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ text {
animation: light-ext-flashing 1s infinite !important;
}

.dark-federated-flashing {
animation: dark-federated-flashing 1s infinite !important;
}

.light-federated-flashing {
animation: light-federated-flashing 1s infinite !important;
}

.dark-mention-flashing {
animation: dark-mention-flashing 1s infinite !important;
}
Expand All @@ -365,3 +373,11 @@ text {
.light-ext-mention-flashing {
animation: light-ext-mention-flashing 1s infinite !important;
}

.dark-federated-mention-flashing {
animation: dark-federated-mention-flashing 1s infinite !important;
}

.light-federated-mention-flashing {
animation: light-federated-mention-flashing 1s infinite !important;
}
20 changes: 20 additions & 0 deletions src/renderer/styles/notification-comp.less
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ body {
}
}

.federated-border {
border: 2px solid #65c862;
}

.external-border {
border: 2px solid #f7ca3b;
}
Expand Down Expand Up @@ -359,6 +363,14 @@ body {
animation: light-ext-flashing 1s infinite !important;
}

.dark-federated-flashing {
animation: dark-federated-flashing 1s infinite !important;
}

.light-federated-flashing {
animation: light-federated-flashing 1s infinite !important;
}

.dark-mention-flashing {
animation: dark-mention-flashing 1s infinite !important;
}
Expand All @@ -374,3 +386,11 @@ body {
.light-ext-mention-flashing {
animation: light-ext-mention-flashing 1s infinite !important;
}

.dark-federated-mention-flashing {
animation: dark-federated-mention-flashing 1s infinite !important;
}

.light-federated-mention-flashing {
animation: light-federated-mention-flashing 1s infinite !important;
}
38 changes: 38 additions & 0 deletions src/renderer/styles/notifications-animations.less
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@
}
}

@keyframes dark-federated-mention-flashing {
0% {
background-color: @dark-notification-bg-color;
border-color: @dark-federated-flash-border-color;
}
50% {
background-color: @dark-mention-flash-bg-color;
border: 2px solid @dark-mention-flash-border-color;
box-shadow: 0px 2px 4px rgba(5, 6, 6, 0.16),
0px 12px 28px rgba(5, 6, 6, 0.64);
}
}

@keyframes light-federated-mention-flashing {
0% {
background-color: @light-notification-bg-color;
border-color: @light-federated-flash-border-color;
}
50% {
background-color: @light-mention-flash-mention-bg-color;
border-color: @light-mention-flash-border-color;
}
}

@keyframes light-flashing {
50% {
background-color: @light-notification-bg-color;
Expand Down Expand Up @@ -76,3 +100,17 @@
border-color: @dark-external-flash-border-color;
}
}

@keyframes light-federated-flashing {
50% {
background-color: @light-notification-bg-color;
border-color: @light-federated-flash-border-color;
}
}

@keyframes dark-federated-flashing {
50% {
background-color: @dark-notification-bg-color;
border-color: @dark-federated-flash-border-color;
}
}
2 changes: 2 additions & 0 deletions src/renderer/styles/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@dark-mention-flash-bg-color: #99342c;
@dark-mention-flash-border-color: #ff5d50;
@dark-external-flash-border-color: #f7ca3b;
@dark-federated-flash-border-color: #65c862;
@dark-external-flash-bg-color: #70511f;

@light-notification-bg-color: #f1f1f3;
Expand All @@ -14,4 +15,5 @@
@light-mention-flash-mention-bg-color: #fcc1b9;
@light-mention-flash-border-color: #ff5d50;
@light-external-flash-border-color: #f7ca3b;
@light-federated-flash-border-color: #65c862;
@light-external-flash-bg-color: #f6e5a6;
Loading