cherry-styled-components 0.2.10 → 0.2.11
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/theme-toggle.d.ts +5 -0
- package/dist/theme-toggle.js +14 -3
- package/package.json +9 -8
package/dist/theme-toggle.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export interface ThemeToggleProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
3
|
$hidden?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Binds the Cmd/Ctrl+Shift+L keyboard shortcut while the toggle is mounted,
|
|
6
|
+
* flipping between the light and dark theme without a click. Off by default.
|
|
7
|
+
*/
|
|
8
|
+
$shortcut?: boolean;
|
|
4
9
|
}
|
|
5
10
|
declare const ThemeToggle: React.ForwardRefExoticComponent<ThemeToggleProps & React.RefAttributes<HTMLButtonElement>>;
|
|
6
11
|
export { ThemeToggle };
|
package/dist/theme-toggle.js
CHANGED
|
@@ -4,13 +4,13 @@ import { interactiveStyles, resetButton } from "./utils/mixins.js";
|
|
|
4
4
|
import { ThemeContext } from "./styled-components/theme-provider.js";
|
|
5
5
|
import { Icon } from "./icon.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { forwardRef, useContext } from "react";
|
|
7
|
+
import { forwardRef, useContext, useEffect } from "react";
|
|
8
8
|
import styled, { css } from "styled-components";
|
|
9
9
|
import { rgba } from "polished";
|
|
10
10
|
//#region src/lib/theme-toggle.tsx
|
|
11
11
|
var StyledThemeToggle = styled.button.withConfig({
|
|
12
12
|
displayName: "theme-toggle__StyledThemeToggle",
|
|
13
|
-
componentId: "sc-
|
|
13
|
+
componentId: "sc-b64afa35-0"
|
|
14
14
|
})([
|
|
15
15
|
``,
|
|
16
16
|
` `,
|
|
@@ -23,8 +23,19 @@ var StyledThemeToggle = styled.button.withConfig({
|
|
|
23
23
|
`;}&:hover svg[stroke]{stroke:`,
|
|
24
24
|
`;}`
|
|
25
25
|
], resetButton, interactiveStyles, ({ theme }) => theme.colors.light, ({ theme }) => theme.colors.grayLight, ({ theme }) => rgba(theme.colors.primaryLight, .2), ({ theme }) => theme.isDark && css([`transform:translateX(26px);`]), ({ $hidden }) => $hidden && css([`display:none;`]), ({ theme }) => theme.colors.primary, ({ theme }) => theme.isDark ? theme.colors.primaryLight : theme.colors.primaryDark);
|
|
26
|
-
function LocalThemeToggle({ onClick, ...props }, ref) {
|
|
26
|
+
function LocalThemeToggle({ onClick, $shortcut = false, ...props }, ref) {
|
|
27
27
|
const { toggleTheme } = useContext(ThemeContext);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!$shortcut) return;
|
|
30
|
+
function handleKeyDown(event) {
|
|
31
|
+
if (!(event.metaKey || event.ctrlKey) || !event.shiftKey || event.altKey) return;
|
|
32
|
+
if (event.key.toLowerCase() !== "l") return;
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
toggleTheme();
|
|
35
|
+
}
|
|
36
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
37
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
38
|
+
}, [$shortcut, toggleTheme]);
|
|
28
39
|
return /*#__PURE__*/ jsxs(StyledThemeToggle, {
|
|
29
40
|
type: "button",
|
|
30
41
|
"aria-label": "Toggle Theme",
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cherry-styled-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Cherry is a design system for the modern web. Designed in Figma, built in React using Typescript.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./dist/
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"screenshots": "node scripts/screenshot-previews.cjs"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"lucide-react": "^1.
|
|
46
|
+
"lucide-react": "^1.24.0",
|
|
47
47
|
"polished": "^4.3.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -53,22 +53,23 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@swc/plugin-styled-components": "^12.15.0",
|
|
56
|
-
"@types/node": "^26.1.
|
|
56
|
+
"@types/node": "^26.1.1",
|
|
57
57
|
"@types/react": "^19.2.17",
|
|
58
58
|
"@types/react-dom": "^19.2.3",
|
|
59
|
+
"@typescript/typescript6": "^6.0.2",
|
|
59
60
|
"@vitejs/plugin-react-swc": "^4.3.1",
|
|
60
61
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
61
62
|
"eslint-plugin-react-refresh": "^0.5.3",
|
|
62
63
|
"next": "^16.2.10",
|
|
63
64
|
"playwright-core": "^1.61.1",
|
|
64
|
-
"prettier": "^3.9.
|
|
65
|
+
"prettier": "^3.9.5",
|
|
65
66
|
"react": "^19.2.7",
|
|
66
67
|
"react-dom": "^19.2.7",
|
|
67
68
|
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
68
69
|
"sharp": "^0.35.3",
|
|
69
70
|
"styled-components": "^6.4.3",
|
|
70
|
-
"typescript": "^
|
|
71
|
-
"vite": "^8.1.
|
|
71
|
+
"typescript": "^7.0.2",
|
|
72
|
+
"vite": "^8.1.4",
|
|
72
73
|
"vite-plugin-dts": "^5.0.3"
|
|
73
74
|
}
|
|
74
75
|
}
|