This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bac6e12
commit 8e3f829
Showing
14 changed files
with
314 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.mx_VoiceBroadcastHeader { | ||
align-items: flex-start; | ||
display: flex; | ||
gap: $spacing-8; | ||
line-height: 20px; | ||
margin-bottom: $spacing-8; | ||
width: 266px; | ||
} | ||
|
||
.mx_VoiceBroadcastHeader_sender { | ||
font-size: $font-12px; | ||
font-weight: $font-semi-bold; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.mx_VoiceBroadcastHeader_room { | ||
font-size: $font-12px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
|
||
.mx_VoiceBroadcastHeader_line { | ||
align-items: center; | ||
color: $secondary-content; | ||
font-size: $font-12px; | ||
display: flex; | ||
gap: $spacing-6; | ||
} |
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
55 changes: 55 additions & 0 deletions
55
src/voice-broadcast/components/atoms/VoiceBroadcastHeader.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,55 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from "react"; | ||
import { RoomMember } from "matrix-js-sdk/src/matrix"; | ||
|
||
import MemberAvatar from "../../../components/views/avatars/MemberAvatar"; | ||
import { LiveBadge } from "../.."; | ||
import { Icon, IconColour, IconType } from "../../../components/atoms/Icon"; | ||
import { _t } from "../../../languageHandler"; | ||
|
||
interface VoiceBroadcastHeaderProps { | ||
live: boolean; | ||
sender: RoomMember; | ||
roomName: string; | ||
showBroadcast?: boolean; | ||
} | ||
|
||
export const VoiceBroadcastHeader: React.FC<VoiceBroadcastHeaderProps> = ({ | ||
live, | ||
sender, | ||
roomName, | ||
showBroadcast = false, | ||
}) => { | ||
const broadcast = showBroadcast | ||
? <div className="mx_VoiceBroadcastHeader_line"> | ||
<Icon type={IconType.Live} colour={IconColour.CompoundSecondaryContent} /> | ||
{ _t("Voice broadcast") } | ||
</div> | ||
: null; | ||
const liveBadge = live ? <LiveBadge /> : null; | ||
return <div className="mx_VoiceBroadcastHeader"> | ||
<MemberAvatar member={sender} fallbackUserId={sender.userId} /> | ||
<div className="mx_VoiceBroadcastHeader_content"> | ||
<div className="mx_VoiceBroadcastHeader_sender"> | ||
{ sender.name } | ||
</div> | ||
<div className="mx_VoiceBroadcastHeader_room"> | ||
{ roomName } | ||
</div> | ||
{ broadcast } | ||
</div> | ||
{ liveBadge } | ||
</div>; | ||
}; |
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
88 changes: 88 additions & 0 deletions
88
test/voice-broadcast/components/atoms/VoiceBroadcastHeader-test.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,88 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Container } from "react-dom"; | ||
import { RoomMember } from "matrix-js-sdk/src/matrix"; | ||
import { render, RenderResult } from "@testing-library/react"; | ||
|
||
import MemberAvatar from "../../../../src/components/views/avatars/MemberAvatar"; | ||
import { VoiceBroadcastHeader } from "../../../../src/voice-broadcast"; | ||
import { Icon } from "../../../../src/components/atoms/Icon"; | ||
|
||
jest.mock("../../../../src/components/views/avatars/MemberAvatar", () => ({ | ||
__esModule: true, | ||
default: ({ member, fallbackUserId }: React.ComponentProps<typeof MemberAvatar>) => { | ||
return <div data-testid="member-avatar"> | ||
{ member.name }, | ||
{ fallbackUserId } | ||
</div>; | ||
}, | ||
})); | ||
|
||
jest.mock("../../../../src/voice-broadcast/components/atoms/LiveBadge", () => ({ | ||
LiveBadge: () => { | ||
return <div data-testid="live-badge" />; | ||
}, | ||
})); | ||
|
||
jest.mock("../../../../src/components/atoms/Icon", () => ({ | ||
...jest.requireActual("../../../../src/components/atoms/Icon") as object, | ||
Icon: ({ type, colour }: React.ComponentProps<typeof Icon>) => { | ||
return <div data-testid="icon"> | ||
type: { type }, | ||
colour: { colour } | ||
</div>; | ||
}, | ||
})); | ||
|
||
describe("VoiceBroadcastHeader", () => { | ||
const userId = "@user:example.com"; | ||
const roomId = "!room:example.com"; | ||
const roomName = "test room"; | ||
const sender = new RoomMember(roomId, userId); | ||
let container: Container; | ||
|
||
const renderHeader = (live: boolean, showBroadcast: boolean = undefined): RenderResult => { | ||
return render(<VoiceBroadcastHeader | ||
live={live} | ||
sender={sender} | ||
roomName={roomName} | ||
showBroadcast={showBroadcast} | ||
/>); | ||
}; | ||
|
||
beforeAll(() => { | ||
sender.name = "test user"; | ||
}); | ||
|
||
describe("when rendering a live broadcast header with broadcast info", () => { | ||
beforeEach(() => { | ||
container = renderHeader(true, true).container; | ||
}); | ||
|
||
it("should render the header with a live badge", () => { | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe("when rendering a non-live broadcast header", () => { | ||
beforeEach(() => { | ||
container = renderHeader(false).container; | ||
}); | ||
|
||
it("should render the header without a live badge", () => { | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.