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

Improve support for theme icons #2159

Merged
merged 2 commits into from
Oct 10, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import '@testing-library/jest-dom/extend-expect'
import {render} from '@testing-library/react'
import {renderInEntry} from 'support'

import {PlayPauseButton} from 'frontend/PlayerControls/PlayPauseButton';
import {useFakeTranslations} from 'pageflow/testHelpers';
Expand All @@ -12,12 +12,12 @@ describe('PlayPauseButton', () => {
});

it('shows pause button when playing', () => {
const {getByLabelText} = render(<PlayPauseButton isPlaying={true}/>);
const {getByLabelText} = renderInEntry(<PlayPauseButton isPlaying={true}/>);
expect(getByLabelText('Pause')).toBeVisible();
});

it('shows play button when paused', () => {
const {getByLabelText} = render(<PlayPauseButton isPlaying={false}/>);
const {getByLabelText} = renderInEntry(<PlayPauseButton isPlaying={false}/>);
expect(getByLabelText('Play')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,14 @@
display: block;
width: var(--theme-hotspts-scroll-button-size);
height: var(--theme-hotspots-scroll-button-size);
filter: drop-shadow(0 1px 4px #000);
}

.button:not(.disabled):hover svg,
.button:not(.disabled):active svg {
transform: scale(1.2);
}

.icon {
position: relative;
}

.icon::before {
content: ' ';
position: absolute;
top: 50%;
left: 50%;
width: 50px;
height: 50px;
transform: translate(-50%, -50%);
background: radial-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0) 60%);
z-index: -1;
}

.visuallyHidden {
border: 0;
clip: rect(0 0 0 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
display: block;
width: var(--theme-image-gallery-scroll-button-size);
height: var(--theme-image-gallery-scroll-button-size);
filter: drop-shadow(0 1px 4px #000);
}

.button:not(.disabled):hover svg,
Expand All @@ -26,22 +27,9 @@
}

.icon {
position: relative;
transition: opacity 0.2s linear;
}

.disabled .icon {
opacity: 0;
}

.icon::before {
content: ' ';
position: absolute;
top: 50%;
left: 50%;
width: 50px;
height: 50px;
transform: translate(-50%, -50%);
background: radial-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0) 60%);
z-index: -1;
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import React from 'react';
import classNames from 'classnames';

import ArrowLeftIcon from '../icons/arrowLeft.svg';
import {ThemeIcon} from '../ThemeIcon';

import styles from './FullscreenIndicator.module.css';

export function FullscreenIndicator({visible, onClick}) {
const size = 50;

return (
<div className={classNames(styles.indicator, {[styles.visible]: visible})}>
<div className={styles.icons}>
<div className={styles.iconTopLeft}>
<ArrowLeftIcon width={size} height={size} />
<ThemeIcon name="arrowLeft" />
</div>
<div className={styles.iconTopRight}>
<ArrowLeftIcon width={size} height={size} />
<ThemeIcon name="arrowLeft" />
</div>
<div className={styles.iconBottomRight}>
<ArrowLeftIcon width={size} height={size} />
<ThemeIcon name="arrowLeft" />
</div>
<div className={styles.iconBottomLeft}>
<ArrowLeftIcon width={size} height={size} />
<ThemeIcon name="arrowLeft" />
</div>
</div>
<div className={styles.text}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
left: 50%;
}

.icons svg {
width: 50px;
height: 50px;
filter: drop-shadow(0 1px 4px #000);
}

.text {
transform: translate(-50%, -50%);
font-weight: bold;
Expand All @@ -28,18 +34,6 @@
animation: pulse 4s infinite ease;
}

.icon::before {
content: ' ';
position: absolute;
top: 50%;
left: 50%;
width: 45px;
height: 45px;
transform: translate(-45%, -50%);
background: radial-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0) 60%);
z-index: -1;
}

.iconTopLeft {
composes: icon;
transform: translate(-50%, -50%) rotate(45deg);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import React from 'react';
import classNames from 'classnames';

import ArrowLeftIcon from '../icons/arrowLeft.svg';
import ArrowRightIcon from '../icons/arrowRight.svg';
import {ThemeIcon} from '../ThemeIcon';

import styles from './PanoramaIndicator.module.css';

export function PanoramaIndicator({visible}) {
const size = 40;

return (
<div className={classNames(styles.indicator, {[styles.visible]: visible})}>
<div className={styles.arrowLeft}>
<div>
<ArrowLeftIcon width={size} height={size} />
<ThemeIcon name="arrowLeft" />
</div>
</div>
<div className={styles.arrowRight}>
<div>
<ArrowRightIcon width={size} height={size} />
<ThemeIcon name="arrowRight" />
</div>
</div>
<div className={styles.text}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,15 @@

.indicator svg {
transition: transform 0.2s ease;
width: 40px;
height: 40px;
filter: drop-shadow(0 1px 4px #000);
}

*:hover > .indicator svg {
transform: scale(1.2);
}

.arrow div::before {
content: ' ';
position: absolute;
top: 50%;
left: 50%;
width: 30px;
height: 30px;
transform: translate(-50%, -50%);
background: radial-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0) 60%);
z-index: -1;
}

@keyframes nudgeLeft {
0% {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import classNames from 'classnames';
import styles from './BigPlayPauseButton.module.css'
import PlayIcon from '../images/play.svg';
import PauseIcon from '../images/pause.svg';
import {ThemeIcon} from '../../ThemeIcon';

export function BigPlayPauseButton(props) {
const c = classNames(styles.button, {
Expand All @@ -27,9 +26,9 @@ export function BigPlayPauseButton(props) {

function pausePlayIcon(props) {
if (props.unplayed || props.isPlaying) {
return <PlayIcon />;
return <ThemeIcon name="play" />;
}
else {
return <PauseIcon />
return <ThemeIcon name="pause" />;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import PropTypes from 'prop-types';
import {MenuBarButton} from '../MenuBarButton';
import {useI18n} from '../../i18n';

import QualityIcon from '../images/quality.svg';

export function QualityMenu(props) {
const {t} = useI18n();

Expand All @@ -15,7 +13,7 @@ export function QualityMenu(props) {

return (
<MenuBarButton title={t('pageflow_scrolled.public.player_controls.quality')}
icon={QualityIcon}
icon="gear"
subMenuItems={props.items}
subMenuExpanded={props.subMenuExpanded}
onSubMenuItemClick={props.onItemClick} x/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import PropTypes from 'prop-types';

import classNames from 'classnames';

import {ThemeIcon} from '../ThemeIcon';

import styles from './MenuBarButton.module.css';
import CheckIcon from './images/check.svg';

export function MenuBarButton(props) {
const {subMenuItems, onClick} = props;
Expand Down Expand Up @@ -58,7 +59,7 @@ export function MenuBarButton(props) {
<button className={styles.button}
title={props.title}
onClick={onButtonClick}>
{React.createElement(props.icon, {className: styles.icon})}
<ThemeIcon name={props.icon} />
</button>
{renderSubMenu(props, closeMenu)}
</div>
Expand All @@ -67,7 +68,7 @@ export function MenuBarButton(props) {

MenuBarButton.propTypes = {
title: PropTypes.string,
icon: PropTypes.elementType,
icon: PropTypes.string,
subMenuItems: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
Expand Down Expand Up @@ -118,7 +119,7 @@ function renderSubMenuItems(props, closeMenu) {
function renderSubMenuItemIcon(item) {
if (item.active) {
return (
<CheckIcon className={styles.subMenuItemIcon} />
<ThemeIcon name="checked" />
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
composes: button from './ControlBar.module.css';
}

.icon {
width: 25px;
height: 25px;
fill: currentColor;
}

.subMenuItemAnnotation {
color: #ff0000;
font-size: 70%;
Expand Down Expand Up @@ -57,7 +51,7 @@
list-style: none;
}

.subMenuItemIcon {
.subMenuItem svg {
position: absolute;
top: 8px;
left: 5px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import controlBarStyles from "./ControlBar.module.css";
import PlayIcon from "./images/play.svg";
import PauseIcon from "./images/pause.svg";
import {ThemeIcon} from '../ThemeIcon';

import {useI18n} from '../i18n';

Expand All @@ -21,8 +20,8 @@ export function PlayPauseButton(props) {

function pausePlayIcon(props) {
if (props.isPlaying) {
return <PauseIcon className={controlBarStyles.controlsIcon} />
return <ThemeIcon name="pause" />
} else {
return <PlayIcon className={controlBarStyles.controlsIcon} />
return <ThemeIcon name="play" />
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import PropTypes from 'prop-types';
import {MenuBarButton} from './MenuBarButton';
import {useI18n} from '../i18n';

import TextTracksIcon from './images/textTracks.svg';

export function TextTracksMenu(props) {
const {t} = useI18n();

Expand All @@ -15,7 +13,7 @@ export function TextTracksMenu(props) {

return (
<MenuBarButton title={t('pageflow_scrolled.public.player_controls.text_tracks')}
icon={TextTracksIcon}
icon="textTracks"
subMenuItems={props.items}
onSubMenuItemClick={props.onItemClick} />
);
Expand Down

This file was deleted.

Loading
Loading