cherry-styled-components 0.2.20 → 0.2.21
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
CHANGED
|
@@ -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-5bf22726-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
|
@@ -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.colors.primary, theme.colors.primary, theme.colors.primary, $outline ? "transparent" : theme.colors.primaryDark, theme.colors.primaryDark, $outline && `color: ${theme.colors.primaryDark}`, theme.colors.primaryLight, theme.colors.primaryLight), !disabled && $variant === "secondary" && css([
|
|
32
|
+
], $outline ? theme.colors.primary : filledTextColor(theme, "primary"), !$outline && darkFilledTextRule(theme, "primary"), $outline ? "transparent" : theme.colors.primary, theme.colors.primary, theme.colors.primary, $outline ? "transparent" : theme.colors.primaryDark, theme.colors.primaryDark, $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-75947fe4-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
|
@@ -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-3bca3977-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.colors.primary, filledTextColor(theme), darkFilledTextRule(theme)) : css([`& .chat-message-content{color:`, `;width:100%;}& .chat-message-avatar{position:sticky;bottom:0;}`], theme.colors.dark));
|
|
39
|
+
], theme.colors.primary, 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,
|
|
@@ -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,23 @@ 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
|
+
export type FilledTextFill = "primary" | "other";
|
|
12
14
|
/**
|
|
13
|
-
* Text color for a label sitting on a brand-colored fill: the
|
|
15
|
+
* Text color for a label sitting on a brand-colored fill: the theme's
|
|
16
|
+
* `onPrimary` on a primary fill when it sets one, else the palette's
|
|
14
17
|
* contrasting end, `light` in light mode and `dark` in dark mode.
|
|
15
18
|
*/
|
|
16
|
-
export declare const filledTextColor: (theme: Theme) => string;
|
|
19
|
+
export declare const filledTextColor: (theme: Theme, fill?: FilledTextFill) => string;
|
|
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.
|
|
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`.
|
|
22
27
|
*/
|
|
23
|
-
export declare const darkFilledTextRule: (theme: Theme) => string;
|
|
28
|
+
export declare const darkFilledTextRule: (theme: Theme, fill?: FilledTextFill) => string;
|
|
24
29
|
/**
|
|
25
30
|
* Slim, theme-aware scrollbar for internal scroll areas (chat transcripts, code
|
|
26
31
|
* blocks, tables) so the chunky native bar doesn't stand out, especially in
|
package/dist/utils/mixins.js
CHANGED
|
@@ -11,15 +11,18 @@ import { css } from "styled-components";
|
|
|
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
13
|
/**
|
|
14
|
-
* Text color for a label sitting on a brand-colored fill: the
|
|
14
|
+
* Text color for a label sitting on a brand-colored fill: the theme's
|
|
15
|
+
* `onPrimary` on a primary fill when it sets one, else the palette's
|
|
15
16
|
* contrasting end, `light` in light mode and `dark` in dark mode.
|
|
16
|
-
*/ var filledTextColor = (theme) => theme.isDark ? theme.colors.dark : theme.colors.light;
|
|
17
|
+
*/ var filledTextColor = (theme, fill = "other") => fill === "primary" && theme.colors.onPrimary ? theme.colors.onPrimary : theme.isDark ? theme.colors.dark : theme.colors.light;
|
|
17
18
|
/**
|
|
18
19
|
* The same choice restated as a rule scoped to a `dark` class on <html>, which
|
|
19
20
|
* is what apps resolving the mode in CSS key off before hydration can swap the
|
|
20
21
|
* theme object. Additive: with an already-dark theme object both paths resolve
|
|
21
|
-
* to the same color.
|
|
22
|
-
|
|
22
|
+
* to the same color. A dark theme object's `onPrimary` answers for a primary
|
|
23
|
+
* fill; a light one under the class cannot know the dark value, so it keeps
|
|
24
|
+
* the palette's `dark`. Interpolate alongside `filledTextColor`.
|
|
25
|
+
*/ var darkFilledTextRule = (theme, fill = "other") => `:root.dark & { color: ${fill === "primary" && theme.isDark && theme.colors.onPrimary ? theme.colors.onPrimary : theme.colors.dark}; }`;
|
|
23
26
|
/**
|
|
24
27
|
* Slim, theme-aware scrollbar for internal scroll areas (chat transcripts, code
|
|
25
28
|
* blocks, tables) so the chunky native bar doesn't stand out, especially in
|
package/dist/utils/theme.d.ts
CHANGED
|
@@ -57,6 +57,14 @@ 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;
|
|
60
68
|
}
|
|
61
69
|
export interface Shadows<TString = string> {
|
|
62
70
|
xs: TString;
|
package/package.json
CHANGED