From 3d1671d6b5da164cc29797b01525220a4367482d Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 29 Sep 2021 12:15:16 +0200 Subject: [PATCH] iconify like, delete and addtag buttons fix lukas/openmediacenter#45 --- src/elements/GPElements/Button.module.css | 5 +++- src/elements/GPElements/Button.test.js | 31 ++++++++++++++++------- src/elements/GPElements/Button.tsx | 26 ++++++++++++++++++- src/pages/Player/Player.test.js | 6 ++--- src/pages/Player/Player.tsx | 22 ++++++---------- 5 files changed, 62 insertions(+), 28 deletions(-) diff --git a/src/elements/GPElements/Button.module.css b/src/elements/GPElements/Button.module.css index 8e1b61b..e84d423 100644 --- a/src/elements/GPElements/Button.module.css +++ b/src/elements/GPElements/Button.module.css @@ -2,7 +2,10 @@ background-color: green; border-radius: 5px; border-width: 0; - color: white; margin-right: 15px; padding: 6px; } + +.button:hover{ + opacity: 0.7; +} diff --git a/src/elements/GPElements/Button.test.js b/src/elements/GPElements/Button.test.js index e4f375f..ec7f0b1 100644 --- a/src/elements/GPElements/Button.test.js +++ b/src/elements/GPElements/Button.test.js @@ -1,14 +1,6 @@ import {shallow} from 'enzyme'; import React from 'react'; -import {Button} from './Button'; - -function prepareFetchApi(response) { - const mockJsonPromise = Promise.resolve(response); - const mockFetchPromise = Promise.resolve({ - json: () => mockJsonPromise - }); - return (jest.fn().mockImplementation(() => mockFetchPromise)); -} +import {Button, IconButton} from './Button'; describe(' ); } + +interface IconButtonProps { + title: string | JSX.Element; + onClick?: () => void; + icon: IconDefinition; +} + +export function IconButton(props: IconButtonProps): JSX.Element { + const theme = GlobalInfos.getThemeStyle(); + + return ( + + ); +} diff --git a/src/pages/Player/Player.test.js b/src/pages/Player/Player.test.js index 5f38be2..f24ced7 100644 --- a/src/pages/Player/Player.test.js +++ b/src/pages/Player/Player.test.js @@ -38,7 +38,7 @@ describe('', function () { // initial fetch for getting movie data expect(global.fetch).toHaveBeenCalledTimes(1); - wrapper.find('.videoactions').find('Button').first().simulate('click'); + wrapper.find('.videoactions').find('IconButton').first().simulate('click'); // fetch for liking expect(global.fetch).toHaveBeenCalledTimes(2); @@ -81,7 +81,7 @@ describe('', function () { const wrapper = instance(); expect(wrapper.find('AddTagPopup')).toHaveLength(0); // todo dynamic button find without index - wrapper.find('.videoactions').find('Button').at(1).simulate('click'); + wrapper.find('.videoactions').find('IconButton').at(1).simulate('click'); // addtagpopup should be showing now expect(wrapper.find('AddTagPopup')).toHaveLength(1); }); @@ -106,7 +106,7 @@ describe('', function () { wrapper.setContext({VideosFullyDeleteable: false}) // request the popup to pop - wrapper.find('.videoactions').find('Button').at(2).simulate('click'); + wrapper.find('.videoactions').find('IconButton').at(2).simulate('click'); // click the first submit button wrapper.find('ButtonPopup').dive().find('Button').at(0).simulate('click') diff --git a/src/pages/Player/Player.tsx b/src/pages/Player/Player.tsx index 2d86029..c14bb38 100644 --- a/src/pages/Player/Player.tsx +++ b/src/pages/Player/Player.tsx @@ -9,7 +9,7 @@ import Tag from '../../elements/Tag/Tag'; import AddTagPopup from '../../elements/Popups/AddTagPopup/AddTagPopup'; import PageTitle, {Line} from '../../elements/PageTitle/PageTitle'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; -import {faPlusCircle} from '@fortawesome/free-solid-svg-icons'; +import {faPlusCircle, faTag, faThumbsUp, faTrash} from '@fortawesome/free-solid-svg-icons'; import AddActorPopup from '../../elements/Popups/AddActorPopup/AddActorPopup'; import ActorTile from '../../elements/ActorTile/ActorTile'; import {withRouter} from 'react-router-dom'; @@ -18,7 +18,7 @@ import {RouteComponentProps} from 'react-router'; import {DefaultPlyrOptions, GeneralSuccess} from '../../types/GeneralTypes'; import {ActorType, TagType} from '../../types/VideoTypes'; import PlyrJS from 'plyr'; -import {Button} from '../../elements/GPElements/Button'; +import {IconButton} from '../../elements/GPElements/Button'; import {VideoTypes} from '../../types/ApiTypes'; import GlobalInfos from '../../utils/GlobalInfos'; import {ButtonPopup} from '../../elements/Popups/ButtonPopup/ButtonPopup'; @@ -90,18 +90,12 @@ export class Player extends React.Component {
not loaded yet
)}
-
{this.assembleActorTiles()}