Skip to content

Commit 6e2f765

Browse files
committed
change theme button to use sun, moon images
1 parent 6bc3847 commit 6e2f765

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

src/components/Button.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@ import { ReactNode } from 'react'
33
type ButtonProps = {
44
children: ReactNode
55
onClick?: () => void
6+
color?: 'primary' | 'secondary' | 'transparent'
7+
variant?: 'contained' | 'outlined' | 'text'
68
}
79

8-
const Button = ({ children, onClick: onClick }: ButtonProps) => {
10+
const Button = ({
11+
children,
12+
onClick: onClick,
13+
color = 'primary',
14+
variant = 'contained',
15+
}: ButtonProps) => {
16+
const getColorStyles = (color: string) => {
17+
if (color === 'primary') {
18+
return 'text-white bg-blue-700 hover:bg-blue-800 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800'
19+
}
20+
if (color === 'transparent') {
21+
return 'focus:ring-transparent'
22+
}
23+
return ''
24+
}
925
return (
1026
<button
1127
type="button"
12-
className="text-white font-bold bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
28+
className={` focus:ring-4 rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 ${getColorStyles(
29+
color
30+
)} `}
1331
onClick={onClick}
1432
>
1533
{children}

src/components/comment/Comments.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { graphql, usePaginationFragment } from 'react-relay'
2-
import { Comments_story$key } from '../../queries/__generated__/Comments_story.graphql'
32
import NewComment from './NewComment'
43
import Comment from './Comment'
54

65
type CommentsProps = {
7-
story: Comments_story$key
6+
story: any
87
}
98

109
const Comments = ({ story }: CommentsProps) => {

src/components/navbar/ThemeButton.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,33 @@ export default function ThemeButton() {
2121
setDarkMode(!darkMode)
2222
}
2323

24-
return <Button onClick={onClick}>toggle dark mode</Button>
24+
return (
25+
<Button onClick={onClick} color="transparent">
26+
{darkMode ? (
27+
<svg
28+
id="day"
29+
xmlns="http://www.w3.org/2000/svg"
30+
width="24"
31+
height="24"
32+
style={{ fill: '#fff' }}
33+
>
34+
<path d="M18.1 5.1c0 .3-.1.6-.3.9l-1.4 1.4-.9-.8 2.2-2.2c.3.1.4.4.4.7zm-.5 5.3h3.2c0 .3-.1.6-.4.9s-.5.4-.8.4h-2v-1.3zm-6.2-5V2.2c.3 0 .6.1.9.4s.4.5.4.8v2h-1.3zm6.4 11.7c-.3 0-.6-.1-.8-.3l-1.4-1.4.8-.8 2.2 2.2c-.2.2-.5.3-.8.3zM6.2 4.9c.3 0 .6.1.8.3l1.4 1.4-.8.9-2.2-2.3c.2-.2.5-.3.8-.3zm5.2 11.7h1.2v3.2c-.3 0-.6-.1-.9-.4s-.4-.5-.4-.8l.1-2zm-7-6.2h2v1.2H3.2c0-.3.1-.6.4-.9s.5-.3.8-.3zM6.2 16l1.4-1.4.8.8-2.2 2.2c-.2-.2-.3-.5-.3-.8s.1-.6.3-.8z" />
35+
<circle cx="12" cy="11" r="4" />
36+
</svg>
37+
) : (
38+
<svg
39+
id="night"
40+
xmlns="http://www.w3.org/2000/svg"
41+
width="24"
42+
height="24"
43+
viewBox="0 0 24 24"
44+
>
45+
<path
46+
d="M19.1 17.5c-3.3 1.4-7.1-.2-8.5-3.5-1.4-3.3.2-7.1 3.5-8.5.2-.1.5-.2.7-.3-1.6-.4-3.2-.3-4.8.4C6 7.3 4 12 5.7 16c1.7 4.1 6.4 6 10.5 4.3 1.7-.7 3-1.9 3.8-3.4-.3.3-.6.4-.9.6z"
47+
fill="#444;"
48+
/>
49+
</svg>
50+
)}
51+
</Button>
52+
)
2553
}

0 commit comments

Comments
 (0)