Skip to content

Commit 836bf2d

Browse files
committed
muted badge
1 parent 79a953f commit 836bf2d

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

src/pages/Content/helpers/TabPreviewHelper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ let unmountTabPreviewFrameTimeout;
3030
window.addEventListener('message', (event) => {
3131
const { msg, payload } = event.data;
3232
if (msg === 'PREVIEW_TAB_ON') {
33-
const { title, url, faviconUrl, tabItemY, isDark } = payload;
33+
const { title, url, muted, audible, faviconUrl, tabItemY, isDark } =
34+
payload;
3435
// console.log(title, url, faviconUrl, tabItemY, isDark);
3536

3637
if (unmountTabPreviewFrameTimeout) {
@@ -42,6 +43,8 @@ window.addEventListener('message', (event) => {
4243
<TabPreviewFrame
4344
title={title}
4445
url={url}
46+
muted={muted}
47+
audible={audible}
4548
faviconUrl={faviconUrl}
4649
isDark={isDark}
4750
/>,

src/pages/Content/modules/tabPreviewFrame/tabPreviewFrame.jsx

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { detect } from 'detect-browser';
44
import styled from 'styled-components';
55

66
const Container = styled.div`
7-
width: 220px;
7+
width: 240px;
88
box-shadow: 0 2px 5px 0 rgb(0 0 0 / 16%), 0 2px 10px 0 rgb(0 0 0 / 12%);
99
border-radius: 3px;
1010
padding: 0px;
@@ -16,21 +16,45 @@ const Container = styled.div`
1616
line-height: normal !important;
1717
`;
1818

19-
const Title = styled.div`
19+
const TitleContainer = styled.div`
2020
padding: 8px 10px;
2121
background: ${(props) => (props.isDark ? 'rgb(36, 36, 36)' : '#fefefe')};
22-
color: ${(props) => (props.isDark ? 'rgb(167, 167, 167)' : '#333')};
22+
color: ${(props) => (props.isDark ? 'rgb(190, 190, 190)' : '#333')};
2323
2424
border-top-left-radius: 3px;
2525
border-top-right-radius: 3px;
2626
2727
word-wrap: break-word;
2828
`;
2929

30+
const TabInfoContainer = styled.div`
31+
font-size: 11px;
32+
opacity: 0.8;
33+
`;
34+
35+
const AudibleOrMuted = styled.div`
36+
margin-top: 5px;
37+
display: flex;
38+
align-items: center;
39+
`;
40+
41+
const AudioMutedBadge = styled.span`
42+
border-radius: 3px;
43+
background-color: ${(props) => (props.isMuted ? 'inherent' : '#fe8c0a')};
44+
color: ${(props) => (props.isMuted ? 'inherent' : '#fff')};
45+
border: 1px solid transparent;
46+
border-color: ${(props) => (props.isMuted ? '#666' : 'transparent')};
47+
48+
margin-left: 4px;
49+
margin-right: 1px;
50+
51+
padding: 0.5px 2px;
52+
`;
53+
3054
const Domain = styled.div`
3155
padding: 8px 10px;
3256
background: ${(props) => (props.isDark ? '#35363A' : 'rgb(222, 225, 230)')};
33-
color: ${(props) => (props.isDark ? 'rgb(167, 167, 167)' : '#444')};
57+
color: ${(props) => (props.isDark ? 'rgb(190, 190, 190)' : '#444')};
3458
3559
border-bottom-left-radius: 3px;
3660
border-bottom-right-radius: 3px;
@@ -76,7 +100,14 @@ const NotSecureBadge = styled.div`
76100

77101
const browserInfo = detect();
78102

79-
const TabPreviewFrame = ({ title, url, faviconUrl, isDark }) => {
103+
const TabPreviewFrame = ({
104+
title,
105+
url,
106+
muted,
107+
audible,
108+
faviconUrl,
109+
isDark,
110+
}) => {
80111
let domain = new URL(url).hostname;
81112

82113
if (url.startsWith(browserInfo.name + '://') && !domain.includes('://')) {
@@ -89,7 +120,23 @@ const TabPreviewFrame = ({ title, url, faviconUrl, isDark }) => {
89120

90121
return (
91122
<Container className="TabPreviewContainer">
92-
<Title isDark={isDark}>{title}</Title>
123+
<TitleContainer isDark={isDark}>
124+
<div>{title}</div>
125+
<TabInfoContainer>
126+
{muted && audible && (
127+
<AudibleOrMuted>
128+
This tab is{' '}
129+
<AudioMutedBadge isMuted={true}>muted</AudioMutedBadge>.
130+
</AudibleOrMuted>
131+
)}
132+
{!muted && audible && (
133+
<AudibleOrMuted>
134+
This tab is{' '}
135+
<AudioMutedBadge isMuted={false}>playing audio</AudioMutedBadge>.
136+
</AudibleOrMuted>
137+
)}
138+
</TabInfoContainer>
139+
</TitleContainer>
93140

94141
<Domain isDark={isDark}>
95142
<DomainNameDisplay>

src/pages/Sidebar/containers/TabsList/Tab/Tab.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ const Tab = ({
186186
payload: {
187187
title,
188188
url,
189+
muted: mutedInfo.muted,
190+
audible: audible,
189191
faviconUrl: faviconDataUrl,
190192
tabItemY,
191193
isDark,

0 commit comments

Comments
 (0)