Skip to content

Commit 72a631f

Browse files
committed
feat: add SessionLucideIconButton and bump lucide font to 0.488.0
1 parent 6208f82 commit 72a631f

File tree

4 files changed

+130
-2
lines changed

4 files changed

+130
-2
lines changed

fonts/lucide.ttf

7.75 KB
Binary file not shown.

ts/components/icon/LucideIcon.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { SessionDataTestId } from 'react';
2+
import styled from 'styled-components';
3+
4+
const LucideIconWrapper = styled.div<{ iconColor?: string; iconSize: string }>`
5+
font-family: var(--font-icon);
6+
font-size: ${({ iconSize }) => iconSize};
7+
color: ${({ iconColor }) => iconColor};
8+
`;
9+
10+
export type LucideIconProps = {
11+
unicode: string;
12+
iconColor?: string;
13+
iconSize: string;
14+
dataTestId?: SessionDataTestId;
15+
};
16+
17+
/**
18+
* This is a wrapper around Lucide icons with unicode.
19+
*/
20+
export const LucideIcon = ({ unicode, iconColor, iconSize, dataTestId }: LucideIconProps) => {
21+
return (
22+
<LucideIconWrapper iconColor={iconColor} iconSize={iconSize} data-testid={dataTestId}>
23+
{unicode}
24+
</LucideIconWrapper>
25+
);
26+
};

ts/components/icon/SessionIconButton.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { KeyboardEvent, MouseEvent, SessionDataTestId, ReactNode, forwardRef, me
33
import clsx from 'clsx';
44
import styled from 'styled-components';
55
import { SessionIcon, SessionIconProps } from './SessionIcon';
6+
import { LucideIcon, type LucideIconProps } from './LucideIcon';
67

78
export type SessionIconButtonProps = SessionIconProps & {
89
onClick?: (e?: MouseEvent<HTMLButtonElement>) => void;
@@ -128,3 +129,78 @@ const SessionIconButtonInner = forwardRef<HTMLButtonElement, SessionIconButtonPr
128129
);
129130

130131
export const SessionIconButton = memo(SessionIconButtonInner, _.isEqual);
132+
133+
export const SessionLucideIconButton = (
134+
props: Pick<
135+
SessionIconButtonProps,
136+
| 'onClick'
137+
| 'disabled'
138+
| 'isSelected'
139+
| 'margin'
140+
| 'padding'
141+
| 'ariaLabel'
142+
| 'title'
143+
| 'dataTestId'
144+
| 'dataTestIdIcon'
145+
| 'style'
146+
| 'tabIndex'
147+
> &
148+
Pick<LucideIconProps, 'unicode' | 'iconSize' | 'iconColor'>
149+
) => {
150+
const {
151+
unicode,
152+
iconSize,
153+
isSelected: $isSelected,
154+
margin,
155+
padding,
156+
ariaLabel,
157+
title,
158+
dataTestId,
159+
dataTestIdIcon,
160+
style,
161+
iconColor,
162+
tabIndex,
163+
disabled,
164+
onClick,
165+
} = props;
166+
167+
const clickHandler = (e: MouseEvent<HTMLButtonElement>) => {
168+
if (!disabled && onClick) {
169+
e.stopPropagation();
170+
onClick(e);
171+
}
172+
};
173+
const keyPressHandler = (e: KeyboardEvent<HTMLButtonElement>) => {
174+
if (e.currentTarget.tabIndex > -1 && e.key === 'Enter' && !disabled && onClick) {
175+
e.stopPropagation();
176+
onClick();
177+
}
178+
};
179+
180+
return (
181+
<StyledSessionIconButton
182+
color={iconColor}
183+
$isSelected={$isSelected}
184+
title={title}
185+
aria-label={ariaLabel}
186+
onClick={clickHandler}
187+
style={{
188+
...style,
189+
display: style?.display ? style.display : 'flex',
190+
margin: margin || '',
191+
padding: padding || '',
192+
}}
193+
tabIndex={tabIndex}
194+
onKeyDown={keyPressHandler}
195+
disabled={disabled}
196+
data-testid={dataTestId}
197+
>
198+
<LucideIcon
199+
unicode={unicode}
200+
iconSize={iconSize}
201+
iconColor={iconColor}
202+
dataTestId={dataTestIdIcon}
203+
/>
204+
</StyledSessionIconButton>
205+
);
206+
};

ts/components/icon/lucide.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1+
export enum LUCIDE_ICONS_UNICODE {
2+
EXTERNAL_LINK_ICON = '',
3+
COPY = '',
4+
REPLY = '',
5+
REFRESH_CW = '',
6+
CIRCLE_ARROW_DOWN = '',
7+
TRASH2 = '',
8+
LOG_OUT = '',
9+
AT_SIGN = '',
10+
VOLUME_OFF = '',
11+
VOLUME_2 = '',
12+
BUG = '',
13+
TIMER = '',
14+
USER_ROUND = '',
15+
USER_ROUND_PEN = '',
16+
USER_ROUND_PLUS = '',
17+
FILE = '',
18+
PIN = '',
19+
PIN_OFF = '',
20+
BAN = '',
21+
EYE_OFF = '',
22+
USER_ROUND_X = '',
23+
USER_ROUND_CHECK = '',
24+
PENCIL = '',
25+
}
26+
127
/**
228
* Used for rendering icons inside of the Localizer component
3-
* @note Current: Lucide v0.473.0
29+
* @note Current: Lucide v0.488.0
430
* @note The Lucide Icon font must be installed locally to see these icons.
531
* @note Download from https://github.com/lucide-icons/lucide/releases
632
*/
733
export const LUCIDE_INLINE_ICONS = {
8-
EXTERNAL_LINK_ICON: "<span role='img' aria-label='external link icon'></span>",
34+
EXTERNAL_LINK_ICON: `<span role='img' aria-label='external link icon'>${LUCIDE_ICONS_UNICODE.EXTERNAL_LINK_ICON}</span>`,
935
};
1036

1137
export type LucideInlineIconKeys = keyof typeof LUCIDE_INLINE_ICONS;

0 commit comments

Comments
 (0)