Skip to content

Commit 6e5fa3e

Browse files
committed
Adjust ImageIcon, Text, and Card focus/hover styles
1 parent 39d2c57 commit 6e5fa3e

File tree

7 files changed

+60
-39
lines changed

7 files changed

+60
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@near-pagoda/ui",
3-
"version": "2.0.18",
3+
"version": "2.1.0",
44
"description": "A React component library that implements the official NEAR design system.",
55
"license": "MIT",
66
"repository": {

src/components/Card.module.scss

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
min-width: 0;
1919
}
2020

21+
:global(.dark) & {
22+
--card-shadow-hover-color: rgba(0, 0, 0, 0.2);
23+
}
24+
2125
&[data-padding='s'] {
2226
padding: var(--gap-s);
2327
}
@@ -51,23 +55,26 @@
5155
gap: var(--gap-l);
5256
}
5357

54-
&:hover,
55-
&:focus {
58+
&:hover {
5659
z-index: 5;
5760
}
61+
&:focus-visible {
62+
z-index: 10;
63+
}
5864

5965
&[role='button'],
6066
&[href] {
6167
cursor: pointer;
6268

6369
&:hover {
64-
--card-background-color: var(--sand-0) !important;
65-
box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.075);
70+
background-color: var(--card-background-hover-color, var(--sand-0)) !important;
71+
border-color: var(--card-border-hover-color, var(--card-border-color)) !important;
6672
&[data-background='sand-0'] {
67-
--card-background-color: var(--sand-1) !important;
73+
background-color: var(--card-background-hover-color, var(--sand-1)) !important;
6874
}
6975
}
70-
&:focus-visible {
76+
77+
&[data-focus='true']:focus-visible {
7178
box-shadow: 0 0 0 4px var(--violet-5);
7279
border-color: var(--violet-9);
7380
}
@@ -115,10 +122,9 @@
115122
.card {
116123
border-radius: 0;
117124
box-shadow: none;
118-
margin-bottom: -1px;
119125

120-
&:last-child {
121-
margin-bottom: 0;
126+
&:not(:last-child) {
127+
margin-bottom: -1px;
122128
}
123129

124130
&:first-child {

src/components/Card.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ type Props = ComponentPropsWithRef<'div'> & {
99
href?: string;
1010
target?: ComponentPropsWithRef<'a'>['target'];
1111
background?: ThemeColor;
12+
backgroundHover?: ThemeColor;
1213
border?: ThemeColor;
14+
borderHover?: ThemeColor;
15+
indicateFocus?: boolean;
1316
padding?: 's' | 'm' | 'l';
1417
paddingInline?: 's' | 'm' | 'l';
1518
gap?: 'xs' | 's' | 'm' | 'l';
@@ -20,8 +23,11 @@ export const Card = forwardRef<HTMLDivElement, Props>(
2023
{
2124
animateIn,
2225
background = 'sand-0',
26+
backgroundHover,
2327
border = 'sand-5',
28+
borderHover,
2429
className = '',
30+
indicateFocus = true,
2531
gap,
2632
padding,
2733
paddingInline,
@@ -38,6 +44,7 @@ export const Card = forwardRef<HTMLDivElement, Props>(
3844
className={`${s.card} ${className}`}
3945
data-animate-in={animateIn}
4046
data-background={background}
47+
data-focus={indicateFocus}
4148
data-gap={gap}
4249
data-padding={padding}
4350
data-padding-inline={paddingInline}
@@ -46,7 +53,9 @@ export const Card = forwardRef<HTMLDivElement, Props>(
4653
ref={ref}
4754
style={{
4855
'--card-background-color': `var(--${background})`,
56+
'--card-background-hover-color': backgroundHover ? `var(--${backgroundHover})` : undefined,
4957
'--card-border-color': `var(--${border})`,
58+
'--card-border-hover-color': borderHover ? `var(--${borderHover})` : undefined,
5059
...style,
5160
}}
5261
{...props}

src/components/ImageIcon.module.scss

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,20 @@
4747
height: var(--icon-size-xl);
4848
padding: 8px;
4949
}
50-
}
5150

52-
a:focus-visible .imageIcon {
53-
box-shadow:
54-
0 0 0 1px var(--violet-9),
55-
0 0 0 5px var(--violet-5);
51+
&[data-parent-clickable='true'] {
52+
a:focus-visible &,
53+
[role='button']:focus-visible &,
54+
button:focus-visible & {
55+
box-shadow:
56+
0 0 0 1px var(--violet-9),
57+
0 0 0 5px var(--violet-5);
58+
}
59+
60+
a:hover &,
61+
[role='button']:hover &,
62+
button:hover & {
63+
transform: scale(1.15, 1.15);
64+
}
65+
}
5666
}

src/components/ImageIcon.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,28 @@ type Props = {
77
alt: string;
88
className?: string;
99
fallbackIcon?: ReactNode;
10+
indicateParentClickable?: boolean;
1011
size?: ThemeIconSize;
1112
src: string | undefined;
1213
style?: CSSProperties;
1314
};
1415

15-
export const ImageIcon = ({ alt, className = '', fallbackIcon, size = 'm', src, ...props }: Props) => {
16+
export const ImageIcon = ({
17+
alt,
18+
className = '',
19+
fallbackIcon,
20+
indicateParentClickable,
21+
size = 'm',
22+
src,
23+
...props
24+
}: Props) => {
1625
return (
17-
<div className={`${s.imageIcon} ${className} image-icon`} data-size={size} {...props}>
26+
<div
27+
className={`${s.imageIcon} ${className} image-icon`}
28+
data-parent-clickable={indicateParentClickable}
29+
data-size={size}
30+
{...props}
31+
>
1832
{src ? <img src={src} alt={alt} /> : fallbackIcon}
1933
</div>
2034
);

src/components/Text.module.scss

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,7 @@ a.text {
2323
font-family: monospace !important;
2424
}
2525

26-
a > & {
27-
display: inline;
28-
}
29-
a:has(&) {
30-
line-height: 0;
31-
}
32-
&[role='button']:hover,
33-
&[role='button']:focus-visible,
34-
[role='button']:hover > &,
35-
[role='button']:focus-visible > &,
36-
button:hover > &,
37-
button:focus-visible > &,
38-
a:hover > &,
39-
a:focus-visible > & {
40-
color: var(--violet-11) !important;
41-
text-decoration: underline;
42-
}
43-
44-
&[data-clickable-highlight='true'] {
26+
&[data-parent-clickable='true'] {
4527
[role='button']:hover &,
4628
[role='button']:focus-visible &,
4729
button:hover &,

src/components/Text.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const defaultSizes: Record<Tag, ThemeFontSize> = {
2121
type Props = Omit<ComponentPropsWithRef<'p'>, 'color'> & {
2222
as?: Tag;
2323
clampLines?: number;
24-
clickableHighlight?: boolean;
2524
color?: ThemeColor;
2625
decoration?: CSSProperties['textDecoration'];
2726
family?: 'standard' | 'monospace';
2827
forceWordBreak?: boolean;
2928
href?: string;
29+
indicateParentClickable?: boolean;
3030
target?: ComponentProps<'a'>['target'];
3131
size?: ThemeFontSize;
3232
noWrap?: boolean;
@@ -41,9 +41,9 @@ export const Text = forwardRef<HTMLParagraphElement, Props>(
4141
children,
4242
clampLines,
4343
className = '',
44-
clickableHighlight,
4544
family,
4645
forceWordBreak,
46+
indicateParentClickable,
4747
size,
4848
style,
4949
noWrap,
@@ -66,7 +66,7 @@ export const Text = forwardRef<HTMLParagraphElement, Props>(
6666
className={`${s.text} ${className}`}
6767
data-clamp-lines={clampLines}
6868
data-size={size ?? defaultSize}
69-
data-clickable-highlight={clickableHighlight}
69+
data-parent-clickable={indicateParentClickable}
7070
data-family={family}
7171
role={onClick ? 'button' : undefined}
7272
tabIndex={onClick ? 0 : undefined}

0 commit comments

Comments
 (0)