diff --git a/packages/core/media-store/src/state-mediators/playable.ts b/packages/core/media-store/src/state-mediators/playable.ts index dbfe31a7..3171e7ee 100644 --- a/packages/core/media-store/src/state-mediators/playable.ts +++ b/packages/core/media-store/src/state-mediators/playable.ts @@ -15,4 +15,4 @@ export const playable = { mediapauserequest: () => true, }, }, -}; \ No newline at end of file +}; diff --git a/packages/html/html/src/components/MuteButton.ts b/packages/html/html/src/components/MuteButton.ts deleted file mode 100644 index 018b1aad..00000000 --- a/packages/html/html/src/components/MuteButton.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { toConnectedHTMLComponent, StateHook, PropsHook, EventsHook } from '../utils/component-factory'; -import { MediaMuteButton } from './ui/media-mute-button'; - -/** - * MuteButton state hook - equivalent to React's useMuteButtonState - * Handles media store state subscription and transformation - */ -export const useMuteButtonState: StateHook<{ muted: boolean; volumeLevel: string }> = { - keys: ['mediaMuted', 'mediaVolumeLevel'], - transform: (rawState) => ({ - muted: rawState.mediaMuted ?? false, - volumeLevel: rawState.mediaVolumeLevel ?? 'off' - }) -}; - -/** - * MuteButton props hook - equivalent to React's useMuteButtonProps - * Handles element attributes and properties based on state - */ -export const useMuteButtonProps: PropsHook<{ muted: boolean; volumeLevel: string }> = (state, element) => { - // Handle boolean data attribute: present with empty string when true, absent when false - // This matches the React component behavior exactly - if (state.muted) { - element.setAttribute('data-muted', ''); - } else { - element.removeAttribute('data-muted'); - } - - // Set volume level data attribute - element.setAttribute('data-volume-level', state.volumeLevel); - - // Set element properties for backwards compatibility - // @ts-ignore - Custom element property - element.mediaMuted = state.muted; - // @ts-ignore - Custom element property - element.mediaVolumeLevel = state.volumeLevel; -}; - -/** - * MuteButton events hook - equivalent to React's event handlers - * Handles event dispatch to media store - */ -export const useMuteButtonEvents: EventsHook = { - events: ['mediamuterequest', 'mediaunmuterequest'], - handler: (event, mediaStore) => { - if (['mediamuterequest', 'mediaunmuterequest'].includes(event.type)) { - const { type, detail } = event; - mediaStore.dispatch({ type, detail }); - } - } -}; - -/** - * Connected MuteButton component using hook-style architecture - * Equivalent to React's MuteButton = toConnectedComponent(...) - */ -export const MuteButton = toConnectedHTMLComponent( - MediaMuteButton, - useMuteButtonState, - useMuteButtonProps, - useMuteButtonEvents, - 'MuteButton' -); - -export default MuteButton; \ No newline at end of file diff --git a/packages/html/html/src/components/PlayButton.ts b/packages/html/html/src/components/PlayButton.ts deleted file mode 100644 index 0bf7ad7c..00000000 --- a/packages/html/html/src/components/PlayButton.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { toConnectedHTMLComponent, StateHook, PropsHook, EventsHook } from '../utils/component-factory'; -import { MediaPlayButton } from './ui/media-play-button'; - -/** - * PlayButton state hook - equivalent to React's usePlayButtonState - * Handles media store state subscription and transformation - */ -export const usePlayButtonState: StateHook<{ paused: boolean }> = { - keys: ['mediaPaused'], - transform: (rawState) => ({ - paused: rawState.mediaPaused ?? true - }) -}; - -/** - * PlayButton props hook - equivalent to React's usePlayButtonProps - * Handles element attributes and properties based on state - */ -export const usePlayButtonProps: PropsHook<{ paused: boolean }> = (state, element) => { - // Handle boolean data attribute: present with empty string when true, absent when false - // This matches the React component behavior exactly - if (state.paused) { - element.setAttribute('data-paused', ''); - } else { - element.removeAttribute('data-paused'); - } - - // Set element property for backwards compatibility - // @ts-ignore - Custom element property - element.mediaPaused = state.paused; -}; - -/** - * PlayButton events hook - equivalent to React's event handlers - * Handles event dispatch to media store - */ -export const usePlayButtonEvents: EventsHook = { - events: ['mediaplayrequest', 'mediapauserequest'], - handler: (event, mediaStore) => { - if (['mediaplayrequest', 'mediapauserequest'].includes(event.type)) { - const { type, detail } = event; - mediaStore.dispatch({ type, detail }); - } - } -}; - -/** - * Connected PlayButton component using hook-style architecture - * Equivalent to React's PlayButton = toConnectedComponent(...) - */ -export const PlayButton = toConnectedHTMLComponent( - MediaPlayButton, - usePlayButtonState, - usePlayButtonProps, - usePlayButtonEvents, - 'PlayButton' -); - -export default PlayButton; \ No newline at end of file diff --git a/packages/html/html/src/components/connected-with-defaults/media-mute-button.ts b/packages/html/html/src/components/connected-with-defaults/media-mute-button.ts deleted file mode 100644 index 4c816891..00000000 --- a/packages/html/html/src/components/connected-with-defaults/media-mute-button.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { MuteButton } from '../MuteButton.js'; - -// NOTE: In this architecture it will be important to decouple component class definitions from their registration in the CustomElementsRegistry. (CJP) -if (!globalThis.customElements.get('media-mute-button')) { - // @ts-ignore - Custom element constructor compatibility - globalThis.customElements.define('media-mute-button', MuteButton); -} - -export { MuteButton as MediaMuteButton }; -export default MuteButton; \ No newline at end of file diff --git a/packages/html/html/src/components/connected-with-defaults/media-play-button.ts b/packages/html/html/src/components/connected-with-defaults/media-play-button.ts deleted file mode 100644 index 328101dd..00000000 --- a/packages/html/html/src/components/connected-with-defaults/media-play-button.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PlayButton } from '../PlayButton.js'; - -// NOTE: In this architecture it will be important to decouple component class definitions from their registration in the CustomElementsRegistry. (CJP) -if (!globalThis.customElements.get('media-play-button')) { - // @ts-ignore - Custom element constructor compatibility - globalThis.customElements.define('media-play-button', PlayButton); -} - -export { PlayButton as MediaPlayButton }; -export default PlayButton; \ No newline at end of file diff --git a/packages/html/html/src/components/ui/media-chrome-button.ts b/packages/html/html/src/components/media-chrome-button.ts similarity index 66% rename from packages/html/html/src/components/ui/media-chrome-button.ts rename to packages/html/html/src/components/media-chrome-button.ts index 50e9663f..3895b002 100644 --- a/packages/html/html/src/components/ui/media-chrome-button.ts +++ b/packages/html/html/src/components/media-chrome-button.ts @@ -1,9 +1,9 @@ -import { namedNodeMapToObject } from '../../utils/element-utils.js'; +import { namedNodeMapToObject } from '../utils/element-utils.js'; export function getTemplateHTML( this: typeof MediaChromeButton, _attrs: Record, - _props: Record = {} + _props: Record = {}, ) { return /* html */ `