@react-cupertino-ui/playback-controls 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/dist/index.css +44 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +18 -0
- package/dist/index.scss +49 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Anderson Lima
|
|
4
|
+
|
|
5
|
+
This project is inspired by Apple's design principles but is not affiliated with, endorsed, or sponsored by Apple Inc.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.react-cupertino-ui-playback-controls {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
}
|
|
6
|
+
.react-cupertino-ui-playback-controls__button {
|
|
7
|
+
border: none;
|
|
8
|
+
border-radius: 999px;
|
|
9
|
+
width: 40px;
|
|
10
|
+
height: 40px;
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
background: rgba(255, 255, 255, 0.8);
|
|
15
|
+
box-shadow: 0 12px 24px rgba(15, 15, 15, 0.18);
|
|
16
|
+
transition: transform 120ms ease;
|
|
17
|
+
}
|
|
18
|
+
.react-cupertino-ui-playback-controls__button:hover:not(:disabled) {
|
|
19
|
+
transform: translateY(-2px);
|
|
20
|
+
}
|
|
21
|
+
.react-cupertino-ui-playback-controls__button:disabled {
|
|
22
|
+
opacity: 0.4;
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
}
|
|
25
|
+
.react-cupertino-ui-playback-controls__button--primary {
|
|
26
|
+
width: 52px;
|
|
27
|
+
height: 52px;
|
|
28
|
+
background: linear-gradient(135deg, #0ea5e9, #6366f1);
|
|
29
|
+
color: white;
|
|
30
|
+
}
|
|
31
|
+
.react-cupertino-ui-playback-controls__spinner {
|
|
32
|
+
width: 16px;
|
|
33
|
+
height: 16px;
|
|
34
|
+
border: 2px solid rgba(255, 255, 255, 0.7);
|
|
35
|
+
border-top-color: transparent;
|
|
36
|
+
border-radius: 999px;
|
|
37
|
+
animation: playback-controls-spin 1s linear infinite;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@keyframes playback-controls-spin {
|
|
41
|
+
to {
|
|
42
|
+
transform: rotate(360deg);
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { BaseProps } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
|
|
3
|
+
import "./index.scss";
|
|
4
|
+
export type PlaybackState = "playing" | "paused" | "loading";
|
|
5
|
+
export interface PlaybackControlsProps extends Omit<BaseProps<HTMLDivElement>, "children"> {
|
|
6
|
+
state?: PlaybackState;
|
|
7
|
+
onPlayPause?: () => void;
|
|
8
|
+
onNext?: () => void;
|
|
9
|
+
onPrevious?: () => void;
|
|
10
|
+
onShuffle?: () => void;
|
|
11
|
+
shuffleActive?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const PlaybackControls: React.ForwardRefExoticComponent<PlaybackControlsProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export { PlaybackControls };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Play, Pause, SkipBack, SkipForward, Shuffle } from "lucide-react";
|
|
4
|
+
import { cn } from "@react-cupertino-ui/shared/lib/utils";
|
|
5
|
+
import "./index.scss";
|
|
6
|
+
const PlaybackControls = React.forwardRef((props, ref) => {
|
|
7
|
+
const { className, state = "paused", onPlayPause, onNext, onPrevious, onShuffle, shuffleActive = false, disabled = false, ...rest } = props;
|
|
8
|
+
const isPlaying = state === "playing";
|
|
9
|
+
const renderPlayPauseIcon = () => {
|
|
10
|
+
if (state === "loading") {
|
|
11
|
+
return _jsx("div", { className: "react-cupertino-ui-playback-controls__spinner", "aria-hidden": "true" });
|
|
12
|
+
}
|
|
13
|
+
return isPlaying ? _jsx(Pause, { size: 18 }) : _jsx(Play, { size: 18 });
|
|
14
|
+
};
|
|
15
|
+
return (_jsxs("div", { ref: ref, className: cn("react-cupertino-ui-playback-controls", className), ...rest, children: [_jsx("button", { type: "button", className: "react-cupertino-ui-playback-controls__button", onClick: onShuffle, disabled: disabled, "aria-pressed": shuffleActive, "aria-label": "Shuffle", children: _jsx(Shuffle, { size: 16 }) }), _jsx("button", { type: "button", className: "react-cupertino-ui-playback-controls__button", onClick: onPrevious, disabled: disabled, "aria-label": "Previous", children: _jsx(SkipBack, { size: 16 }) }), _jsx("button", { type: "button", className: "react-cupertino-ui-playback-controls__button react-cupertino-ui-playback-controls__button--primary", onClick: onPlayPause, disabled: disabled || state === "loading", "aria-label": isPlaying ? "Pause" : "Play", children: renderPlayPauseIcon() }), _jsx("button", { type: "button", className: "react-cupertino-ui-playback-controls__button", onClick: onNext, disabled: disabled, "aria-label": "Next", children: _jsx(SkipForward, { size: 16 }) })] }));
|
|
16
|
+
});
|
|
17
|
+
PlaybackControls.displayName = "PlaybackControls";
|
|
18
|
+
export { PlaybackControls };
|
package/dist/index.scss
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.react-cupertino-ui-playback-controls {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
|
|
6
|
+
&__button {
|
|
7
|
+
border: none;
|
|
8
|
+
border-radius: 999px;
|
|
9
|
+
width: 40px;
|
|
10
|
+
height: 40px;
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
background: rgba(255, 255, 255, 0.8);
|
|
15
|
+
box-shadow: 0 12px 24px rgba(15, 15, 15, 0.18);
|
|
16
|
+
transition: transform 120ms ease;
|
|
17
|
+
|
|
18
|
+
&:hover:not(:disabled) {
|
|
19
|
+
transform: translateY(-2px);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&:disabled {
|
|
23
|
+
opacity: 0.4;
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&--primary {
|
|
28
|
+
width: 52px;
|
|
29
|
+
height: 52px;
|
|
30
|
+
background: linear-gradient(135deg, #0ea5e9, #6366f1);
|
|
31
|
+
color: white;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&__spinner {
|
|
36
|
+
width: 16px;
|
|
37
|
+
height: 16px;
|
|
38
|
+
border: 2px solid rgba(255, 255, 255, 0.7);
|
|
39
|
+
border-top-color: transparent;
|
|
40
|
+
border-radius: 999px;
|
|
41
|
+
animation: playback-controls-spin 1s linear infinite;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@keyframes playback-controls-spin {
|
|
46
|
+
to {
|
|
47
|
+
transform: rotate(360deg);
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-cupertino-ui/playback-controls",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Playback control buttons (play/pause/skip)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./dist/**/*.css",
|
|
14
|
+
"./dist/**/*.scss"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.build.json && npm run build:styles",
|
|
18
|
+
"build:styles": "node ../../../scripts/build-styles.mjs"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": "^18.3.1",
|
|
22
|
+
"react-dom": "^18.3.1"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@react-cupertino-ui/shared": "0.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.2.2"
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "a6b07a7a8a0ab6f4c80884b6fb9d5eb16ee6da1d",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|