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('', function () { it('renders without crashing ', function () { @@ -30,3 +22,24 @@ describe('', function () { expect(func).toHaveBeenCalledTimes(1); }); }); + +describe('', function () { + it('renders without crashing ', function () { + const wrapper = shallow( {}} title='test'/>); + wrapper.unmount(); + }); + + it('renders title', function () { + const wrapper = shallow( {}} title='test1'/>); + expect(wrapper.text()).toBe('test1'); + }); + + it('test onclick handling', () => { + const func = jest.fn(); + const wrapper = shallow(); + + wrapper.find('button').simulate('click'); + + expect(func).toHaveBeenCalledTimes(1); + }); +}); diff --git a/src/elements/GPElements/Button.tsx b/src/elements/GPElements/Button.tsx index 99b43ce..5b29972 100644 --- a/src/elements/GPElements/Button.tsx +++ b/src/elements/GPElements/Button.tsx @@ -1,5 +1,8 @@ import React from 'react'; import style from './Button.module.css'; +import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; +import {IconDefinition} from '@fortawesome/fontawesome-common-types'; +import GlobalInfos from '../../utils/GlobalInfos'; interface ButtonProps { title: string | JSX.Element; @@ -8,9 +11,30 @@ interface ButtonProps { } export function Button(props: ButtonProps): JSX.Element { + const theme = GlobalInfos.getThemeStyle(); + return ( - + {props.title} ); } + +interface IconButtonProps { + title: string | JSX.Element; + onClick?: () => void; + icon: IconDefinition; +} + +export function IconButton(props: IconButtonProps): JSX.Element { + const theme = GlobalInfos.getThemeStyle(); + + return ( + + + + + {props.title} + + ); +} 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.likebtn()} title='Like this Video!' color={{backgroundColor: 'green'}} /> - this.setState({popupvisible: true})} - title='Give this Video a Tag' - color={{backgroundColor: '#3574fe'}} - /> - { - this.setState({deletepopupvisible: true}); - }} - color={{backgroundColor: 'red'}} + this.likebtn()} title='Like!' /> + this.setState({popupvisible: true})} title='Add Tag!' /> + this.setState({deletepopupvisible: true})} + title='Delete Video!' /> {this.assembleActorTiles()}