Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duckplayer: larger video on mobile landscape #1164

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions special-pages/messages/duckplayer/telemetryEvent.notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "TelemetryEvent",
"type": "object",
"required": ["attributes"],
"properties": {
"attributes": {
"oneOf": [
{
"type": "object",
"title": "Impression",
"required": ["name", "value"],
"properties": {
"name": {
"const": "impression"
},
"value": {
"type": "string",
"enum": ["landscape-layout"]
}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
display: flex;
height: 44px;
line-height: 44px;
font-size: 16px;
font-size: 15px;
font-weight: bold;
padding: 0 20px;
flex-shrink: 0;
box-shadow: none;
background: rgba(255, 255, 255, 0.12);
border-radius: var(--inner-radius);
font-weight: bold;
color: rgba(255, 255, 255, 1);
text-decoration: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createAppFeaturesFrom } from "../features/app.js";
import { MobileButtons } from "./MobileButtons.jsx";
import { OrientationProvider } from "../providers/OrientationProvider.jsx";
import { FocusMode } from "./FocusMode.jsx";
import { useTelemetry } from "../types.js";

const DISABLED_HEIGHT = 450;

Expand All @@ -23,6 +24,7 @@ const DISABLED_HEIGHT = 450;
*/
export function MobileApp({ embed }) {
const settings = useSettings();
const telemetry = useTelemetry();
const features = createAppFeaturesFrom(settings)
return (
<>
Expand All @@ -35,7 +37,9 @@ export function MobileApp({ embed }) {
// landscape
// if the height is too low, just disable it
if (window.innerHeight < DISABLED_HEIGHT) {
return FocusMode.disable()
FocusMode.disable()
telemetry.landscapeImpression()
return;
}
return FocusMode.enable()
}} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
body[data-display="app"] {
padding: 8px;
}
html[data-focus-mode="on"]:root .main {
--bg-color: transparent;
}
Expand Down Expand Up @@ -26,14 +29,11 @@ html[data-focus-mode="on"] .hideInFocus {
.main {
--bg-color: rgba(0, 0, 0, 0.3);
--logo-spacing: 185px;
--ui-control-height: calc(44px + 12px + 12px);
--additional-ui: calc(44px * 3);
--gutter-width: 8px;
--gutter-combined: calc(var(--gutter-width) * 2);
--outer-radius: 16px;
--inner-radius: 8px;
--inner-radius: 12px;
--logo-width: 157px;
--inner-padding: 12px;
--inner-padding: 8px;
position: relative;
max-width: 100vh;
margin: 0 auto;
Expand All @@ -44,7 +44,7 @@ html[data-focus-mode="on"] .hideInFocus {
--row-2: auto;
--row-3: max-content;
--row-4: max-content;
--row-5: 12px;
--row-5: 16px;
--row-6: max-content;
--row-7: auto;
grid-template-rows:
Expand Down Expand Up @@ -83,7 +83,7 @@ body:has([data-state="completed"] [aria-checked="true"]) .switch {
.embed {
background: var(--bg-color);
grid-area: embed;
padding: var(--inner-padding);
padding: calc(var(--inner-padding) / 2);
padding-bottom: 0;
border-top-left-radius: var(--outer-radius);
border-top-right-radius: var(--outer-radius);
Expand All @@ -104,9 +104,7 @@ body:has([data-state="completed"] [aria-checked="true"]) .switch {

.switch {
grid-area: switch;
height: 50px;
background: rgba(255, 255, 255, 0.03);
border-radius: 16px;
height: 44px;
}

@media screen and (min-width: 425px) and (max-height: 600px) {
Expand All @@ -129,7 +127,7 @@ body:has([data-state="completed"] [aria-checked="true"]) .switch {
border-bottom-left-radius: var(--outer-radius);
display: grid;
align-items: center;
padding-left: var(--inner-padding);
padding-left: 12px;
}
.buttons {
border-bottom-left-radius: unset;
Expand Down Expand Up @@ -159,8 +157,8 @@ body:has([data-state="completed"] [aria-checked="true"]) .switch {
background: var(--bg-color);
border-radius: unset;
display: grid;
padding-top: 12px;
padding-bottom: 12px;
padding-top: 8px;
padding-bottom: 8px;
height: 100%;
}
.buttons {
Expand All @@ -180,75 +178,41 @@ body:has([data-state="completed"] [aria-checked="true"]) .switch {
}
}
@media screen and (min-width: 600px) and (max-height: 450px) {
.main {
grid-template-columns: 1fr 1fr;
grid-template-rows: calc(44px + 24px) 44px auto calc(44px + 24px);
grid-template-areas:
'embed logo'
'embed buttons'
'embed filler'
'embed switch';
align-content: center;
max-width: 100%;
max-height: 90vh;
}
body:has([data-state="completed"] [aria-checked="true"]) .main {
grid-template-rows: max-content max-content 0 0;
:root {
--body-padding: 4px;
--max-width: calc(100vw - var(--body-padding) * 2);
}
body:has([data-state="completed"] [aria-checked="true"]) .logo {
padding-top: 0;
align-items: end;
body[data-display="app"] {
padding: 0;
}
body:has([data-state="completed"] [aria-checked="true"]) .buttons {
border-bottom-right-radius: var(--outer-radius);
padding-bottom: 12px;
.main {
grid-template-columns: 100%;
grid-template-rows: 100%;
grid-template-areas: 'embed';
max-width: none;
}
body:has([data-state="completed"] [aria-checked="true"]) .switch {
display: none;
.embed {
padding: 0;
border-radius: 0;
width: 100%;
/*max-width: var(--max-width);*/
background-color: transparent;
}
.filler {
display: block;
height: 100%;
grid-area: filler;
background: var(--bg-color)
}
.embed {
padding: var(--inner-padding);
border-bottom-left-radius: var(--outer-radius);
border-top-right-radius: 0;
display: none;
}
.logo {
display: grid;
width: 100%;
background: var(--bg-color);
justify-content: center;
border-top-right-radius: var(--outer-radius);
padding: var(--inner-padding);
padding-left: 0;
display: none;
}
.buttons {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
padding: 0;
padding-right: var(--inner-padding);
display: none;
}
.switch {
background: var(--bg-color);
border-top-right-radius: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: var(--outer-radius);
align-self: end;
padding: var(--inner-padding);
padding-left: 0;
height: 100%;
display: none;
}
}
@media screen and (min-width: 1100px) {
.switch {
justify-content: end;
}
.switch > * {
min-width: 400px
}
}
19 changes: 19 additions & 0 deletions special-pages/pages/duckplayer/app/components/Player.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.root.mobile {
aspect-ratio: 16/9;
border-radius: var(--inner-radius);
overflow: hidden;
height: auto;
}

Expand Down Expand Up @@ -45,3 +46,21 @@
justify-items: center;
background: #2f2f2f;
}

@media screen and (min-width: 600px) and (max-height: 450px) {
.root.mobile {
max-height: 100%;
margin: 0 auto;
overflow: hidden;
background: rgba(0, 0, 0, 0.3);
border-radius: 0;
}
.iframe.mobile {
overflow: hidden;
border-radius: 0;
}
.error {
overflow: hidden;
border-radius: 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
.switchBar {
display: grid;
border-radius: 16px;
border-radius: 8px;
background: rgba(255, 255, 255, 0.03);
padding-inline: 16px;
height: 100%;
line-height: 1.1;
}

@media screen and (min-width: 900px) {
.switchBar {
border-radius: 8px;
}
}
@media screen and (min-width: 667px) and (max-height: 450px) {
.switchBar {
border-radius: 8px;
}
}

.stateExiting {
transition: all .3s ease-in-out;
transition-delay: 2s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
grid-column-gap: 8px;
grid-template-columns: max-content max-content;
}
@media screen and (max-width: 500px) {

@media screen and (max-width: 767px) {
.logo {
height: 100px;
}
}
.logoSvg {
img {
display: block;
width: 32px;
height: 32px;
}
.logoSvg img {
display: block;
width: 32px;
height: 32px;
}
.text {
font-size: 17px;
Expand Down
6 changes: 6 additions & 0 deletions special-pages/pages/duckplayer/app/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ body[data-display="app"] {
padding: 16px;
}

@media screen and (min-width: 600px) and (max-height: 450px) {
body[data-display="app"] {
padding: 8px;
}
}

41 changes: 22 additions & 19 deletions special-pages/pages/duckplayer/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EmbedSettings } from './embed-settings.js'
import enStrings from '../src/locales/en/duckplayer.json'
import { Settings } from './settings.js'
import { SettingsProvider } from './providers/SettingsProvider.jsx'
import { MessagingContext } from './types.js'
import { MessagingContext, TelemetryContext } from './types.js'
import { UserValuesProvider } from './providers/UserValuesProvider.jsx'
import { Fallback } from '../../../shared/components/Fallback/Fallback.jsx'
import { Components } from './components/Components.jsx'
Expand All @@ -17,10 +17,11 @@ import { DesktopApp } from './components/DesktopApp.jsx'

/**
* @param {import("../src/js/index.js").DuckplayerPage} messaging
* @param {import("../src/js/index.js").Telemetry} telemetry
* @param {import("../../../shared/environment").Environment} baseEnvironment
* @return {Promise<void>}
*/
export async function init (messaging, baseEnvironment) {
export async function init (messaging, telemetry, baseEnvironment) {
const result = await callWithRetry(() => messaging.initialSetup())
if ('error' in result) {
throw new Error(result.error)
Expand Down Expand Up @@ -77,23 +78,25 @@ export async function init (messaging, baseEnvironment) {
willThrow={environment.willThrow}>
<ErrorBoundary didCatch={didCatch} fallback={<Fallback showDetails={environment.env === 'development'}/>}>
<UpdateEnvironment search={window.location.search}/>
<MessagingContext.Provider value={messaging}>
<SettingsProvider settings={settings}>
<UserValuesProvider initial={init.userValues}>
{settings.layout === 'desktop' && (
<TranslationProvider translationObject={enStrings} fallback={enStrings} textLength={environment.textLength}>
<DesktopApp embed={embed} />
</TranslationProvider>
)}
{settings.layout === 'mobile' && (
<TranslationProvider translationObject={strings} fallback={enStrings} textLength={environment.textLength}>
<MobileApp embed={embed} />
</TranslationProvider>
)}
<WillThrow />
</UserValuesProvider>
</SettingsProvider>
</MessagingContext.Provider>
<TelemetryContext.Provider value={telemetry}>
<MessagingContext.Provider value={messaging}>
<SettingsProvider settings={settings}>
<UserValuesProvider initial={init.userValues}>
{settings.layout === 'desktop' && (
<TranslationProvider translationObject={enStrings} fallback={enStrings} textLength={environment.textLength}>
<DesktopApp embed={embed} />
</TranslationProvider>
)}
{settings.layout === 'mobile' && (
<TranslationProvider translationObject={strings} fallback={enStrings} textLength={environment.textLength}>
<MobileApp embed={embed} />
</TranslationProvider>
)}
<WillThrow />
</UserValuesProvider>
</SettingsProvider>
</MessagingContext.Provider>
</TelemetryContext.Provider>
</ErrorBoundary>
</EnvironmentProvider>
, root)
Expand Down
Loading
Loading