From 78732d3ae120b2b9bcf4cb06f98ce78fc78d7f3a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 5 Apr 2024 18:47:54 +0200 Subject: [PATCH] Fix TypeScript errors --- .../src/audioSticker/constants.js | 34 +------------ .../audio-cloud/audio-cloud-posttap.png | Bin .../audio-cloud/audio-cloud-pretap.png | Bin .../headphone-cat/headphone-cat-posttap.gif | Bin .../headphone-cat/headphone-cat-pretap.png | Bin .../loud-speaker/loud-speaker-posttap.png | Bin .../loud-speaker/loud-speaker-pretap.png | Bin .../tape-player/tape-player-posttap.gif | Bin .../tape-player/tape-player-pretap.png | Bin packages/element-library/src/constants.ts | 47 ++++++++++++++++-- .../element-library/src/typings/images.d.ts | 20 ++++++++ packages/element-library/tsconfig.json | 2 + .../output/src/utils/getUsedAmpExtensions.ts | 2 +- 13 files changed, 66 insertions(+), 39 deletions(-) rename packages/element-library/src/audioSticker/{sticker-images => images}/audio-cloud/audio-cloud-posttap.png (100%) rename packages/element-library/src/audioSticker/{sticker-images => images}/audio-cloud/audio-cloud-pretap.png (100%) rename packages/element-library/src/audioSticker/{sticker-images => images}/headphone-cat/headphone-cat-posttap.gif (100%) rename packages/element-library/src/audioSticker/{sticker-images => images}/headphone-cat/headphone-cat-pretap.png (100%) rename packages/element-library/src/audioSticker/{sticker-images => images}/loud-speaker/loud-speaker-posttap.png (100%) rename packages/element-library/src/audioSticker/{sticker-images => images}/loud-speaker/loud-speaker-pretap.png (100%) rename packages/element-library/src/audioSticker/{sticker-images => images}/tape-player/tape-player-posttap.gif (100%) rename packages/element-library/src/audioSticker/{sticker-images => images}/tape-player/tape-player-pretap.png (100%) create mode 100644 packages/element-library/src/typings/images.d.ts diff --git a/packages/element-library/src/audioSticker/constants.js b/packages/element-library/src/audioSticker/constants.js index a5c85776abc8..2a704767996e 100644 --- a/packages/element-library/src/audioSticker/constants.js +++ b/packages/element-library/src/audioSticker/constants.js @@ -13,20 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /** * External dependencies */ import { PanelTypes } from '@googleforcreators/design-system'; -import { __ } from '@googleforcreators/i18n'; /** * Internal dependencies */ import { SHARED_DEFAULT_ATTRIBUTES } from '../shared'; -import headphoneCat from './sticker-images/headphone-cat/headphone-cat-pretap.png'; -import tapePlayer from './sticker-images/tape-player/tape-player-pretap.png'; -import loudSpeaker from './sticker-images/loud-speaker/loud-speaker-posttap.png'; -import audioCloud from './sticker-images/audio-cloud/audio-cloud-posttap.png'; export const hasEditMode = false; export const hasEditModeIfLocked = false; @@ -51,34 +47,6 @@ export const resizeRules = { diagonal: false, }; -export const AUDIO_STICKERS = { - 'headphone-cat': headphoneCat, - 'tape-player': tapePlayer, - 'loud-speaker': loudSpeaker, - 'audio-cloud': audioCloud, -}; - -export const AUDIO_STICKER_STYLES = { - none: '', - outline: 'border: 4px solid white; border-radius: 20px', - dropshadow: 'filter: drop-shadow(2px 2px 10px white)', -}; - -export const AUDIO_STICKER_LABELS = { - 'headphone-cat': { - label: __('Headphone Cat', 'web-stories'), - }, - 'tape-player': { - label: __('Tape Player', 'web-stories'), - }, - 'loud-speaker': { - label: __('Loud Speaker', 'web-stories'), - }, - 'audio-cloud': { - label: __('Audio Cloud', 'web-stories'), - }, -}; - export const defaultAttributes = { ...SHARED_DEFAULT_ATTRIBUTES, size: 'small', diff --git a/packages/element-library/src/audioSticker/sticker-images/audio-cloud/audio-cloud-posttap.png b/packages/element-library/src/audioSticker/images/audio-cloud/audio-cloud-posttap.png similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/audio-cloud/audio-cloud-posttap.png rename to packages/element-library/src/audioSticker/images/audio-cloud/audio-cloud-posttap.png diff --git a/packages/element-library/src/audioSticker/sticker-images/audio-cloud/audio-cloud-pretap.png b/packages/element-library/src/audioSticker/images/audio-cloud/audio-cloud-pretap.png similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/audio-cloud/audio-cloud-pretap.png rename to packages/element-library/src/audioSticker/images/audio-cloud/audio-cloud-pretap.png diff --git a/packages/element-library/src/audioSticker/sticker-images/headphone-cat/headphone-cat-posttap.gif b/packages/element-library/src/audioSticker/images/headphone-cat/headphone-cat-posttap.gif similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/headphone-cat/headphone-cat-posttap.gif rename to packages/element-library/src/audioSticker/images/headphone-cat/headphone-cat-posttap.gif diff --git a/packages/element-library/src/audioSticker/sticker-images/headphone-cat/headphone-cat-pretap.png b/packages/element-library/src/audioSticker/images/headphone-cat/headphone-cat-pretap.png similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/headphone-cat/headphone-cat-pretap.png rename to packages/element-library/src/audioSticker/images/headphone-cat/headphone-cat-pretap.png diff --git a/packages/element-library/src/audioSticker/sticker-images/loud-speaker/loud-speaker-posttap.png b/packages/element-library/src/audioSticker/images/loud-speaker/loud-speaker-posttap.png similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/loud-speaker/loud-speaker-posttap.png rename to packages/element-library/src/audioSticker/images/loud-speaker/loud-speaker-posttap.png diff --git a/packages/element-library/src/audioSticker/sticker-images/loud-speaker/loud-speaker-pretap.png b/packages/element-library/src/audioSticker/images/loud-speaker/loud-speaker-pretap.png similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/loud-speaker/loud-speaker-pretap.png rename to packages/element-library/src/audioSticker/images/loud-speaker/loud-speaker-pretap.png diff --git a/packages/element-library/src/audioSticker/sticker-images/tape-player/tape-player-posttap.gif b/packages/element-library/src/audioSticker/images/tape-player/tape-player-posttap.gif similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/tape-player/tape-player-posttap.gif rename to packages/element-library/src/audioSticker/images/tape-player/tape-player-posttap.gif diff --git a/packages/element-library/src/audioSticker/sticker-images/tape-player/tape-player-pretap.png b/packages/element-library/src/audioSticker/images/tape-player/tape-player-pretap.png similarity index 100% rename from packages/element-library/src/audioSticker/sticker-images/tape-player/tape-player-pretap.png rename to packages/element-library/src/audioSticker/images/tape-player/tape-player-pretap.png diff --git a/packages/element-library/src/constants.ts b/packages/element-library/src/constants.ts index af2f08bec8b8..c7afb4ebb54b 100644 --- a/packages/element-library/src/constants.ts +++ b/packages/element-library/src/constants.ts @@ -14,11 +14,48 @@ * limitations under the License. */ -export { - AUDIO_STICKERS, - AUDIO_STICKER_STYLES, - AUDIO_STICKER_LABELS, -} from './audioSticker/constants'; +/** + * External dependencies + */ +import { __ } from '@googleforcreators/i18n'; + +/** + * Internal dependencies + */ +import headphoneCat from './audioSticker/images/headphone-cat/headphone-cat-pretap.png'; +import tapePlayer from './audioSticker/images/tape-player/tape-player-pretap.png'; +import loudSpeaker from './audioSticker/images/loud-speaker/loud-speaker-posttap.png'; +import audioCloud from './audioSticker/images/audio-cloud/audio-cloud-posttap.png'; + +// TODO: Move to audioSticker folder once TypeScript conversion is complete. +// See https://github.com/GoogleForCreators/web-stories-wp/pull/13503. +export const AUDIO_STICKERS: Record = { + 'headphone-cat': headphoneCat, + 'tape-player': tapePlayer, + 'loud-speaker': loudSpeaker, + 'audio-cloud': audioCloud, +} as const; + +export const AUDIO_STICKER_STYLES = { + none: '', + outline: 'border: 4px solid white; border-radius: 20px', + dropshadow: 'filter: drop-shadow(2px 2px 10px white)', +}; + +export const AUDIO_STICKER_LABELS = { + 'headphone-cat': { + label: __('Headphone Cat', 'web-stories'), + }, + 'tape-player': { + label: __('Tape Player', 'web-stories'), + }, + 'loud-speaker': { + label: __('Loud Speaker', 'web-stories'), + }, + 'audio-cloud': { + label: __('Audio Cloud', 'web-stories'), + }, +}; export const DEFAULT_ATTRIBUTES_FOR_MEDIA = { scale: 100, diff --git a/packages/element-library/src/typings/images.d.ts b/packages/element-library/src/typings/images.d.ts new file mode 100644 index 000000000000..a806794ce5bd --- /dev/null +++ b/packages/element-library/src/typings/images.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +declare module '*.png' { + const value: string; + export = value; +} diff --git a/packages/element-library/tsconfig.json b/packages/element-library/tsconfig.json index 8d8998d7ea2f..37b6ba5ba1d5 100644 --- a/packages/element-library/tsconfig.json +++ b/packages/element-library/tsconfig.json @@ -19,9 +19,11 @@ { "path": "../units" } ], "include": [ + "src/audioSticker/images", "src/constants.ts", "src/types.ts", "src/types", + "src/typings", "src/utils/textMeasurements.tsx", "src/text/*.ts", "src/text/*.tsx" diff --git a/packages/output/src/utils/getUsedAmpExtensions.ts b/packages/output/src/utils/getUsedAmpExtensions.ts index 5ac7387feb69..d52f45f7b049 100644 --- a/packages/output/src/utils/getUsedAmpExtensions.ts +++ b/packages/output/src/utils/getUsedAmpExtensions.ts @@ -63,7 +63,7 @@ const getUsedAmpExtensions = (pages: Page[]) => { src: 'https://cdn.ampproject.org/v0/amp-story-shopping-0.1.js', }; - const ampStoryAudioSticker = { + const ampStoryAudioSticker: AmpExtension = { name: 'amp-story-audio-sticker', src: 'https://cdn.ampproject.org/v0/amp-story-audio-sticker-0.1.js', };