Skip to content

Commit fac5dc9

Browse files
committed
fix: address PR comments + fix shining animation
1 parent bb42d83 commit fac5dc9

File tree

8 files changed

+61
-26
lines changed

8 files changed

+61
-26
lines changed

stylesheets/_modules.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
overflow-y: hidden;
198198
white-space: nowrap;
199199
text-overflow: ellipsis;
200+
align-items: center;
200201
}
201202

202203
// Module: Contact List Item

ts/components/SessionWrapperModal.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { StyledRootDialog } from './dialog/StyledRootDialog';
1414
import { LUCIDE_ICONS_UNICODE } from './icon/lucide';
1515
import { IsModalScrolledContext, useIsModalScrolled } from '../contexts/IsModalScrolledContext';
1616
import { OnModalCloseContext, useOnModalClose } from '../contexts/OnModalCloseContext';
17+
import { SessionButton, SessionButtonColor } from './basic/SessionButton';
1718

1819
type WithExtraLeftButton = {
1920
/**
@@ -179,6 +180,35 @@ export const ModalActionsContainer = ({
179180
);
180181
};
181182

183+
/**
184+
* In the modal, the bottom actions sometimes have a border.
185+
* When they do, they all share the same styling (minWidth 125px) so this component is here to reuse that logic.
186+
*/
187+
export function ModalBottomButtonWithBorder({
188+
text,
189+
onClick,
190+
buttonColor,
191+
dataTestId,
192+
disabled,
193+
}: {
194+
text: string;
195+
onClick: () => void | Promise<void>;
196+
disabled?: boolean;
197+
buttonColor?: SessionButtonColor;
198+
dataTestId?: SessionDataTestId;
199+
}) {
200+
return (
201+
<SessionButton
202+
text={text}
203+
onClick={onClick}
204+
disabled={disabled}
205+
buttonColor={buttonColor ?? SessionButtonColor.PrimaryDark}
206+
dataTestId={dataTestId}
207+
style={{ minWidth: '125px' }}
208+
/>
209+
);
210+
}
211+
182212
export type ModalTopAnchor = '15vh' | '25vh' | '35vh' | '45vh';
183213

184214
export type SessionWrapperModalType = {

ts/components/basic/SessionButtonShiny.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import styled, { keyframes, type CSSProperties } from 'styled-components';
22
import { SessionButton, type SessionButtonProps, StyledBaseButton } from './SessionButton';
33

4+
/**
5+
* Note: we want 0.6s shine + 3s pause
6+
*/
47
const shine = keyframes`
5-
0% {
8+
0% {
69
transform: translateX(-100%);
710
}
11+
16.6% {
12+
transform: translateX(100%);
13+
}
814
100% {
915
transform: translateX(100%);
1016
}
@@ -19,7 +25,6 @@ const ShinyButtonContainer = styled.div`
1925
width: 100%;
2026
height: 100%;
2127
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
22-
transform: translateX(-100%);
2328
animation: ${shine} 0.6s ease-in-out infinite;
2429
animation-delay: 0s;
2530
animation-iteration-count: infinite;

ts/components/buttons/CopyToClipboardButton.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import useTimeoutFn from 'react-use/lib/useTimeoutFn';
55

66
import { useHotkey } from '../../hooks/useHotkey';
77
import { ToastUtils } from '../../session/utils';
8-
import { SessionButton, SessionButtonProps } from '../basic/SessionButton';
8+
import { SessionButtonProps } from '../basic/SessionButton';
99
import { SessionIconButtonProps, SessionLucideIconButton } from '../icon/SessionIconButton';
1010
import { LUCIDE_ICONS_UNICODE } from '../icon/lucide';
1111
import type { SessionIconSize } from '../icon';
1212
import { tr } from '../../localization/localeTools';
1313
import { DURATION } from '../../session/constants';
14+
import { ModalBottomButtonWithBorder } from '../SessionWrapperModal';
1415

1516
type CopyProps = {
1617
copyContent?: string;
@@ -54,11 +55,13 @@ export const CopyToClipboardButton = (props: CopyToClipboardButtonProps) => {
5455
useHotkey('c', onClick, !hotkey);
5556

5657
return (
57-
<SessionButton
58+
<ModalBottomButtonWithBorder
5859
aria-label={'copy to clipboard button'}
59-
{...props}
60-
text={!isEmpty(text) ? text : copied ? tr('copied') : tr('copy')}
60+
text={text && !isEmpty(text) ? text : copied ? tr('copied') : tr('copy')}
6161
onClick={onClick}
62+
buttonColor={props.buttonColor}
63+
dataTestId={props.dataTestId}
64+
disabled={props.disabled}
6265
/>
6366
);
6467
};

ts/components/buttons/ProButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function ProIconButton({
3737
dataTestId: SessionDataTestId;
3838
style?: CSSProperties;
3939
}) {
40+
const mergedStyle = { ...defaultStyle, ...style };
4041
if (onClick) {
4142
return (
4243
<SessionIconButton
@@ -46,7 +47,7 @@ export function ProIconButton({
4647
dataTestId={dataTestId}
4748
disabled={disabled}
4849
onClick={onClick}
49-
style={{ ...style, ...defaultStyle }}
50+
style={mergedStyle}
5051
/>
5152
);
5253
}
@@ -57,7 +58,7 @@ export function ProIconButton({
5758
iconSize={iconSize}
5859
borderRadius={sizeToBorderRadius(iconSize)}
5960
dataTestId={dataTestId}
60-
style={{ ...style, ...defaultStyle }}
61+
style={mergedStyle}
6162
/>
6263
);
6364
}

ts/components/dialog/UserProfileModal.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import styled from 'styled-components';
66
import { ConvoHub } from '../../session/conversations';
77
import { openConversationWithMessages } from '../../state/ducks/conversations';
88
import { updateUserProfileModal, UserProfileModalState } from '../../state/ducks/modalDialog';
9-
import { SessionButton, SessionButtonColor } from '../basic/SessionButton';
9+
import { SessionButtonColor } from '../basic/SessionButton';
1010
import { CopyToClipboardButton } from '../buttons/CopyToClipboardButton';
1111
import { ConversationTypeEnum } from '../../models/types';
1212
import { Flex } from '../basic/Flex';
@@ -15,6 +15,7 @@ import {
1515
ModalBasicHeader,
1616
ModalActionsContainer,
1717
SessionWrapperModal,
18+
ModalBottomButtonWithBorder,
1819
} from '../SessionWrapperModal';
1920
import { tr } from '../../localization/localeTools';
2021
import { PubKey } from '../../session/types';
@@ -103,12 +104,10 @@ export const UserProfileModal = ({
103104
onClose={closeDialog}
104105
buttonChildren={
105106
<ModalActionsContainer extraBottomMargin={true}>
106-
<SessionButton
107+
<ModalBottomButtonWithBorder
107108
text={tr('message')}
108109
onClick={onClickStartConversation}
109-
buttonColor={SessionButtonColor.PrimaryDark}
110110
dataTestId="new-session-conversation"
111-
style={{ minWidth: '125px' }}
112111
disabled={isBlindedAndNotResolved && hasDisabledMsgRequests}
113112
/>
114113

@@ -117,7 +116,6 @@ export const UserProfileModal = ({
117116
copyContent={conversationIdToDisplay}
118117
buttonColor={SessionButtonColor.PrimaryDark}
119118
dataTestId="copy-button-account-id"
120-
style={{ minWidth: '125px' }}
121119
hotkey={true}
122120
/>
123121
)}

ts/components/dialog/edit-profile/EditProfileDialog.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import {
2222
ModalBasicHeader,
2323
ModalActionsContainer,
2424
SessionWrapperModal,
25+
ModalBottomButtonWithBorder,
2526
} from '../../SessionWrapperModal';
26-
import { SessionButtonColor, SessionButton } from '../../basic/SessionButton';
27+
import { SessionButtonColor } from '../../basic/SessionButton';
2728
import { CopyToClipboardButton } from '../../buttons';
2829
import { SessionIDNotEditable } from '../../basic/SessionIdNotEditable';
2930
import { Flex } from '../../basic/Flex';
@@ -245,37 +246,31 @@ export const EditProfileDialog = () => {
245246
hotkey={true}
246247
reference={copyButtonRef}
247248
dataTestId="copy-button-profile-update"
248-
style={{ minWidth: '125px' }}
249249
/>
250250
{mode === 'default' ? (
251-
<SessionButton
251+
<ModalBottomButtonWithBorder
252252
text={tr('qrView')}
253253
onClick={() => {
254254
setMode('qr');
255255
}}
256256
buttonColor={SessionButtonColor.PrimaryDark}
257257
dataTestId="view-qr-code-button"
258-
style={{ minWidth: '125px' }}
259258
/>
260259
) : null}
261260
</ModalActionsContainer>
262261
) : (
263262
!loading && (
264263
<ModalActionsContainer extraBottomMargin={true}>
265-
<SessionButton
264+
<ModalBottomButtonWithBorder
266265
text={tr('save')}
267266
onClick={onClickOK}
268267
disabled={cannotContinue}
269-
buttonColor={SessionButtonColor.PrimaryDark}
270268
dataTestId="save-button-profile-update"
271-
style={{ minWidth: '125px' }}
272269
/>
273-
<SessionButton
270+
<ModalBottomButtonWithBorder
274271
text={tr('cancel')}
275272
onClick={cancelEdit}
276-
buttonColor={SessionButtonColor.PrimaryDark}
277273
dataTestId="invalid-data-testid"
278-
style={{ minWidth: '125px' }}
279274
/>
280275
</ModalActionsContainer>
281276
)

ts/components/leftpane/overlay/OverlayInvite.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { tr } from '../../../localization/localeTools';
1717
import { SessionIDNotEditable } from '../../basic/SessionIdNotEditable';
1818

1919
const StyledHeadingContainer = styled(Flex)`
20+
gap: var(--margins-xs);
21+
2022
.session-icon-button {
2123
border: 1px solid var(--text-primary-color);
2224
border-radius: 9999px;
@@ -47,7 +49,7 @@ const StyledDescription = styled.div`
4749
padding: 0 var(--margins-sm);
4850
`;
4951

50-
const StyledButtonerContainer = styled.div`
52+
const StyledButtonContainer = styled.div`
5153
.session-button {
5254
width: 160px;
5355
height: 41px;
@@ -90,15 +92,15 @@ export const OverlayInvite = () => {
9092
<SpacerMD />
9193
<StyledDescription>{tr('accountIdCopyDescription')}</StyledDescription>
9294
<SpacerLG />
93-
<StyledButtonerContainer>
95+
<StyledButtonContainer>
9496
<CopyToClipboardButton
9597
buttonColor={SessionButtonColor.PrimaryDark}
9698
copyContent={ourSessionID}
9799
onCopyComplete={() => setIdCopied(true)}
98100
hotkey={true}
99101
dataTestId="copy-button-account-id"
100102
/>
101-
</StyledButtonerContainer>
103+
</StyledButtonContainer>
102104
</>
103105
) : (
104106
<>

0 commit comments

Comments
 (0)