diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3073bb4e0..341721b8d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Sable Client Changelog
+## Version 1.1.2
+
+- Profile banners. Support's Commet's format.
+- Global name colors. Can be disabled in settings.
+
## Version 1.1.1
- More cache fixes and improvements.
diff --git a/src/app/components/user-profile/UserRoomProfile.tsx b/src/app/components/user-profile/UserRoomProfile.tsx
index 8e47b1105..3489dbfb1 100644
--- a/src/app/components/user-profile/UserRoomProfile.tsx
+++ b/src/app/components/user-profile/UserRoomProfile.tsx
@@ -38,6 +38,7 @@ const KNOWN_KEYS = [
'io.fsky.nyx.pronouns',
'us.cloke.msc4175.tz',
'm.tz',
+ 'moe.sable.app.name_color',
'avatar_url',
'displayname'
];
diff --git a/src/app/components/user-profile/styles.css.ts b/src/app/components/user-profile/styles.css.ts
index 62272a2e8..8a7791fef 100644
--- a/src/app/components/user-profile/styles.css.ts
+++ b/src/app/components/user-profile/styles.css.ts
@@ -18,6 +18,7 @@ export const UserHeroCoverContainer = style({
height: toRem(96),
overflow: 'hidden',
});
+
export const UserHeroCover = style({
height: '100%',
width: '100%',
diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx
index c1c919bc2..f6471011c 100644
--- a/src/app/features/room/RoomTimeline.tsx
+++ b/src/app/features/room/RoomTimeline.tsx
@@ -1081,6 +1081,8 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
delete cleanExtended['chat.commet.profile_bio'];
delete cleanExtended['us.cloke.msc4175.tz'];
delete cleanExtended['m.tz'];
+ delete cleanExtended['chat.commet.profile_banner'];
+ delete cleanExtended['moe.sable.app.name_color'];
delete cleanExtended['avatar_url'];
delete cleanExtended['displayname'];
}
diff --git a/src/app/features/settings/account/NameColorEditor.tsx b/src/app/features/settings/account/NameColorEditor.tsx
new file mode 100644
index 000000000..f1a088970
--- /dev/null
+++ b/src/app/features/settings/account/NameColorEditor.tsx
@@ -0,0 +1,132 @@
+import React, { useState, useEffect } from 'react';
+import { Box, Button, config, Text, Input, IconButton, Icon, Icons } from 'folds';
+import { HexColorPicker } from 'react-colorful';
+import { SettingTile } from '../../../components/setting-tile';
+import { HexColorPickerPopOut } from '../../../components/HexColorPickerPopOut';
+
+type NameColorEditorProps = {
+ current?: string;
+ onSave: (color: string | null) => void;
+};
+
+export function NameColorEditor({ current, onSave }: NameColorEditorProps) {
+ const [tempColor, setTempColor] = useState(current || '#FFFFFF');
+ const [hasChanged, setHasChanged] = useState(false);
+
+ useEffect(() => {
+ if (current) setTempColor(current);
+ else setTempColor('#FFFFFF');
+ }, [current]);
+
+ const handleUpdate = (newColor: string) => {
+ const sanitized = newColor.startsWith('#') ? newColor : `#${newColor}`;
+ setTempColor(sanitized);
+ setHasChanged(sanitized.toUpperCase() !== (current?.toUpperCase() || '#FFFFFF'));
+ };
+
+ const handleSave = () => {
+ if (/^#[0-9A-F]{6}$/i.test(tempColor)) {
+ onSave(tempColor);
+ setHasChanged(false);
+ }
+ };
+
+ const handleReset = () => {
+ onSave(null);
+ setHasChanged(false);
+ setTempColor('#FFFFFF');
+ };
+
+ return (
+
+
+
+
+
+ }
+ >
+ {(onOpen, opened) => (
+
+ )}
+
+
+
+ handleUpdate(e.currentTarget.value)}
+ placeholder="#FFFFFF"
+ variant="Background"
+ size="300"
+ radii="300"
+ style={{
+ textTransform: 'uppercase',
+ fontFamily: 'monospace',
+ width: '100px'
+ }}
+ />
+ {current && (
+
+
+
+ )}
+
+
+
+ {hasChanged && (
+
+ )}
+
+
+ );
+}
\ No newline at end of file
diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx
index 3a61c6cc5..22d5d6ce9 100644
--- a/src/app/features/settings/account/Profile.tsx
+++ b/src/app/features/settings/account/Profile.tsx
@@ -47,6 +47,7 @@ import { useCapabilities } from '../../../hooks/useCapabilities';
import { TimezoneEditor } from './TimezoneEditor';
import { PronounEditor } from './PronounEditor';
import { BioEditor } from './BioEditor';
+import { NameColorEditor } from './NameColorEditor';
type PronounSet = {
summary: string;
@@ -328,6 +329,12 @@ function ProfileExtended({ profile, userId }: ProfileProps) {
return (
Extended Profile
+
+ handleSaveField("moe.sable.app.name_color", color)}
+ />
+
@@ -166,11 +167,18 @@ function IdentityCosmetics() {
}
/>
+
+ }
+ />
+
);
}
diff --git a/src/app/hooks/useSableCosmetics.ts b/src/app/hooks/useSableCosmetics.ts
index eb84a21e0..3878a814b 100644
--- a/src/app/hooks/useSableCosmetics.ts
+++ b/src/app/hooks/useSableCosmetics.ts
@@ -1,4 +1,5 @@
import { useMemo } from 'react';
+import { useAtomValue } from 'jotai';
import { EventTimeline, Room } from 'matrix-js-sdk';
import { useMatrixClient } from './useMatrixClient';
import { StateEvent } from '../../types/matrix/room';
@@ -11,6 +12,7 @@ import colorMXID from '../../util/colorMXID';
import { useRoomCreatorsTag } from './useRoomCreatorsTag';
import { usePowerLevelTags } from './usePowerLevelTags';
import { useTheme } from './useTheme';
+import { profilesCacheAtom } from '../state/userRoomProfile';
const isValidHex = (c: string) => /^#[0-9A-F]{6}$/i.test(c);
const sanitizeFont = (f: string) => f.replace(/[;{}<>]/g, '').slice(0, 32);
@@ -19,7 +21,11 @@ export function useSableCosmetics(userId: string, room: Room) {
const mx = useMatrixClient();
const theme = useTheme();
+ const globalProfiles = useAtomValue(profilesCacheAtom);
+
const [legacyUsernameColor] = useSetting(settingsAtom, 'legacyUsernameColor');
+ const [renderGlobalColors] = useSetting(settingsAtom, 'renderGlobalNameColors');
+
const powerLevels = usePowerLevels(room);
const creators = useRoomCreators(room);
@@ -72,6 +78,15 @@ export function useSableCosmetics(userId: string, room: Room) {
?.getContent()?.font;
}
+ // global name color
+ const cachedProfile = globalProfiles[userId];
+ const hasGlobalColor = cachedProfile?.nameColor && isValidHex(cachedProfile.nameColor);
+ // show if its on, or the user is you
+ const isMe = userId === mx.getUserId();
+ const validGlobal = (renderGlobalColors || isMe) && hasGlobalColor
+ ? cachedProfile.nameColor
+ : undefined;
+
// resolve traditional fallbacks
const memberPowerTag = getPowerTag(userId);
const tagColor = memberPowerTag?.color ? accessibleTagColors?.get(memberPowerTag.color) : undefined;
@@ -81,7 +96,8 @@ export function useSableCosmetics(userId: string, room: Room) {
const validSpace = spaceColor && isValidHex(spaceColor) ? spaceColor : undefined;
// color decision hierarchy
- const resolvedColor = validLocal || validSpace || (legacyUsernameColor ? colorMXID(userId) : tagColor);
+ // Room > Space > Global (if enabled) > Random Colors (if enabled) > Tag
+ const resolvedColor = validLocal || validSpace || validGlobal || (legacyUsernameColor ? colorMXID(userId) : tagColor);
// font decision hierarchy
const rawFont = localFont || spaceFont;
@@ -92,5 +108,5 @@ export function useSableCosmetics(userId: string, room: Room) {
}
return { color: resolvedColor, font: resolvedFont };
- }, [room, userId, mx, getPowerTag, accessibleTagColors, legacyUsernameColor]);
+ }, [room, userId, mx, getPowerTag, accessibleTagColors, legacyUsernameColor, renderGlobalColors, globalProfiles]);
}
\ No newline at end of file
diff --git a/src/app/hooks/useUserProfile.ts b/src/app/hooks/useUserProfile.ts
index 65918a026..b95ef4403 100644
--- a/src/app/hooks/useUserProfile.ts
+++ b/src/app/hooks/useUserProfile.ts
@@ -10,6 +10,8 @@ export type UserProfile = {
pronouns?: any[];
timezone?: string;
bio?: string;
+ bannerUrl?: string;
+ nameColor?: string;
extended?: Record;
};
@@ -17,33 +19,6 @@ export const useUserProfile = (userId: string, initialProfile?: Partial {
- const normalized: UserProfile = {
- avatarUrl: info.avatar_url,
- displayName: info.displayname,
- pronouns: info['io.fsky.nyx.pronouns'],
- timezone: info['us.cloke.msc4175.tz'] || info['m.tz'],
- bio: info['moe.sable.app.bio'] || info['chat.commet.profile_bio'],
- extended: {},
- };
-
- const knownKeys = [
- 'avatar_url',
- 'displayname',
- 'io.fsky.nyx.pronouns',
- 'us.cloke.msc4175.tz', 'm.tz',
- 'moe.sable.app.bio', 'chat.commet.profile_bio'
- ];
-
- Object.keys(info).forEach((key) => {
- if (!knownKeys.includes(key)) {
- normalized.extended![key] = info[key];
- }
- });
-
- return normalized;
- }, []);
-
const [profile, setProfile] = useState(() => {
const user = mx.getUser(userId);
const cached = globalProfiles[userId];
@@ -53,10 +28,43 @@ export const useUserProfile = (userId: string, initialProfile?: Partial {
+ const normalized: UserProfile = {
+ avatarUrl: info.avatar_url,
+ displayName: info.displayname,
+ pronouns: info['io.fsky.nyx.pronouns'],
+ timezone: info['us.cloke.msc4175.tz'] || info['m.tz'],
+ bio: info['moe.sable.app.bio'] || info['chat.commet.profile_bio'],
+ bannerUrl: info['chat.commet.profile_banner'],
+ nameColor: info['moe.sable.app.name_color'],
+ extended: { ...(profile?.extended || {}) },
+ };
+
+ const knownKeys = [
+ 'avatar_url',
+ 'displayname',
+ 'io.fsky.nyx.pronouns',
+ 'us.cloke.msc4175.tz', 'm.tz',
+ 'moe.sable.app.bio', 'chat.commet.profile_bio',
+ 'moe.sable.app.name_color',
+ 'chat.commet.profile_banner'
+ ];
+
+ Object.keys(info).forEach((key) => {
+ if (!knownKeys.includes(key)) {
+ normalized.extended![key] = info[key];
+ }
+ });
+
+ return normalized;
+ }, [profile?.extended]);
+
useEffect(() => {
const user = mx.getUser(userId);
diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts
index ac0f7ddac..57aafd3bf 100644
--- a/src/app/state/settings.ts
+++ b/src/app/state/settings.ts
@@ -56,6 +56,7 @@ export interface Settings {
privacyBlurAvatars: boolean;
privacyBlurEmotes: boolean;
showPronouns: boolean,
+ renderGlobalNameColors: boolean;
// Sable features!
mobileGestures: boolean;
@@ -102,6 +103,7 @@ const defaultSettings: Settings = {
privacyBlurAvatars: false,
privacyBlurEmotes: false,
showPronouns: true,
+ renderGlobalNameColors: true,
// Sable features!
mobileGestures: true,