Skip to content

Commit 314a6ac

Browse files
add random button temporary
1 parent 026848b commit 314a6ac

File tree

13 files changed

+575
-189
lines changed

13 files changed

+575
-189
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ dist-ssr
2525

2626
site
2727
todo_*
28+
tempCodeRunnerFile.*

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/programming-with-ia/shadcn-theme-editor)
1616
![GitHub top language](https://img.shields.io/github/languages/top/programming-with-ia/shadcn-theme-editor)
1717

18-
![minified size](https://badgen.net/bundlephobia/minzip/shadcn-theme-editor@0.0.5?label=minified_size)
18+
![minified size](https://badgen.net/bundlephobia/min/shadcn-theme-editor@latest)
1919

2020
[![NPM Version](https://img.shields.io/npm/v/shadcn-theme-editor?logo=npm)](https://www.npmjs.com/package/shadcn-theme-editor)
2121
[![GitHub](https://img.shields.io/badge/shadcn_theme_editor-161b22?logo=github)](https://github.com/programming-with-ia/shadcn-theme-editor)
@@ -85,11 +85,13 @@ and use
8585
<ThemeEditor />
8686
```
8787

88-
<!-- # Images
88+
</br>
89+
90+
# Screenshots
8991

9092
<p align="center">
91-
<img width="18%" align="center" src="https://raw.githubusercontent.com/zhiyiYo/PyQt-Fluent-Widgets/master/docs/source/_static/logo.png" alt="logo">
92-
</p> -->
93+
<img align="center" src="https://raw.githubusercontent.com/programming-with-ia/shadcn-theme-editor/master/screenshots/shadcn-theme-editor.png" alt="logo">
94+
</p>
9395

9496
## 📄 License
9597

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"class-variance-authority": "^0.7.0",
4848
"clsx": "^2.1.1",
4949
"cmdk": "^1.0.0",
50+
"colord": "^2.9.3",
5051
"embla-carousel": "^8.1.8",
5152
"embla-carousel-react": "^8.1.8",
5253
"lodash.debounce": "^4.0.8",

app/pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/components/display-container.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { SVGProps } from "react";
33

44
function DisplayContainer({ children, className }: { children: React.ReactNode, className?: string }) {
55
return (
6-
<div className=" drop-shadow-xl lg:w-11/12 xl:w-4/5 mx-auto">
6+
<div className=" drop-shadow-xl xl:w-4/5 mx-auto">
77
<div className={cn("p-8 md:p-16 lg:p-24 w-[98.6%] bg-card mx-auto rounded-t-xl drop-shadow-lg relative -z-10 flex flex-col items-center", className)}>
88
{children}
99
</div>

app/src/components/icons.tsx

Lines changed: 0 additions & 179 deletions
This file was deleted.

src/components/SideBarColors.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ function SideBarColors() {
6969
}, [currentTheme]);
7070
return (
7171
<>
72-
{/* <span title="Currently, the `next-themes` feature is not working correctly. I will fix this issue in a later version, or feel free to submit a PR" className="text-muted-foreground px-4 py-2">!ResolvedTheme: {currentTheme}</span> */}
7372
{colors?.map((color) => (
7473
<Item
7574
key={color.variable.replace(/^-+/, "") + currentTheme}

src/components/icons.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,44 @@ export function CopyIcon({ className, ...props }: SVGProps<SVGSVGElement>) {
4040
</svg>
4141
);
4242
}
43+
44+
export const Dices = (props: SVGProps<SVGSVGElement>) => (
45+
<svg
46+
xmlns="http://www.w3.org/2000/svg"
47+
width={24}
48+
height={24}
49+
viewBox="0 0 24 24"
50+
fill="none"
51+
stroke="currentColor"
52+
strokeWidth={2}
53+
strokeLinecap="round"
54+
strokeLinejoin="round"
55+
className="lucide lucide-dices"
56+
{...props}
57+
>
58+
<rect width={12} height={12} x={2} y={10} rx={2} ry={2} />
59+
<path d="m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6" />
60+
<path d="M6 18h.01" />
61+
<path d="M10 14h.01" />
62+
<path d="M15 6h.01" />
63+
<path d="M18 9h.01" />
64+
</svg>
65+
);
66+
67+
export const UnLock = (props: SVGProps<SVGSVGElement>) => (
68+
<svg width={24} height={24} viewBox="0 0 24 24" fill="#ffffff" {...props}>
69+
<g>
70+
<path d="M17.44,9.325h-1.1c0-0.97,0.01-1.95,0-2.92c-0.03-2.37-1.96-4.34-4.34-4.34 c-1.48-0.01-2.82,0.76-3.64,1.97c-0.36,0.53,0.51,1.03,0.87,0.5c1.2-1.77,3.78-1.96,5.23-0.39c1.04,1.11,0.88,2.57,0.88,3.96v1.22 H6.56c-1.38,0-2.5,1.12-2.5,2.5v7.61c0,1.37,1.12,2.5,2.5,2.5h10.88c1.38,0,2.5-1.13,2.5-2.5v-7.61 C19.94,10.445,18.82,9.325,17.44,9.325z M18.94,19.435c0,0.82-0.68,1.5-1.5,1.5H6.56c-0.82,0-1.5-0.68-1.5-1.5v-7.61 c0-0.83,0.68-1.5,1.5-1.5h10.88c0.82,0,1.5,0.67,1.5,1.5V19.435z" />
71+
<path d="M13,14.945c0,0.37-0.2,0.69-0.5,0.86v1.5c0,0.28-0.23,0.49-0.5,0.5s-0.5-0.24-0.5-0.5v-1.5 c-0.3-0.17-0.5-0.49-0.5-0.86c0-0.55,0.45-1,1-1S13,14.395,13,14.945z" />
72+
</g>
73+
</svg>
74+
);
75+
76+
export const Lock = (props: SVGProps<SVGSVGElement>) => (
77+
<svg width={32} height={32} viewBox="0 0 24 24" fill="#ffffff" {...props}>
78+
<g>
79+
<path d="M17.44,9.33h-1.1V6.4c0-2.39-1.95-4.34-4.34-4.34S7.66,4.01,7.66,6.4v2.93h-1.1 c-1.38,0-2.5,1.12-2.5,2.5v7.61c0,1.37,1.12,2.5,2.5,2.5h10.88c1.38,0,2.5-1.13,2.5-2.5v-7.61C19.94,10.45,18.82,9.33,17.44,9.33z M8.66,6.4c0-1.84,1.5-3.34,3.34-3.34s3.34,1.5,3.34,3.34v2.93H8.66V6.4z M18.94,19.44c0,0.82-0.68,1.5-1.5,1.5H6.56 c-0.82,0-1.5-0.68-1.5-1.5v-7.61c0-0.83,0.68-1.5,1.5-1.5h10.88c0.82,0,1.5,0.67,1.5,1.5V19.44z" />
80+
<path d="M13,14.95c0,0.37-0.2,0.69-0.5,0.86v1.5c0,0.28-0.23,0.49-0.5,0.5s-0.5-0.24-0.5-0.5v-1.5 c-0.3-0.17-0.5-0.49-0.5-0.86c0-0.55,0.45-1,1-1S13,14.4,13,14.95z" />
81+
</g>
82+
</svg>
83+
);

src/components/random.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { useState } from 'react'
2+
import { Button } from './ui/button'
3+
import { createRandomTheme } from '../lib/create-theme-config'
4+
import { useTheme } from 'next-themes'
5+
import { getComputedHSLColor, setColorsProperties } from '../lib/utils'
6+
import { Dices, Lock, UnLock } from './icons';
7+
8+
function RandomBtn() {
9+
const { systemTheme } = useTheme()
10+
const [lockPrimary, setLockPrimary] = useState(true);
11+
const onClickHandler = ()=>{
12+
const themes = createRandomTheme(lockPrimary ? getComputedHSLColor("--primary"): undefined)
13+
const theme = themes[systemTheme!] ?? themes.dark
14+
// const theme = themes.dark
15+
console.log(theme)
16+
setColorsProperties(theme)
17+
}
18+
const LockIcon = lockPrimary? Lock: UnLock
19+
return (
20+
<Button onClick={onClickHandler} title={'Generate Random theme, Primary is '+(lockPrimary? "locked": "not locked")} variant={"colorbtn"} className='cursor-pointer'>
21+
<Dices className='size-5' /> Randomize <LockIcon onClick={(e)=>console.log(setLockPrimary(!lockPrimary), lockPrimary, e.stopPropagation())} aria-label={(lockPrimary ?'unlock' : 'lock')+ ' primary color'} className='ml-auto size-6 hover:opacity-80 rounded-md hover:bg-background hover:fill-foreground p-0.5 fill-current'/>
22+
</Button>
23+
)
24+
}
25+
26+
export default RandomBtn

src/components/sidebar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { cn } from "../lib/utils";
33
import SideBarColors from "./SideBarColors";
44
import { CopyTheme } from "./copy-theme";
55
import ThemeToggle from "./theme-toggle";
6+
import RandomBtn from "./random";
67

78
export function Sidebar({ isOpen }: { isOpen: boolean }) {
89
return (
910
<aside
1011
role="dialog"
1112
className={cn(
12-
"fixed customScrollBar transition-colors duration-500 left-0 inset-y-0 z-50 hidden h-screen max-h-screen w-fit shrink-0 bg-background overflow-y-auto py-6 pl-8 pr-6 lg:py-8 border-r-2 shadow-md drop-shadow-sm",
13+
"fixed customScrollBar duration-500 left-0 inset-y-0 z-50 hidden h-screen max-h-screen w-fit shrink-0 bg-background overflow-y-auto py-6 pl-8 pr-6 lg:py-8 border-r-2 shadow-md drop-shadow-sm",
1314
isOpen && "md:flex flex-col"
1415
)}
1516
>
@@ -26,6 +27,8 @@ export function Sidebar({ isOpen }: { isOpen: boolean }) {
2627

2728
<div className="text-sm flex flex-col flex-1">
2829
<SideBarColors />
30+
<hr className="my-2" />
31+
<RandomBtn />
2932
</div>
3033
<footer className="flex flex-col gap-2 text-sm pt-4 mt-2 border-t -mb-4">
3134
<div className="flex flex-wrap justify-between gap-2">

0 commit comments

Comments
 (0)