Skip to content

Commit dbe2d72

Browse files
authored
Merge pull request #1447 from session-foundation/dev
Add donate and settings order
2 parents a142a00 + 150e10c commit dbe2d72

File tree

11 files changed

+274
-216
lines changed

11 files changed

+274
-216
lines changed

ts/components/icon/Icons.tsx

Lines changed: 12 additions & 30 deletions
Large diffs are not rendered by default.

ts/components/icon/LucideIcon.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SessionDataTestId } from 'react';
1+
import type { CSSProperties, SessionDataTestId } from 'react';
22
import styled from 'styled-components';
33

44
const LucideIconWrapper = styled.div<{ iconColor?: string; iconSize: string }>`
@@ -12,14 +12,26 @@ export type LucideIconProps = {
1212
iconColor?: string;
1313
iconSize: string;
1414
dataTestId?: SessionDataTestId;
15+
style?: CSSProperties;
1516
};
1617

1718
/**
1819
* This is a wrapper around Lucide icons with unicode.
1920
*/
20-
export const LucideIcon = ({ unicode, iconColor, iconSize, dataTestId }: LucideIconProps) => {
21+
export const LucideIcon = ({
22+
unicode,
23+
iconColor,
24+
iconSize,
25+
dataTestId,
26+
style,
27+
}: LucideIconProps) => {
2128
return (
22-
<LucideIconWrapper iconColor={iconColor} iconSize={iconSize} data-testid={dataTestId}>
29+
<LucideIconWrapper
30+
iconColor={iconColor}
31+
iconSize={iconSize}
32+
data-testid={dataTestId}
33+
style={style}
34+
>
2335
{unicode}
2436
</LucideIconWrapper>
2537
);

ts/components/icon/SessionIconButton.tsx

Lines changed: 83 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const StyledSessionIconButton = styled.button<{ color?: string; $isSelected?: bo
3737
};`}
3838
}
3939
40+
color: ${props =>
41+
props.color || props.$isSelected
42+
? 'var(--button-icon-stroke-selected-color)'
43+
: 'var(--button-icon-stroke-color)'};
44+
4045
${props => props.disabled && 'cursor: not-allowed;'}
4146
4247
&:hover svg path {
@@ -130,77 +135,83 @@ const SessionIconButtonInner = forwardRef<HTMLButtonElement, SessionIconButtonPr
130135

131136
export const SessionIconButton = memo(SessionIconButtonInner, _.isEqual);
132137

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;
138+
export type SessionLucideIconButtonProps = Pick<
139+
SessionIconButtonProps,
140+
| 'onClick'
141+
| 'disabled'
142+
| 'isSelected'
143+
| 'margin'
144+
| 'padding'
145+
| 'ariaLabel'
146+
| 'title'
147+
| 'dataTestId'
148+
| 'dataTestIdIcon'
149+
| 'style'
150+
| 'tabIndex'
151+
| 'children'
152+
> &
153+
Pick<LucideIconProps, 'unicode' | 'iconSize' | 'iconColor'>;
166154

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-
};
155+
export const SessionLucideIconButton = forwardRef<HTMLButtonElement, SessionLucideIconButtonProps>(
156+
(props, ref) => {
157+
const {
158+
unicode,
159+
iconSize,
160+
isSelected: $isSelected,
161+
margin,
162+
padding,
163+
ariaLabel,
164+
title,
165+
dataTestId,
166+
dataTestIdIcon,
167+
style,
168+
iconColor,
169+
tabIndex,
170+
disabled,
171+
onClick,
172+
children,
173+
} = props;
179174

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-
};
175+
const clickHandler = (e: MouseEvent<HTMLButtonElement>) => {
176+
if (!disabled && onClick) {
177+
e.stopPropagation();
178+
onClick(e);
179+
}
180+
};
181+
const keyPressHandler = (e: KeyboardEvent<HTMLButtonElement>) => {
182+
if (e.currentTarget.tabIndex > -1 && e.key === 'Enter' && !disabled && onClick) {
183+
e.stopPropagation();
184+
onClick();
185+
}
186+
};
187+
188+
return (
189+
<StyledSessionIconButton
190+
color={iconColor}
191+
$isSelected={$isSelected}
192+
title={title}
193+
aria-label={ariaLabel}
194+
onClick={clickHandler}
195+
style={{
196+
...style,
197+
display: style?.display ? style.display : 'flex',
198+
margin: margin || '',
199+
padding: padding || '',
200+
}}
201+
tabIndex={tabIndex}
202+
onKeyDown={keyPressHandler}
203+
disabled={disabled}
204+
data-testid={dataTestId}
205+
ref={ref}
206+
>
207+
<LucideIcon
208+
unicode={unicode}
209+
iconSize={iconSize}
210+
iconColor={iconColor}
211+
dataTestId={dataTestIdIcon}
212+
/>
213+
{children}
214+
</StyledSessionIconButton>
215+
);
216+
}
217+
);

ts/components/icon/SessionNotificationCount.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const StyledCountContainer = styled.div<{ $centeredOnTop: boolean }>`
1414
padding: ${props => (props.$centeredOnTop ? '1px 3px 0' : '1px 4px')};
1515
1616
position: absolute;
17-
top: ${props => (props.$centeredOnTop ? '-10px' : '27px')};
17+
top: ${props => (props.$centeredOnTop ? '-10px' : '22px')};
1818
left: ${props => (props.$centeredOnTop ? '50%' : '28px')};
1919
2020
font-size: var(--font-size-xs);

ts/components/icon/lucide.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ export enum LUCIDE_ICONS_UNICODE {
2222
USER_ROUND_X = '',
2323
USER_ROUND_CHECK = '',
2424
PENCIL = '',
25+
HEART = '',
26+
LOCK_KEYHOLE = '',
27+
MESSAGE_SQUARE = '',
28+
MESSAGE_SQUARE_WARNING = '',
29+
PAINTBRUSH_VERTICAL = '',
30+
CIRCLE_CHECK = '',
31+
MOON = '',
32+
SUN_MEDIUM = '',
33+
SETTINGS = '',
34+
SQUARE_CODE = '',
35+
CHEVRON_RIGHT = '',
2536
}
2637

2738
/**

ts/components/leftpane/ActionsPanel.tsx

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ import { getSwarmPollingInstance } from '../../session/apis/snode_api';
4141
import { UserUtils } from '../../session/utils';
4242
import { Avatar, AvatarSize } from '../avatar/Avatar';
4343
import { ActionPanelOnionStatusLight } from '../dialog/OnionStatusPathDialog';
44-
import { SessionIconButton } from '../icon/SessionIconButton';
44+
import {
45+
SessionLucideIconButton,
46+
type SessionLucideIconButtonProps,
47+
} from '../icon/SessionIconButton';
4548
import { LeftPaneSectionContainer } from './LeftPaneSectionContainer';
4649

4750
import { SettingsKey } from '../../data/settings-key';
@@ -61,6 +64,7 @@ import { useCheckReleasedFeatures } from '../../hooks/useCheckReleasedFeatures';
6164
import { useDebugMode } from '../../state/selectors/debug';
6265
import { networkDataActions } from '../../state/ducks/networkData';
6366
import { isSesh101ReadyOutsideRedux } from '../../state/selectors/releasedFeatures';
67+
import { LUCIDE_ICONS_UNICODE } from '../icon/lucide';
6468

6569
const Section = (props: { type: SectionType }) => {
6670
const ourNumber = useSelector(getOurNumber);
@@ -71,7 +75,7 @@ const Section = (props: { type: SectionType }) => {
7175
const isModalVisible = useSelector(getIsModalVisible);
7276
const isDarkTheme = useIsDarkTheme();
7377
const focusedSection = useSelector(getFocusedSection);
74-
const isSelected = focusedSection === props.type;
78+
const isSelected = focusedSection === type;
7579

7680
const handleClick = () => {
7781
if (type === SectionType.Profile) {
@@ -125,38 +129,42 @@ const Section = (props: { type: SectionType }) => {
125129

126130
const unreadToShow = type === SectionType.Message ? globalUnreadMessageCount : undefined;
127131

132+
const buttonProps = {
133+
iconSize: '22px',
134+
padding: 'var(--margins-lg)',
135+
onClick: handleClick,
136+
isSelected,
137+
} satisfies Omit<SessionLucideIconButtonProps, 'unicode' | 'dataTestId'>;
138+
128139
switch (type) {
129140
case SectionType.Message:
130141
return (
131-
<SessionIconButton
132-
iconSize="medium"
142+
<SessionLucideIconButton
143+
{...buttonProps}
133144
dataTestId="message-section"
134-
iconType={'chatBubble'}
135-
onClick={handleClick}
136-
isSelected={isSelected}
145+
unicode={LUCIDE_ICONS_UNICODE.MESSAGE_SQUARE}
146+
style={{
147+
position: 'relative',
148+
}}
137149
>
138150
{Boolean(unreadToShow) && <SessionNotificationCount count={unreadToShow} />}
139-
</SessionIconButton>
151+
</SessionLucideIconButton>
140152
);
141153
case SectionType.Settings:
142154
return (
143-
<SessionIconButton
144-
iconSize="medium"
155+
<SessionLucideIconButton
156+
{...buttonProps}
145157
dataTestId="settings-section"
146-
iconType={'gear'}
147-
onClick={handleClick}
148-
isSelected={isSelected}
158+
unicode={LUCIDE_ICONS_UNICODE.SETTINGS}
149159
ref={settingsIconRef}
150160
/>
151161
);
152162
case SectionType.DebugMenu:
153163
return (
154-
<SessionIconButton
155-
iconSize="medium"
164+
<SessionLucideIconButton
165+
{...buttonProps}
166+
unicode={LUCIDE_ICONS_UNICODE.SQUARE_CODE}
156167
dataTestId="debug-menu-section"
157-
iconType={'debug'}
158-
onClick={handleClick}
159-
isSelected={isSelected}
160168
/>
161169
);
162170
case SectionType.PathIndicator:
@@ -170,12 +178,10 @@ const Section = (props: { type: SectionType }) => {
170178
case SectionType.ColorMode:
171179
default:
172180
return (
173-
<SessionIconButton
174-
iconSize="medium"
175-
iconType={isDarkTheme ? 'moon' : 'sun'}
181+
<SessionLucideIconButton
182+
{...buttonProps}
183+
unicode={isDarkTheme ? LUCIDE_ICONS_UNICODE.MOON : LUCIDE_ICONS_UNICODE.SUN_MEDIUM}
176184
dataTestId="theme-section"
177-
onClick={handleClick}
178-
isSelected={isSelected}
179185
/>
180186
);
181187
}

0 commit comments

Comments
 (0)