-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Message): new audio file preview [WPB-15809] (#18711)
* feat: draft * feat(Message): new audio file asset * refactor(AudioAsset): adjust PlayIcon size and import styles * refactor(AudioAsset): improve audio asset placeholder and card component * refactor(AudioAsset): consolidate audio metadata into single prop * refactor(AudioAsset): create AudioAssetRestricted component and update imports * feat(AudioAsset): bring back the old version * test(ContentMessage): add isFileShareRestricted prop to test setup * style(AudioAsset): set placeholder time text color * test(CollectionDetails): update AudioAsset import path * fix(AudioAsset): reorder file share restriction check * refactor(AudioAsset): improve type safety for getAssetUrl parameter * feat(i18n): add localization for audio asset interactions * chore: bump @wireapp/core * refactor(AudioAsset): use "V2" instead of "New" for the new version of components * refactor(AudioAssets): use import aliases instead of relative paths * refactor(AudioAssetPlaceholder): simplify loading state logic * refactor(AudioPlayButton): simplify event listener management * refactor(useAudioMetadata): simplify transfer state name handling * fix(AudioPlayButton): not all code paths return a value
- Loading branch information
1 parent
d57b497
commit ab2adc3
Showing
44 changed files
with
1,392 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...sagesList/Message/ContentMessage/asset/AudioAsset/AudioAssetCard/AudioAssetCard.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2025 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {CSSObject} from '@emotion/react'; | ||
|
||
export const contentStyles: CSSObject = { | ||
height: '48px', | ||
}; |
71 changes: 71 additions & 0 deletions
71
...ts/MessagesList/Message/ContentMessage/asset/AudioAsset/AudioAssetCard/AudioAssetCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2025 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {ReactNode, SyntheticEvent} from 'react'; | ||
|
||
import {FileCard} from 'Components/FileCard/FileCard'; | ||
|
||
import {contentStyles} from './AudioAssetCard.styles'; | ||
|
||
interface AudioMetadata { | ||
name: string; | ||
extension: string; | ||
size: string; | ||
duration: number; | ||
loudnessPreview: boolean; | ||
} | ||
|
||
interface AudioAssetCardProps { | ||
src?: string; | ||
getAudioElementRef: (element: HTMLMediaElement) => void; | ||
metadata: AudioMetadata; | ||
isError?: boolean; | ||
isLoading?: boolean; | ||
loadingProgress?: number; | ||
onTimeUpdate: (event: SyntheticEvent<HTMLAudioElement>) => void; | ||
children: ReactNode; | ||
} | ||
|
||
export const AudioAssetCard = ({ | ||
src, | ||
metadata, | ||
children, | ||
isError, | ||
isLoading, | ||
loadingProgress, | ||
getAudioElementRef, | ||
onTimeUpdate, | ||
}: AudioAssetCardProps) => { | ||
return ( | ||
<FileCard.Root variant="large" extension={metadata.extension} name={metadata.name} size={metadata.size}> | ||
<FileCard.Header> | ||
<FileCard.Icon /> | ||
<FileCard.Type /> | ||
</FileCard.Header> | ||
<FileCard.Name /> | ||
<FileCard.Content> | ||
{/* eslint-disable-next-line jsx-a11y/media-has-caption */} | ||
<audio ref={getAudioElementRef} src={src} onTimeUpdate={onTimeUpdate} /> | ||
<div css={contentStyles}>{children}</div> | ||
</FileCard.Content> | ||
{isError && <FileCard.Error />} | ||
{isLoading && <FileCard.Loading progress={loadingProgress} />} | ||
</FileCard.Root> | ||
); | ||
}; |
76 changes: 76 additions & 0 deletions
76
...age/ContentMessage/asset/AudioAsset/AudioAssetPlaceholder/AudioAssetPlaceholder.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2025 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
* | ||
*/ | ||
|
||
import {CSSObject} from '@emotion/react'; | ||
|
||
export const wrapperStyles: CSSObject = { | ||
display: 'flex', | ||
alignItems: 'flex-start', | ||
justifyContent: 'flex-start', | ||
overflow: 'hidden', | ||
gap: '8px', | ||
}; | ||
|
||
export const buttonStyles: CSSObject = { | ||
width: '32px', | ||
height: '32px', | ||
borderRadius: '50%', | ||
backgroundColor: 'var(--icon-button-primary-disabled-bg)', | ||
border: '1px solid var(--icon-button-primary-disabled-border)', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flexShrink: 0, | ||
cursor: 'not-allowed', | ||
|
||
'& svg': { | ||
fill: 'var(--gray-70)', | ||
}, | ||
|
||
'body.dark &': { | ||
'& svg': { | ||
fill: 'var(--gray-60)', | ||
}, | ||
}, | ||
}; | ||
|
||
export const seekBarStyles: CSSObject = { | ||
height: '32px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}; | ||
|
||
export const timerWrapperStyles: CSSObject = { | ||
width: '100%', | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
}; | ||
|
||
export const timerWrapperStylesWithLoading: CSSObject = { | ||
...timerWrapperStyles, | ||
paddingRight: '16px', | ||
}; | ||
|
||
export const timeStyles: CSSObject = { | ||
margin: 0, | ||
fontSize: 'var(--font-size-xsmall)', | ||
fontWeight: 'var(--font-weight-regular)', | ||
color: 'var(--foreground)', | ||
}; |
Oops, something went wrong.