Skip to content

Commit aa18aac

Browse files
committed
feat: Update the theme colors and use them in Button and CircleButton components.
1 parent d40e92f commit aa18aac

File tree

6 files changed

+75
-39
lines changed

6 files changed

+75
-39
lines changed

src/assets/index.css

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
body {
55
margin: 0;
6-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
7-
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
6+
font-family:
7+
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
8+
'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
89
-webkit-font-smoothing: antialiased;
910
-moz-osx-font-smoothing: grayscale;
1011
}
@@ -24,8 +25,38 @@ code {
2425
@custom-variant dark (&:where(.dark, .dark *));
2526

2627
@theme {
27-
--color-btn-background-color: var(--button-background-color);
28-
--color-btn-hover-background-color: var(--button-hover-background-color);
29-
--color-btn-text-color: var(--button-text-color);
30-
--color-btn-hover-text-color: var(--button-hover-text-color);
28+
--color-mint-500: oklch(0.72 0.11 178);
29+
--color-bg-primary: oklch(0.53 0.1896 257.41);
30+
--color-bg-secondary: oklch(0.9 0.0221 250.23);
31+
--color-bg-secondary-hover: oklch(0.83 0.0314 249.73);
32+
--color-bg-danger: oklch(0.67 0.2143 24.47);
33+
--color-bg-success: oklch(0.73 0.2182 138.49);
34+
--color-bg-warning: oklch(0.85 0.1452 85.83);
35+
36+
--color-on-primary: oklch(1 0 0);
37+
--color-on-secondary: oklch(0.42 0.0431 250.1);
38+
--color-on-secondary-hover: oklch(0.42 0.0431 250.1);
39+
--color-on-danger: oklch(1 0 0);
40+
--color-on-success: oklch(1 0 0);
41+
--color-on-warning: oklch(1 0 0);
42+
--color-on-background: oklch(1 0 0);
43+
}
44+
45+
@layer base {
46+
@variant dark {
47+
--color-bg-primary: oklch(0.53 0.1896 257.41);
48+
--color-bg-secondary: oklch(0.24 0.0129 258.37);
49+
--color-bg-secondary-hover: oklch(0.22 0.0115 254.07);
50+
--color-bg-danger: oklch(0.67 0.2143 24.47);
51+
--color-bg-success: oklch(0.73 0.2182 138.49);
52+
--color-bg-warning: oklch(0.85 0.1452 85.83);
53+
54+
--color-on-primary: oklch(1 0 0);
55+
--color-on-secondary: oklch(1 0 0);
56+
--color-on-secondary-hover: oklch(0.42 0.0431 250.1);
57+
--color-on-danger: oklch(1 0 0);
58+
--color-on-success: oklch(1 0 0);
59+
--color-on-warning: oklch(1 0 0);
60+
--color-on-background: oklch(1 0 0);
61+
}
3162
}

src/components/Elements/Button/Button.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,51 @@
1+
import clsx from 'clsx'
12
import React from 'react'
23
import { Spinner } from '../Spinner'
3-
import './Button.css'
4+
45
const sizes = {
5-
small: 'small',
6-
medium: 'medium',
7-
large: 'large',
6+
small: 'py-1 px-2 text-xs',
7+
medium: 'py-3 px-4 text-base',
8+
large: 'py-4 px-8 text-xl',
89
}
9-
type ButtonProps = {
10+
11+
const types = {
12+
primary: 'bg-bg-primary text-on-primary ',
13+
secondary:
14+
'bg-bg-secondary text-on-secondary hover:bg-bg-secondary-hover hover:text-on-secondary-hover',
15+
danger: 'bg-bg-danger text-on-danger ',
16+
success: 'bg-bg-success text-on-success ',
17+
warning: 'bg-bg-warning text-on-warning ',
18+
}
19+
20+
interface ButtonProps {
1021
children: React.ReactNode
1122
onClick: () => void
1223
className?: string
24+
type?: keyof typeof types
1325
size?: keyof typeof sizes
1426
startIcon?: React.ReactNode
1527
endIcon?: React.ReactNode
1628
isLoading?: boolean
1729
}
1830
export const Button = ({
19-
size = 'medium',
2031
onClick,
32+
type = 'secondary',
2133
className,
34+
size = 'medium',
2235
startIcon,
2336
endIcon,
2437
children,
2538
isLoading = false,
2639
}: ButtonProps) => {
2740
return (
28-
<button
29-
className="gap-2 px-4 bg-btn-background-color py-2 rounded-full hover:bg-btn-hover-background-color text-btn-text-color hover:text-btn-hover-text-color cursor-pointer justify-center items-center"
41+
<button
42+
className={clsx(
43+
'inline-flex items-center justify-center gap-2 rounded-full text-center',
44+
types[type],
45+
sizes[size],
46+
className,
47+
isLoading ? 'pointer-events-none cursor-not-allowed' : 'cursor-pointer'
48+
)}
3049
onClick={onClick}
3150
disabled={isLoading}>
3251
{isLoading ? <Spinner size="small" /> : startIcon}

src/components/Elements/Button/CircleButton.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import clsx from 'clsx'
22
import { Spinner } from '../Spinner'
33

44
const sizes = {
5-
small: 'small',
6-
medium: 'medium',
7-
large: 'large',
5+
small: 'size-[30px]',
6+
medium: 'size-[40px]',
7+
large: 'size-[50px]',
88
}
99

1010
const variants = {
11-
primary: 'primary',
12-
darkfocus: 'dark-focus',
11+
primary:
12+
'bg-bg-secondary text-on-secondary hover:bg-bg-secondary-hover hover:text-on-secondary-hover',
13+
darkfocus: 'bg-[#1c2026] text-[#f0c73d] hover:opacity-80',
1314
}
1415

1516
type CircleButtonProps = {
@@ -33,11 +34,11 @@ export const CircleButton = ({
3334
<button
3435
disabled={isLoading}
3536
className={clsx(
36-
'circle-button',
37+
'inline-flex items-center justify-center rounded-full text-center',
3738
sizes[size],
3839
variants[variant],
3940
className,
40-
isLoading && 'disabled'
41+
isLoading ? 'pointer-events-none cursor-not-allowed' : 'cursor-pointer'
4142
)}
4243
onClick={onClick}>
4344
{isLoading ? <Spinner size="small" /> : children}

src/features/settings/components/GeneralSettings/generalSettings.css

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@
1616
border-bottom: 1px solid var(--card-content-divider);
1717
}
1818

19-
.settingContent button {
20-
display: flex;
21-
align-items: center;
22-
column-gap: 8px;
23-
background-color: none;
24-
border: none;
25-
border-radius: 50px;
26-
padding: 6px 12px;
27-
font-size: 14px;
28-
font-weight: bold;
29-
cursor: pointer;
30-
transition: opacity 0.2s linear;
31-
}
32-
.settingContent button:hover {
33-
opacity: 0.9;
34-
}
3519
.rssButton {
3620
background-color: #ee802f;
3721
color: white;

src/features/settings/components/UserSettings/DeleteAccount.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const DeleteAccount = () => {
4949

5050
<Button
5151
size="small"
52+
type="danger"
5253
onClick={() => setConfirmDelete(true)}
5354
isLoading={deleteAccountMutation.isLoading}>
5455
Delete account

src/features/settings/components/UserSettings/UserInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const UserInfo = () => {
2727
Create a free account on <b>Hackertab</b> to sync, save bookmarks, and earn rewards.
2828
</div>
2929
<div className="actions">
30-
<Button className="logoutBtn" onClick={() => openAuthModal()} size="small">
30+
<Button onClick={() => openAuthModal()} size="small">
3131
Connect
3232
</Button>
3333
</div>
@@ -60,7 +60,7 @@ export const UserInfo = () => {
6060
Connected with <span className="capitalize">{providerName}</span>
6161
</div>
6262
<div className="actions">
63-
<Button className="logoutBtn" onClick={() => setShowLogout(true)} size="small">
63+
<Button onClick={() => setShowLogout(true)} size="small">
6464
Logout
6565
</Button>
6666
</div>

0 commit comments

Comments
 (0)