cherry-styled-components 0.2.20 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/avatar.js +5 -4
- package/dist/button.js +3 -3
- package/dist/chat-message.js +3 -3
- package/dist/index.js +2 -2
- package/dist/styled-components/client-theme-provider.js +3 -1
- package/dist/utils/mixins.d.ts +13 -4
- package/dist/utils/mixins.js +10 -5
- package/dist/utils/theme.d.ts +16 -0
- package/package.json +1 -1
package/dist/avatar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { darkFilledTextRule, filledTextColor } from "./utils/mixins.js";
|
|
3
|
+
import { darkFilledTextRule, filledTextColor, primaryFillColor } from "./utils/mixins.js";
|
|
4
4
|
import { renderIcon } from "./icon.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { forwardRef } from "react";
|
|
@@ -22,7 +22,7 @@ var avatarSizes = {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
var avatarColors = {
|
|
25
|
-
primary: (theme) => theme
|
|
25
|
+
primary: (theme) => primaryFillColor(theme),
|
|
26
26
|
secondary: (theme) => theme.colors.secondary,
|
|
27
27
|
tertiary: (theme) => theme.colors.tertiary,
|
|
28
28
|
gray: (theme) => theme.colors.grayDark
|
|
@@ -32,9 +32,10 @@ function toInitials(name) {
|
|
|
32
32
|
}
|
|
33
33
|
var StyledAvatar = styled.span.withConfig({
|
|
34
34
|
displayName: "avatar__StyledAvatar",
|
|
35
|
-
componentId: "sc-
|
|
35
|
+
componentId: "sc-616c0fb2-0"
|
|
36
36
|
})([``, `;`], ({ theme, $size = "default", $color = "primary" }) => {
|
|
37
37
|
const { box } = avatarSizes[$size];
|
|
38
|
+
const fill = $color === "primary" ? "primary" : "other";
|
|
38
39
|
return css([
|
|
39
40
|
`display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;overflow:hidden;width:`,
|
|
40
41
|
`px;height:`,
|
|
@@ -43,7 +44,7 @@ var StyledAvatar = styled.span.withConfig({
|
|
|
43
44
|
`;font-size:`,
|
|
44
45
|
`px;line-height:1;font-weight:600;user-select:none;`,
|
|
45
46
|
`;& img{width:100%;height:100%;object-fit:cover;display:block;}`
|
|
46
|
-
], box, box, avatarColors[$color](theme), filledTextColor(theme), Math.round(box * .38), darkFilledTextRule(theme));
|
|
47
|
+
], box, box, avatarColors[$color](theme), filledTextColor(theme, fill), Math.round(box * .38), darkFilledTextRule(theme, fill));
|
|
47
48
|
});
|
|
48
49
|
function LocalAvatar({ $size = "default", $src, $alt, $name, $icon = User, $color, ...props }, ref) {
|
|
49
50
|
const initials = $name ? toInitials($name) : "";
|
package/dist/button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { darkFilledTextRule, filledTextColor, formElementHeightStyles, resetButton, shade, tint } from "./utils/mixins.js";
|
|
3
|
+
import { darkFilledTextRule, filledTextColor, formElementHeightStyles, primaryFillColor, primaryFillHoverColor, resetButton, shade, tint } from "./utils/mixins.js";
|
|
4
4
|
import { jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { forwardRef } from "react";
|
|
6
6
|
import styled, { css } from "styled-components";
|
|
@@ -29,7 +29,7 @@ var buttonStyles = (theme, $variant, $size, $outline, $fullWidth, $error, disabl
|
|
|
29
29
|
`;}&:focus{box-shadow:0 0 0 4px `,
|
|
30
30
|
`;}&:active{box-shadow:0 0 0 2px `,
|
|
31
31
|
`;}`
|
|
32
|
-
], $outline ? theme.colors.primary : filledTextColor(theme), !$outline && darkFilledTextRule(theme), $outline ? "transparent" : theme
|
|
32
|
+
], $outline ? theme.colors.primary : filledTextColor(theme, "primary"), !$outline && darkFilledTextRule(theme, "primary"), $outline ? "transparent" : primaryFillColor(theme), $outline ? theme.colors.primary : primaryFillColor(theme), theme.colors.primary, $outline ? "transparent" : primaryFillHoverColor(theme), $outline ? theme.colors.primaryDark : primaryFillHoverColor(theme), $outline && `color: ${theme.colors.primaryDark}`, theme.colors.primaryLight, theme.colors.primaryLight), !disabled && $variant === "secondary" && css([
|
|
33
33
|
`color:`,
|
|
34
34
|
`;`,
|
|
35
35
|
` background:`,
|
|
@@ -80,7 +80,7 @@ var buttonStyles = (theme, $variant, $size, $outline, $fullWidth, $error, disabl
|
|
|
80
80
|
`, $fullWidth && `width: 100%;`);
|
|
81
81
|
var StyledButton = styled.button.withConfig({
|
|
82
82
|
displayName: "button__StyledButton",
|
|
83
|
-
componentId: "sc-
|
|
83
|
+
componentId: "sc-577b793f-0"
|
|
84
84
|
})([``, ``], ({ theme, $variant, $error, $size, $outline, $fullWidth, disabled }) => buttonStyles(theme, $variant, $size, $outline, $fullWidth, $error, disabled));
|
|
85
85
|
function LocalButton({ $variant = "primary", ...props }, ref) {
|
|
86
86
|
return /*#__PURE__*/ jsxs(StyledButton, {
|
package/dist/chat-message.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
import { mq } from "./utils/theme.js";
|
|
4
|
-
import { darkFilledTextRule, filledTextColor } from "./utils/mixins.js";
|
|
4
|
+
import { darkFilledTextRule, filledTextColor, primaryFillColor } from "./utils/mixins.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { forwardRef } from "react";
|
|
7
7
|
import styled, { css } from "styled-components";
|
|
@@ -19,7 +19,7 @@ import styled, { css } from "styled-components";
|
|
|
19
19
|
], theme.fontSizes.text.xs, theme.lineHeights.text.xs, mq("lg"), theme.fontSizes.small.lg, theme.lineHeights.small.lg);
|
|
20
20
|
var StyledChatMessage = styled.div.withConfig({
|
|
21
21
|
displayName: "chat-message__StyledChatMessage",
|
|
22
|
-
componentId: "sc-
|
|
22
|
+
componentId: "sc-7327cbb7-0"
|
|
23
23
|
})([
|
|
24
24
|
`display:flex;align-items:flex-end;gap:10px;width:100%;& .chat-message-avatar{flex-shrink:0;display:flex;align-items:center;height:calc( `,
|
|
25
25
|
` * `,
|
|
@@ -36,7 +36,7 @@ var StyledChatMessage = styled.div.withConfig({
|
|
|
36
36
|
`;color:`,
|
|
37
37
|
`;`,
|
|
38
38
|
`;padding:9px 14px;border-radius:16px 16px 4px 16px;margin-left:auto;width:fit-content;max-width:min(560px,88%);font-weight:500;white-space:pre-wrap;overflow-wrap:anywhere;}`
|
|
39
|
-
], theme
|
|
39
|
+
], primaryFillColor(theme), filledTextColor(theme, "primary"), darkFilledTextRule(theme, "primary")) : css([`& .chat-message-content{color:`, `;width:100%;}& .chat-message-avatar{position:sticky;bottom:0;}`], theme.colors.dark));
|
|
40
40
|
function LocalChatMessage({ children, $role = "assistant", $avatar, ...props }, ref) {
|
|
41
41
|
return /*#__PURE__*/ jsxs(StyledChatMessage, {
|
|
42
42
|
$role,
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GlobalStyles } from "./utils/global.js";
|
|
2
2
|
import { breakpoints, colors, colorsDark, fontSizes, fonts, lineHeights, mq, shadows, shadowsDark, spacing, theme, themeDark } from "./utils/theme.js";
|
|
3
|
-
import { alpha, darkFilledTextRule, errorInteractiveStyles, filledTextColor, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, interactiveStyles, resetButton, resetInput, shade, statusBorderStyles, thinScrollbar, tint } from "./utils/mixins.js";
|
|
3
|
+
import { alpha, darkFilledTextRule, errorInteractiveStyles, filledTextColor, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, interactiveStyles, primaryFillColor, primaryFillHoverColor, resetButton, resetInput, shade, statusBorderStyles, thinScrollbar, tint } from "./utils/mixins.js";
|
|
4
4
|
import { createTypographyStyle, styledBlockquote, styledButton, styledButtonBig, styledCode, styledH1, styledH2, styledH3, styledH4, styledH5, styledH6, styledHero1, styledHero2, styledHero3, styledInput, styledInputBig, styledSmall, styledStrong, styledText } from "./utils/typography.js";
|
|
5
5
|
import { useLockBodyScroll } from "./utils/use-lock-body-scroll.js";
|
|
6
6
|
import { useBelowBreakpoint, useMediaQuery } from "./utils/use-media-query.js";
|
|
@@ -44,4 +44,4 @@ import { Textarea } from "./textarea.js";
|
|
|
44
44
|
import { ThemeToggle } from "./theme-toggle.js";
|
|
45
45
|
import { StyledNotificationItem, StyledNotifications, ToastNotifications, ToastNotificationsContext, ToastNotificationsProvider, useToastNotifications } from "./toast.js";
|
|
46
46
|
import { Toggle } from "./toggle.js";
|
|
47
|
-
export { Accordion, Avatar, AvatarDropzone, Box, Button, Callout, ChatContext, ChatInput, ChatLauncher, ChatMessage, ChatMessageList, ChatPanel, ChatProvider, ChatSource, ChatSources, ChatTyping, CherryThemeProvider, ClientThemeProvider, Col, Container, Dropzone, Flex, GlobalStyles, Grid, Icon, IconButton, Input, MaxWidth, Modal, Password, Prose, Range, Select, Space, Spinner, StyledIconWrapper, StyledInputWrapper, StyledLabel, StyledNotificationItem, StyledNotifications, TabContent, Tabs, Textarea, ThemeContext, ThemeToggle, ToastNotifications, ToastNotificationsContext, ToastNotificationsProvider, Toggle, alpha, breakpoints, buttonStyles, chatTextStyles, colors, colorsDark, createThemeInitScript, createTypographyStyle, darkFilledTextRule, errorInteractiveStyles, filledTextColor, fontSizes, fonts, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, iconButtonStyles, interactiveStyles, lineHeights, matchesAccept, mq, proseStyles, renderIcon, resetButton, resetInput, resolveShowcaseCommand, resolveTheme, shade, shadows, shadowsDark, showcaseCommands, spacing, statusBorderStyles, styledBlockquote, styledButton, styledButtonBig, styledCode, styledH1, styledH2, styledH3, styledH4, styledH5, styledH6, styledHero1, styledHero2, styledHero3, styledInput, styledInputBig, styledSmall, styledStrong, styledText, theme, themeDark, themeInitScript, thinScrollbar, tint, useBelowBreakpoint, useChat, useLockBodyScroll, useMediaQuery, useModalLayer, useOnClickOutside, useToastNotifications };
|
|
47
|
+
export { Accordion, Avatar, AvatarDropzone, Box, Button, Callout, ChatContext, ChatInput, ChatLauncher, ChatMessage, ChatMessageList, ChatPanel, ChatProvider, ChatSource, ChatSources, ChatTyping, CherryThemeProvider, ClientThemeProvider, Col, Container, Dropzone, Flex, GlobalStyles, Grid, Icon, IconButton, Input, MaxWidth, Modal, Password, Prose, Range, Select, Space, Spinner, StyledIconWrapper, StyledInputWrapper, StyledLabel, StyledNotificationItem, StyledNotifications, TabContent, Tabs, Textarea, ThemeContext, ThemeToggle, ToastNotifications, ToastNotificationsContext, ToastNotificationsProvider, Toggle, alpha, breakpoints, buttonStyles, chatTextStyles, colors, colorsDark, createThemeInitScript, createTypographyStyle, darkFilledTextRule, errorInteractiveStyles, filledTextColor, fontSizes, fonts, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, iconButtonStyles, interactiveStyles, lineHeights, matchesAccept, mq, primaryFillColor, primaryFillHoverColor, proseStyles, renderIcon, resetButton, resetInput, resolveShowcaseCommand, resolveTheme, shade, shadows, shadowsDark, showcaseCommands, spacing, statusBorderStyles, styledBlockquote, styledButton, styledButtonBig, styledCode, styledH1, styledH2, styledH3, styledH4, styledH5, styledH6, styledHero1, styledHero2, styledHero3, styledInput, styledInputBig, styledSmall, styledStrong, styledText, theme, themeDark, themeInitScript, thinScrollbar, tint, useBelowBreakpoint, useChat, useLockBodyScroll, useMediaQuery, useModalLayer, useOnClickOutside, useToastNotifications };
|
|
@@ -77,7 +77,9 @@ function resolveColor(value) {
|
|
|
77
77
|
}, [effectiveTheme.isDark, reconciled]);
|
|
78
78
|
useEffect(() => {
|
|
79
79
|
if (!$themeColor) return;
|
|
80
|
-
const
|
|
80
|
+
const color = effectiveTheme.colors[$themeColor];
|
|
81
|
+
if (!color) return;
|
|
82
|
+
const background = resolveColor(color);
|
|
81
83
|
let meta = document.querySelector("meta[name=\"theme-color\"]");
|
|
82
84
|
if (!meta) {
|
|
83
85
|
meta = document.createElement("meta");
|
package/dist/utils/mixins.d.ts
CHANGED
|
@@ -9,18 +9,27 @@ export declare const alpha: (color: string, percent: number) => string;
|
|
|
9
9
|
export declare const shade: (color: string, percent: number) => string;
|
|
10
10
|
/** Lightens a color by mixing it toward white. See `alpha` for why it is CSS. */
|
|
11
11
|
export declare const tint: (color: string, percent: number) => string;
|
|
12
|
+
/** Which fill a label sits on, so a theme's `onPrimary` can answer for its own. */
|
|
13
|
+
/** The solid primary fill: the theme's `primaryFill`, else `primary`. */
|
|
14
|
+
export declare const primaryFillColor: (theme: Theme) => string;
|
|
15
|
+
/** The solid primary fill on hover: a shade of `primaryFill`, else `primaryDark`. */
|
|
16
|
+
export declare const primaryFillHoverColor: (theme: Theme) => string;
|
|
17
|
+
export type FilledTextFill = "primary" | "other";
|
|
12
18
|
/**
|
|
13
|
-
* Text color for a label sitting on a brand-colored fill: the
|
|
19
|
+
* Text color for a label sitting on a brand-colored fill: the theme's
|
|
20
|
+
* `onPrimary` on a primary fill when it sets one, else the palette's
|
|
14
21
|
* contrasting end, `light` in light mode and `dark` in dark mode.
|
|
15
22
|
*/
|
|
16
|
-
export declare const filledTextColor: (theme: Theme) => string;
|
|
23
|
+
export declare const filledTextColor: (theme: Theme, fill?: FilledTextFill) => string;
|
|
17
24
|
/**
|
|
18
25
|
* The same choice restated as a rule scoped to a `dark` class on <html>, which
|
|
19
26
|
* is what apps resolving the mode in CSS key off before hydration can swap the
|
|
20
27
|
* theme object. Additive: with an already-dark theme object both paths resolve
|
|
21
|
-
* to the same color.
|
|
28
|
+
* to the same color. A dark theme object's `onPrimary` answers for a primary
|
|
29
|
+
* fill; a light one under the class cannot know the dark value, so it keeps
|
|
30
|
+
* the palette's `dark`. Interpolate alongside `filledTextColor`.
|
|
22
31
|
*/
|
|
23
|
-
export declare const darkFilledTextRule: (theme: Theme) => string;
|
|
32
|
+
export declare const darkFilledTextRule: (theme: Theme, fill?: FilledTextFill) => string;
|
|
24
33
|
/**
|
|
25
34
|
* Slim, theme-aware scrollbar for internal scroll areas (chat transcripts, code
|
|
26
35
|
* blocks, tables) so the chunky native bar doesn't stand out, especially in
|
package/dist/utils/mixins.js
CHANGED
|
@@ -10,16 +10,21 @@ import { css } from "styled-components";
|
|
|
10
10
|
*/ var alpha = (color, percent) => `color-mix(in srgb, ${color} ${percent}%, transparent)`;
|
|
11
11
|
/** Darkens a color by mixing it toward black. See `alpha` for why it is CSS. */ var shade = (color, percent) => `color-mix(in srgb, ${color} ${100 - percent}%, black)`;
|
|
12
12
|
/** Lightens a color by mixing it toward white. See `alpha` for why it is CSS. */ var tint = (color, percent) => `color-mix(in srgb, ${color} ${100 - percent}%, white)`;
|
|
13
|
+
/** Which fill a label sits on, so a theme's `onPrimary` can answer for its own. */ /** The solid primary fill: the theme's `primaryFill`, else `primary`. */ var primaryFillColor = (theme) => theme.colors.primaryFill ?? theme.colors.primary;
|
|
14
|
+
/** The solid primary fill on hover: a shade of `primaryFill`, else `primaryDark`. */ var primaryFillHoverColor = (theme) => theme.colors.primaryFill ? shade(theme.colors.primaryFill, 10) : theme.colors.primaryDark;
|
|
13
15
|
/**
|
|
14
|
-
* Text color for a label sitting on a brand-colored fill: the
|
|
16
|
+
* Text color for a label sitting on a brand-colored fill: the theme's
|
|
17
|
+
* `onPrimary` on a primary fill when it sets one, else the palette's
|
|
15
18
|
* contrasting end, `light` in light mode and `dark` in dark mode.
|
|
16
|
-
*/ var filledTextColor = (theme) => theme.isDark ? theme.colors.dark : theme.colors.light;
|
|
19
|
+
*/ var filledTextColor = (theme, fill = "other") => fill === "primary" && theme.colors.onPrimary ? theme.colors.onPrimary : theme.isDark ? theme.colors.dark : theme.colors.light;
|
|
17
20
|
/**
|
|
18
21
|
* The same choice restated as a rule scoped to a `dark` class on <html>, which
|
|
19
22
|
* is what apps resolving the mode in CSS key off before hydration can swap the
|
|
20
23
|
* theme object. Additive: with an already-dark theme object both paths resolve
|
|
21
|
-
* to the same color.
|
|
22
|
-
|
|
24
|
+
* to the same color. A dark theme object's `onPrimary` answers for a primary
|
|
25
|
+
* fill; a light one under the class cannot know the dark value, so it keeps
|
|
26
|
+
* the palette's `dark`. Interpolate alongside `filledTextColor`.
|
|
27
|
+
*/ var darkFilledTextRule = (theme, fill = "other") => `:root.dark & { color: ${fill === "primary" && theme.isDark && theme.colors.onPrimary ? theme.colors.onPrimary : theme.colors.dark}; }`;
|
|
23
28
|
/**
|
|
24
29
|
* Slim, theme-aware scrollbar for internal scroll areas (chat transcripts, code
|
|
25
30
|
* blocks, tables) so the chunky native bar doesn't stand out, especially in
|
|
@@ -105,4 +110,4 @@ var generateDirectionStyles = (size, direction) => css([
|
|
|
105
110
|
`;}`
|
|
106
111
|
], mq(size), direction && `${direction}`);
|
|
107
112
|
//#endregion
|
|
108
|
-
export { alpha, darkFilledTextRule, errorInteractiveStyles, filledTextColor, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, interactiveStyles, resetButton, resetInput, shade, statusBorderStyles, thinScrollbar, tint };
|
|
113
|
+
export { alpha, darkFilledTextRule, errorInteractiveStyles, filledTextColor, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, interactiveStyles, primaryFillColor, primaryFillHoverColor, resetButton, resetInput, shade, statusBorderStyles, thinScrollbar, tint };
|
package/dist/utils/theme.d.ts
CHANGED
|
@@ -57,6 +57,22 @@ export interface Colors<TString = string> {
|
|
|
57
57
|
info: TString;
|
|
58
58
|
dark: TString;
|
|
59
59
|
light: TString;
|
|
60
|
+
/**
|
|
61
|
+
* Optional label color for text on a `primary` fill (a primary button, a
|
|
62
|
+
* sent chat bubble, a primary avatar). Set it when neither `light` nor
|
|
63
|
+
* `dark` reads on the theme's primary, e.g. a bright dark-mode primary
|
|
64
|
+
* that a light label cannot sit on. Without it the fill takes the palette's
|
|
65
|
+
* contrasting end, as `filledTextColor` describes.
|
|
66
|
+
*/
|
|
67
|
+
onPrimary?: TString;
|
|
68
|
+
/**
|
|
69
|
+
* Optional fill for the solid primary surfaces (the primary button, the
|
|
70
|
+
* sent chat bubble, the primary avatar), whose label is `onPrimary`. Set it
|
|
71
|
+
* when the theme's `primary` is too bright to carry a label but still right
|
|
72
|
+
* for accents (links, rings, outlines): the fills take this deeper shade
|
|
73
|
+
* and the accents keep `primary`. Without it the fills use `primary`.
|
|
74
|
+
*/
|
|
75
|
+
primaryFill?: TString;
|
|
60
76
|
}
|
|
61
77
|
export interface Shadows<TString = string> {
|
|
62
78
|
xs: TString;
|
package/package.json
CHANGED