Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type for width/height config properties #3573

Open
bouzidanas opened this issue Feb 7, 2024 · 0 comments
Open

Incorrect type for width/height config properties #3573

bouzidanas opened this issue Feb 7, 2024 · 0 comments

Comments

@bouzidanas
Copy link
Contributor

Problem

The width and height properties of the config object (of type Reveal.Options) do not accept strings.

It is clear that it is supposed to accept strings for two reasons.

  1. Code shows that string values are an expected option. Specifically, in reveal.js :
// Expose our configured slide dimensions as custom props
dom.viewport.style.setProperty( '--slide-width', typeof config.width === 'string' ? config.width :  config.width + 'px' );
dom.viewport.style.setProperty( '--slide-height', typeof config.height === 'string' ? config.height :  config.height + 'px' );
  1. In the comment directly above the type declaration for width and height, it says

Can be specified using percentage units.

The typical way this is done is using string values.

Solution

The fix for this is a simple one. The following changes need to be made to the type declaration file in the official @types/reveal.js:

        /**
         * The "normal" size of the presentation, aspect ratio will be preserved
         * when the presentation is scaled to fit different resolutions
         *
         * Can be specified using percentage units.
         *
         * @defaultValue `960`
         */
-       width?: number;
+       width?: number | string;

        /**
         * The "normal" size of the presentation, aspect ratio will be preserved
         * when the presentation is scaled to fit different resolutions
         *
         * Can be specified using percentage units.
         *
         * @defaultValue `700`
         */
-       height?: number;
+       height?: number | string;

I will try to make these changes and make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant