Add Stationery and Stationery Dark themes with notebook chrome.
Manila folders, ruled chat, post-it nav, and folder tabs; dark variant uses Catppuccin Mocha colors with muted stickies and soft glows.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import React from 'react';
|
||||
import React, { CSSProperties, useMemo } from 'react';
|
||||
import { Text, as } from 'folds';
|
||||
import classNames from 'classnames';
|
||||
import * as css from './layout.css';
|
||||
import { isStationeryTheme, useTheme } from '../../../hooks/useTheme';
|
||||
import { STATIONERY_NAME_INK } from '../../../utils/paperSafeInk';
|
||||
|
||||
export const MessageBase = as<'div', css.MessageBaseVariants>(
|
||||
({ className, highlight, selected, collapse, autoCollapse, space, newMessage, ...props }, ref) => (
|
||||
@@ -10,6 +12,7 @@ export const MessageBase = as<'div', css.MessageBaseVariants>(
|
||||
css.MessageBase({ highlight, selected, collapse, autoCollapse, space, newMessage }),
|
||||
className
|
||||
)}
|
||||
data-message-collapsed={collapse ? '' : undefined}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
@@ -17,12 +20,45 @@ export const MessageBase = as<'div', css.MessageBaseVariants>(
|
||||
);
|
||||
|
||||
export const AvatarBase = as<'span'>(({ className, ...props }, ref) => (
|
||||
<span className={classNames(css.AvatarBase, className)} {...props} ref={ref} />
|
||||
<span
|
||||
className={classNames(css.AvatarBase, className)}
|
||||
data-message-avatar=""
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
));
|
||||
|
||||
export const Username = as<'span'>(({ as: AsUsername = 'span', className, ...props }, ref) => (
|
||||
<AsUsername className={classNames(css.Username, className)} {...props} ref={ref} />
|
||||
));
|
||||
export const Username = as<'span'>(({ as: AsUsername = 'span', className, style, ...props }, ref) => {
|
||||
const theme = useTheme();
|
||||
const isStationery = isStationeryTheme(theme);
|
||||
const userColor =
|
||||
typeof (style as CSSProperties | undefined)?.color === 'string'
|
||||
? ((style as CSSProperties).color as string)
|
||||
: undefined;
|
||||
|
||||
const safeStyle = useMemo((): CSSProperties | undefined => {
|
||||
if (!isStationery) return style as CSSProperties | undefined;
|
||||
return {
|
||||
...(style as CSSProperties | undefined),
|
||||
// Name in ink; keep their color as an accent underline
|
||||
color: STATIONERY_NAME_INK,
|
||||
...(userColor
|
||||
? { ['--username-accent' as string]: userColor, textDecorationColor: userColor }
|
||||
: null),
|
||||
};
|
||||
}, [style, isStationery, userColor]);
|
||||
|
||||
return (
|
||||
<AsUsername
|
||||
className={classNames(css.Username, className)}
|
||||
data-message-username=""
|
||||
data-username-accent={isStationery && userColor ? '' : undefined}
|
||||
style={safeStyle}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const UsernameBold = as<'b'>(({ as: AsUsernameBold = 'b', className, ...props }, ref) => (
|
||||
<AsUsernameBold className={classNames(css.UsernameBold, className)} {...props} ref={ref} />
|
||||
@@ -36,6 +72,8 @@ export const MessageTextBody = as<'div', css.MessageTextBodyVariants & { notice?
|
||||
priority={notice ? '300' : '400'}
|
||||
className={classNames(css.MessageTextBody({ preWrap, jumboEmoji, emote }), className)}
|
||||
data-allow-text-selection="true"
|
||||
data-message-body=""
|
||||
data-jumbo-emoji={jumboEmoji ? '' : undefined}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user