Skip to content

Commit

Permalink
Add ButtonRSWP class
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbarbara committed Sep 19, 2023
1 parent 18b76ea commit 37aeecc
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 71 deletions.
4 changes: 3 additions & 1 deletion src/components/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function Controls(props: Props) {
<div>
<Button
aria-label={locale.previous}
className="ButtonRSWP"
disabled={!isActive && !isExternalDevice}
onClick={onClickPrevious}
title={locale.previous}
Expand All @@ -158,7 +159,7 @@ function Controls(props: Props) {
<div>
<Button
aria-label={isPlaying ? locale.pause : locale.play}
className="rswp__toggle"
className="ButtonRSWP rswp__toggle"
onClick={onClickTogglePlay}
title={isPlaying ? locale.pause : locale.play}
type="button"
Expand All @@ -169,6 +170,7 @@ function Controls(props: Props) {
<div>
<Button
aria-label={locale.next}
className="ButtonRSWP"
disabled={!nextTracks.length && !isActive && !isExternalDevice}
onClick={onClickNext}
title={locale.next}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const Wrapper = styled('div')(
alignItems: 'center',
display: 'flex',
whiteSpace: 'nowrap',
width: '100%',

'&:not(:last-of-type)': {
marginBottom: px(12),
Expand Down Expand Up @@ -250,6 +251,7 @@ export default function Devices(props: Props) {
<button
key={device.id}
aria-label={device.name}
className="ButtonRSWP"
data-id={device.id}
onClick={handleClickSetDevice}
type="button"
Expand All @@ -265,6 +267,7 @@ export default function Devices(props: Props) {
)}
<button
aria-label={locale.devices}
className="ButtonRSWP"
onClick={handleClickToggleList}
title={locale.devices}
type="button"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Wrapper = styled('div')(
'> a': {
display: 'inline-flex',
textDecoration: 'none',
minHeigth: px(64),
minHeight: px(64),
minWidth: px(64),

'&:hover': {
Expand Down Expand Up @@ -299,7 +299,7 @@ function Info(props: Props) {
favorite = (
<button
aria-label={isSaved ? locale.removeTrack : locale.saveTrack}
className={isSaved ? 'rswp__active' : undefined}
className={`ButtonRSWP${isSaved ? ' rswp__active' : ''}`}
onClick={handleClickIcon}
title={isSaved ? locale.removeTrack : locale.saveTrack}
type="button"
Expand Down
65 changes: 19 additions & 46 deletions src/components/Player.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,27 @@
import { forwardRef } from 'react';

import { put, px } from '~/modules/styled';
import { px } from '~/modules/styled';

import { ComponentsProps } from '~/types';

put('.PlayerRSWP', {
boxSizing: 'border-box',
fontSize: 'inherit',
width: '100%',

'*': {
boxSizing: 'border-box',
},

button: {
appearance: 'none',
background: 'transparent',
border: 0,
borderRadius: 0,
color: 'inherit',
cursor: 'pointer',
display: 'inline-flex',
lineHeight: 1,
padding: 0,

':focus': {
outlineColor: '#000',
outlineOffset: 3,
},
},

p: {
margin: 0,
},
const Player = forwardRef<HTMLDivElement, ComponentsProps>((props, ref) => {
const {
children,
styles: { bgColor, height },
...rest
} = props;

return (
<div
ref={ref}
className="PlayerRSWP"
data-component-name="Player"
style={{ background: bgColor, minHeight: px(height) }}
{...rest}
>
{children}
</div>
);
});

const Player = forwardRef<HTMLDivElement, ComponentsProps>(
({ children, styles: { bgColor, height }, ...rest }, ref) => {
return (
<div
ref={ref}
className="PlayerRSWP"
data-component-name="Player"
style={{ background: bgColor, minHeight: px(height) }}
{...rest}
>
{children}
</div>
);
},
);

export default Player;
1 change: 1 addition & 0 deletions src/components/Volume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export default function Volume(props: Props) {
)}
<button
aria-label={locale.volume}
className="ButtonRSWP"
onClick={handleClickToggleList}
title={locale.volume}
type="button"
Expand Down
4 changes: 3 additions & 1 deletion src/components/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const StyledWrapper = styled('div')(
'WrapperRSWP',
);

function Wrapper({ children, layout, styles }: ComponentsProps) {
function Wrapper(props: ComponentsProps) {
const { children, layout, styles } = props;

return (
<StyledWrapper data-component-name="Wrapper" style={{ h: styles.height, layout }}>
{children}
Expand Down
32 changes: 32 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
setDevice,
setVolume,
} from '~/modules/spotify';
import { put } from '~/modules/styled';

import Actions from '~/components/Actions';
import Controls from '~/components/Controls';
Expand Down Expand Up @@ -52,6 +53,37 @@ import {
StylesOptions,
} from './types';

put('.PlayerRSWP', {
boxSizing: 'border-box',
fontSize: 'inherit',
width: '100%',

'*': {
boxSizing: 'border-box',
},

p: {
margin: 0,
},
});

put('.ButtonRSWP', {
appearance: 'none',
background: 'transparent',
border: 0,
borderRadius: 0,
color: 'inherit',
cursor: 'pointer',
display: 'inline-flex',
lineHeight: 1,
padding: 0,

':focus': {
outlineColor: '#000',
outlineOffset: 3,
},
});

class SpotifyWebPlayer extends PureComponent<Props, State> {
private isMounted = false;
private emptyTrack = {
Expand Down
Loading

0 comments on commit 37aeecc

Please sign in to comment.