cheogram-www
created pr with
cheogram-www/style-overhaul-for-real-v2.1
commented
Changes are available at https://tangled.org/mrry.band/cheogram-www style-overhaul-for-real-v2
added cheogram-www/style-overhaul-for-real-v2.2
1: 7b21cbd ! 1: 894cb5f Design refresh + dark mode + custom themes
added cheogram-www/style-overhaul-for-real-v2.3
1: 894cb5f ! 1: 13476dc Design refresh + dark mode + custom themes
added cheogram-www/style-overhaul-for-real-v2.4
1: 13476dc ! 1: 8658664 Design refresh + dark mode + custom themes
added cheogram-www/style-overhaul-for-real-v2.5
1: 8658664 ! 1: 3a9bdd1 Design refresh + dark mode + custom themes
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-www:style-overhaul-for-real-v2 | git am -3checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www:style-overhaul-for-real-v2 [rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www:style-overhaul-for-real-v2add comment to patch request:
ssh pr.pico.sh comment cheogram-www:style-overhaul-for-real-v2 "lgtm!"
Patchset
cheogram-www/style-overhaul-for-real-v2.5
Design refresh + dark mode + custom themes
Eric Roberts
2026-10-29T19:01:59ZTweaks a lot of things about the design, adds multiple colour schemes, and allows users to set custom colour schemes. Our internal colour schemes have a few extra colour options so we can customize them further than the custom editor allows. Trying to keep the custom editor minimal while still allowing for us to have some more freedom for in house themes.
Diff stat
23 files changed, 1995 insertions(+), 649 deletions(-)
Semantic diff summary
16 added,
0 modified,
0 signature changed,
0 removed
across 19 analyzed files
(4 files skipped: unsupported file type)
src/theme.ts
-
type_alias_declarationPaletteadded -
type_alias_declarationThemeadded -
function_declarationluminanceadded -
function_declarationcontrastadded -
function_declarationforegroundadded -
function_declarationapplyThemeadded -
type_alias_declarationPresetPaletteadded -
function_declarationmixadded -
function_declarationthemeVariablesadded
+2
-1
index.html
#
| ... | ... | @@ -5,7 +5,7 @@ | |
| 5 | 5 | <link rel="icon" href="/favicon.ico" /> | |
| 6 | 6 | <meta | |
| 7 | 7 | name="viewport" | |
| 8 | - | content="width=device-width, initial-scale=1, interactive-widget=resizes-content" | |
| 8 | + | content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-content" | |
| 9 | 9 | /> | |
| 10 | 10 | <meta name="theme-color" content="#7401cf" /> | |
| 11 | 11 | <base target="_blank" /> |
| ... | ... | @@ -13,6 +13,7 @@ | |
| 13 | 13 | <script type="module" src="/src/bootstrap.ts"></script> | |
| 14 | 14 | </head> | |
| 15 | 15 | <body> | |
| 16 | + | <div id="ios-status-bar-surface" aria-hidden="true"></div> | |
| 16 | 17 | <noscript>You need to enable JavaScript to run this app.</noscript> | |
| 17 | 18 | <a class="sr-only" href="https://wiki.soprani.ca/CheogramWWW/Orca?action=raw">Information about using this app with a screen reader</a> | |
| 18 | 19 | <div id="root"> |
+2
-1
src-tauri/capabilities/default.json
#
+1
-1
src-tauri/tauri.conf.json
#
+852
-340
src/App.scss
#
| ... | ... | @@ -1,6 +1,7 @@ | |
| 1 | - | @use "sass:color"; | |
| 1 | + | @use "sass:meta"; | |
| 2 | 2 | @import "@chatscope/chat-ui-kit-styles/themes/default/helpers/_functions.scss"; | |
| 3 | 3 | $default-font-family: system-ui, sans-serif; | |
| 4 | + | $default-border-radius: 6px; | |
| 4 | 5 | $conversation-font-family: $default-font-family; | |
| 5 | 6 | $conversation-header-font-family: $default-font-family; | |
| 6 | 7 | $expansion-panel-font-family: $default-font-family; |
| ... | ... | @@ -14,18 +15,6 @@ $message-input-content-editor-font-family: $default-font-family; | |
| 14 | 15 | $message-separator-font-family: $default-font-family; | |
| 15 | 16 | $typing-indicator-font-family: $default-font-family; | |
| 16 | 17 | ||
| 17 | - | $perpy: #7401cf; | |
| 18 | - | $color-primary: color.scale($perpy, $lightness: 70%, $saturation: -25%); | |
| 19 | - | $color-primary-light: color.scale($color-primary, $lightness: 30%); | |
| 20 | - | $color-primary-dark: $perpy; | |
| 21 | - | ||
| 22 | - | $yeller: #ffc700; | |
| 23 | - | $color-secondary: color.scale($yeller, $lightness: 70%, $saturation: -25%); | |
| 24 | - | $color-secondary-light: color.scale($color-secondary, $lightness: 30%); | |
| 25 | - | $color-secondary-dark: $yeller; | |
| 26 | - | ||
| 27 | - | $search-border-radius: 10em; | |
| 28 | - | ||
| 29 | 18 | $conversation-header-font-size: 1.5em; | |
| 30 | 19 | $conversation-header-bg-color: transparent; | |
| 31 | 20 | $conversation-header-color: inherit; |
| ... | ... | @@ -35,79 +24,245 @@ $main-container-sidebar-left-max-width: 22em; | |
| 35 | 24 | $main-container-sidebar-right-max-width: 22em; | |
| 36 | 25 | ||
| 37 | 26 | :root { | |
| 38 | - | --color-primary: #{$color-primary}; | |
| 39 | - | --color-primary-light: #{$color-primary-light}; | |
| 40 | - | --color-primary-dark: #{$color-primary-dark}; | |
| 41 | - | --color-secondary: #{$color-secondary}; | |
| 42 | - | --color-secondary-light: #{$color-secondary-light}; | |
| 43 | - | --color-secondary-dark: #{$color-secondary-dark}; | |
| 44 | - | --color-on-secondary: #1e0038; | |
| 27 | + | --accent-surface: var(--theme-light-accent-surface); | |
| 28 | + | color-scheme: light; | |
| 29 | + | --theme-primary: var(--theme-light-primary, #7401cf); | |
| 30 | + | --theme-secondary: var(--theme-light-secondary, #ffc700); | |
| 31 | + | --theme-on-primary: var(--theme-light-on-primary, white); | |
| 32 | + | --theme-on-secondary: var(--theme-light-on-secondary, #212121); | |
| 33 | + | --surface-base: var(--theme-light-background, white); | |
| 34 | + | --text-base: var(--theme-light-text, #212121); | |
| 35 | + | --app-background: var(--theme-primary); | |
| 36 | + | --color-on-app: var(--theme-light-on-app, white); | |
| 37 | + | --default-bg-color: var(--surface-base); | |
| 38 | + | --paper-background: var(--default-bg-color); | |
| 39 | + | --color-primary: var( | |
| 40 | + | --accent-surface, | |
| 41 | + | color-mix(in srgb, var(--theme-primary) 13%, var(--surface-base)) | |
| 42 | + | ); | |
| 43 | + | --color-primary-light: var( | |
| 44 | + | --accent-surface, | |
| 45 | + | color-mix(in srgb, var(--theme-primary) 8%, var(--surface-base)) | |
| 46 | + | ); | |
| 47 | + | --color-primary-dark: var(--theme-light-link, #7401cf); | |
| 48 | + | --theme-secondary-surface: var(--theme-light-secondary-surface); | |
| 49 | + | --color-secondary: var( | |
| 50 | + | --theme-secondary-surface, | |
| 51 | + | color-mix(in srgb, var(--theme-secondary) 30%, var(--surface-base)) | |
| 52 | + | ); | |
| 53 | + | --color-secondary-light: color-mix( | |
| 54 | + | in srgb, | |
| 55 | + | var(--theme-secondary) 20%, | |
| 56 | + | white | |
| 57 | + | ); | |
| 58 | + | --color-secondary-dark: var(--theme-secondary); | |
| 59 | + | --color-on-secondary: var(--theme-on-secondary); | |
| 45 | 60 | --color-danger: rgb(211, 47, 47); | |
| 46 | - | --color-on-danger: #fff; | |
| 47 | - | --default-border-color: #{rgba-to-rgb( | |
| 48 | - | rgba(scale-color($color-primary-dark, $saturation: -55%), 0.4), | |
| 49 | - | #fff | |
| 50 | - | )}; | |
| 51 | - | --color-bg-hover: #{rgba-to-rgb(rgba($color-primary-dark, 0.08), #fff)}; | |
| 52 | - | --color-bg-focus: #{rgba-to-rgb( | |
| 53 | - | rgba($color-primary-dark, 0.24), | |
| 54 | - | $color-primary-light | |
| 55 | - | )}; | |
| 56 | - | --default-bg-color: #fff; | |
| 57 | - | --color-text: rgba(0, 0, 0, 0.87); | |
| 58 | - | --color-text-medium: rgba(0, 0, 0, 0.6); | |
| 59 | - | --color-text-disabled: rgba(0, 0, 0, 0.38); | |
| 60 | - | --message-outgoing-color: var(--color-text); | |
| 61 | - | } | |
| 62 | - | ||
| 63 | - | /*@media (prefers-color-scheme: dark) { | |
| 64 | - | :root { | |
| 65 | - | --color-primary: #{color.scale($perpy, $saturation: -60%)}; | |
| 66 | - | --color-secondary: #{color.scale($yeller, $saturation: -60%)}; | |
| 67 | - | --default-bg-color: #000; | |
| 68 | - | --color-text: rgba(255, 255, 255, 0.87); | |
| 69 | - | --color-text-medium: rgba(255, 255, 255, 0.6); | |
| 70 | - | --color-text-disabled: rgba(255, 255, 255, 0.38); | |
| 71 | - | --message-outgoing-color: rgba(0, 0, 0, 0.87); | |
| 72 | - | --default-border-color: #{rgba-to-rgb( | |
| 73 | - | rgba(scale-color($color-primary-dark, $saturation: -55%), 0.6), | |
| 74 | - | #000 | |
| 75 | - | )}; | |
| 76 | - | --color-bg-hover: #{rgba-to-rgb(rgba($color-primary-dark, 0.2), #000)}; | |
| 77 | - | } | |
| 78 | - | }*/ | |
| 61 | + | --color-on-danger: white; | |
| 62 | + | --color-text: var(--text-base); | |
| 63 | + | --color-text-medium: color-mix( | |
| 64 | + | in srgb, | |
| 65 | + | var(--text-base) 70%, | |
| 66 | + | var(--surface-base) | |
| 67 | + | ); | |
| 68 | + | --color-text-disabled: color-mix( | |
| 69 | + | in srgb, | |
| 70 | + | var(--text-base) 45%, | |
| 71 | + | var(--surface-base) | |
| 72 | + | ); | |
| 73 | + | --default-border-color: color-mix( | |
| 74 | + | in srgb, | |
| 75 | + | var(--text-base) 20%, | |
| 76 | + | var(--surface-base) | |
| 77 | + | ); | |
| 78 | + | --divider-color: var(--default-border-color); | |
| 79 | + | --color-bg-hover: var( | |
| 80 | + | --accent-surface, | |
| 81 | + | color-mix(in srgb, var(--theme-primary) 8%, var(--surface-base)) | |
| 82 | + | ); | |
| 83 | + | --color-bg-focus: var( | |
| 84 | + | --accent-surface, | |
| 85 | + | color-mix(in srgb, var(--theme-primary) 24%, var(--surface-base)) | |
| 86 | + | ); | |
| 87 | + | --chat-panel-border: var(--surface-base); | |
| 88 | + | --chat-panel-background: color-mix( | |
| 89 | + | in srgb, | |
| 90 | + | var(--surface-base) 85%, | |
| 91 | + | transparent | |
| 92 | + | ); | |
| 93 | + | --border-radius: #{$default-border-radius}; | |
| 94 | + | --message-incoming-background: var( | |
| 95 | + | --theme-incoming-background, | |
| 96 | + | color-mix(in srgb, var(--text-base) 7%, var(--surface-base)) | |
| 97 | + | ); | |
| 98 | + | --theme-incoming-background: var(--theme-light-incoming-background); | |
| 99 | + | --message-outgoing-background: var( | |
| 100 | + | --theme-light-outgoing-background, | |
| 101 | + | var(--theme-primary) | |
| 102 | + | ); | |
| 103 | + | --message-outgoing-color: var( | |
| 104 | + | --theme-light-outgoing-color, | |
| 105 | + | var(--theme-on-primary) | |
| 106 | + | ); | |
| 107 | + | --gloop-start: color-mix(in srgb, var(--app-background) 94%, white); | |
| 108 | + | --gloop-end: color-mix(in srgb, var(--app-background) 88%, white); | |
| 109 | + | } | |
| 110 | + | ||
| 111 | + | :root[data-theme="dark"] { | |
| 112 | + | --accent-surface: var(--theme-dark-accent-surface); | |
| 113 | + | color-scheme: dark; | |
| 114 | + | --theme-incoming-background: var(--theme-dark-incoming-background); | |
| 115 | + | --message-outgoing-background: var( | |
| 116 | + | --theme-dark-outgoing-background, | |
| 117 | + | var(--theme-primary) | |
| 118 | + | ); | |
| 119 | + | --message-outgoing-color: var( | |
| 120 | + | --theme-dark-outgoing-color, | |
| 121 | + | var(--theme-on-primary) | |
| 122 | + | ); | |
| 123 | + | --theme-primary: var(--theme-dark-primary, #7401cf); | |
| 124 | + | --theme-secondary: var(--theme-dark-secondary, #ffc700); | |
| 125 | + | --theme-secondary-surface: var(--theme-dark-secondary-surface); | |
| 126 | + | --theme-on-primary: var(--theme-dark-on-primary, white); | |
| 127 | + | --theme-on-secondary: var(--theme-dark-on-secondary, #212121); | |
| 128 | + | --surface-base: var(--theme-dark-background, #191919); | |
| 129 | + | --text-base: var(--theme-dark-text, #f1f1f1); | |
| 130 | + | --color-on-app: var(--theme-dark-on-app, white); | |
| 131 | + | --paper-background: color-mix( | |
| 132 | + | in srgb, | |
| 133 | + | var(--text-base) 3%, | |
| 134 | + | var(--surface-base) | |
| 135 | + | ); | |
| 136 | + | --color-primary-light: var( | |
| 137 | + | --accent-surface, | |
| 138 | + | color-mix(in srgb, var(--theme-primary) 24%, var(--surface-base)) | |
| 139 | + | ); | |
| 140 | + | --color-primary-dark: var(--theme-dark-link, #c99aff); | |
| 141 | + | --chat-panel-border: color-mix(in srgb, var(--text-base) 12%, transparent); | |
| 142 | + | --chat-panel-background: color-mix( | |
| 143 | + | in srgb, | |
| 144 | + | var(--paper-background) 90%, | |
| 145 | + | transparent | |
| 146 | + | ); | |
| 147 | + | ||
| 148 | + | @include meta.load-css("highlight.js/styles/github-dark.css"); | |
| 149 | + | ||
| 150 | + | .ql-snow { | |
| 151 | + | .ql-stroke { | |
| 152 | + | stroke: var(--color-text-medium); | |
| 153 | + | } | |
| 154 | + | ||
| 155 | + | .ql-fill { | |
| 156 | + | fill: var(--color-text-medium); | |
| 157 | + | } | |
| 158 | + | ||
| 159 | + | .ql-picker { | |
| 160 | + | color: var(--color-text-medium); | |
| 161 | + | } | |
| 162 | + | ||
| 163 | + | .ql-picker-options, | |
| 164 | + | .ql-tooltip { | |
| 165 | + | background: var(--default-bg-color); | |
| 166 | + | color: var(--color-text); | |
| 167 | + | border-color: var(--default-border-color); | |
| 168 | + | } | |
| 169 | + | ||
| 170 | + | .ql-editor.ql-blank::before { | |
| 171 | + | color: var(--color-text-disabled); | |
| 172 | + | } | |
| 173 | + | } | |
| 174 | + | } | |
| 79 | 175 | ||
| 80 | 176 | $default-bg-color: var(--default-bg-color); | |
| 81 | - | $typing-indicator-indicator-bg-color: transparent; | |
| 82 | - | //$color-text: var(--color-text); | |
| 83 | 177 | $color-text-medium: var(--color-text-medium); | |
| 84 | 178 | $color-text-disabled: var(--color-text-disabled); | |
| 85 | 179 | $default-border-color: var(--default-border-color); | |
| 86 | 180 | $color-bg-hover: var(--color-bg-hover); | |
| 87 | 181 | $color-bg-focus: var(--color-bg-focus); | |
| 88 | - | $message-header-color: color-mix(in srgb, var(--color-text), white 30%); | |
| 89 | - | $message-footer-color: color-mix(in srgb, var(--color-text), white 30%); | |
| 182 | + | $message-header-color: color-mix( | |
| 183 | + | in srgb, | |
| 184 | + | var(--color-text), | |
| 185 | + | var(--default-bg-color) 30% | |
| 186 | + | ); | |
| 187 | + | $message-footer-color: $message-header-color; | |
| 90 | 188 | $color-selected: color-mix(in srgb, var(--color-primary-dark), black 25%); | |
| 91 | - | $color-activated: color-mix(in srgb, var(--color-primary-dark), black 25%); | |
| 189 | + | $color-activated: $color-selected; | |
| 92 | 190 | $color-primary: var(--color-primary); | |
| 93 | 191 | $color-primary-light: var(--color-primary-light); | |
| 94 | 192 | $color-primary-dark: var(--color-primary-dark); | |
| 95 | - | $color-secondary: var(--color-secondary); | |
| 96 | - | $color-secondary-light: var(--color-secondary-light); | |
| 97 | - | $color-secondary-dark: var(--color-secondary-dark); | |
| 193 | + | $button-color: var(--theme-primary); | |
| 194 | + | ||
| 195 | + | $conversation-unread-bg-color: var(--theme-primary); | |
| 196 | + | $conversation-unread-color: var(--theme-on-primary); | |
| 98 | 197 | ||
| 99 | - | $conversation-unread-bg-color: var(--color-primary-dark); | |
| 198 | + | $message-list-typing-indicator-bg-color: $default-bg-color; | |
| 199 | + | $message-list-loading-more-bg-color: $default-bg-color; | |
| 100 | 200 | ||
| 101 | 201 | $message-outgoing-color: var(--message-outgoing-color); | |
| 102 | 202 | $message-content-outgoing-color: var(--message-outgoing-color); | |
| 103 | 203 | $message-group-message-content-outgoing-color: var(--message-outgoing-color); | |
| 104 | - | $message-content-outgoing-bg-color: $color-secondary; | |
| 204 | + | $message-content-incoming-bg-color: var(--message-incoming-background); | |
| 205 | + | $message-group-message-content-incoming-bg-color: $message-content-incoming-bg-color; | |
| 206 | + | $message-content-outgoing-bg-color: var(--message-outgoing-background); | |
| 105 | 207 | $message-group-message-content-outgoing-bg-color: $message-content-outgoing-bg-color; | |
| 208 | + | $conversation-activated-bg-color: $color-primary; | |
| 209 | + | $conversation-hover-bg-color: $conversation-activated-bg-color; | |
| 210 | + | $conversation-name-activated-color: var(--color-text); | |
| 211 | + | $conversation-info-activated-color: var(--color-text-medium); | |
| 212 | + | ||
| 213 | + | // ChatScope uses its base text color in Sass color functions. | |
| 214 | + | $main-container-color: var(--color-text); | |
| 215 | + | $chat-container-color: var(--color-text); | |
| 216 | + | $chat-container-message-input-color: var(--color-text); | |
| 217 | + | $chat-container-input-toolbox-color: var(--color-text); | |
| 218 | + | $conversation-color: var(--color-text); | |
| 219 | + | $conversation-name-color: var(--color-text); | |
| 220 | + | $conversation-header-actions-color: var(--color-text); | |
| 221 | + | $conversation-list-color: var(--color-text); | |
| 222 | + | $expansion-panel-color: var(--color-text); | |
| 223 | + | $expansion-panel-content-color: var(--color-text); | |
| 224 | + | $loader-color: var(--color-text); | |
| 225 | + | $message-color: var(--color-text); | |
| 226 | + | $message-content-color: var(--color-text); | |
| 227 | + | $message-content-incoming-color: var(--color-text); | |
| 228 | + | $message-group-message-content-incoming-color: var(--color-text); | |
| 229 | + | $message-input-content-editor-color: var(--color-text); | |
| 230 | + | $message-list-color: var(--color-text); | |
| 231 | + | $search-color: var(--color-text); | |
| 232 | + | $search-placeholder-color: var(--color-text); | |
| 233 | + | $status-list-color: var(--color-text); | |
| 234 | + | $status-list-item-active-color: var(--color-text); | |
| 106 | 235 | ||
| 107 | 236 | @import "@chatscope/chat-ui-kit-styles/themes/default/main.scss"; | |
| 108 | 237 | ||
| 238 | + | .cs-conversation__unread-dot { | |
| 239 | + | background: radial-gradient( | |
| 240 | + | circle at 3px 3px, | |
| 241 | + | color-mix(in srgb, var(--theme-primary), white 30%), | |
| 242 | + | var(--theme-primary) | |
| 243 | + | ); | |
| 244 | + | } | |
| 245 | + | ||
| 109 | 246 | * { | |
| 110 | 247 | box-sizing: border-box; | |
| 248 | + | scrollbar-width: thin; | |
| 249 | + | scrollbar-color: var(--color-primary) transparent; | |
| 250 | + | } | |
| 251 | + | ||
| 252 | + | @supports not (scrollbar-color: auto) { | |
| 253 | + | ::-webkit-scrollbar { | |
| 254 | + | width: 6px; | |
| 255 | + | height: 6px; | |
| 256 | + | } | |
| 257 | + | ||
| 258 | + | ::-webkit-scrollbar-thumb { | |
| 259 | + | background: var(--color-primary); | |
| 260 | + | border-radius: $default-border-radius; | |
| 261 | + | } | |
| 262 | + | ||
| 263 | + | ::-webkit-scrollbar-track { | |
| 264 | + | background: transparent; | |
| 265 | + | } | |
| 111 | 266 | } | |
| 112 | 267 | ||
| 113 | 268 | html, |
| ... | ... | @@ -124,14 +280,62 @@ html, | |
| 124 | 280 | height: 100%; | |
| 125 | 281 | margin: 0; | |
| 126 | 282 | padding: 0; | |
| 127 | - | box-sizing: border-box; | |
| 128 | 283 | font-size: 16px; | |
| 129 | 284 | } | |
| 130 | 285 | ||
| 286 | + | #ios-status-bar-surface { | |
| 287 | + | display: none; | |
| 288 | + | } | |
| 289 | + | ||
| 290 | + | @media (display-mode: standalone) { | |
| 291 | + | @supports (-webkit-touch-callout: none) and (-webkit-background-clip: text) { | |
| 292 | + | // Avoid iOS 27's system blur over page content. Keep a nontransparent | |
| 293 | + | // background for WebKit's sampler; empty-text clipping prevents painting. | |
| 294 | + | // https://github.com/HKUDS/nanobot/blob/main/docs/guides/ios-pwa-status-bar.md | |
| 295 | + | #ios-status-bar-surface { | |
| 296 | + | display: block; | |
| 297 | + | position: fixed; | |
| 298 | + | inset: 0 0 auto; | |
| 299 | + | height: 11px; | |
| 300 | + | z-index: 2147483647; | |
| 301 | + | pointer-events: none; | |
| 302 | + | background-color: var(--app-background); | |
| 303 | + | -webkit-background-clip: text; | |
| 304 | + | background-clip: text; | |
| 305 | + | } | |
| 306 | + | ||
| 307 | + | body:has(.cs-chat-container[role="main"].active) #ios-status-bar-surface { | |
| 308 | + | background-color: var(--default-bg-color); | |
| 309 | + | } | |
| 310 | + | ||
| 311 | + | .cs-chat-container[role="main"].active { | |
| 312 | + | --chat-message-gutter: 1rem; | |
| 313 | + | ||
| 314 | + | --chat-composer-bottom-offset: 1.2rem; | |
| 315 | + | ||
| 316 | + | > .chat-composer { | |
| 317 | + | margin-bottom: 0; | |
| 318 | + | } | |
| 319 | + | } | |
| 320 | + | } | |
| 321 | + | } | |
| 322 | + | ||
| 131 | 323 | input { | |
| 132 | 324 | font-size: inherit; | |
| 133 | 325 | } | |
| 134 | 326 | ||
| 327 | + | #root.tauri-overlay { | |
| 328 | + | padding-top: 28px; | |
| 329 | + | } | |
| 330 | + | ||
| 331 | + | .tauri-titlebar { | |
| 332 | + | position: fixed; | |
| 333 | + | top: 0; | |
| 334 | + | left: 0; | |
| 335 | + | right: 0; | |
| 336 | + | height: 28px; | |
| 337 | + | } | |
| 338 | + | ||
| 135 | 339 | .form-option-icon { | |
| 136 | 340 | display: flex; | |
| 137 | 341 | align-items: center; |
| ... | ... | @@ -199,9 +403,42 @@ li.MuiListSubheader-root { | |
| 199 | 403 | object-fit: cover; | |
| 200 | 404 | } | |
| 201 | 405 | ||
| 406 | + | #root:not(.tauri-overlay):not(:has(.cs-chat-container[role="main"].active)) { | |
| 407 | + | padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 | |
| 408 | + | env(safe-area-inset-left, 0px); | |
| 409 | + | } | |
| 410 | + | ||
| 202 | 411 | #root { | |
| 203 | 412 | display: flex; | |
| 204 | - | padding-bottom: env(safe-area-inset-bottom, 0px); | |
| 413 | + | position: relative; | |
| 414 | + | isolation: isolate; | |
| 415 | + | background: var(--app-background); | |
| 416 | + | ||
| 417 | + | &::before, | |
| 418 | + | &::after { | |
| 419 | + | content: ""; | |
| 420 | + | position: absolute; | |
| 421 | + | z-index: -1; | |
| 422 | + | pointer-events: none; | |
| 423 | + | width: 50vh; | |
| 424 | + | max-width: 100%; | |
| 425 | + | background: linear-gradient(135deg, var(--gloop-start), var(--gloop-end)); | |
| 426 | + | mask: var(--gloop-mask) center / contain no-repeat; | |
| 427 | + | } | |
| 428 | + | ||
| 429 | + | &::before { | |
| 430 | + | --gloop-mask: url(/gloop01.svg); | |
| 431 | + | top: 0; | |
| 432 | + | left: 0; | |
| 433 | + | aspect-ratio: 748 / 660; | |
| 434 | + | } | |
| 435 | + | ||
| 436 | + | &::after { | |
| 437 | + | --gloop-mask: url(/gloop02.svg); | |
| 438 | + | bottom: 0; | |
| 439 | + | right: 0; | |
| 440 | + | aspect-ratio: 1260 / 1852; | |
| 441 | + | } | |
| 205 | 442 | ||
| 206 | 443 | > main { | |
| 207 | 444 | display: flex; |
| ... | ... | @@ -222,17 +459,12 @@ li.MuiListSubheader-root { | |
| 222 | 459 | margin: auto; | |
| 223 | 460 | min-width: 25em; | |
| 224 | 461 | max-width: 100vw; | |
| 225 | - | border: 1px solid var(--default-border-color); | |
| 226 | 462 | border-radius: 2em; | |
| 227 | 463 | text-align: center; | |
| 228 | - | background: var(--color-primary-dark) url(/gloop01.svg) no-repeat; | |
| 229 | - | background-size: 40%; | |
| 230 | 464 | overflow: hidden; | |
| 231 | - | color: white; | |
| 465 | + | color: var(--color-on-app); | |
| 232 | 466 | ||
| 233 | 467 | > form { | |
| 234 | - | background: url(/gloop02.svg) no-repeat right bottom; | |
| 235 | - | background-size: 60%; | |
| 236 | 468 | padding: 2em; | |
| 237 | 469 | } | |
| 238 | 470 |
| ... | ... | @@ -266,12 +499,12 @@ li.MuiListSubheader-root { | |
| 266 | 499 | gap: 1em; | |
| 267 | 500 | width: 21em; | |
| 268 | 501 | margin-top: 1em; | |
| 269 | - | background: rgba(96, 14, 181, 0.4); | |
| 502 | + | background: color-mix(in srgb, var(--app-background) 80%, black); | |
| 270 | 503 | border-radius: 10em; | |
| 271 | - | border: 1px solid #550ca1; | |
| 272 | - | box-shadow: 0 1px 0 #550ca1; | |
| 504 | + | border: 1px solid var(--app-background); | |
| 505 | + | box-shadow: 0 1px 0 var(--app-background); | |
| 273 | 506 | padding: 1em; | |
| 274 | - | text-shadow: 0 2px 1px #550ca1; | |
| 507 | + | text-shadow: 0 2px 1px var(--app-background); | |
| 275 | 508 | ||
| 276 | 509 | span { | |
| 277 | 510 | flex: 1; |
| ... | ... | @@ -324,6 +557,107 @@ li.MuiListSubheader-root { | |
| 324 | 557 | } | |
| 325 | 558 | } | |
| 326 | 559 | ||
| 560 | + | .cs-chat-container[role="main"] { | |
| 561 | + | --chat-message-gutter: 0.5rem; | |
| 562 | + | --chat-composer-bottom-offset: env(safe-area-inset-bottom, 0px); | |
| 563 | + | position: relative; | |
| 564 | + | min-height: 0; | |
| 565 | + | ||
| 566 | + | > .cs-conversation-header, | |
| 567 | + | > .chat-composer { | |
| 568 | + | position: absolute; | |
| 569 | + | left: env(safe-area-inset-left, 0px); | |
| 570 | + | right: env(safe-area-inset-right, 0px); | |
| 571 | + | z-index: 2; | |
| 572 | + | margin: 10px var(--chat-message-gutter); | |
| 573 | + | margin-right: calc( | |
| 574 | + | var(--chat-message-gutter) + var(--chat-scrollbar-width, 0px) | |
| 575 | + | ); | |
| 576 | + | } | |
| 577 | + | ||
| 578 | + | > .cs-conversation-header, | |
| 579 | + | #message-input-root, | |
| 580 | + | .chat-typing-overlay { | |
| 581 | + | border: 1px solid var(--chat-panel-border); | |
| 582 | + | border-radius: 6px; | |
| 583 | + | -webkit-backdrop-filter: blur(12px); | |
| 584 | + | backdrop-filter: blur(12px); | |
| 585 | + | background: var(--chat-panel-background); | |
| 586 | + | } | |
| 587 | + | ||
| 588 | + | > .cs-conversation-header, | |
| 589 | + | #message-input-root { | |
| 590 | + | box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2); | |
| 591 | + | } | |
| 592 | + | ||
| 593 | + | > .cs-conversation-header { | |
| 594 | + | top: env(safe-area-inset-top, 0px); | |
| 595 | + | margin-top: var(--chat-message-gutter); | |
| 596 | + | } | |
| 597 | + | ||
| 598 | + | > .chat-composer { | |
| 599 | + | bottom: var(--chat-composer-bottom-offset); | |
| 600 | + | } | |
| 601 | + | ||
| 602 | + | #message-input-root { | |
| 603 | + | .cs-message-input { | |
| 604 | + | border: 0; | |
| 605 | + | background: transparent; | |
| 606 | + | } | |
| 607 | + | ||
| 608 | + | .cs-message-input__content-editor-wrapper { | |
| 609 | + | background: transparent; | |
| 610 | + | } | |
| 611 | + | } | |
| 612 | + | ||
| 613 | + | .chat-typing-overlay { | |
| 614 | + | width: fit-content; | |
| 615 | + | max-width: 100%; | |
| 616 | + | margin-bottom: 8px; | |
| 617 | + | padding: 0.4em 0.75em; | |
| 618 | + | pointer-events: none; | |
| 619 | + | } | |
| 620 | + | ||
| 621 | + | > .cs-message-list { | |
| 622 | + | min-height: 0; | |
| 623 | + | height: 100%; | |
| 624 | + | ||
| 625 | + | .virtuoso-container { | |
| 626 | + | min-height: 0; | |
| 627 | + | } | |
| 628 | + | ||
| 629 | + | .jump-to-bottom { | |
| 630 | + | bottom: calc( | |
| 631 | + | var(--chat-composer-height, 0px) + var(--chat-composer-bottom-offset) + | |
| 632 | + | 1rem | |
| 633 | + | ); | |
| 634 | + | } | |
| 635 | + | } | |
| 636 | + | ||
| 637 | + | > .cs-message-list:has(> .MuiTabs-root) { | |
| 638 | + | padding-top: calc( | |
| 639 | + | var(--chat-header-height, 0px) + env(safe-area-inset-top, 0px) + 20px | |
| 640 | + | ); | |
| 641 | + | ||
| 642 | + | .chat-header-spacer { | |
| 643 | + | height: 0; | |
| 644 | + | } | |
| 645 | + | } | |
| 646 | + | ||
| 647 | + | .chat-header-spacer { | |
| 648 | + | height: calc( | |
| 649 | + | var(--chat-header-height, 0px) + env(safe-area-inset-top, 0px) | |
| 650 | + | ); | |
| 651 | + | } | |
| 652 | + | ||
| 653 | + | .chat-composer-spacer { | |
| 654 | + | height: calc( | |
| 655 | + | var(--chat-composer-height, 0px) + var(--chat-composer-bottom-offset) + | |
| 656 | + | 12px | |
| 657 | + | ); | |
| 658 | + | } | |
| 659 | + | } | |
| 660 | + | ||
| 327 | 661 | .cs-message-list { | |
| 328 | 662 | display: flex; | |
| 329 | 663 | flex-direction: column; |
| ... | ... | @@ -347,7 +681,7 @@ li.MuiListSubheader-root { | |
| 347 | 681 | background: var(--color-danger); | |
| 348 | 682 | color: var(--color-on-danger); | |
| 349 | 683 | padding: 0.5em 1em; | |
| 350 | - | border-radius: 10em; | |
| 684 | + | border-radius: $default-border-radius; | |
| 351 | 685 | ||
| 352 | 686 | &:first-of-type { | |
| 353 | 687 | color: var(--color-on-secondary); |
| ... | ... | @@ -479,36 +810,21 @@ li.MuiListSubheader-root { | |
| 479 | 810 | ||
| 480 | 811 | [readonly] { | |
| 481 | 812 | caret-color: transparent; | |
| 482 | - | ||
| 483 | - | ~ fieldset.MuiOutlinedInput-notchedOutline:hover { | |
| 484 | - | border-color: rgba(0, 0, 0, 0.23); | |
| 485 | - | border-width: 1px; | |
| 486 | - | } | |
| 487 | 813 | } | |
| 488 | 814 | ||
| 489 | - | .MuiInputBase-root:hover { | |
| 490 | - | [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline { | |
| 491 | - | border-color: rgba(0, 0, 0, 0.23); | |
| 492 | - | border-width: 1px; | |
| 493 | - | } | |
| 494 | - | } | |
| 495 | - | ||
| 496 | - | .MuiInputBase-root.Mui-readOnly:hover { | |
| 497 | - | fieldset.MuiOutlinedInput-notchedOutline { | |
| 498 | - | border-color: rgba(0, 0, 0, 0.23); | |
| 499 | - | border-width: 1px; | |
| 500 | - | } | |
| 815 | + | [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline:hover, | |
| 816 | + | .MuiInputBase-root:hover | |
| 817 | + | [readonly] | |
| 818 | + | ~ fieldset.MuiOutlinedInput-notchedOutline, | |
| 819 | + | .MuiInputBase-root.Mui-readOnly:hover | |
| 820 | + | fieldset.MuiOutlinedInput-notchedOutline, | |
| 821 | + | div.Mui-focused [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline { | |
| 822 | + | border-color: var(--mui-palette-divider); | |
| 823 | + | border-width: 1px; | |
| 501 | 824 | } | |
| 502 | 825 | ||
| 503 | 826 | label.Mui-focused:has(~ .MuiInputBase-root [readonly]) { | |
| 504 | - | color: rgba(0, 0, 0, 0.6); | |
| 505 | - | } | |
| 506 | - | ||
| 507 | - | div.Mui-focused { | |
| 508 | - | [readonly] ~ fieldset.MuiOutlinedInput-notchedOutline { | |
| 509 | - | border-color: rgba(0, 0, 0, 0.23); | |
| 510 | - | border-width: 1px; | |
| 511 | - | } | |
| 827 | + | color: var(--color-text-medium); | |
| 512 | 828 | } | |
| 513 | 829 | ||
| 514 | 830 | .command-actions { |
| ... | ... | @@ -566,8 +878,8 @@ li.MuiListSubheader-root { | |
| 566 | 878 | ||
| 567 | 879 | section.cs-message-group { | |
| 568 | 880 | margin: 0; | |
| 569 | - | padding-left: 0.5em; | |
| 570 | - | padding-right: 0.5em; | |
| 881 | + | padding-left: var(--chat-message-gutter, 0.5rem); | |
| 882 | + | padding-right: var(--chat-message-gutter, 0.5rem); | |
| 571 | 883 | padding-bottom: 0.5em; | |
| 572 | 884 | ||
| 573 | 885 | * { |
| ... | ... | @@ -579,32 +891,33 @@ li.MuiListSubheader-root { | |
| 579 | 891 | padding-bottom: 0.5em; | |
| 580 | 892 | } | |
| 581 | 893 | ||
| 582 | - | &.back-in-time .meta time { | |
| 583 | - | font-weight: bold; | |
| 584 | - | color: var(--color-primary-dark); | |
| 585 | - | } | |
| 586 | - | ||
| 587 | 894 | .cs-message-group__content { | |
| 588 | 895 | flex: 1; | |
| 896 | + | min-width: 0; | |
| 589 | 897 | max-width: 80em; | |
| 590 | 898 | } | |
| 591 | 899 | ||
| 592 | 900 | .cs-message:not(:only-child) { | |
| 593 | 901 | margin: 0; | |
| 594 | 902 | padding-top: 0.2em; | |
| 903 | + | ||
| 904 | + | &:first-child { | |
| 905 | + | padding-top: 0; | |
| 906 | + | } | |
| 595 | 907 | } | |
| 596 | 908 | ||
| 597 | 909 | &.cs-message-group--incoming { | |
| 598 | - | padding-right: 0.5em; | |
| 910 | + | padding-right: calc( | |
| 911 | + | var(--chat-message-gutter, 0.5rem) + | |
| 912 | + | var(--chat-avatar-size, #{$avatar-md-width}) + 8px - 2rem | |
| 913 | + | ); | |
| 599 | 914 | } | |
| 600 | 915 | ||
| 601 | 916 | &.cs-message-group--outgoing { | |
| 602 | - | padding-left: 0.5em; | |
| 603 | - | } | |
| 604 | - | ||
| 605 | - | .cs-message-group__footer { | |
| 606 | - | margin: 0; | |
| 607 | - | padding-top: 0.2em; | |
| 917 | + | padding-left: calc( | |
| 918 | + | var(--chat-message-gutter, 0.5rem) + | |
| 919 | + | var(--chat-avatar-size, #{$avatar-md-width}) + 8px - 2em | |
| 920 | + | ); | |
| 608 | 921 | } | |
| 609 | 922 | ||
| 610 | 923 | .call { |
| ... | ... | @@ -624,34 +937,8 @@ li.MuiListSubheader-root { | |
| 624 | 937 | } | |
| 625 | 938 | } | |
| 626 | 939 | ||
| 627 | - | button.cs-button:has(~ .u-in-reply-to) { | |
| 628 | - | padding: 0; | |
| 629 | - | } | |
| 630 | - | ||
| 631 | 940 | .cs-message--outgoing .cs-message__content button.cs-button { | |
| 632 | - | color: var(--color-primary-dark); | |
| 633 | - | } | |
| 634 | - | ||
| 635 | - | .cs-message--incoming .meta { | |
| 636 | - | display: flex; | |
| 637 | - | flex-wrap: wrap; | |
| 638 | - | flex-direction: row; | |
| 639 | - | div:not(.h-card.sender) { | |
| 640 | - | order: 2; | |
| 641 | - | flex: 1; | |
| 642 | - | } | |
| 643 | - | .h-card.sender { | |
| 644 | - | margin-right: 1em; | |
| 645 | - | order: 1; | |
| 646 | - | } | |
| 647 | - | } | |
| 648 | - | ||
| 649 | - | .small.cs-message--incoming .meta { | |
| 650 | - | flex-direction: column; | |
| 651 | - | div:not(.h-card.sender) { | |
| 652 | - | margin-left: 0; | |
| 653 | - | order: 0; | |
| 654 | - | } | |
| 941 | + | color: inherit; | |
| 655 | 942 | } | |
| 656 | 943 | } | |
| 657 | 944 |
| ... | ... | @@ -927,6 +1209,16 @@ div.cs-message__content { | |
| 927 | 1209 | } | |
| 928 | 1210 | ||
| 929 | 1211 | &.cs-sidebar--left { | |
| 1212 | + | [data-index] { | |
| 1213 | + | padding: 0 0.35em; | |
| 1214 | + | border-bottom: 1px solid transparent; | |
| 1215 | + | } | |
| 1216 | + | ||
| 1217 | + | .cs-conversation:hover, | |
| 1218 | + | .cs-conversation--active { | |
| 1219 | + | border-radius: $default-border-radius; | |
| 1220 | + | } | |
| 1221 | + | ||
| 930 | 1222 | .cs-conversation-header { | |
| 931 | 1223 | padding-top: 0.5em; | |
| 932 | 1224 | padding-bottom: 0.7em; |
| ... | ... | @@ -1054,10 +1346,10 @@ div.cs-message__content { | |
| 1054 | 1346 | ||
| 1055 | 1347 | #tag-nav { | |
| 1056 | 1348 | width: fit-content; | |
| 1057 | - | margin: 0 0.5rem 0.5rem; | |
| 1349 | + | margin: 0 0.5rem 0.5em; | |
| 1058 | 1350 | padding: 0.3rem 0.9rem; | |
| 1059 | 1351 | border: none; | |
| 1060 | - | border-radius: 2em; | |
| 1352 | + | border-radius: $default-border-radius; | |
| 1061 | 1353 | background: var(--color-secondary); | |
| 1062 | 1354 | } | |
| 1063 | 1355 |
| ... | ... | @@ -1124,7 +1416,7 @@ div.cs-message__content { | |
| 1124 | 1416 | display: inline-block; | |
| 1125 | 1417 | padding: 0.2em 0.5em; | |
| 1126 | 1418 | margin: 0.5em; | |
| 1127 | - | border-radius: 2em; | |
| 1419 | + | border-radius: $default-border-radius; | |
| 1128 | 1420 | color: var(--color-on-danger); | |
| 1129 | 1421 | text-transform: lowercase; | |
| 1130 | 1422 | font-variant: small-caps; |
| ... | ... | @@ -1145,19 +1437,13 @@ div.cs-message__content { | |
| 1145 | 1437 | } | |
| 1146 | 1438 | ||
| 1147 | 1439 | #message-input-root { | |
| 1148 | - | border-top: 1px solid var(--default-border-color); | |
| 1149 | - | ||
| 1150 | - | &:has(.reply) { | |
| 1151 | - | border-top: none; | |
| 1152 | - | } | |
| 1153 | - | ||
| 1154 | 1440 | .reply { | |
| 1155 | 1441 | display: flex; | |
| 1156 | 1442 | flex-direction: row; | |
| 1157 | 1443 | ||
| 1158 | - | background: var(--color-primary-dark); | |
| 1159 | - | color: var(--default-bg-color); | |
| 1160 | - | border-radius: 1em 1em 0 0; | |
| 1444 | + | background: var(--theme-primary); | |
| 1445 | + | color: var(--theme-on-primary); | |
| 1446 | + | border-radius: $default-border-radius $default-border-radius 0 0; | |
| 1161 | 1447 | padding: 0 1em; | |
| 1162 | 1448 | line-height: 2; | |
| 1163 | 1449 |
| ... | ... | @@ -1167,14 +1453,13 @@ div.cs-message__content { | |
| 1167 | 1453 | ||
| 1168 | 1454 | button { | |
| 1169 | 1455 | margin-left: auto; | |
| 1170 | - | color: var(--default-bg-color); | |
| 1456 | + | color: var(--theme-on-primary); | |
| 1171 | 1457 | padding: 0; | |
| 1172 | 1458 | } | |
| 1173 | 1459 | } | |
| 1174 | 1460 | ||
| 1175 | 1461 | .attachments { | |
| 1176 | 1462 | display: flex; | |
| 1177 | - | flex-direction: flex-row; | |
| 1178 | 1463 | padding: 0.5em; | |
| 1179 | 1464 | ||
| 1180 | 1465 | img { |
| ... | ... | @@ -1241,6 +1523,10 @@ div.cs-message__content { | |
| 1241 | 1523 | } | |
| 1242 | 1524 | ||
| 1243 | 1525 | .ql-toolbar { | |
| 1526 | + | // Quill's bold icon starts 4px into its SVG, after 5px of button padding. | |
| 1527 | + | // The negative margin visually aligns the B with the "Send message" placeholder below. | |
| 1528 | + | margin-left: -9px; | |
| 1529 | + | margin-bottom: 0.25rem; | |
| 1244 | 1530 | white-space: nowrap; | |
| 1245 | 1531 | overflow: hidden; | |
| 1246 | 1532 | } |
| ... | ... | @@ -1271,58 +1557,58 @@ div.cs-message__content { | |
| 1271 | 1557 | cursor: pointer; | |
| 1272 | 1558 | } | |
| 1273 | 1559 | ||
| 1274 | - | .cs-message:has(.cs-message__footer.reactions) { | |
| 1275 | - | padding-bottom: 0.55em; | |
| 1276 | - | } | |
| 1277 | - | ||
| 1278 | - | .cs-message__footer.reactions { | |
| 1279 | - | position: absolute; | |
| 1280 | - | bottom: -0.2em; | |
| 1281 | - | right: 0; | |
| 1560 | + | section.cs-message .cs-message__footer.reactions { | |
| 1561 | + | position: relative; | |
| 1562 | + | margin: -8px -1px -1px -1px; | |
| 1563 | + | display: flex; | |
| 1564 | + | flex-wrap: wrap; | |
| 1565 | + | gap: 2px; | |
| 1282 | 1566 | ||
| 1283 | 1567 | .cs-button.reaction { | |
| 1284 | - | padding: 0 0.2em; | |
| 1285 | - | border-color: var(--default-border-color); | |
| 1568 | + | margin: 0; | |
| 1569 | + | padding: 0 4px; | |
| 1570 | + | border-radius: 6px; | |
| 1571 | + | border: 1px solid var(--default-bg-color); | |
| 1286 | 1572 | color: var(--color-text); | |
| 1287 | - | background: color-mix(in srgb, var(--color-primary-light), transparent 35%); | |
| 1573 | + | background: var(--color-primary-light); | |
| 1288 | 1574 | width: max-content; | |
| 1289 | - | } | |
| 1575 | + | opacity: 1; | |
| 1576 | + | transition: | |
| 1577 | + | background-color 120ms ease, | |
| 1578 | + | color 120ms ease; | |
| 1579 | + | height: 22px; | |
| 1580 | + | line-height: 20px; | |
| 1581 | + | font-size: 10px; | |
| 1582 | + | display: flex; | |
| 1583 | + | align-items: center; | |
| 1584 | + | gap: 4px; | |
| 1290 | 1585 | ||
| 1291 | - | .cs-button.reaction.mine { | |
| 1292 | - | color: var(--default-bg-color); | |
| 1293 | - | background: color-mix(in srgb, var(--color-primary-dark), transparent 35%); | |
| 1294 | - | } | |
| 1586 | + | > span { | |
| 1587 | + | font-size: 16px; | |
| 1588 | + | } | |
| 1295 | 1589 | ||
| 1296 | - | .cs-button.reaction img { | |
| 1297 | - | max-height: 1rem; | |
| 1298 | - | } | |
| 1299 | - | } | |
| 1590 | + | img { | |
| 1591 | + | max-height: 1rem; | |
| 1592 | + | } | |
| 1300 | 1593 | ||
| 1301 | - | .cs-message.cs-message--single:has(.cs-message__footer.reactions), | |
| 1302 | - | .cs-message.cs-message--last:has(.cs-message__footer.reactions) { | |
| 1303 | - | padding-bottom: 0em; | |
| 1594 | + | &.mine, | |
| 1595 | + | &:hover, | |
| 1596 | + | &:focus-visible { | |
| 1597 | + | background: var(--color-secondary-dark); | |
| 1598 | + | color: var(--color-on-secondary); | |
| 1599 | + | } | |
| 1304 | 1600 | ||
| 1305 | - | .cs-message__footer.reactions { | |
| 1306 | - | bottom: -0.6em; | |
| 1601 | + | &.mine:hover, | |
| 1602 | + | &.mine:focus-visible { | |
| 1603 | + | color: var(--color-text); | |
| 1604 | + | background: $color-primary; | |
| 1605 | + | } | |
| 1307 | 1606 | } | |
| 1308 | 1607 | } | |
| 1309 | 1608 | ||
| 1310 | - | .cs-message--outgoing .cs-message__footer.reactions { | |
| 1311 | - | .cs-button.reaction { | |
| 1312 | - | background: color-mix( | |
| 1313 | - | in srgb, | |
| 1314 | - | var(--color-secondary-light), | |
| 1315 | - | transparent 35% | |
| 1316 | - | ); | |
| 1317 | - | } | |
| 1318 | - | ||
| 1319 | - | .cs-button.reaction.mine { | |
| 1320 | - | background: color-mix( | |
| 1321 | - | in srgb, | |
| 1322 | - | var(--color-secondary-dark), | |
| 1323 | - | transparent 35% | |
| 1324 | - | ); | |
| 1325 | - | } | |
| 1609 | + | .cs-message-group--outgoing section.cs-message .cs-message__footer.reactions, | |
| 1610 | + | section.cs-message--outgoing .cs-message__footer.reactions { | |
| 1611 | + | justify-content: flex-end; | |
| 1326 | 1612 | } | |
| 1327 | 1613 | ||
| 1328 | 1614 | img.thread { |
| ... | ... | @@ -1351,26 +1637,56 @@ img.thread { | |
| 1351 | 1637 | } | |
| 1352 | 1638 | ||
| 1353 | 1639 | .cs-message__custom-content { | |
| 1354 | - | .meta { | |
| 1355 | - | line-height: 1.3; | |
| 1640 | + | .message-timed-text { | |
| 1641 | + | position: relative; | |
| 1356 | 1642 | ||
| 1357 | - | img.thread { | |
| 1358 | - | float: right; | |
| 1359 | - | margin-top: 0.25em; | |
| 1360 | - | margin-left: 0.5em; | |
| 1643 | + | &::after { | |
| 1644 | + | content: attr(data-time); | |
| 1645 | + | display: inline-block; | |
| 1646 | + | visibility: hidden; | |
| 1647 | + | padding-right: calc(var(--message-status-count, 0) * 1.5em); | |
| 1361 | 1648 | } | |
| 1362 | 1649 | ||
| 1363 | - | time, | |
| 1364 | - | svg { | |
| 1365 | - | font-size: 0.8em; | |
| 1366 | - | opacity: 0.6; | |
| 1650 | + | > .message-time { | |
| 1651 | + | position: absolute; | |
| 1652 | + | right: 0; | |
| 1653 | + | bottom: 0; | |
| 1367 | 1654 | } | |
| 1655 | + | } | |
| 1368 | 1656 | ||
| 1369 | - | svg { | |
| 1370 | - | padding-left: 0.5em; | |
| 1657 | + | .message-timed-text::after, | |
| 1658 | + | .message-time { | |
| 1659 | + | font-size: 0.75rem; | |
| 1660 | + | font-weight: normal; | |
| 1661 | + | font-style: normal; | |
| 1662 | + | white-space: nowrap; | |
| 1663 | + | padding-left: 0.75em; | |
| 1664 | + | line-height: 1.5; | |
| 1665 | + | } | |
| 1666 | + | ||
| 1667 | + | .message-time { | |
| 1668 | + | display: inline-flex; | |
| 1669 | + | align-items: center; | |
| 1670 | + | ||
| 1671 | + | .message-badge { | |
| 1672 | + | width: 1.5em; | |
| 1673 | + | color: inherit; | |
| 1674 | + | ||
| 1675 | + | svg { | |
| 1676 | + | font-size: 1em; | |
| 1677 | + | } | |
| 1678 | + | } | |
| 1679 | + | ||
| 1680 | + | > :not(:has(.thread)) { | |
| 1681 | + | color: color-mix(in srgb, currentColor 60%, transparent); | |
| 1371 | 1682 | } | |
| 1372 | 1683 | } | |
| 1373 | 1684 | ||
| 1685 | + | .message-time-row { | |
| 1686 | + | display: block; | |
| 1687 | + | text-align: right; | |
| 1688 | + | } | |
| 1689 | + | ||
| 1374 | 1690 | .action { | |
| 1375 | 1691 | font-style: italic; | |
| 1376 | 1692 | &:before { |
| ... | ... | @@ -1383,8 +1699,15 @@ img.thread { | |
| 1383 | 1699 | } | |
| 1384 | 1700 | } | |
| 1385 | 1701 | ||
| 1386 | - | .cs-message__html-content:has(.action) ~ .meta .sender { | |
| 1387 | - | display: none; | |
| 1702 | + | div:has(> .cs-message__html-content .action) > .message-heading { | |
| 1703 | + | .sender, | |
| 1704 | + | .subject-separator { | |
| 1705 | + | display: none; | |
| 1706 | + | } | |
| 1707 | + | } | |
| 1708 | + | ||
| 1709 | + | .message-heading { | |
| 1710 | + | font-weight: 500; | |
| 1388 | 1711 | } | |
| 1389 | 1712 | ||
| 1390 | 1713 | .h-card.sender { |
| ... | ... | @@ -1392,9 +1715,68 @@ img.thread { | |
| 1392 | 1715 | } | |
| 1393 | 1716 | } | |
| 1394 | 1717 | ||
| 1718 | + | .back-in-time .cs-message__custom-content { | |
| 1719 | + | .message-timed-text::after, | |
| 1720 | + | .message-time > time { | |
| 1721 | + | font-weight: bold; | |
| 1722 | + | } | |
| 1723 | + | } | |
| 1724 | + | ||
| 1395 | 1725 | section.cs-message { | |
| 1396 | 1726 | overflow: visible; | |
| 1397 | 1727 | position: relative; | |
| 1728 | + | max-width: 100%; | |
| 1729 | + | ||
| 1730 | + | button.cs-button:has(+ .u-in-reply-to) { | |
| 1731 | + | padding: 0; | |
| 1732 | + | color: inherit; | |
| 1733 | + | } | |
| 1734 | + | ||
| 1735 | + | .cs-message__content { | |
| 1736 | + | position: relative; | |
| 1737 | + | } | |
| 1738 | + | ||
| 1739 | + | .message-badge { | |
| 1740 | + | display: flex; | |
| 1741 | + | align-items: center; | |
| 1742 | + | justify-content: center; | |
| 1743 | + | font: inherit; | |
| 1744 | + | color: var(--color-text-disabled); | |
| 1745 | + | padding: 0; | |
| 1746 | + | border: 0; | |
| 1747 | + | background: transparent; | |
| 1748 | + | ||
| 1749 | + | svg { | |
| 1750 | + | font-size: 0.75em; | |
| 1751 | + | } | |
| 1752 | + | ||
| 1753 | + | img { | |
| 1754 | + | height: 0.75em; | |
| 1755 | + | object-fit: contain; | |
| 1756 | + | } | |
| 1757 | + | } | |
| 1758 | + | ||
| 1759 | + | button.message-badge { | |
| 1760 | + | cursor: pointer; | |
| 1761 | + | } | |
| 1762 | + | ||
| 1763 | + | .cs-message__custom-content a { | |
| 1764 | + | color: var(--color-primary-dark); | |
| 1765 | + | text-decoration: underline; | |
| 1766 | + | text-underline-offset: 0.15em; | |
| 1767 | + | text-decoration-thickness: 1px; | |
| 1768 | + | text-decoration-color: color-mix(in srgb, currentColor 30%, transparent); | |
| 1769 | + | transition: text-decoration-color 250ms ease; | |
| 1770 | + | ||
| 1771 | + | &:hover, | |
| 1772 | + | &:focus-visible { | |
| 1773 | + | text-decoration-color: currentColor; | |
| 1774 | + | } | |
| 1775 | + | } | |
| 1776 | + | ||
| 1777 | + | &.cs-message--outgoing .cs-message__custom-content a { | |
| 1778 | + | color: var(--message-outgoing-color); | |
| 1779 | + | } | |
| 1398 | 1780 | ||
| 1399 | 1781 | .cs-message__header { | |
| 1400 | 1782 | opacity: 0; |
| ... | ... | @@ -1417,12 +1799,11 @@ section.cs-message { | |
| 1417 | 1799 | content: "Private invite only to you"; | |
| 1418 | 1800 | font-style: italic; | |
| 1419 | 1801 | opacity: 0.9; | |
| 1420 | - | text-size: 0.9em; | |
| 1421 | 1802 | color: var(--color-primary-dark); | |
| 1422 | 1803 | } | |
| 1423 | 1804 | ||
| 1424 | 1805 | &.highlight .cs-message__content { | |
| 1425 | - | border: 3px solid var(--color-primary-dark); | |
| 1806 | + | border: 3px solid var(--accent-surface, var(--color-primary-dark)); | |
| 1426 | 1807 | } | |
| 1427 | 1808 | ||
| 1428 | 1809 | &.cs-message--incoming { |
| ... | ... | @@ -1472,38 +1852,29 @@ section.cs-message { | |
| 1472 | 1852 | ||
| 1473 | 1853 | .embed-responsive { | |
| 1474 | 1854 | position: relative; | |
| 1475 | - | display: block; | |
| 1476 | - | width: 100%; | |
| 1855 | + | aspect-ratio: 4 / 3; | |
| 1477 | 1856 | overflow: hidden; | |
| 1478 | - | padding: 0; | |
| 1479 | - | ||
| 1480 | - | &::before { | |
| 1481 | - | content: ""; | |
| 1482 | - | display: block; | |
| 1483 | - | padding-top: 75%; | |
| 1484 | - | } | |
| 1485 | 1857 | ||
| 1486 | 1858 | video { | |
| 1487 | 1859 | position: absolute; | |
| 1488 | - | top: 0; | |
| 1489 | - | bottom: 0; | |
| 1490 | - | left: 0; | |
| 1860 | + | inset: 0; | |
| 1491 | 1861 | width: 100%; | |
| 1492 | 1862 | height: 100%; | |
| 1493 | 1863 | } | |
| 1494 | 1864 | } | |
| 1495 | 1865 | ||
| 1496 | - | .h-card { | |
| 1866 | + | .h-card, | |
| 1867 | + | .call-account { | |
| 1497 | 1868 | display: flex; | |
| 1498 | 1869 | align-items: center; | |
| 1499 | 1870 | justify-content: center; | |
| 1871 | + | } | |
| 1872 | + | ||
| 1873 | + | .h-card { | |
| 1500 | 1874 | margin-top: 1.5em; | |
| 1501 | 1875 | } | |
| 1502 | 1876 | ||
| 1503 | 1877 | .call-account { | |
| 1504 | - | display: flex; | |
| 1505 | - | align-items: center; | |
| 1506 | - | justify-content: center; | |
| 1507 | 1878 | gap: 0.5em; | |
| 1508 | 1879 | font-size: 0.85em; | |
| 1509 | 1880 | line-height: 1; |
| ... | ... | @@ -1531,17 +1902,24 @@ section.cs-message { | |
| 1531 | 1902 | width: 100%; | |
| 1532 | 1903 | text-align: left; | |
| 1533 | 1904 | border-radius: 0; | |
| 1534 | - | border-bottom: 1px solid #ccc; | |
| 1905 | + | border-bottom: 1px solid var(--divider-color); | |
| 1535 | 1906 | margin-bottom: 0.5em; | |
| 1536 | 1907 | padding: 0.2em 0; | |
| 1537 | 1908 | line-height: 1; | |
| 1538 | 1909 | gap: 0.5em; | |
| 1539 | 1910 | } | |
| 1540 | 1911 | ||
| 1541 | - | a.u-email::before { | |
| 1912 | + | a.u-email::before, | |
| 1913 | + | a.u-tel::before, | |
| 1914 | + | a.u-url::before, | |
| 1915 | + | a.u-impp::before, | |
| 1916 | + | .p-org::before, | |
| 1917 | + | .p-pronouns::before, | |
| 1918 | + | .p-tz::before, | |
| 1919 | + | time::before, | |
| 1920 | + | .dt-bday::before { | |
| 1542 | 1921 | content: ""; | |
| 1543 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/envelope.svg) no-repeat | |
| 1544 | - | center; | |
| 1922 | + | mask: none no-repeat center; | |
| 1545 | 1923 | background: var(--color-text); | |
| 1546 | 1924 | height: 1em; | |
| 1547 | 1925 | width: 1em; |
| ... | ... | @@ -1549,98 +1927,43 @@ section.cs-message { | |
| 1549 | 1927 | flex-shrink: 0; | |
| 1550 | 1928 | } | |
| 1551 | 1929 | ||
| 1930 | + | a.u-email::before { | |
| 1931 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/envelope.svg); | |
| 1932 | + | } | |
| 1933 | + | ||
| 1552 | 1934 | a.u-tel::before { | |
| 1553 | - | content: ""; | |
| 1554 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/phone.svg) no-repeat | |
| 1555 | - | center; | |
| 1556 | - | background: var(--color-text); | |
| 1557 | - | height: 1em; | |
| 1558 | - | width: 1em; | |
| 1559 | - | display: block; | |
| 1560 | - | flex-shrink: 0; | |
| 1935 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/phone.svg); | |
| 1561 | 1936 | } | |
| 1562 | 1937 | ||
| 1563 | 1938 | a.u-url::before { | |
| 1564 | - | content: ""; | |
| 1565 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/link.svg) no-repeat | |
| 1566 | - | center; | |
| 1567 | - | background: var(--color-text); | |
| 1568 | - | height: 1em; | |
| 1569 | - | width: 1em; | |
| 1570 | - | display: block; | |
| 1571 | - | flex-shrink: 0; | |
| 1939 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/link.svg); | |
| 1572 | 1940 | } | |
| 1573 | 1941 | ||
| 1574 | 1942 | a.u-impp::before { | |
| 1575 | - | content: ""; | |
| 1576 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/message.svg) no-repeat | |
| 1577 | - | center; | |
| 1578 | - | background: var(--color-text); | |
| 1579 | - | height: 1em; | |
| 1580 | - | width: 1em; | |
| 1581 | - | display: block; | |
| 1582 | - | flex-shrink: 0; | |
| 1943 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/message.svg); | |
| 1583 | 1944 | } | |
| 1584 | 1945 | ||
| 1585 | 1946 | .p-org::before { | |
| 1586 | - | content: ""; | |
| 1587 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/building.svg) no-repeat | |
| 1588 | - | center; | |
| 1589 | - | background: var(--color-text); | |
| 1590 | - | height: 1em; | |
| 1591 | - | width: 1em; | |
| 1592 | - | display: block; | |
| 1593 | - | flex-shrink: 0; | |
| 1947 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/building.svg); | |
| 1594 | 1948 | } | |
| 1595 | 1949 | ||
| 1596 | 1950 | .p-pronouns::before { | |
| 1597 | - | content: ""; | |
| 1598 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/genderless.svg) no-repeat | |
| 1599 | - | center; | |
| 1600 | - | background: var(--color-text); | |
| 1601 | - | height: 1em; | |
| 1602 | - | width: 1em; | |
| 1603 | - | display: block; | |
| 1604 | - | flex-shrink: 0; | |
| 1951 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/genderless.svg); | |
| 1605 | 1952 | } | |
| 1606 | 1953 | ||
| 1607 | 1954 | .p-tz::before { | |
| 1608 | - | content: ""; | |
| 1609 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/user-clock.svg) no-repeat | |
| 1610 | - | center; | |
| 1611 | - | background: var(--color-text); | |
| 1612 | - | height: 1em; | |
| 1613 | - | width: 1em; | |
| 1614 | - | display: block; | |
| 1615 | - | flex-shrink: 0; | |
| 1955 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/user-clock.svg); | |
| 1616 | 1956 | } | |
| 1617 | 1957 | ||
| 1618 | 1958 | time::before { | |
| 1619 | - | content: ""; | |
| 1620 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/calendar.svg) no-repeat | |
| 1621 | - | center; | |
| 1622 | - | background: var(--color-text); | |
| 1623 | - | height: 1em; | |
| 1624 | - | width: 1em; | |
| 1625 | - | display: block; | |
| 1626 | - | flex-shrink: 0; | |
| 1959 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/calendar.svg); | |
| 1627 | 1960 | } | |
| 1628 | 1961 | ||
| 1629 | 1962 | .dt-bday::before { | |
| 1630 | - | content: ""; | |
| 1631 | - | mask: url(@fortawesome/fontawesome-free/svgs/solid/cake-candles.svg) | |
| 1632 | - | no-repeat center; | |
| 1633 | - | background: var(--color-text); | |
| 1634 | - | height: 1em; | |
| 1635 | - | width: 1em; | |
| 1636 | - | display: block; | |
| 1637 | - | flex-shrink: 0; | |
| 1638 | - | } | |
| 1639 | - | ||
| 1640 | - | a.u-url[href^="https://www.patreon.com/c/"]::before { | |
| 1641 | - | mask-image: url(@fortawesome/fontawesome-free/svgs/brands/patreon.svg); | |
| 1963 | + | mask-image: url(@fortawesome/fontawesome-free/svgs/solid/cake-candles.svg); | |
| 1642 | 1964 | } | |
| 1643 | 1965 | ||
| 1966 | + | a.u-url[href^="https://www.patreon.com/c/"]::before, | |
| 1644 | 1967 | a.u-url[href^="https://patreon.com/c/"]::before { | |
| 1645 | 1968 | mask-image: url(@fortawesome/fontawesome-free/svgs/brands/patreon.svg); | |
| 1646 | 1969 | } |
| ... | ... | @@ -1718,6 +2041,17 @@ button.MuiFab-root { | |
| 1718 | 2041 | } | |
| 1719 | 2042 | ||
| 1720 | 2043 | @media (max-width: 576px) { | |
| 2044 | + | .cs-main-container { | |
| 2045 | + | --chat-avatar-size: 28px; | |
| 2046 | + | ||
| 2047 | + | .cs-avatar.cs-avatar--md { | |
| 2048 | + | width: var(--chat-avatar-size); | |
| 2049 | + | height: var(--chat-avatar-size); | |
| 2050 | + | min-width: var(--chat-avatar-size); | |
| 2051 | + | min-height: var(--chat-avatar-size); | |
| 2052 | + | } | |
| 2053 | + | } | |
| 2054 | + | ||
| 1721 | 2055 | .cs-main-container--responsive { | |
| 1722 | 2056 | .cs-sidebar .cs-search { | |
| 1723 | 2057 | display: flex; |
| ... | ... | @@ -1734,12 +2069,14 @@ button.MuiFab-root { | |
| 1734 | 2069 | } | |
| 1735 | 2070 | } | |
| 1736 | 2071 | ||
| 1737 | - | #account-nav:has(~ .cs-main-container) { | |
| 2072 | + | #account-nav:has(~ main > .cs-main-container) { | |
| 1738 | 2073 | display: none; | |
| 1739 | 2074 | } | |
| 1740 | 2075 | ||
| 1741 | - | #account-nav:has(~ .cs-main-container > .cs-sidebar--left.active), | |
| 1742 | - | #account-nav:has(~ .cs-main-container > .active > .cs-message-list.account) { | |
| 2076 | + | #account-nav:has(~ main > .cs-main-container > .cs-sidebar--left.active), | |
| 2077 | + | #account-nav:has( | |
| 2078 | + | ~ main > .cs-main-container > .active > .cs-message-list.account | |
| 2079 | + | ) { | |
| 1743 | 2080 | display: flex; | |
| 1744 | 2081 | } | |
| 1745 | 2082 | } |
| ... | ... | @@ -1759,17 +2096,102 @@ button.MuiFab-root { | |
| 1759 | 2096 | } | |
| 1760 | 2097 | } | |
| 1761 | 2098 | ||
| 2099 | + | .cs-main-container { | |
| 2100 | + | border: 0; | |
| 2101 | + | ||
| 2102 | + | &.page { | |
| 2103 | + | flex: 1; | |
| 2104 | + | min-height: 0; | |
| 2105 | + | ||
| 2106 | + | .page-back { | |
| 2107 | + | display: none; | |
| 2108 | + | font-size: $conversation-header-font-size; | |
| 2109 | + | padding: 0; | |
| 2110 | + | @media (max-width: 576px) { | |
| 2111 | + | display: inline-flex; | |
| 2112 | + | } | |
| 2113 | + | } | |
| 2114 | + | ||
| 2115 | + | > section { | |
| 2116 | + | margin: 0 auto; | |
| 2117 | + | max-width: 100%; | |
| 2118 | + | overflow: auto; | |
| 2119 | + | scrollbar-gutter: stable; | |
| 2120 | + | padding: 1em 2em; | |
| 2121 | + | ||
| 2122 | + | &:has(> .settings-appearance) { | |
| 2123 | + | width: 40rem; | |
| 2124 | + | } | |
| 2125 | + | } | |
| 2126 | + | } | |
| 2127 | + | ||
| 2128 | + | &.tauri { | |
| 2129 | + | flex: 1; | |
| 2130 | + | min-height: 0; | |
| 2131 | + | height: auto; | |
| 2132 | + | border-radius: $default-border-radius; | |
| 2133 | + | border-bottom-right-radius: 13px; | |
| 2134 | + | overflow: hidden; | |
| 2135 | + | box-shadow: 0 0 6px rgba(0, 0, 0, 0.3); | |
| 2136 | + | } | |
| 2137 | + | } | |
| 2138 | + | ||
| 2139 | + | main:has(> .cs-main-container.tauri) { | |
| 2140 | + | padding: 0.35em 0.35em 0.35em 0; | |
| 2141 | + | } | |
| 2142 | + | ||
| 2143 | + | #account-nav:has(~ main > .cs-main-container.tauri) { | |
| 2144 | + | isolation: auto; | |
| 2145 | + | box-shadow: none; | |
| 2146 | + | ||
| 2147 | + | .active-account, | |
| 2148 | + | > a.active { | |
| 2149 | + | z-index: 1; | |
| 2150 | + | } | |
| 2151 | + | ||
| 2152 | + | > .active-account:first-child::after { | |
| 2153 | + | background-image: radial-gradient( | |
| 2154 | + | circle at bottom left, | |
| 2155 | + | transparent 70%, | |
| 2156 | + | var(--default-bg-color) 72% | |
| 2157 | + | ); | |
| 2158 | + | background-position: bottom; | |
| 2159 | + | } | |
| 2160 | + | } | |
| 2161 | + | ||
| 2162 | + | #account-nav:has(> .active-account:first-child) | |
| 2163 | + | ~ main | |
| 2164 | + | > .cs-main-container.tauri { | |
| 2165 | + | border-top-left-radius: 0; | |
| 2166 | + | } | |
| 2167 | + | ||
| 1762 | 2168 | #account-nav { | |
| 1763 | - | background: var(--color-primary-dark) url(/gloop01.svg) no-repeat; | |
| 1764 | - | background-size: 40vh; | |
| 2169 | + | flex: 0 0 5.5em; | |
| 2170 | + | width: 5.5em; | |
| 2171 | + | padding-block: 0.35em; | |
| 2172 | + | isolation: isolate; | |
| 2173 | + | overflow: hidden; | |
| 2174 | + | box-shadow: inset -12px 0 12px -8px rgba(0, 0, 0, 0.2); | |
| 1765 | 2175 | display: flex; | |
| 1766 | 2176 | flex-direction: column; | |
| 2177 | + | gap: 0.35em; | |
| 2178 | + | ||
| 2179 | + | .account-nav-group { | |
| 2180 | + | position: relative; | |
| 2181 | + | margin-left: 0.35em; | |
| 2182 | + | padding: 0.35em 0; | |
| 2183 | + | display: flex; | |
| 2184 | + | flex-direction: column; | |
| 2185 | + | gap: 0.35em; | |
| 2186 | + | } | |
| 1767 | 2187 | ||
| 1768 | - | > a { | |
| 2188 | + | > a, | |
| 2189 | + | .account-nav-group > a { | |
| 1769 | 2190 | position: relative; | |
| 1770 | 2191 | display: block; | |
| 2192 | + | margin-left: 0.35em; | |
| 1771 | 2193 | padding: 0.5em; | |
| 1772 | - | color: white; | |
| 2194 | + | color: inherit; | |
| 1773 | 2195 | text-decoration: none; | |
| 1774 | 2196 | ||
| 1775 | 2197 | .cs-avatar { |
| ... | ... | @@ -1803,9 +2225,62 @@ button.MuiFab-root { | |
| 1803 | 2225 | } | |
| 1804 | 2226 | } | |
| 1805 | 2227 | ||
| 1806 | - | a.active { | |
| 1807 | - | background: $color-primary-light; | |
| 1808 | - | color: $color-primary-dark; | |
| 2228 | + | color: var(--color-on-app); | |
| 2229 | + | ||
| 2230 | + | .account-nav-group > a { | |
| 2231 | + | margin: 0 0.35em; | |
| 2232 | + | } | |
| 2233 | + | ||
| 2234 | + | .account-nav-group .cs-avatar { | |
| 2235 | + | border: 2px solid var(--color-on-app); | |
| 2236 | + | } | |
| 2237 | + | ||
| 2238 | + | .active-account > a.active { | |
| 2239 | + | border-radius: $default-border-radius; | |
| 2240 | + | background: $conversation-activated-bg-color; | |
| 2241 | + | } | |
| 2242 | + | ||
| 2243 | + | .active-account::after, | |
| 2244 | + | > a.active::after { | |
| 2245 | + | content: ""; | |
| 2246 | + | position: absolute; | |
| 2247 | + | right: 0; | |
| 2248 | + | top: -$default-border-radius; | |
| 2249 | + | bottom: -$default-border-radius; | |
| 2250 | + | width: $default-border-radius; | |
| 2251 | + | background: | |
| 2252 | + | radial-gradient( | |
| 2253 | + | circle at top left, | |
| 2254 | + | transparent 70%, | |
| 2255 | + | var(--default-bg-color) 72% | |
| 2256 | + | ) | |
| 2257 | + | top, | |
| 2258 | + | radial-gradient( | |
| 2259 | + | circle at bottom left, | |
| 2260 | + | transparent 70%, | |
| 2261 | + | var(--default-bg-color) 72% | |
| 2262 | + | ) | |
| 2263 | + | bottom; | |
| 2264 | + | background-size: 100% $default-border-radius; | |
| 2265 | + | background-repeat: no-repeat; | |
| 2266 | + | pointer-events: none; | |
| 2267 | + | } | |
| 2268 | + | ||
| 2269 | + | .active-account, | |
| 2270 | + | > a.active { | |
| 2271 | + | border-radius: $default-border-radius 0 0 $default-border-radius; | |
| 2272 | + | background: var(--default-bg-color); | |
| 2273 | + | color: var(--color-primary-dark); | |
| 2274 | + | ||
| 2275 | + | &::before { | |
| 2276 | + | content: ""; | |
| 2277 | + | position: absolute; | |
| 2278 | + | inset: 0; | |
| 2279 | + | border-radius: inherit; | |
| 2280 | + | z-index: -1; | |
| 2281 | + | box-shadow: 0 0 6px rgba(0, 0, 0, 0.3); | |
| 2282 | + | pointer-events: none; | |
| 2283 | + | } | |
| 1809 | 2284 | } | |
| 1810 | 2285 | } | |
| 1811 | 2286 |
| ... | ... | @@ -1873,6 +2348,12 @@ em-emoji-picker { | |
| 1873 | 2348 | } | |
| 1874 | 2349 | } | |
| 1875 | 2350 | ||
| 2351 | + | .message-attachments .message-attachment-media { | |
| 2352 | + | max-height: 15em; | |
| 2353 | + | max-width: min(100%, 35em); | |
| 2354 | + | object-fit: scale-down; | |
| 2355 | + | } | |
| 2356 | + | ||
| 1876 | 2357 | .message-attachments-toggle { | |
| 1877 | 2358 | display: inline-flex; | |
| 1878 | 2359 | align-items: center; |
| ... | ... | @@ -1889,3 +2371,33 @@ em-emoji-picker { | |
| 1889 | 2371 | font-size: 0.75em; | |
| 1890 | 2372 | } | |
| 1891 | 2373 | } | |
| 2374 | + | ||
| 2375 | + | .settings-appearance { | |
| 2376 | + | > .MuiFormControl-root { | |
| 2377 | + | margin-bottom: 1em; | |
| 2378 | + | } | |
| 2379 | + | ||
| 2380 | + | display: flex; | |
| 2381 | + | flex-direction: column; | |
| 2382 | + | gap: 1em; | |
| 2383 | + | margin-top: 2em; | |
| 2384 | + | padding-top: 1em; | |
| 2385 | + | border-top: 1px solid var(--divider-color); | |
| 2386 | + | ||
| 2387 | + | h2 { | |
| 2388 | + | margin: 0; | |
| 2389 | + | } | |
| 2390 | + | ||
| 2391 | + | .theme-colour { | |
| 2392 | + | display: flex; | |
| 2393 | + | align-items: flex-start; | |
| 2394 | + | gap: 0.75em; | |
| 2395 | + | ||
| 2396 | + | input[type="color"] { | |
| 2397 | + | flex-shrink: 0; | |
| 2398 | + | width: 2.5em; | |
| 2399 | + | height: 2.5em; | |
| 2400 | + | cursor: pointer; | |
| 2401 | + | } | |
| 2402 | + | } | |
| 2403 | + | } |
+25
-1
src/App.tsx
#
| ... | ... | @@ -1,6 +1,12 @@ | |
| 1 | + | import { | |
| 2 | + | applyTheme, | |
| 3 | + | defaultCustomPalette, | |
| 4 | + | defaultTheme, | |
| 5 | + | type Theme, | |
| 6 | + | } from "./theme"; | |
| 1 | 7 | import { assertNever } from "./assert-never"; | |
| 2 | 8 | import "./App.scss"; | |
| 3 | - | import { CircularProgress } from "@mui/material"; | |
| 9 | + | import { CircularProgress, useColorScheme } from "@mui/material"; | |
| 4 | 10 | import { newAccount } from "./components/Login"; | |
| 5 | 11 | import { Suspense, useEffect, useState } from "react"; | |
| 6 | 12 | import * as borogove from "borogove"; |
| ... | ... | @@ -83,6 +89,13 @@ const AppInner = () => { | |
| 83 | 89 | }; | |
| 84 | 90 | const [accounts, setAccounts] = useState(initialAccounts); | |
| 85 | 91 | const [settings, setSettings] = useState<SettingsData>(initialSettings); | |
| 92 | + | const { setMode } = useColorScheme(); | |
| 93 | + | useEffect(() => { | |
| 94 | + | setMode(settings.appearance); | |
| 95 | + | }, [setMode, settings.appearance]); | |
| 96 | + | useEffect(() => { | |
| 97 | + | applyTheme(settings.theme, settings.customPalette); | |
| 98 | + | }, [settings.theme, settings.customPalette]); | |
| 86 | 99 | const params = useParams(); | |
| 87 | 100 | const { showNotification, onNotificationClick, onNotificationClose } = | |
| 88 | 101 | useNotifications(); |
| ... | ... | @@ -242,12 +255,23 @@ const initialP = (async () => { | |
| 242 | 255 | const accountIds = await persistence.listAccounts(); | |
| 243 | 256 | const initialSelectedAccount = | |
| 244 | 257 | (await persistence.get("ui#selectedAccount")) || accountIds[0]; | |
| 258 | + | const appearance = await persistence.get("config#appearance"); | |
| 259 | + | const savedTheme = (await persistence.get( | |
| 260 | + | "config#themePreset", | |
| 261 | + | )) as Theme | null; | |
| 262 | + | const savedCustomPalette = await persistence.get("config#customPalette"); | |
| 245 | 263 | return { | |
| 246 | 264 | initialAccounts: Object.fromEntries( | |
| 247 | 265 | accountIds.map((id: string) => [id, newAccount(id, idbp, persistence)]), | |
| 248 | 266 | ), | |
| 249 | 267 | initialSelectedAccount, | |
| 250 | 268 | initialSettings: { | |
| 269 | + | theme: savedTheme ?? defaultTheme, | |
| 270 | + | customPalette: savedCustomPalette | |
| 271 | + | ? JSON.parse(savedCustomPalette) | |
| 272 | + | : defaultCustomPalette, | |
| 273 | + | appearance: | |
| 274 | + | appearance === "light" || appearance === "dark" ? appearance : "system", | |
| 251 | 275 | enterIsSend: | |
| 252 | 276 | "" + (await persistence.get("config#enterIsSend")) !== "false", | |
| 253 | 277 | richTextToolbar: |
+3
-2
src/components/About.tsx
#
+10
-4
src/components/Accounts.tsx
#
| ... | ... | @@ -8,7 +8,7 @@ import { | |
| 8 | 8 | useParams, | |
| 9 | 9 | useNavigate, | |
| 10 | 10 | } from "react-router"; | |
| 11 | - | import { Fragment, useContext, useEffect, useState } from "react"; | |
| 11 | + | import { useContext, useEffect, useState } from "react"; | |
| 12 | 12 | import { useHotkeys } from "react-hotkeys-hook"; | |
| 13 | 13 | import { Context } from "../App"; | |
| 14 | 14 | import { AvatarWithPlaceholder } from "./AvatarWithPlaceholder"; |
| ... | ... | @@ -231,8 +231,14 @@ export const Accounts = () => { | |
| 231 | 231 | const client = accounts[accountId].client; | |
| 232 | 232 | const selfChat = client.getChat(accountId); | |
| 233 | 233 | return ( | |
| 234 | - | <Fragment key={`account-${accountId}`}> | |
| 235 | - | <NavLink to={href("/accounts/:accountId", { accountId })}> | |
| 234 | + | <div | |
| 235 | + | key={`account-${accountId}`} | |
| 236 | + | className={ | |
| 237 | + | "account-nav-group" + | |
| 238 | + | (params.accountId === accountId ? " active-account" : "") | |
| 239 | + | } | |
| 240 | + | > | |
| 241 | + | <NavLink end to={href("/accounts/:accountId", { accountId })}> | |
| 236 | 242 | <AvatarWithPlaceholder | |
| 237 | 243 | displayName={`Account: ${accountId}`} | |
| 238 | 244 | placeholderUri={selfChat?.getPlaceholder()} |
+141
-0
src/components/AppearanceSettings.tsx
#
| ... | ... | @@ -0,0 +1,141 @@ | |
| 1 | + | import type { persistence } from "borogove"; | |
| 2 | + | import { useState } from "react"; | |
| 3 | + | import { contrast, themePresets, type Palette, type Theme } from "../theme"; | |
| 4 | + | import type { SettingsData } from "./Settings"; | |
| 5 | + | import { | |
| 6 | + | MenuItem, | |
| 7 | + | TextField, | |
| 8 | + | FormLabel, | |
| 9 | + | FormControl, | |
| 10 | + | RadioGroup, | |
| 11 | + | Radio, | |
| 12 | + | FormControlLabel, | |
| 13 | + | useColorScheme, | |
| 14 | + | } from "@mui/material"; | |
| 15 | + | import { capitalize } from "@mui/material/utils"; | |
| 16 | + | ||
| 17 | + | const colourRoles = ["background", "text", "primary", "secondary"] as const; | |
| 18 | + | ||
| 19 | + | function ColourField({ | |
| 20 | + | role, | |
| 21 | + | value, | |
| 22 | + | onChange, | |
| 23 | + | }: { | |
| 24 | + | role: keyof Palette; | |
| 25 | + | value: string; | |
| 26 | + | onChange: (value: string) => void; | |
| 27 | + | }) { | |
| 28 | + | const [draft, setDraft] = useState(value); | |
| 29 | + | const isColour = (value: string) => /^#[\da-f]{6}$/i.test(value); | |
| 30 | + | const change = (value: string) => { | |
| 31 | + | setDraft(value); | |
| 32 | + | if (isColour(value.trim())) onChange(value.trim()); | |
| 33 | + | }; | |
| 34 | + | const invalid = !isColour(draft.trim()); | |
| 35 | + | return ( | |
| 36 | + | <div className="theme-colour"> | |
| 37 | + | <TextField | |
| 38 | + | fullWidth | |
| 39 | + | size="small" | |
| 40 | + | label={`${capitalize(role)} colour`} | |
| 41 | + | value={draft} | |
| 42 | + | error={invalid} | |
| 43 | + | helperText={invalid ? "Use a six-digit hex colour." : undefined} | |
| 44 | + | onChange={(event) => change(event.target.value)} | |
| 45 | + | /> | |
| 46 | + | <input | |
| 47 | + | type="color" | |
| 48 | + | aria-label={`Choose ${role} colour`} | |
| 49 | + | value={value} | |
| 50 | + | onChange={(event) => change(event.target.value)} | |
| 51 | + | /> | |
| 52 | + | </div> | |
| 53 | + | ); | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | export function AppearanceSettings({ | |
| 57 | + | settings, | |
| 58 | + | setSettings, | |
| 59 | + | persistence, | |
| 60 | + | }: { | |
| 61 | + | settings: SettingsData; | |
| 62 | + | setSettings: (settings: SettingsData) => void; | |
| 63 | + | persistence: persistence.KeyValueStore; | |
| 64 | + | }) { | |
| 65 | + | const { customPalette } = settings; | |
| 66 | + | const { systemMode } = useColorScheme(); | |
| 67 | + | return ( | |
| 68 | + | <section className="settings-appearance" aria-labelledby="appearance-title"> | |
| 69 | + | <h2 id="appearance-title">Appearance</h2> | |
| 70 | + | ||
| 71 | + | <FormControl> | |
| 72 | + | <FormLabel id="appearance-label">Mode</FormLabel> | |
| 73 | + | <RadioGroup | |
| 74 | + | aria-labelledby="appearance-label" | |
| 75 | + | row | |
| 76 | + | value={settings.appearance} | |
| 77 | + | onChange={(_, value) => { | |
| 78 | + | const appearance = value as SettingsData["appearance"]; | |
| 79 | + | persistence.set("config#appearance", appearance); | |
| 80 | + | setSettings({ ...settings, appearance }); | |
| 81 | + | }} | |
| 82 | + | > | |
| 83 | + | <FormControlLabel value="system" control={<Radio />} label="System" /> | |
| 84 | + | <FormControlLabel value="light" control={<Radio />} label="Light" /> | |
| 85 | + | <FormControlLabel value="dark" control={<Radio />} label="Dark" /> | |
| 86 | + | </RadioGroup> | |
| 87 | + | </FormControl> | |
| 88 | + | ||
| 89 | + | <TextField | |
| 90 | + | select | |
| 91 | + | label="Theme" | |
| 92 | + | value={settings.theme} | |
| 93 | + | onChange={(event) => { | |
| 94 | + | const theme = event.target.value as Theme; | |
| 95 | + | let palette = customPalette; | |
| 96 | + | if (theme === "custom" && settings.theme !== "custom") { | |
| 97 | + | const mode = | |
| 98 | + | settings.appearance === "system" | |
| 99 | + | ? systemMode | |
| 100 | + | : settings.appearance; | |
| 101 | + | const { background, text, primary, secondary } = | |
| 102 | + | themePresets[settings.theme][mode ?? "light"]; | |
| 103 | + | palette = { background, text, primary, secondary }; | |
| 104 | + | persistence.set("config#customPalette", JSON.stringify(palette)); | |
| 105 | + | } | |
| 106 | + | persistence.set("config#themePreset", theme); | |
| 107 | + | setSettings({ ...settings, theme, customPalette: palette }); | |
| 108 | + | }} | |
| 109 | + | > | |
| 110 | + | {Object.entries(themePresets).map(([id, preset]) => ( | |
| 111 | + | <MenuItem key={id} value={id}> | |
| 112 | + | {preset.name} | |
| 113 | + | </MenuItem> | |
| 114 | + | ))} | |
| 115 | + | <MenuItem value="custom">Custom</MenuItem> | |
| 116 | + | </TextField> | |
| 117 | + | {settings.theme === "custom" && ( | |
| 118 | + | <> | |
| 119 | + | {colourRoles.map((role) => ( | |
| 120 | + | <ColourField | |
| 121 | + | key={role} | |
| 122 | + | role={role} | |
| 123 | + | value={customPalette[role]} | |
| 124 | + | onChange={(value) => { | |
| 125 | + | const palette = { ...customPalette, [role]: value }; | |
| 126 | + | persistence.set( | |
| 127 | + | "config#customPalette", | |
| 128 | + | JSON.stringify(palette), | |
| 129 | + | ); | |
| 130 | + | setSettings({ ...settings, customPalette: palette }); | |
| 131 | + | }} | |
| 132 | + | /> | |
| 133 | + | ))} | |
| 134 | + | {contrast(customPalette.text, customPalette.background) < 4.5 && ( | |
| 135 | + | <p role="status">Text and background have low contrast.</p> | |
| 136 | + | )} | |
| 137 | + | </> | |
| 138 | + | )} | |
| 139 | + | </section> | |
| 140 | + | ); | |
| 141 | + | } |
+232
-173
src/components/Chat.tsx
#
| ... | ... | @@ -135,6 +137,23 @@ type Group = { | |
| 135 | 137 | messages: borogove.ChatMessage[]; | |
| 136 | 138 | }; | |
| 137 | 139 | ||
| 140 | + | const messageListComponents = { | |
| 141 | + | Header: () => <div className="chat-header-spacer" />, | |
| 142 | + | Footer: () => <div className="chat-composer-spacer" />, | |
| 143 | + | }; | |
| 144 | + | ||
| 145 | + | function measureScrollbarWidth(scroller: HTMLElement | null) { | |
| 146 | + | if (!scroller) return 0; | |
| 147 | + | const style = getComputedStyle(scroller); | |
| 148 | + | return Math.max( | |
| 149 | + | 0, | |
| 150 | + | scroller.offsetWidth - | |
| 151 | + | scroller.clientWidth - | |
| 152 | + | parseFloat(style.borderLeftWidth) - | |
| 153 | + | parseFloat(style.borderRightWidth), | |
| 154 | + | ); | |
| 155 | + | } | |
| 156 | + | ||
| 138 | 157 | export const ChatInner = () => { | |
| 139 | 158 | const { enterIsSend, richTextToolbar, messageRequests } = | |
| 140 | 159 | useContext(SettingsContext); |
| ... | ... | @@ -189,8 +208,13 @@ export const ChatInner = () => { | |
| 189 | 208 | const scrollTop = useRef<string | null>(null); | |
| 190 | 209 | const inputRef = useRef<QuillInner>(); | |
| 191 | 210 | const messageListContainer = useRef<HTMLDivElement | null>(null); | |
| 192 | - | const virtuosoContainer = useRef<HTMLDivElement | null>(null); | |
| 211 | + | const composerRef = useRef<HTMLDivElement | null>(null); | |
| 212 | + | const [scroller, setScroller] = useState<HTMLElement | null>(null); | |
| 213 | + | const setScrollerRef = useCallback((node: HTMLElement | Window | null) => { | |
| 214 | + | setScroller(node instanceof HTMLElement ? node : null); | |
| 215 | + | }, []); | |
| 193 | 216 | const messageList = useRef<VirtuosoHandle | null>(null); | |
| 217 | + | const headerHeight = useRef(0); | |
| 194 | 218 | const { | |
| 195 | 219 | messages: initialMessages, | |
| 196 | 220 | members: initialMembers, |
| ... | ... | @@ -235,11 +259,10 @@ export const ChatInner = () => { | |
| 235 | 259 | idx + 1 < messages.length | |
| 236 | 260 | ? ["readUpToMarker"] | |
| 237 | 261 | : []; | |
| 238 | - | // There is a group less than 5 messages from the same sender and thread not more than 2 minutes long | |
| 239 | 262 | if ( | |
| 240 | 263 | lastGroup && | |
| 241 | 264 | lastGroup !== "readUpToMarker" && | |
| 242 | - | lastGroup.messages.length < 5 && | |
| 265 | + | lastGroup.messages.length < 10 && | |
| 243 | 266 | (message.moderationReason() || | |
| 244 | 267 | lastGroup.senderId === message.senderId) && | |
| 245 | 268 | lastGroup.threadId === message.threadId && |
| ... | ... | @@ -415,7 +439,10 @@ export const ChatInner = () => { | |
| 415 | 439 | if (!messageList.current) return; | |
| 416 | 440 | ||
| 417 | 441 | if (hashIndex) { | |
| 418 | - | messageList.current.scrollToIndex({ index: hashIndex }); | |
| 442 | + | messageList.current.scrollToIndex({ | |
| 443 | + | index: hashIndex, | |
| 444 | + | offset: -headerHeight.current, | |
| 445 | + | }); | |
| 419 | 446 | } else if (messageId) { | |
| 420 | 447 | const chat = activeChat; | |
| 421 | 448 | const message = await persistence.getMessage( |
| ... | ... | @@ -937,7 +964,11 @@ export const ChatInner = () => { | |
| 937 | 964 | ); | |
| 938 | 965 | if (!typingText) return null; | |
| 939 | 966 | ||
| 940 | - | return <TypingIndicator content={typingText} />; | |
| 967 | + | return ( | |
| 968 | + | <div as={InputToolbox} className="chat-typing-overlay"> | |
| 969 | + | <TypingIndicator content={typingText} /> | |
| 970 | + | </div> | |
| 971 | + | ); | |
| 941 | 972 | }; | |
| 942 | 973 | ||
| 943 | 974 | const waitForImagesLoaded = useCallback(() => { |
| ... | ... | @@ -1051,37 +1082,61 @@ export const ChatInner = () => { | |
| 1051 | 1082 | setAtBottom(nowAtBottom); | |
| 1052 | 1083 | }; | |
| 1053 | 1084 | ||
| 1054 | - | useEffect(() => { | |
| 1055 | - | if (atBottom) { | |
| 1056 | - | (async () => { | |
| 1057 | - | await waitForImagesLoaded(); | |
| 1058 | - | setTimeout(() => { | |
| 1059 | - | console.log("XYZZY force to bottom", atBottom); | |
| 1060 | - | messageList.current?.scrollToIndex({ | |
| 1061 | - | index: Number.MAX_SAFE_INTEGER, | |
| 1062 | - | align: "end", | |
| 1063 | - | }); | |
| 1064 | - | }, 400); | |
| 1065 | - | })(); | |
| 1066 | - | } | |
| 1067 | - | }, [messages.length, atBottom, waitForImagesLoaded]); | |
| 1068 | - | ||
| 1069 | - | useEffect(() => { | |
| 1070 | - | const container = virtuosoContainer.current; | |
| 1071 | - | if (!container) return; | |
| 1072 | - | ||
| 1073 | - | const observer = new ResizeObserver(() => { | |
| 1074 | - | if (!atBottom) return; | |
| 1075 | - | ||
| 1085 | + | const forceToBottom = useCallback(async () => { | |
| 1086 | + | await waitForImagesLoaded(); | |
| 1087 | + | setTimeout(() => { | |
| 1088 | + | console.log("XYZZY force to bottom", atBottom); | |
| 1076 | 1089 | messageList.current?.scrollToIndex({ | |
| 1077 | 1090 | index: Number.MAX_SAFE_INTEGER, | |
| 1078 | 1091 | align: "end", | |
| 1079 | 1092 | }); | |
| 1080 | - | }); | |
| 1081 | - | observer.observe(container); | |
| 1093 | + | }, 400); | |
| 1094 | + | }, [atBottom, waitForImagesLoaded]); | |
| 1095 | + | ||
| 1096 | + | useEffect(() => { | |
| 1097 | + | if (atBottom) void forceToBottom(); | |
| 1098 | + | }, [messages.length, atBottom, forceToBottom]); | |
| 1099 | + | ||
| 1100 | + | const followComposerResize = useEffectEvent((heightChange: number) => { | |
| 1101 | + | if (atBottom && heightChange > 0) | |
| 1102 | + | messageList.current?.scrollBy({ top: heightChange, behavior: "auto" }); | |
| 1103 | + | }); | |
| 1104 | + | ||
| 1105 | + | useLayoutEffect(() => { | |
| 1106 | + | const container = messageListContainer.current?.parentElement; | |
| 1107 | + | const header = container?.querySelector<HTMLElement>( | |
| 1108 | + | ":scope > .cs-conversation-header", | |
| 1109 | + | ); | |
| 1110 | + | if (!container || !header) return; | |
| 1111 | + | const composer = composerRef.current; | |
| 1112 | + | ||
| 1113 | + | // Keep the message spacer stable when the floating header wraps or resizes. | |
| 1114 | + | if (!headerHeight.current) | |
| 1115 | + | headerHeight.current = header.getBoundingClientRect().height; | |
| 1116 | + | container.style.setProperty( | |
| 1117 | + | "--chat-header-height", | |
| 1118 | + | `${headerHeight.current}px`, | |
| 1119 | + | ); | |
| 1120 | + | ||
| 1121 | + | const update = () => { | |
| 1122 | + | container.style.setProperty( | |
| 1123 | + | "--chat-scrollbar-width", | |
| 1124 | + | `${measureScrollbarWidth(scroller)}px`, | |
| 1125 | + | ); | |
| 1126 | + | const previousHeight = parseFloat( | |
| 1127 | + | container.style.getPropertyValue("--chat-composer-height"), | |
| 1128 | + | ); | |
| 1129 | + | const height = composer?.getBoundingClientRect().height ?? 0; | |
| 1130 | + | container.style.setProperty("--chat-composer-height", `${height}px`); | |
| 1131 | + | followComposerResize(height - previousHeight); | |
| 1132 | + | }; | |
| 1133 | + | const observer = new ResizeObserver(update); | |
| 1134 | + | if (composer) observer.observe(composer); | |
| 1135 | + | if (scroller) observer.observe(scroller); | |
| 1136 | + | update(); | |
| 1082 | 1137 | ||
| 1083 | 1138 | return () => observer.disconnect(); | |
| 1084 | - | }, [atBottom]); | |
| 1139 | + | }, [active, tabIndex, isInvite, scroller, virtuosoGeneration]); | |
| 1085 | 1140 | ||
| 1086 | 1141 | const pgUpRef = useHotkeys( | |
| 1087 | 1142 | "PageUp", |
| ... | ... | @@ -1318,14 +1373,15 @@ export const ChatInner = () => { | |
| 1318 | 1373 | /> | |
| 1319 | 1374 | )} | |
| 1320 | 1375 | <div | |
| 1321 | - | ref={virtuosoContainer} | |
| 1322 | 1376 | className="virtuoso-container" | |
| 1323 | 1377 | style={{ display: tabIndex === 0 ? "block" : "none" }} | |
| 1324 | 1378 | > | |
| 1325 | 1379 | <Virtuoso | |
| 1326 | 1380 | aria-label="Chat Messages" | |
| 1381 | + | components={messageListComponents} | |
| 1327 | 1382 | key={virtuosoGeneration} | |
| 1328 | 1383 | ref={messageList} | |
| 1384 | + | scrollerRef={setScrollerRef} | |
| 1329 | 1385 | followOutput={() => atBottom} | |
| 1330 | 1386 | alignToBottom={true} | |
| 1331 | 1387 | startReached={onYReachStart} |
| ... | ... | @@ -1431,20 +1487,17 @@ export const ChatInner = () => { | |
| 1431 | 1487 | /> | |
| 1432 | 1488 | </div> | |
| 1433 | 1489 | {tabIndex === 0 && ( | |
| 1434 | - | <> | |
| 1435 | - | {getTypingIndicator()} | |
| 1436 | - | <Button | |
| 1437 | - | title="Jump to bottom" | |
| 1438 | - | className={"jump-to-bottom " + (atBottom ? "" : "visible")} | |
| 1439 | - | {...{ inert: atBottom ? "" : undefined }} | |
| 1440 | - | icon={ | |
| 1441 | - | <FontAwesomeIcon | |
| 1442 | - | icon={faAnglesDown} | |
| 1443 | - | onClick={() => jumpToBottom()} | |
| 1444 | - | /> | |
| 1445 | - | } | |
| 1446 | - | /> | |
| 1447 | - | </> | |
| 1490 | + | <Button | |
| 1491 | + | title="Jump to bottom" | |
| 1492 | + | className={"jump-to-bottom " + (atBottom ? "" : "visible")} | |
| 1493 | + | {...{ inert: atBottom ? "" : undefined }} | |
| 1494 | + | icon={ | |
| 1495 | + | <FontAwesomeIcon | |
| 1496 | + | icon={faAnglesDown} | |
| 1497 | + | onClick={() => jumpToBottom()} | |
| 1498 | + | /> | |
| 1499 | + | } | |
| 1500 | + | /> | |
| 1448 | 1501 | )} | |
| 1449 | 1502 | {isInvite && ( | |
| 1450 | 1503 | <div className="invite-approve"> |
| ... | ... | @@ -1498,148 +1551,154 @@ export const ChatInner = () => { | |
| 1498 | 1551 | </div> | |
| 1499 | 1552 | ||
| 1500 | 1553 | {tabIndex === 0 && !isInvite && ( | |
| 1501 | - | <div as={MessageInput} id="message-input-root"> | |
| 1502 | - | {replyTo && ( | |
| 1503 | - | <div className="reply"> | |
| 1504 | - | <span> | |
| 1505 | - | Replying to{" "} | |
| 1506 | - | <span className="h-card"> | |
| 1507 | - | {members.get(replyTo.senderId)?.displayName} | |
| 1554 | + | <div as={MessageInput} className="chat-composer" ref={composerRef}> | |
| 1555 | + | {getTypingIndicator()} | |
| 1556 | + | <div id="message-input-root"> | |
| 1557 | + | {replyTo && ( | |
| 1558 | + | <div className="reply"> | |
| 1559 | + | <span> | |
| 1560 | + | Replying to{" "} | |
| 1561 | + | <span className="h-card"> | |
| 1562 | + | {members.get(replyTo.senderId)?.displayName} | |
| 1563 | + | </span> | |
| 1508 | 1564 | </span> | |
| 1509 | - | </span> | |
| 1510 | - | <Button | |
| 1511 | - | onClick={() => { | |
| 1512 | - | setReplyTo(null); | |
| 1513 | - | setSelectedThread(null); | |
| 1514 | - | }} | |
| 1515 | - | title="Cancel reply" | |
| 1516 | - | icon={<FontAwesomeIcon icon={faCircleXmark} />} | |
| 1517 | - | /> | |
| 1518 | - | </div> | |
| 1519 | - | )} | |
| 1520 | - | {attachmentError && ( | |
| 1521 | - | <Alert severity="error" onClose={() => setAttachmentError(null)}> | |
| 1522 | - | {attachmentError} | |
| 1523 | - | </Alert> | |
| 1524 | - | )} | |
| 1525 | - | {(attachmentProgress || attachments.length > 0) && ( | |
| 1526 | - | <div className="attachments"> | |
| 1527 | - | {attachments.map((attachment) => ( | |
| 1528 | - | <img | |
| 1529 | - | crossOrigin="anonymous" | |
| 1530 | - | key={attachment.uri} | |
| 1531 | - | src={attachment.uri} | |
| 1532 | - | alt={attachment.attachment.name ?? undefined} | |
| 1533 | - | title="Click to remove" | |
| 1534 | - | onClick={() => removeAttachment(attachment)} | |
| 1535 | - | /> | |
| 1536 | - | ))} | |
| 1537 | - | {attachmentProgress && <CircularProgress />} | |
| 1538 | - | </div> | |
| 1539 | - | )} | |
| 1540 | - | <div className="cs-message-input" ref={inputHotkeyRef}> | |
| 1541 | - | <div className="cs-message-input__tools"> | |
| 1542 | - | {activeChat.hasCommands() && ( | |
| 1543 | - | <CommandMenu | |
| 1544 | - | chat={activeChat} | |
| 1545 | - | addSession={addCommandSession} | |
| 1565 | + | <Button | |
| 1566 | + | onClick={() => { | |
| 1567 | + | setReplyTo(null); | |
| 1568 | + | setSelectedThread(null); | |
| 1569 | + | }} | |
| 1570 | + | title="Cancel reply" | |
| 1571 | + | icon={<FontAwesomeIcon icon={faCircleXmark} />} | |
| 1546 | 1572 | /> | |
| 1547 | - | )} | |
| 1548 | - | {activeChat.canSend() && ( | |
| 1549 | - | <> | |
| 1550 | - | <Button | |
| 1551 | - | onClick={() => setSelectedThread(uuidv7())} | |
| 1552 | - | onContextMenu={(event) => { | |
| 1553 | - | event.preventDefault(); | |
| 1554 | - | setSelectedThread(null); | |
| 1555 | - | }} | |
| 1556 | - | title={ | |
| 1557 | - | currentThread | |
| 1558 | - | ? "Thread to send this message to. Click to start a new thread or right-click to clear" | |
| 1559 | - | : "Click to start a new thread" | |
| 1560 | - | } | |
| 1561 | - | icon={ | |
| 1562 | - | currentThread ? ( | |
| 1563 | - | <img | |
| 1564 | - | src={borogove.Identicon.svg(currentThread ?? "")} | |
| 1565 | - | alt="Thread icon" | |
| 1566 | - | className="svg-inline--fa" | |
| 1567 | - | /> | |
| 1568 | - | ) : ( | |
| 1569 | - | <SpoolIcon /> | |
| 1570 | - | ) | |
| 1571 | - | } | |
| 1573 | + | </div> | |
| 1574 | + | )} | |
| 1575 | + | {attachmentError && ( | |
| 1576 | + | <Alert | |
| 1577 | + | severity="error" | |
| 1578 | + | onClose={() => setAttachmentError(null)} | |
| 1579 | + | > | |
| 1580 | + | {attachmentError} | |
| 1581 | + | </Alert> | |
| 1582 | + | )} | |
| 1583 | + | {(attachmentProgress || attachments.length > 0) && ( | |
| 1584 | + | <div className="attachments"> | |
| 1585 | + | {attachments.map((attachment) => ( | |
| 1586 | + | <img | |
| 1587 | + | crossOrigin="anonymous" | |
| 1588 | + | key={attachment.uri} | |
| 1589 | + | src={attachment.uri} | |
| 1590 | + | alt={attachment.attachment.name ?? undefined} | |
| 1591 | + | title="Click to remove" | |
| 1592 | + | onClick={() => removeAttachment(attachment)} | |
| 1572 | 1593 | /> | |
| 1573 | - | <AttachmentButton | |
| 1574 | - | title="Attach media to message" | |
| 1575 | - | onClick={handleAttach} | |
| 1594 | + | ))} | |
| 1595 | + | {attachmentProgress && <CircularProgress />} | |
| 1596 | + | </div> | |
| 1597 | + | )} | |
| 1598 | + | <div className="cs-message-input" ref={inputHotkeyRef}> | |
| 1599 | + | <div className="cs-message-input__tools"> | |
| 1600 | + | {activeChat.hasCommands() && ( | |
| 1601 | + | <CommandMenu | |
| 1602 | + | chat={activeChat} | |
| 1603 | + | addSession={addCommandSession} | |
| 1576 | 1604 | /> | |
| 1605 | + | )} | |
| 1606 | + | {activeChat.canSend() && ( | |
| 1607 | + | <> | |
| 1608 | + | <Button | |
| 1609 | + | onClick={() => setSelectedThread(uuidv7())} | |
| 1610 | + | onContextMenu={(event) => { | |
| 1611 | + | event.preventDefault(); | |
| 1612 | + | setSelectedThread(null); | |
| 1613 | + | }} | |
| 1614 | + | title={ | |
| 1615 | + | currentThread | |
| 1616 | + | ? "Thread to send this message to. Click to start a new thread or right-click to clear" | |
| 1617 | + | : "Click to start a new thread" | |
| 1618 | + | } | |
| 1619 | + | icon={ | |
| 1620 | + | currentThread ? ( | |
| 1621 | + | <img | |
| 1622 | + | src={borogove.Identicon.svg(currentThread ?? "")} | |
| 1623 | + | alt="Thread icon" | |
| 1624 | + | className="svg-inline--fa" | |
| 1625 | + | /> | |
| 1626 | + | ) : ( | |
| 1627 | + | <SpoolIcon /> | |
| 1628 | + | ) | |
| 1629 | + | } | |
| 1630 | + | /> | |
| 1631 | + | <AttachmentButton | |
| 1632 | + | title="Attach media to message" | |
| 1633 | + | onClick={handleAttach} | |
| 1634 | + | /> | |
| 1635 | + | </> | |
| 1636 | + | )} | |
| 1637 | + | </div> | |
| 1638 | + | {activeChat.canSend() ? ( | |
| 1639 | + | <> | |
| 1640 | + | <Quill | |
| 1641 | + | aria-label="Compose message" | |
| 1642 | + | className="cs-message-input__content-editor-wrapper" | |
| 1643 | + | ref={inputRef} | |
| 1644 | + | toolbar={richTextToolbar} | |
| 1645 | + | onTextChange={handleChange} | |
| 1646 | + | triggerRecentEdit={triggerRecentEdit} | |
| 1647 | + | enterIsSend={enterIsSend && handleSend} | |
| 1648 | + | mentionHandler={mentionHandler} | |
| 1649 | + | mentionClose={mentionClose} | |
| 1650 | + | attachFiles={attachFiles} | |
| 1651 | + | placeholder="Send message" | |
| 1652 | + | /> | |
| 1653 | + | {!editing && ( | |
| 1654 | + | <div className="cs-message-input__tools"> | |
| 1655 | + | <SendButton | |
| 1656 | + | title="Send message" | |
| 1657 | + | onClick={handleSend} | |
| 1658 | + | disabled={inputEmpty && attachments.length < 1} | |
| 1659 | + | /> | |
| 1660 | + | </div> | |
| 1661 | + | )} | |
| 1577 | 1662 | </> | |
| 1663 | + | ) : ( | |
| 1664 | + | activeChat instanceof borogove.Channel && ( | |
| 1665 | + | <Button | |
| 1666 | + | style={{ marginLeft: "auto" }} | |
| 1667 | + | border | |
| 1668 | + | onClick={() => { | |
| 1669 | + | activeChat.requestToSend(); | |
| 1670 | + | setRequestToSpeakSent(true); | |
| 1671 | + | }} | |
| 1672 | + | disabled={requestToSpeakSent} | |
| 1673 | + | > | |
| 1674 | + | {requestToSpeakSent ? "Request Sent" : "Request to Speak"} | |
| 1675 | + | </Button> | |
| 1676 | + | ) | |
| 1578 | 1677 | )} | |
| 1579 | 1678 | </div> | |
| 1580 | - | {activeChat.canSend() ? ( | |
| 1581 | - | <> | |
| 1582 | - | <Quill | |
| 1583 | - | aria-label="Compose message" | |
| 1584 | - | className="cs-message-input__content-editor-wrapper" | |
| 1585 | - | ref={inputRef} | |
| 1586 | - | toolbar={richTextToolbar} | |
| 1587 | - | onTextChange={handleChange} | |
| 1588 | - | triggerRecentEdit={triggerRecentEdit} | |
| 1589 | - | enterIsSend={enterIsSend && handleSend} | |
| 1590 | - | mentionHandler={mentionHandler} | |
| 1591 | - | mentionClose={mentionClose} | |
| 1592 | - | attachFiles={attachFiles} | |
| 1593 | - | placeholder="Send message" | |
| 1594 | - | /> | |
| 1595 | - | {!editing && ( | |
| 1596 | - | <div className="cs-message-input__tools"> | |
| 1597 | - | <SendButton | |
| 1598 | - | title="Send message" | |
| 1599 | - | onClick={handleSend} | |
| 1600 | - | disabled={inputEmpty && attachments.length < 1} | |
| 1601 | - | /> | |
| 1602 | - | </div> | |
| 1603 | - | )} | |
| 1604 | - | </> | |
| 1605 | - | ) : ( | |
| 1606 | - | activeChat instanceof borogove.Channel && ( | |
| 1679 | + | {editing && ( | |
| 1680 | + | <div className="edit-tools"> | |
| 1681 | + | <small>editing</small> | |
| 1607 | 1682 | <Button | |
| 1608 | - | style={{ marginLeft: "auto" }} | |
| 1609 | 1683 | border | |
| 1610 | 1684 | onClick={() => { | |
| 1611 | - | activeChat.requestToSend(); | |
| 1612 | - | setRequestToSpeakSent(true); | |
| 1685 | + | setEditing(null); | |
| 1686 | + | inputRef.current?.setText(""); | |
| 1687 | + | clearAttachments(); | |
| 1613 | 1688 | }} | |
| 1614 | - | disabled={requestToSpeakSent} | |
| 1615 | 1689 | > | |
| 1616 | - | {requestToSpeakSent ? "Request Sent" : "Request to Speak"} | |
| 1690 | + | Cancel | |
| 1617 | 1691 | </Button> | |
| 1618 | - | ) | |
| 1692 | + | <Button | |
| 1693 | + | border | |
| 1694 | + | onClick={handleSend} | |
| 1695 | + | disabled={inputEmpty && attachments.length < 1} | |
| 1696 | + | > | |
| 1697 | + | Save | |
| 1698 | + | </Button> | |
| 1699 | + | </div> | |
| 1619 | 1700 | )} | |
| 1620 | 1701 | </div> | |
| 1621 | - | {editing && ( | |
| 1622 | - | <div className="edit-tools"> | |
| 1623 | - | <small>editing</small> | |
| 1624 | - | <Button | |
| 1625 | - | border | |
| 1626 | - | onClick={() => { | |
| 1627 | - | setEditing(null); | |
| 1628 | - | inputRef.current?.setText(""); | |
| 1629 | - | clearAttachments(); | |
| 1630 | - | }} | |
| 1631 | - | > | |
| 1632 | - | Cancel | |
| 1633 | - | </Button> | |
| 1634 | - | <Button | |
| 1635 | - | border | |
| 1636 | - | onClick={handleSend} | |
| 1637 | - | disabled={inputEmpty && attachments.length < 1} | |
| 1638 | - | > | |
| 1639 | - | Save | |
| 1640 | - | </Button> | |
| 1641 | - | </div> | |
| 1642 | - | )} | |
| 1643 | 1702 | </div> | |
| 1644 | 1703 | )} | |
| 1645 | 1704 | </ChatContainer> |
+3
-5
src/components/Chats.tsx
#
| ... | ... | @@ -777,10 +778,7 @@ export const Chats = () => { | |
| 777 | 778 | visible={c.uiState === borogove.UiState.Pinned} | |
| 778 | 779 | > | |
| 779 | 780 | <Button | |
| 780 | - | style={{ | |
| 781 | - | opacity: | |
| 782 | - | c.uiState === borogove.UiState.Pinned ? 0.9 : 0.5, | |
| 783 | - | }} | |
| 781 | + | style={{ opacity: 1 }} | |
| 784 | 782 | icon={<FontAwesomeIcon icon={faThumbtack} />} | |
| 785 | 783 | title={ | |
| 786 | 784 | c.uiState === borogove.UiState.Pinned |
+3
-4
src/components/CommandMenu.tsx
#
| ... | ... | @@ -56,17 +56,16 @@ export const CommandMenu = ({ | |
| 56 | 56 | return ( | |
| 57 | 57 | <> | |
| 58 | 58 | <Button | |
| 59 | + | aria-label="Menu" | |
| 59 | 60 | aria-haspopup="menu" | |
| 60 | - | border | |
| 61 | + | aria-expanded={!!menu} | |
| 61 | 62 | icon={<FontAwesomeIcon icon={faBars} />} | |
| 62 | 63 | onClick={(e) => { | |
| 63 | 64 | setMenu(e.currentTarget); | |
| 64 | 65 | setPromise(chat.commands()); | |
| 65 | 66 | setKey(key + 1); | |
| 66 | 67 | }} | |
| 67 | - | > | |
| 68 | - | Menu | |
| 69 | - | </Button> | |
| 68 | + | /> | |
| 70 | 69 | <Menu | |
| 71 | 70 | open={!!menu} | |
| 72 | 71 | anchorEl={menu} |
+2
-2
src/components/MessageAttachments.tsx
#
+0
-1
src/components/MessageBubble.test.tsx
#
+128
-92
src/components/MessageBubble.tsx
#
| ... | ... | @@ -1,5 +1,6 @@ | |
| 1 | 1 | import * as borogove from "borogove"; | |
| 2 | 2 | import { MessageDebugger } from "./MessageDebugger"; | |
| 3 | + | import { MessageHeading } from "./MessageHeading"; | |
| 3 | 4 | import DOMPurify from "dompurify"; | |
| 4 | 5 | import { Button, Message } from "@chatscope/chat-ui-kit-react"; | |
| 5 | 6 | import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; |
| ... | ... | @@ -8,6 +9,7 @@ import { useNavigate } from "react-router"; | |
| 8 | 9 | import { MessageAttachments } from "./MessageAttachments"; | |
| 9 | 10 | import { ReactNode, useRef, useLayoutEffect, useState } from "react"; | |
| 10 | 11 | import hljs from "highlight.js"; | |
| 12 | + | import { createPortal } from "react-dom"; | |
| 11 | 13 | import { shortDateTimeOnlyToday } from "../util"; | |
| 12 | 14 | import { | |
| 13 | 15 | Dialog, |
| ... | ... | @@ -25,6 +27,29 @@ import { | |
| 25 | 27 | faPencil, | |
| 26 | 28 | faReply, | |
| 27 | 29 | } from "@fortawesome/free-solid-svg-icons"; | |
| 30 | + | import type { IconDefinition } from "@fortawesome/fontawesome-svg-core"; | |
| 31 | + | ||
| 32 | + | const deliveryByStatus = { | |
| 33 | + | [borogove.MessageStatus.MessagePending]: { | |
| 34 | + | icon: faClock, | |
| 35 | + | text: "Sending...", | |
| 36 | + | }, | |
| 37 | + | [borogove.MessageStatus.MessageFailedToSend]: { | |
| 38 | + | icon: faCircleExclamation, | |
| 39 | + | text: "Error", | |
| 40 | + | }, | |
| 41 | + | [borogove.MessageStatus.MessageDeliveredToServer]: { | |
| 42 | + | icon: faCheck, | |
| 43 | + | text: "Sent", | |
| 44 | + | }, | |
| 45 | + | [borogove.MessageStatus.MessageDeliveredToDevice]: { | |
| 46 | + | icon: faCheckDouble, | |
| 47 | + | text: "Received", | |
| 48 | + | }, | |
| 49 | + | } satisfies Record< | |
| 50 | + | borogove.ChatMessage["status"], | |
| 51 | + | { icon: IconDefinition; text: string } | |
| 52 | + | >; | |
| 28 | 53 | ||
| 29 | 54 | const renderReaction = (reaction: borogove.Reaction) => { | |
| 30 | 55 | return reaction.render<JSX.Element | string>( |
| ... | ... | @@ -97,14 +122,25 @@ const MessageContent = ({ | |
| 97 | 122 | selfName, | |
| 98 | 123 | sender, | |
| 99 | 124 | hook, | |
| 125 | + | timestamp, | |
| 126 | + | metadata, | |
| 127 | + | statusCount = 0, | |
| 100 | 128 | }: { | |
| 101 | 129 | m: borogove.ChatMessage; | |
| 102 | 130 | selfName: string; | |
| 103 | 131 | sender: borogove.Member | undefined; | |
| 104 | 132 | hook?: (frag: DocumentFragment) => DocumentFragment; | |
| 133 | + | timestamp?: string; | |
| 134 | + | metadata?: ReactNode; | |
| 135 | + | statusCount?: number; | |
| 105 | 136 | }) => { | |
| 106 | 137 | const contentRef = useRef<HTMLDivElement | null>(null); | |
| 107 | 138 | const senderRef = useRef(sender); | |
| 139 | + | const [metadataHost] = useState(() => { | |
| 140 | + | const host = document.createElement("span"); | |
| 141 | + | host.className = "message-time"; | |
| 142 | + | return host; | |
| 143 | + | }); | |
| 108 | 144 | ||
| 109 | 145 | useLayoutEffect(() => { | |
| 110 | 146 | if (!contentRef.current) return; |
| ... | ... | @@ -113,6 +149,8 @@ const MessageContent = ({ | |
| 113 | 149 | DOMPurify.sanitize(formatMention(html, selfName)); | |
| 114 | 150 | const toInsert = hook ? hook(html) : html; | |
| 115 | 151 | ||
| 152 | + | contentRef.current.classList.remove("message-timed-text"); | |
| 153 | + | delete contentRef.current.dataset.time; | |
| 116 | 154 | contentRef.current.replaceChildren(toInsert); | |
| 117 | 155 | for (const el of contentRef.current.querySelectorAll<HTMLElement>( | |
| 118 | 156 | "pre > code", |
| ... | ... | @@ -121,10 +159,21 @@ const MessageContent = ({ | |
| 121 | 159 | if (!el.className) el.className = "language-plaintext"; | |
| 122 | 160 | hljs.highlightElement(el); | |
| 123 | 161 | } | |
| 124 | - | }, [m, selfName, hook]); | |
| 162 | + | if (timestamp || statusCount) { | |
| 163 | + | let target = contentRef.current; | |
| 164 | + | while (target.lastElementChild?.matches("div, p, blockquote")) { | |
| 165 | + | target = target.lastElementChild as HTMLDivElement; | |
| 166 | + | } | |
| 167 | + | target.classList.add("message-timed-text"); | |
| 168 | + | target.dataset.time = timestamp ?? ""; | |
| 169 | + | target.style.setProperty("--message-status-count", String(statusCount)); | |
| 170 | + | target.append(metadataHost); | |
| 171 | + | } | |
| 172 | + | }, [m, selfName, hook, timestamp, statusCount, metadataHost]); | |
| 125 | 173 | ||
| 126 | 174 | return ( | |
| 127 | 175 | <> | |
| 176 | + | {createPortal(metadata, metadataHost)} | |
| 128 | 177 | {!m.moderationReason() && | |
| 129 | 178 | m.encryption?.status !== | |
| 130 | 179 | borogove.EncryptionStatus.DecryptionFailure && ( |
| ... | ... | @@ -250,12 +299,6 @@ export const MessageBubble = ({ | |
| 250 | 299 | }; | |
| 251 | 300 | ||
| 252 | 301 | const [showEdits, setShowEdits] = useState(false); | |
| 253 | - | const bodyLength = m | |
| 254 | - | .body() | |
| 255 | - | .reduce((txt, isTag, _, kids: number[] | null) => | |
| 256 | - | isTag ? (kids ?? []).reduce((x, y) => x + y, 0) : txt.length, | |
| 257 | - | ) | |
| 258 | - | .reduce((x, y) => x + y, 0); | |
| 259 | 302 | const parentMessage = m.replyToMessage; | |
| 260 | 303 | const reactionEntries = [...(m.reactions.entries() || [])]; | |
| 261 | 304 | const shortDateTimeHuman = shortDateTimeOnlyToday(new Date(m.timeSent)); |
| ... | ... | @@ -266,14 +309,73 @@ export const MessageBubble = ({ | |
| 266 | 309 | }) | |
| 267 | 310 | .replace(/\s*\b[A-Z]{2,4}$/, ""); // remove trailing TZ abbrev | |
| 268 | 311 | ||
| 312 | + | const delivery = m.isIncoming() ? undefined : deliveryByStatus[m.status]; | |
| 313 | + | ||
| 314 | + | const timestamp = ["last", "single"].includes(position) | |
| 315 | + | ? shortDateTimeHuman | |
| 316 | + | : undefined; | |
| 317 | + | const inlineTime = | |
| 318 | + | !m.attachments.length && | |
| 319 | + | !m.linkMetadata.length && | |
| 320 | + | !m.moderationReason() && | |
| 321 | + | m.encryption?.status !== borogove.EncryptionStatus.DecryptionFailure; | |
| 269 | 322 | const sender = members.get(m.senderId); | |
| 323 | + | const subject = m.subject(); | |
| 270 | 324 | const showSender = | |
| 271 | 325 | m.senderId !== chat.chatId && | |
| 272 | - | ["last", "single"].includes(position) && | |
| 326 | + | ["first", "single"].includes(position) && | |
| 273 | 327 | !m.moderationReason() && | |
| 274 | 328 | m.isIncoming(); | |
| 275 | 329 | const mention = sender && onMention ? () => onMention(sender) : undefined; | |
| 276 | 330 | ||
| 331 | + | const encrypted = | |
| 332 | + | m.encryption?.status === borogove.EncryptionStatus.EncryptionInfoSuccess; | |
| 333 | + | const statusCount = | |
| 334 | + | Number(m.versions.length > 0) + | |
| 335 | + | Number(!!delivery) + | |
| 336 | + | Number(!!m.threadId) + | |
| 337 | + | Number(encrypted); | |
| 338 | + | const metadata = (timestamp || statusCount > 0) && ( | |
| 339 | + | <> | |
| 340 | + | {timestamp && <time dateTime={m.timeSent}>{timestamp}</time>} | |
| 341 | + | {m.versions.length > 0 && ( | |
| 342 | + | <button | |
| 343 | + | type="button" | |
| 344 | + | className="message-badge" | |
| 345 | + | title={"Edited " + (m.versions.length - 1) + " times"} | |
| 346 | + | onClick={() => setShowEdits(true)} | |
| 347 | + | > | |
| 348 | + | <FontAwesomeIcon icon={faPencil} /> | |
| 349 | + | </button> | |
| 350 | + | )} | |
| 351 | + | {delivery && ( | |
| 352 | + | <span className="message-badge"> | |
| 353 | + | <FontAwesomeIcon | |
| 354 | + | icon={delivery.icon} | |
| 355 | + | title={m.statusText ?? delivery.text} | |
| 356 | + | /> | |
| 357 | + | </span> | |
| 358 | + | )} | |
| 359 | + | {m.threadId && ( | |
| 360 | + | <span className="message-badge"> | |
| 361 | + | <img | |
| 362 | + | src={m.threadIcon() ?? undefined} | |
| 363 | + | alt={"thread " + m.threadId.substring(0, 5)} | |
| 364 | + | className="thread" | |
| 365 | + | /> | |
| 366 | + | </span> | |
| 367 | + | )} | |
| 368 | + | {encrypted && ( | |
| 369 | + | <span className="message-badge"> | |
| 370 | + | <FontAwesomeIcon | |
| 371 | + | icon={faLock} | |
| 372 | + | title={m.encryption!.methodName ?? m.encryption!.method} | |
| 373 | + | /> | |
| 374 | + | </span> | |
| 375 | + | )} | |
| 376 | + | </> | |
| 377 | + | ); | |
| 378 | + | ||
| 277 | 379 | return ( | |
| 278 | 380 | <Message | |
| 279 | 381 | model={{ |
| ... | ... | @@ -285,17 +387,20 @@ export const MessageBubble = ({ | |
| 285 | 387 | data-server-id={m.serverId} | |
| 286 | 388 | data-local-id={m.localId} | |
| 287 | 389 | className={ | |
| 288 | - | (bodyLength < 25 && !m.replyToMessage ? "small " : "") + | |
| 289 | - | (m.type === borogove.MessageType.MessageChannelPrivate | |
| 290 | - | ? "invite" | |
| 291 | - | : "") + | |
| 292 | - | " " + | |
| 293 | - | className | |
| 390 | + | m.type === borogove.MessageType.MessageChannelPrivate | |
| 391 | + | ? `invite ${className ?? ""}` | |
| 392 | + | : className | |
| 294 | 393 | } | |
| 295 | 394 | > | |
| 296 | 395 | {children} | |
| 297 | 396 | <Message.CustomContent> | |
| 298 | 397 | <div title={fullDateTimeHuman}> | |
| 398 | + | <MessageHeading | |
| 399 | + | sender={sender} | |
| 400 | + | showSender={showSender} | |
| 401 | + | subject={subject} | |
| 402 | + | mention={mention} | |
| 403 | + | /> | |
| 299 | 404 | <MessageDebugger m={m} /> | |
| 300 | 405 | {parentMessage && ( | |
| 301 | 406 | <> |
| ... | ... | @@ -327,88 +432,19 @@ export const MessageBubble = ({ | |
| 327 | 432 | m={m} | |
| 328 | 433 | selfName={client.displayName()} | |
| 329 | 434 | sender={sender} | |
| 435 | + | timestamp={inlineTime ? timestamp : undefined} | |
| 436 | + | statusCount={inlineTime ? statusCount : 0} | |
| 437 | + | metadata={metadata} | |
| 330 | 438 | /> | |
| 331 | 439 | {m.attachments.length > 0 && ( | |
| 332 | 440 | <MessageAttachments client={client} chat={chat} message={m} /> | |
| 333 | 441 | )} | |
| 334 | 442 | {m.linkMetadata.map((meta) => linkMeta(meta))} | |
| 335 | - | <div className="meta"> | |
| 336 | - | <div | |
| 337 | - | className={ | |
| 338 | - | (showSender ? "" : "sr-only") + | |
| 339 | - | " h-card sender " + | |
| 340 | - | (mention ? "clickable" : "") | |
| 341 | - | } | |
| 342 | - | onClick={mention} | |
| 343 | - | > | |
| 344 | - | {sender?.displayName} | |
| 443 | + | {!inlineTime && metadata && ( | |
| 444 | + | <div className="message-time-row"> | |
| 445 | + | <span className="message-time">{metadata}</span> | |
| 345 | 446 | </div> | |
| 346 | - | ||
| 347 | - | <div> | |
| 348 | - | {m.subject() && ( | |
| 349 | - | <> | |
| 350 | - | <strong>{m.subject()}</strong>{" "} | |
| 351 | - | </> | |
| 352 | - | )} | |
| 353 | - | {m.timeSent && ["last", "single"].includes(position) && ( | |
| 354 | - | <time dateTime={m.timeSent} title={fullDateTimeHuman}> | |
| 355 | - | {shortDateTimeHuman} | |
| 356 | - | </time> | |
| 357 | - | )} | |
| 358 | - | {m.versions.length > 0 && ( | |
| 359 | - | <FontAwesomeIcon | |
| 360 | - | icon={faPencil} | |
| 361 | - | title={"Edited " + (m.versions.length - 1) + " times"} | |
| 362 | - | onClick={() => setShowEdits(true)} | |
| 363 | - | /> | |
| 364 | - | )} | |
| 365 | - | {m.threadId && ( | |
| 366 | - | <img | |
| 367 | - | src={m.threadIcon() ?? undefined} | |
| 368 | - | alt={"thread " + m.threadId.substring(0, 5)} | |
| 369 | - | className="thread" | |
| 370 | - | /> | |
| 371 | - | )} | |
| 372 | - | {m.encryption && | |
| 373 | - | m.encryption?.status === | |
| 374 | - | borogove.EncryptionStatus.EncryptionInfoSuccess && ( | |
| 375 | - | <FontAwesomeIcon | |
| 376 | - | icon={faLock} | |
| 377 | - | title={m.encryption.methodName ?? m.encryption.method} | |
| 378 | - | /> | |
| 379 | - | )} | |
| 380 | - | {!m.isIncoming() && | |
| 381 | - | m.status === borogove.MessageStatus.MessagePending && ( | |
| 382 | - | <FontAwesomeIcon | |
| 383 | - | icon={faClock} | |
| 384 | - | title={m.statusText ?? "Sending..."} | |
| 385 | - | /> | |
| 386 | - | )} | |
| 387 | - | {!m.isIncoming() && | |
| 388 | - | m.status === borogove.MessageStatus.MessageFailedToSend && ( | |
| 389 | - | <FontAwesomeIcon | |
| 390 | - | icon={faCircleExclamation} | |
| 391 | - | title={m.statusText ?? "Error"} | |
| 392 | - | /> | |
| 393 | - | )} | |
| 394 | - | {!m.isIncoming() && | |
| 395 | - | m.status === | |
| 396 | - | borogove.MessageStatus.MessageDeliveredToServer && ( | |
| 397 | - | <FontAwesomeIcon | |
| 398 | - | icon={faCheck} | |
| 399 | - | title={m.statusText ?? "Sent"} | |
| 400 | - | /> | |
| 401 | - | )} | |
| 402 | - | {!m.isIncoming() && | |
| 403 | - | m.status === | |
| 404 | - | borogove.MessageStatus.MessageDeliveredToDevice && ( | |
| 405 | - | <FontAwesomeIcon | |
| 406 | - | icon={faCheckDouble} | |
| 407 | - | title={m.statusText ?? "Received"} | |
| 408 | - | /> | |
| 409 | - | )} | |
| 410 | - | </div> | |
| 411 | - | </div> | |
| 447 | + | )} | |
| 412 | 448 | </div> | |
| 413 | 449 | <EditHistory | |
| 414 | 450 | open={showEdits} |
| ... | ... | @@ -445,7 +480,8 @@ export const MessageBubble = ({ | |
| 445 | 480 | ) | |
| 446 | 481 | .join("\n")} | |
| 447 | 482 | > | |
| 448 | - | {renderReaction(reactions[0])} {" " + reactions.length} | |
| 483 | + | <span>{renderReaction(reactions[0])}</span> | |
| 484 | + | {reactions.length > 1 && " " + reactions.length} | |
| 449 | 485 | </Button> | |
| 450 | 486 | ))} | |
| 451 | 487 | </Message.Footer> |
+91
-0
src/components/MessageHeading.test.tsx
#
| ... | ... | @@ -0,0 +1,91 @@ | |
| 1 | + | // @vitest-environment jsdom | |
| 2 | + | ||
| 3 | + | import { cleanup, fireEvent, render, within } from "@testing-library/react"; | |
| 4 | + | import type { Member } from "borogove"; | |
| 5 | + | import type { ComponentProps } from "react"; | |
| 6 | + | import { afterEach, expect, it, vi } from "vitest"; | |
| 7 | + | import { mock } from "vitest-mock-extended"; | |
| 8 | + | import { MessageHeading } from "./MessageHeading"; | |
| 9 | + | ||
| 10 | + | afterEach(cleanup); | |
| 11 | + | ||
| 12 | + | const sender = mock<Member>({ displayName: "Alice" }); | |
| 13 | + | ||
| 14 | + | function renderHeading(props: Partial<ComponentProps<typeof MessageHeading>>) { | |
| 15 | + | return render( | |
| 16 | + | <MessageHeading | |
| 17 | + | sender={sender} | |
| 18 | + | showSender | |
| 19 | + | subject={null} | |
| 20 | + | mention={undefined} | |
| 21 | + | {...props} | |
| 22 | + | />, | |
| 23 | + | ); | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | it("renders nothing without a sender or subject", () => { | |
| 27 | + | const { container } = renderHeading({ | |
| 28 | + | sender: undefined, | |
| 29 | + | subject: null, | |
| 30 | + | }); | |
| 31 | + | ||
| 32 | + | expect(container.textContent).toBe(""); | |
| 33 | + | }); | |
| 34 | + | ||
| 35 | + | it("renders the subject without a sender", () => { | |
| 36 | + | const { container } = renderHeading({ | |
| 37 | + | sender: undefined, | |
| 38 | + | subject: "Project updates", | |
| 39 | + | }); | |
| 40 | + | ||
| 41 | + | expect(container.textContent).toBe("Project updates"); | |
| 42 | + | }); | |
| 43 | + | ||
| 44 | + | it("shows the sender name on its own when there is no subject", () => { | |
| 45 | + | const { container } = renderHeading({ | |
| 46 | + | sender, | |
| 47 | + | showSender: true, | |
| 48 | + | subject: null, | |
| 49 | + | }); | |
| 50 | + | ||
| 51 | + | expect(container.textContent).toBe("Alice"); | |
| 52 | + | }); | |
| 53 | + | ||
| 54 | + | it("appends the subject after a separator", () => { | |
| 55 | + | const { container } = renderHeading({ | |
| 56 | + | sender, | |
| 57 | + | showSender: true, | |
| 58 | + | subject: "Project updates", | |
| 59 | + | }); | |
| 60 | + | ||
| 61 | + | expect(container.textContent).toBe("Alice · Project updates"); | |
| 62 | + | }); | |
| 63 | + | ||
| 64 | + | it("keeps the hidden sender name available to screen readers", () => { | |
| 65 | + | const { container } = renderHeading({ | |
| 66 | + | sender, | |
| 67 | + | showSender: false, | |
| 68 | + | }); | |
| 69 | + | ||
| 70 | + | expect(container.querySelector(".sr-only")?.textContent).toBe("Alice"); | |
| 71 | + | }); | |
| 72 | + | ||
| 73 | + | it("renders the subject without a separator when the sender is hidden", () => { | |
| 74 | + | const { container } = renderHeading({ | |
| 75 | + | sender, | |
| 76 | + | showSender: false, | |
| 77 | + | subject: "Project updates", | |
| 78 | + | }); | |
| 79 | + | ||
| 80 | + | expect(container.textContent).toContain("Project updates"); | |
| 81 | + | expect(container.querySelector(".subject-separator")).toBeNull(); | |
| 82 | + | }); | |
| 83 | + | ||
| 84 | + | it("calls the mention handler when the sender name is clicked", () => { | |
| 85 | + | const mention = vi.fn(); | |
| 86 | + | const { container } = renderHeading({ sender, showSender: true, mention }); | |
| 87 | + | ||
| 88 | + | fireEvent.click(within(container).getByText("Alice")); | |
| 89 | + | ||
| 90 | + | expect(mention).toHaveBeenCalledOnce(); | |
| 91 | + | }); |
+60
-0
src/components/MessageHeading.tsx
#
| ... | ... | @@ -0,0 +1,60 @@ | |
| 1 | + | import type { Member } from "borogove"; | |
| 2 | + | import type { ReactElement } from "react"; | |
| 3 | + | ||
| 4 | + | type MessageHeadingProps = { | |
| 5 | + | sender: Member | undefined; | |
| 6 | + | showSender: boolean; | |
| 7 | + | subject: string | null; | |
| 8 | + | mention: (() => void) | undefined; | |
| 9 | + | }; | |
| 10 | + | ||
| 11 | + | export function MessageHeading({ | |
| 12 | + | sender, | |
| 13 | + | showSender, | |
| 14 | + | subject, | |
| 15 | + | mention, | |
| 16 | + | }: MessageHeadingProps) { | |
| 17 | + | const senderName = makeSenderName({ sender, showSender, mention }); | |
| 18 | + | const showSeparator = senderName.visible && subject; | |
| 19 | + | ||
| 20 | + | return ( | |
| 21 | + | <div className="message-heading"> | |
| 22 | + | {senderName.el} | |
| 23 | + | {showSeparator && <span className="subject-separator">{" · "}</span>} | |
| 24 | + | {subject} | |
| 25 | + | </div> | |
| 26 | + | ); | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | function makeSenderName({ | |
| 30 | + | sender, | |
| 31 | + | showSender, | |
| 32 | + | mention, | |
| 33 | + | }: Pick<MessageHeadingProps, "sender" | "showSender" | "mention">): { | |
| 34 | + | el: ReactElement | null; | |
| 35 | + | visible: boolean; | |
| 36 | + | } { | |
| 37 | + | if (!sender) | |
| 38 | + | return { | |
| 39 | + | el: null, | |
| 40 | + | visible: false, | |
| 41 | + | }; | |
| 42 | + | ||
| 43 | + | if (!showSender) | |
| 44 | + | return { | |
| 45 | + | el: <span className="sr-only sender">{sender.displayName}</span>, | |
| 46 | + | visible: false, | |
| 47 | + | }; | |
| 48 | + | ||
| 49 | + | return { | |
| 50 | + | el: ( | |
| 51 | + | <span | |
| 52 | + | className={mention ? "h-card sender clickable" : "h-card sender"} | |
| 53 | + | onClick={mention} | |
| 54 | + | > | |
| 55 | + | {sender.displayName} | |
| 56 | + | </span> | |
| 57 | + | ), | |
| 58 | + | visible: true, | |
| 59 | + | }; | |
| 60 | + | } |
+24
-0
src/components/Page.tsx
#
| ... | ... | @@ -0,0 +1,24 @@ | |
| 1 | + | import { ArrowButton, MainContainer } from "@chatscope/chat-ui-kit-react"; | |
| 2 | + | import { isTauri } from "@tauri-apps/api/core"; | |
| 3 | + | import type { ReactNode } from "react"; | |
| 4 | + | import { useNavigate } from "react-router"; | |
| 5 | + | ||
| 6 | + | export const Page = ({ children }: { children: ReactNode }) => { | |
| 7 | + | const navigate = useNavigate(); | |
| 8 | + | return ( | |
| 9 | + | <MainContainer className={isTauri() ? "page tauri" : "page"}> | |
| 10 | + | <section> | |
| 11 | + | <ArrowButton | |
| 12 | + | className="page-back" | |
| 13 | + | direction="left" | |
| 14 | + | aria-label="Back" | |
| 15 | + | onClick={() => { | |
| 16 | + | if (window.history.state?.idx > 0) navigate(-1); | |
| 17 | + | else navigate("/"); | |
| 18 | + | }} | |
| 19 | + | /> | |
| 20 | + | {children} | |
| 21 | + | </section> | |
| 22 | + | </MainContainer> | |
| 23 | + | ); | |
| 24 | + | }; |
+21
-2
src/components/Settings.tsx
#
| ... | ... | @@ -1,3 +1,11 @@ | |
| 1 | + | import { | |
| 2 | + | defaultCustomPalette, | |
| 3 | + | defaultTheme, | |
| 4 | + | type Palette, | |
| 5 | + | type Theme, | |
| 6 | + | } from "../theme"; | |
| 7 | + | import { AppearanceSettings } from "./AppearanceSettings"; | |
| 8 | + | import { Page } from "./Page"; | |
| 1 | 9 | import * as borogove from "borogove"; | |
| 2 | 10 | import { createContext, useContext } from "react"; | |
| 3 | 11 | import { useOutletContext } from "react-router"; |
| ... | ... | @@ -19,6 +30,9 @@ export type SettingsData = { | |
| 19 | 30 | e2ee: "none" | "pfs"; | |
| 20 | 31 | }; | |
| 21 | 32 | export const SettingsContext = createContext<SettingsData>({ | |
| 33 | + | theme: defaultTheme, | |
| 34 | + | customPalette: defaultCustomPalette, | |
| 35 | + | appearance: "system", | |
| 22 | 36 | enterIsSend: true, | |
| 23 | 37 | richTextToolbar: false, | |
| 24 | 38 | audibleNotifications: false, |
+45
-11
src/index.tsx
#
| ... | ... | @@ -26,21 +27,54 @@ import "~build/console"; | |
| 26 | 27 | window.libsignal = libsignal; | |
| 27 | 28 | ||
| 28 | 29 | const muiTheme = createTheme({ | |
| 29 | - | cssVariables: { nativeColor: true }, | |
| 30 | - | palette: { | |
| 31 | - | primary: { | |
| 32 | - | main: "var(--color-primary-dark)", | |
| 33 | - | }, | |
| 34 | - | secondary: { | |
| 35 | - | main: "var(--color-secondary-dark)", | |
| 36 | - | }, | |
| 37 | - | }, | |
| 30 | + | cssVariables: { nativeColor: true, colorSchemeSelector: "data-theme" }, | |
| 31 | + | shape: { borderRadius: 6 }, | |
| 32 | + | components: { MuiIconButton: { defaultProps: { color: "primary" } } }, | |
| 33 | + | colorSchemes: Object.fromEntries( | |
| 34 | + | ["light", "dark"].map((mode) => [ | |
| 35 | + | mode, | |
| 36 | + | { | |
| 37 | + | palette: { | |
| 38 | + | primary: { | |
| 39 | + | main: "var(--theme-primary)", | |
| 40 | + | contrastText: "var(--theme-on-primary)", | |
| 41 | + | }, | |
| 42 | + | secondary: { | |
| 43 | + | main: "var(--theme-secondary)", | |
| 44 | + | contrastText: "var(--theme-on-secondary)", | |
| 45 | + | }, | |
| 46 | + | background: { | |
| 47 | + | default: "var(--default-bg-color)", | |
| 48 | + | paper: "var(--paper-background)", | |
| 49 | + | }, | |
| 50 | + | text: { | |
| 51 | + | primary: "var(--color-text)", | |
| 52 | + | secondary: "var(--color-text-medium)", | |
| 53 | + | disabled: "var(--color-text-disabled)", | |
| 54 | + | }, | |
| 55 | + | divider: "var(--divider-color)", | |
| 56 | + | action: { | |
| 57 | + | hover: "var(--color-bg-hover)", | |
| 58 | + | selected: "var(--color-bg-focus)", | |
| 59 | + | focus: "var(--color-bg-focus)", | |
| 60 | + | disabled: "var(--color-text-disabled)", | |
| 61 | + | }, | |
| 62 | + | }, | |
| 63 | + | }, | |
| 64 | + | ]), | |
| 65 | + | ), | |
| 38 | 66 | }); | |
| 39 | 67 | ||
| 40 | - | const root = ReactDOM.createRoot(document.getElementById("root")!); | |
| 68 | + | const overlayTitlebar = isTauri() && navigator.platform.startsWith("Mac"); | |
| 69 | + | const rootElement = document.getElementById("root")!; | |
| 70 | + | rootElement.classList.toggle("tauri-overlay", overlayTitlebar); | |
| 71 | + | const root = ReactDOM.createRoot(rootElement); | |
| 41 | 72 | root.render( | |
| 42 | 73 | <StrictMode> | |
| 43 | - | <MuiThemeProvider theme={muiTheme}> | |
| 74 | + | {overlayTitlebar && ( | |
| 75 | + | <div className="tauri-titlebar" data-tauri-drag-region /> | |
| 76 | + | )} | |
| 77 | + | <MuiThemeProvider theme={muiTheme} storageManager={null}> | |
| 44 | 78 | <ConfirmDialog /> | |
| 45 | 79 | <div | |
| 46 | 80 | id="chat-messages-aria-live" |
+89
-0
src/theme.test.ts
#
| ... | ... | @@ -0,0 +1,89 @@ | |
| 1 | + | import { describe, expect, it } from "vitest"; | |
| 2 | + | import { contrast, defaultTheme, themePresets, themeVariables } from "./theme"; | |
| 3 | + | ||
| 4 | + | describe("theme presets", () => { | |
| 5 | + | it("preserves the default Cheogram overrides", () => { | |
| 6 | + | const vars = themeVariables(themePresets[defaultTheme]); | |
| 7 | + | expect(vars["--theme-light-accent-surface"]).toBe("#f3daff"); | |
| 8 | + | expect(vars["--theme-light-outgoing-background"]).toBe("#f3daff"); | |
| 9 | + | expect(vars["--theme-light-outgoing-color"]).toBe("#27123a"); | |
| 10 | + | expect(vars["--theme-dark-outgoing-background"]).toBe( | |
| 11 | + | themePresets[defaultTheme].dark.primary, | |
| 12 | + | ); | |
| 13 | + | expect( | |
| 14 | + | contrast(vars["--theme-light-link"], "#f3daff"), | |
| 15 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 16 | + | }); | |
| 17 | + | ||
| 18 | + | it("uses the original Classic bubble colours", () => { | |
| 19 | + | const vars = themeVariables(themePresets.classic); | |
| 20 | + | expect(vars["--theme-light-incoming-background"]).toBe("#d6b0f3"); | |
| 21 | + | expect(vars["--theme-light-outgoing-background"]).toBe("#f5e9bc"); | |
| 22 | + | expect(vars["--theme-dark-outgoing-background"]).toBe( | |
| 23 | + | vars["--theme-dark-secondary-surface"], | |
| 24 | + | ); | |
| 25 | + | expect( | |
| 26 | + | contrast(vars["--theme-light-link"], "#d6b0f3"), | |
| 27 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 28 | + | }); | |
| 29 | + | ||
| 30 | + | for (const [preset, palette] of Object.entries(themePresets)) { | |
| 31 | + | it(`keeps ${preset} text and accent foregrounds readable`, () => { | |
| 32 | + | const vars = themeVariables(palette); | |
| 33 | + | for (const mode of ["light", "dark"] as const) { | |
| 34 | + | const colours = palette[mode]; | |
| 35 | + | const incoming = vars[`--theme-${mode}-incoming-background`]; | |
| 36 | + | const accent = vars[`--theme-${mode}-accent-surface`]; | |
| 37 | + | for (const surface of [incoming, accent]) { | |
| 38 | + | if (surface === "initial") continue; | |
| 39 | + | expect(contrast(colours.text, surface)).toBeGreaterThanOrEqual(4.5); | |
| 40 | + | expect( | |
| 41 | + | contrast(vars[`--theme-${mode}-link`], surface), | |
| 42 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 43 | + | } | |
| 44 | + | expect( | |
| 45 | + | contrast( | |
| 46 | + | vars[`--theme-${mode}-outgoing-color`], | |
| 47 | + | vars[`--theme-${mode}-outgoing-background`], | |
| 48 | + | ), | |
| 49 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 50 | + | expect( | |
| 51 | + | contrast(colours.text, colours.background), | |
| 52 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 53 | + | expect( | |
| 54 | + | contrast(vars[`--theme-${mode}-link`], colours.background), | |
| 55 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 56 | + | for (const role of ["primary", "secondary"] as const) | |
| 57 | + | expect( | |
| 58 | + | contrast(colours[role], vars[`--theme-${mode}-on-${role}`]), | |
| 59 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 60 | + | } | |
| 61 | + | }); | |
| 62 | + | } | |
| 63 | + | ||
| 64 | + | const base = themePresets[defaultTheme]; | |
| 65 | + | for (const primary of [ | |
| 66 | + | "#ffffff", | |
| 67 | + | "#000000", | |
| 68 | + | "#ffff00", | |
| 69 | + | "#00ff00", | |
| 70 | + | "#ff0000", | |
| 71 | + | "#0000ff", | |
| 72 | + | "#777777", | |
| 73 | + | ]) { | |
| 74 | + | it(`keeps accent text readable with ${primary}`, () => { | |
| 75 | + | const vars = themeVariables({ | |
| 76 | + | light: { ...base.light, primary }, | |
| 77 | + | dark: { ...base.dark, primary }, | |
| 78 | + | }); | |
| 79 | + | for (const mode of ["light", "dark"] as const) { | |
| 80 | + | expect( | |
| 81 | + | contrast(primary, vars[`--theme-${mode}-on-primary`]), | |
| 82 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 83 | + | expect( | |
| 84 | + | contrast(vars[`--theme-${mode}-link`], base[mode].background), | |
| 85 | + | ).toBeGreaterThanOrEqual(4.5); | |
| 86 | + | } | |
| 87 | + | }); | |
| 88 | + | } | |
| 89 | + | }); |
+252
-0
src/theme.ts
#
| ... | ... | @@ -0,0 +1,252 @@ | |
| 1 | + | export type Palette = { | |
| 2 | + | background: string; | |
| 3 | + | text: string; | |
| 4 | + | primary: string; | |
| 5 | + | secondary: string; | |
| 6 | + | }; | |
| 7 | + | ||
| 8 | + | type PresetPalette = Palette & { | |
| 9 | + | accentSurface?: string; | |
| 10 | + | incomingBackground?: string; | |
| 11 | + | outgoingBackground?: string; | |
| 12 | + | outgoingColor?: string; | |
| 13 | + | }; | |
| 14 | + | ||
| 15 | + | const cheogramDark: Palette = { | |
| 16 | + | background: "#191919", | |
| 17 | + | text: "#f1f1f1", | |
| 18 | + | primary: "#7401cf", | |
| 19 | + | secondary: "#ffc700", | |
| 20 | + | }; | |
| 21 | + | ||
| 22 | + | export const themePresets = { | |
| 23 | + | cheogram: { | |
| 24 | + | name: "Cheogram", | |
| 25 | + | light: { | |
| 26 | + | background: "#f7f5f0", | |
| 27 | + | text: "#212121", | |
| 28 | + | primary: "#7401cf", | |
| 29 | + | secondary: "#ffc700", | |
| 30 | + | accentSurface: "#f3daff", | |
| 31 | + | outgoingBackground: "#f3daff", | |
| 32 | + | outgoingColor: "#27123a", | |
| 33 | + | }, | |
| 34 | + | dark: cheogramDark, | |
| 35 | + | }, | |
| 36 | + | classic: { | |
| 37 | + | name: "Cheogram Classic", | |
| 38 | + | light: { | |
| 39 | + | background: "#ffffff", | |
| 40 | + | text: "#212121", | |
| 41 | + | primary: "#7401cf", | |
| 42 | + | secondary: "#ffc700", | |
| 43 | + | incomingBackground: "#d6b0f3", | |
| 44 | + | outgoingBackground: "#f5e9bc", | |
| 45 | + | outgoingColor: "#212121", | |
| 46 | + | }, | |
| 47 | + | dark: { | |
| 48 | + | ...cheogramDark, | |
| 49 | + | incomingBackground: "#3c2951", | |
| 50 | + | outgoingBackground: "secondarySurface", | |
| 51 | + | }, | |
| 52 | + | }, | |
| 53 | + | velvet: { | |
| 54 | + | name: "Velvet", | |
| 55 | + | light: { | |
| 56 | + | background: "#eff1f5", | |
| 57 | + | text: "#4c4f69", | |
| 58 | + | primary: "#8839ef", | |
| 59 | + | secondary: "#df8e1d", | |
| 60 | + | accentSurface: "#ccd0da", | |
| 61 | + | incomingBackground: "#e6e9ef", | |
| 62 | + | outgoingBackground: "#e3d5f5", | |
| 63 | + | outgoingColor: "#4c4f69", | |
| 64 | + | }, | |
| 65 | + | dark: { | |
| 66 | + | background: "#1e1e2e", | |
| 67 | + | text: "#cdd6f4", | |
| 68 | + | primary: "#a779d6", | |
| 69 | + | secondary: "#f9e2af", | |
| 70 | + | accentSurface: "#45475a", | |
| 71 | + | incomingBackground: "#313244", | |
| 72 | + | outgoingBackground: "#45365e", | |
| 73 | + | outgoingColor: "#cdd6f4", | |
| 74 | + | }, | |
| 75 | + | }, | |
| 76 | + | plum: { | |
| 77 | + | name: "Plum", | |
| 78 | + | light: { | |
| 79 | + | background: "#faf4ed", | |
| 80 | + | text: "#464261", | |
| 81 | + | primary: "#826b9b", | |
| 82 | + | secondary: "#d7827e", | |
| 83 | + | accentSurface: "#dfdad9", | |
| 84 | + | incomingBackground: "#f2e9e1", | |
| 85 | + | outgoingBackground: "#ece2f1", | |
| 86 | + | outgoingColor: "#464261", | |
| 87 | + | }, | |
| 88 | + | dark: { | |
| 89 | + | background: "#191724", | |
| 90 | + | text: "#e0def4", | |
| 91 | + | primary: "#744c9b", | |
| 92 | + | secondary: "#f6c177", | |
| 93 | + | accentSurface: "#403d52", | |
| 94 | + | incomingBackground: "#26233a", | |
| 95 | + | outgoingBackground: "#40314c", | |
| 96 | + | outgoingColor: "#e0def4", | |
| 97 | + | }, | |
| 98 | + | }, | |
| 99 | + | solarized: { | |
| 100 | + | name: "Solarized", | |
| 101 | + | light: { | |
| 102 | + | background: "#fdf6e3", | |
| 103 | + | text: "#51666d", | |
| 104 | + | primary: "#268bd2", | |
| 105 | + | secondary: "#b58900", | |
| 106 | + | accentSurface: "#eee8d5", | |
| 107 | + | incomingBackground: "#eee8d5", | |
| 108 | + | outgoingBackground: "#d9ebee", | |
| 109 | + | outgoingColor: "#51666d", | |
| 110 | + | }, | |
| 111 | + | dark: { | |
| 112 | + | background: "#002b36", | |
| 113 | + | text: "#93a1a1", | |
| 114 | + | primary: "#268bd2", | |
| 115 | + | secondary: "#b58900", | |
| 116 | + | accentSurface: "#073642", | |
| 117 | + | incomingBackground: "#073642", | |
| 118 | + | outgoingBackground: "#164654", | |
| 119 | + | outgoingColor: "#eee8d5", | |
| 120 | + | }, | |
| 121 | + | }, | |
| 122 | + | hotdogstand: { | |
| 123 | + | name: "Hot Dog Stand", | |
| 124 | + | light: { | |
| 125 | + | background: "#fec701", | |
| 126 | + | text: "#561029", | |
| 127 | + | primary: "#b51b00", | |
| 128 | + | secondary: "#5a1c00", | |
| 129 | + | }, | |
| 130 | + | dark: { | |
| 131 | + | background: "#b51b00", | |
| 132 | + | text: "#fff2cf", | |
| 133 | + | primary: "#fec701", | |
| 134 | + | secondary: "#5a1c00", | |
| 135 | + | }, | |
| 136 | + | }, | |
| 137 | + | }; | |
| 138 | + | ||
| 139 | + | export type Theme = keyof typeof themePresets | "custom"; | |
| 140 | + | export const defaultTheme = "cheogram"; | |
| 141 | + | export const defaultCustomPalette: Palette = { | |
| 142 | + | background: themePresets.cheogram.light.background, | |
| 143 | + | text: themePresets.cheogram.light.text, | |
| 144 | + | primary: themePresets.cheogram.light.primary, | |
| 145 | + | secondary: themePresets.cheogram.light.secondary, | |
| 146 | + | }; | |
| 147 | + | ||
| 148 | + | const channels = (hex: string) => | |
| 149 | + | [1, 3, 5].map((offset) => parseInt(hex.slice(offset, offset + 2), 16)); | |
| 150 | + | ||
| 151 | + | function mix(color: string, background: string, weight: number) { | |
| 152 | + | const base = channels(background); | |
| 153 | + | return ( | |
| 154 | + | "#" + | |
| 155 | + | channels(color) | |
| 156 | + | .map((channel, i) => | |
| 157 | + | Math.round(channel * weight + base[i] * (1 - weight)) | |
| 158 | + | .toString(16) | |
| 159 | + | .padStart(2, "0"), | |
| 160 | + | ) | |
| 161 | + | .join("") | |
| 162 | + | ); | |
| 163 | + | } | |
| 164 | + | ||
| 165 | + | // https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html#dfn-relative-luminance | |
| 166 | + | function luminance(color: string) { | |
| 167 | + | return channels(color).reduce((sum, channel, i) => { | |
| 168 | + | const value = channel / 255; | |
| 169 | + | return ( | |
| 170 | + | sum + | |
| 171 | + | (value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4) * | |
| 172 | + | [0.2126, 0.7152, 0.0722][i] | |
| 173 | + | ); | |
| 174 | + | }, 0); | |
| 175 | + | } | |
| 176 | + | ||
| 177 | + | export function contrast(a: string, b: string) { | |
| 178 | + | const values = [luminance(a), luminance(b)].sort((x, y) => y - x); | |
| 179 | + | return (values[0] + 0.05) / (values[1] + 0.05); | |
| 180 | + | } | |
| 181 | + | ||
| 182 | + | function foreground(background: string) { | |
| 183 | + | return contrast(background, "#ffffff") > contrast(background, "#000000") | |
| 184 | + | ? "#ffffff" | |
| 185 | + | : "#000000"; | |
| 186 | + | } | |
| 187 | + | ||
| 188 | + | export function themeVariables(theme: { | |
| 189 | + | light: PresetPalette; | |
| 190 | + | dark: PresetPalette; | |
| 191 | + | }) { | |
| 192 | + | const variables: Record<string, string> = {}; | |
| 193 | + | for (const mode of ["light", "dark"] as const) { | |
| 194 | + | const { | |
| 195 | + | background, | |
| 196 | + | text, | |
| 197 | + | primary, | |
| 198 | + | secondary, | |
| 199 | + | accentSurface, | |
| 200 | + | incomingBackground, | |
| 201 | + | } = theme[mode]; | |
| 202 | + | const secondarySurface = mix(secondary, background, 0.3); | |
| 203 | + | const outgoingBackground = | |
| 204 | + | theme[mode].outgoingBackground === "secondarySurface" | |
| 205 | + | ? secondarySurface | |
| 206 | + | : (theme[mode].outgoingBackground ?? primary); | |
| 207 | + | const outgoingColor = | |
| 208 | + | theme[mode].outgoingColor ?? foreground(outgoingBackground); | |
| 209 | + | const backgrounds = [ | |
| 210 | + | background, | |
| 211 | + | incomingBackground ?? mix(text, background, 0.07), | |
| 212 | + | accentSurface ?? mix(primary, background, 0.13), | |
| 213 | + | accentSurface ?? mix(primary, background, 0.24), | |
| 214 | + | secondarySurface, | |
| 215 | + | ]; | |
| 216 | + | const target = foreground(background); | |
| 217 | + | let link = primary; | |
| 218 | + | for ( | |
| 219 | + | let step = 1; | |
| 220 | + | backgrounds.some((bg) => contrast(link, bg) < 4.5) && step <= 100; | |
| 221 | + | step++ | |
| 222 | + | ) | |
| 223 | + | link = mix(primary, target, 1 - step / 100); | |
| 224 | + | const colours = { | |
| 225 | + | background, | |
| 226 | + | text, | |
| 227 | + | primary, | |
| 228 | + | secondary, | |
| 229 | + | "secondary-surface": secondarySurface, | |
| 230 | + | "accent-surface": accentSurface ?? "initial", | |
| 231 | + | "incoming-background": incomingBackground ?? "initial", | |
| 232 | + | "outgoing-background": outgoingBackground, | |
| 233 | + | "outgoing-color": outgoingColor, | |
| 234 | + | "on-primary": foreground(primary), | |
| 235 | + | "on-secondary": foreground(secondary), | |
| 236 | + | "on-app": foreground(primary), | |
| 237 | + | link, | |
| 238 | + | }; | |
| 239 | + | for (const [role, colour] of Object.entries(colours)) | |
| 240 | + | variables[`--theme-${mode}-${role}`] = colour; | |
| 241 | + | } | |
| 242 | + | return variables; | |
| 243 | + | } | |
| 244 | + | ||
| 245 | + | export function applyTheme(theme: Theme, customPalette: Palette) { | |
| 246 | + | const palettes = | |
| 247 | + | theme === "custom" | |
| 248 | + | ? { light: customPalette, dark: customPalette } | |
| 249 | + | : themePresets[theme]; | |
| 250 | + | for (const [name, colour] of Object.entries(themeVariables(palettes))) | |
| 251 | + | document.documentElement.style.setProperty(name, colour); | |
| 252 | + | } |