Skip to content

Commit 47e4235

Browse files
committed
feat: Replace button by Button component.
1 parent aa18aac commit 47e4235

File tree

24 files changed

+172
-210
lines changed

24 files changed

+172
-210
lines changed

src/assets/App.css

Lines changed: 10 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -286,23 +286,6 @@ a {
286286
opacity: 1;
287287
}
288288

289-
.blockHeaderDragButton {
290-
align-items: center;
291-
background: transparent;
292-
border: none;
293-
color: #96a2ae;
294-
cursor: grab;
295-
display: none;
296-
font-size: 24px;
297-
height: 100%;
298-
justify-content: center;
299-
left: 0;
300-
padding: 0;
301-
position: absolute;
302-
top: 0;
303-
width: 50px;
304-
}
305-
306289
.blockHeader:hover .blockHeaderDragButton {
307290
display: flex;
308291
}
@@ -357,29 +340,9 @@ a {
357340
}
358341

359342
.blockActionButton {
360-
background-color: var(--card-action-button-background);
361-
border-radius: 40px;
362-
border: none;
363-
box-shadow: 0 0 15px 2px var(--card-actions-background-shadow);
364-
color: var(--card-action-button-color);
365-
cursor: pointer;
366-
display: block;
367-
font-size: 18px;
368-
height: 28px;
369-
line-height: 12px;
370-
opacity: 1;
371-
padding: 0;
372-
pointer-events: all;
373-
text-align: center;
374-
transition: opacity 0.3s ease, right 0.3s ease;
375-
width: 28px;
376-
margin-bottom: 6px;
377-
margin-right: 6px;
378-
}
379-
380-
.blockActionButton.active {
381-
background-color: var(--card-active-action-button-background);
382-
color: var(--card-active-action-button-color);
343+
transition:
344+
opacity 0.3s ease,
345+
right 0.3s ease;
383346
}
384347

385348
@media (hover: hover) {
@@ -556,7 +519,9 @@ a {
556519
flex-wrap: wrap;
557520
gap: 8px;
558521
order: 4;
559-
transition: opacity 0.3s ease-out 0.1s, transform 0.3s ease-out 0.1s,
522+
transition:
523+
opacity 0.3s ease-out 0.1s,
524+
transform 0.3s ease-out 0.1s,
560525
visibility 0.3s ease-out 0.1s;
561526
width: 100%;
562527
}
@@ -696,21 +661,6 @@ Github languages colors
696661
background-color: #045797;
697662
}
698663

699-
.headerSelect {
700-
background-color: transparent;
701-
border: 0;
702-
border-bottom: 2px solid var(--app-name-text-color);
703-
color: inherit;
704-
cursor: pointer;
705-
font-weight: bold;
706-
padding: 0;
707-
}
708-
709-
.headerSelectIcon {
710-
position: relative;
711-
top: 2px;
712-
}
713-
714664
/**
715665
Contextify
716666
**/
@@ -872,7 +822,10 @@ Producthunt item
872822

873823
.searchBar {
874824
order: 3;
875-
transition: opacity 0.3s ease-out, transform 0.3s ease-out, visibility 0.3s ease-out;
825+
transition:
826+
opacity 0.3s ease-out,
827+
transform 0.3s ease-out,
828+
visibility 0.3s ease-out;
876829
width: 100%;
877830
display: flex;
878831
align-items: center;
@@ -1441,25 +1394,6 @@ Modal
14411394
column-gap: 8px;
14421395
align-items: center;
14431396
}
1444-
.modalCloseBtn {
1445-
align-items: center;
1446-
position: absolute;
1447-
background-color: transparent;
1448-
border-radius: 50%;
1449-
top: 0;
1450-
right: 0;
1451-
border: none;
1452-
color: var(--primary-text-color);
1453-
cursor: pointer;
1454-
display: flex;
1455-
justify-content: center;
1456-
margin: 0;
1457-
padding: 0;
1458-
text-align: center;
1459-
}
1460-
.modalCloseBtn:hover {
1461-
opacity: 0.7;
1462-
}
14631397
.settingContent .form {
14641398
display: flex;
14651399
flex-direction: row;

src/assets/index.css

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,30 @@ code {
2525
@custom-variant dark (&:where(.dark, .dark *));
2626

2727
@theme {
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);
28+
--color-primary: oklch(0.53 0.1896 257.41);
29+
--color-secondary: oklch(0.9 0.0221 250.23);
30+
--color-secondary-hover: oklch(0.83 0.0314 249.73);
31+
--color-danger: oklch(0.67 0.2143 24.47);
32+
--color-success: oklch(0.73 0.2182 138.49);
33+
--color-warning: oklch(0.85 0.1452 85.83);
3534

3635
--color-on-primary: oklch(1 0 0);
3736
--color-on-secondary: oklch(0.42 0.0431 250.1);
3837
--color-on-secondary-hover: oklch(0.42 0.0431 250.1);
3938
--color-on-danger: oklch(1 0 0);
4039
--color-on-success: oklch(1 0 0);
4140
--color-on-warning: oklch(1 0 0);
42-
--color-on-background: oklch(1 0 0);
41+
--color-on-background: oklch(0.42 0.0431 250.1);
4342
}
4443

4544
@layer base {
4645
@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);
46+
--color-primary: oklch(0.53 0.1896 257.41);
47+
--color-secondary: oklch(0.24 0.0129 258.37);
48+
--color-secondary-hover: oklch(0.22 0.0115 254.07);
49+
--color-danger: oklch(0.67 0.2143 24.47);
50+
--color-success: oklch(0.73 0.2182 138.49);
51+
--color-warning: oklch(0.85 0.1452 85.83);
5352

5453
--color-on-primary: oklch(1 0 0);
5554
--color-on-secondary: oklch(1 0 0);

src/components/DropDownMenu.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Item, Menu, MenuId, animation, useContextMenu } from 'react-contexify'
22
import { RiArrowDownSFill } from 'react-icons/ri'
3+
import { Button } from './Elements'
34

45
type Option = {
56
label: string
@@ -29,10 +30,14 @@ export const DropDownMenu = ({
2930

3031
return (
3132
<>
32-
<button onClick={displayMenu} className="headerSelect" data-target-id={tagId}>
33-
{label}
34-
<RiArrowDownSFill className="headerSelectIcon" />
35-
</button>
33+
<Button
34+
type="text"
35+
onClick={(e) => displayMenu(e)}
36+
className="inline-flex items-center justify-center gap-2 text-center"
37+
tagId={tagId}>
38+
<span>{label}</span>
39+
<RiArrowDownSFill />
40+
</Button>
3641
<Menu id={tagId} animation={animation.fade}>
3742
{data &&
3843
data.map((tag) => {

src/components/Elements/Button/Button.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,42 @@ import React from 'react'
33
import { Spinner } from '../Spinner'
44

55
const sizes = {
6-
small: 'py-1 px-2 text-xs',
7-
medium: 'py-3 px-4 text-base',
8-
large: 'py-4 px-8 text-xl',
6+
sm: 'py-1 px-2 text-xs',
7+
md: 'py-3 px-4 text-base',
8+
lg: 'py-4 px-8 text-xl',
99
}
1010

1111
const types = {
12-
primary: 'bg-bg-primary text-on-primary ',
12+
primary: 'bg-primary text-on-primary ',
1313
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 ',
14+
'bg-secondary text-on-secondary hover:bg-secondary-hover hover:text-on-secondary-hover',
15+
danger: 'bg-danger text-on-danger ',
16+
success: 'bg-success text-on-success ',
17+
warning: 'bg-warning text-on-warning ',
18+
text: 'bg-transparent text-on-background',
1819
}
1920

2021
interface ButtonProps {
2122
children: React.ReactNode
22-
onClick: () => void
23+
onClick: (e: React.MouseEvent<HTMLSpanElement>) => void
2324
className?: string
2425
type?: keyof typeof types
2526
size?: keyof typeof sizes
2627
startIcon?: React.ReactNode
2728
endIcon?: React.ReactNode
2829
isLoading?: boolean
30+
tagId?: string
2931
}
3032
export const Button = ({
3133
onClick,
3234
type = 'secondary',
3335
className,
34-
size = 'medium',
36+
size = 'md',
3537
startIcon,
3638
endIcon,
3739
children,
3840
isLoading = false,
41+
tagId,
3942
}: ButtonProps) => {
4043
return (
4144
<button
@@ -47,7 +50,8 @@ export const Button = ({
4750
isLoading ? 'pointer-events-none cursor-not-allowed' : 'cursor-pointer'
4851
)}
4952
onClick={onClick}
50-
disabled={isLoading}>
53+
disabled={isLoading}
54+
data-target-id={tagId}>
5155
{isLoading ? <Spinner size="small" /> : startIcon}
5256
{children}
5357
{endIcon}

src/components/Elements/Button/CircleButton.tsx

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

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

1010
const variants = {
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',
11+
primary: 'bg-primary text-on-primary hover:bg-primary-hover hover:text-on-primary-hover',
12+
secondary:
13+
'bg-secondary text-on-secondary hover:bg-secondary-hover hover:text-on-secondary-hover',
14+
outlined:
15+
'bg-transparent text-on-secondary border-1 dark:border-2 border-secondary hover:bg-secondary-hover hover:text-on-secondary-hover',
16+
text: 'bg-transparent text-on-secondary',
17+
darkfocus: 'bg-blue-900 text-yellow-400 hover:opacity-80',
1418
}
1519

1620
type CircleButtonProps = {
@@ -23,8 +27,8 @@ type CircleButtonProps = {
2327
}
2428

2529
export const CircleButton = ({
26-
size = 'medium',
27-
variant = 'primary',
30+
size = 'md',
31+
variant = 'secondary',
2832
onClick,
2933
isLoading,
3034
className,
@@ -34,7 +38,7 @@ export const CircleButton = ({
3438
<button
3539
disabled={isLoading}
3640
className={clsx(
37-
'inline-flex items-center justify-center rounded-full text-center',
41+
'pointer-events-auto inline-flex cursor-pointer items-center justify-center rounded-full text-center',
3842
sizes[size],
3943
variants[variant],
4044
className,

src/components/Elements/Card/Card.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useRemoteConfigStore } from 'src/features/remoteConfig'
88
import { DesktopBreakpoint } from 'src/providers/DesktopBreakpoint'
99
import { useUserPreferences } from 'src/stores/preferences'
1010
import { SupportedCardType } from 'src/types'
11+
import { CircleButton } from '../Button'
1112

1213
type CardProps = {
1314
children: React.ReactNode
@@ -61,9 +62,9 @@ export const Card = ({
6162
<div className="blockHeader">
6263
<DesktopBreakpoint>
6364
<SortableKnob>
64-
<button className="blockHeaderDragButton">
65-
<MdOutlineDragIndicator />
66-
</button>
65+
<CircleButton onClick={() => {}} variant="text">
66+
<MdOutlineDragIndicator size={24} />
67+
</CircleButton>
6768
</SortableKnob>
6869
</DesktopBreakpoint>
6970
<span className="blockHeaderIcon">{icon}</span> {titleComponent || label}{' '}

src/components/Elements/CardWithActions/CardItemWithActions.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Attributes, trackLinkBookmark, trackLinkUnBookmark } from 'src/lib/anal
88
import { useBookmarks } from 'src/stores/bookmarks'
99
import { useUserPreferences } from 'src/stores/preferences'
1010
import { BaseEntry } from 'src/types'
11+
import { CircleButton } from '../Button'
1112

1213
type CardItemWithActionsProps = {
1314
item: BaseEntry
@@ -80,27 +81,31 @@ export const CardItemWithActions = ({
8081
shareData={shareModalData}
8182
/>
8283
{cardItem}
83-
<div className={`blockActions ${isBookmarked ? 'active' : ''} `}>
84+
<div className={`flex items-end justify-end gap-1 ${isBookmarked ? 'active' : ''}`}>
8485
{source === 'ai' && (
85-
<button
86-
className={`blockActionButton `}
86+
<CircleButton
87+
size="sm"
88+
className={`blockActionButton`}
8789
onClick={onReportClicked}
8890
aria-label="Report item">
8991
<MdBugReport />
90-
</button>
92+
</CircleButton>
9193
)}
92-
<button
93-
className={`blockActionButton `}
94+
<CircleButton
95+
size="sm"
96+
className={`blockActionButton`}
9497
onClick={onShareModalClicked}
9598
aria-label="Open share modal">
9699
<BiShareAlt />
97-
</button>
98-
<button
100+
</CircleButton>
101+
<CircleButton
102+
size="sm"
103+
variant={isBookmarked ? 'darkfocus' : 'secondary'}
99104
className={`blockActionButton ${isBookmarked ? 'active' : ''}`}
100105
onClick={onBookmarkClick}
101106
aria-label="Bookmark item">
102107
{!isBookmarked ? <BiBookmarkPlus /> : <BiBookmarkMinus />}
103-
</button>
108+
</CircleButton>
104109
</div>
105110
</div>
106111
)

0 commit comments

Comments
 (0)