Skip to content

Commit 56a9e0f

Browse files
committed
styling and story for in context use
1 parent 7f5bdad commit 56a9e0f

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed
Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
1-
import { Meta, StoryObj } from "@storybook/react"
1+
import type { Meta, StoryObj } from "@storybook/react"
22

3-
import ListenToPlayerComponent from "."
3+
import { langViewportModes } from "../../../.storybook/modes"
4+
import { BaseLayout as BaseLayoutComponent } from "../../layouts/BaseLayout"
5+
6+
import ListenToPlayer from "."
47

58
const meta = {
69
title: "Atoms / Media & Icons / ListenToPlayer / ListenToPlayer",
7-
component: ListenToPlayerComponent,
8-
args: {
9-
slug: "/eth",
10+
component: BaseLayoutComponent,
11+
parameters: {
12+
layout: "fullscreen",
13+
chromatic: {
14+
modes: {
15+
...langViewportModes,
16+
},
17+
},
18+
},
19+
argTypes: {
20+
children: {
21+
table: {
22+
disable: true,
23+
},
24+
},
25+
lastDeployLocaleTimestamp: {
26+
table: {
27+
disable: true,
28+
},
29+
},
1030
},
11-
} satisfies Meta<typeof ListenToPlayerComponent>
31+
} satisfies Meta<typeof BaseLayoutComponent>
1232

1333
export default meta
1434

15-
type Story = StoryObj<typeof meta>
16-
17-
export const ListenToPlayer: Story = {}
35+
export const BaseLayout: StoryObj<typeof meta> = {
36+
args: {
37+
children: (
38+
<div className="flex w-full flex-col items-center gap-4 px-8 py-9 md:flex-row">
39+
<ListenToPlayer slug="/eth" />
40+
</div>
41+
),
42+
contentIsOutdated: false,
43+
contentNotTranslated: false,
44+
lastDeployLocaleTimestamp: "May 14, 2021",
45+
},
46+
}

src/components/ListenToPlayer/PlayerWidget/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface PlayerWidgetProps {
2424
handleNext: () => void
2525
playbackSpeed: number
2626
handlePlaybackSpeed: (playbackSpeed: number) => void
27-
setShowWidget: (showWidget: boolean) => void
27+
handleCloseWidget: () => void
2828
}
2929

3030
const PlayerWidget = ({
@@ -41,7 +41,7 @@ const PlayerWidget = ({
4141
handleNext,
4242
playbackSpeed,
4343
handlePlaybackSpeed,
44-
setShowWidget,
44+
handleCloseWidget,
4545
}: PlayerWidgetProps) => {
4646
const [isExpanded, setIsExpanded] = useState(true)
4747
const [isDragging, setIsDragging] = useState(false)
@@ -106,7 +106,11 @@ const PlayerWidget = ({
106106

107107
return (
108108
<div
109-
className={` ${showWidget ? "block" : "hidden"} border shadow-player-widget-shadow ${isExpanded ? "w-80 rounded-2xl px-4 py-4" : "w-56 rounded-t-2xl px-2 py-2"} `}
109+
className={` ${showWidget ? "block" : "hidden"} border bg-background shadow-player-widget-shadow ${
110+
isExpanded
111+
? "w-80 rounded-2xl px-4 py-4"
112+
: "w-80 rounded-t-2xl px-2 py-2"
113+
} fixed ${isExpanded ? "bottom-4" : "bottom-0"} right-5 z-[9999]`}
110114
>
111115
<div className={`flex flex-col gap-2 ${isExpanded ? "block" : "hidden"}`}>
112116
<div className="flex justify-between">
@@ -219,7 +223,7 @@ const PlayerWidget = ({
219223
<IoClose
220224
onClick={() => {
221225
setIsExpanded(!isExpanded)
222-
setShowWidget(false)
226+
handleCloseWidget()
223227
}}
224228
/>
225229
</div>

src/components/ListenToPlayer/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ const ListenToPlayer = ({ slug }) => {
103103
}
104104
}
105105

106+
const handleCloseWidget = () => {
107+
setShowWidget(false)
108+
sound?.pause()
109+
}
110+
106111
const handleSeek = (time: number) => {
107112
if (!sound) return
108113
sound.seek(time)
@@ -162,7 +167,7 @@ const ListenToPlayer = ({ slug }) => {
162167
handleNext={handleNext}
163168
playbackSpeed={playbackSpeed}
164169
handlePlaybackSpeed={handlePlaybackSpeed}
165-
setShowWidget={setShowWidget}
170+
handleCloseWidget={handleCloseWidget}
166171
/>
167172
</>
168173
)

0 commit comments

Comments
 (0)