1.2.6 • Published 2 months ago

@solid-primitives/fullscreen v1.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@solid-primitives/fullscreen

turborepo size size stage

Creates a primitive wrapper around the Fullscreen API that can either be used as a directive or a primitive.

Installation

npm install @solid-primitives/fullscreen
# or
yarn add @solid-primitives/fullscreen

How to use it

createFullScreen

const MyComponent2: Component = () => {
  const [fs, setFs] = createSignal(false);
  let ref!: HTMLDivElement;
  const active: Accessor<boolean> = createFullscreen(ref, fs);
  return (
    <div ref={ref} onClick={() => setFs(fs => !fs)}>
      {!active() ? "click to fullscreen" : "click to exit fullscreen"}
    </div>
  );
};

You can either put the options into the second argument accessor output (useful for the directive use case) or as a third argument.

Directive

const isActive: Accessor<boolean> = createFullscreen(
  ref: HTMLElement | undefined,
  active?: Accessor<FullscreenOptions | boolean>,
  options?: FullscreenOptions
);

// can be used as a directive

const MyComponent: Component = () => {
  const [fs, setFs] = createSignal(false);
  return (<div use:createFullScreen={fs} onClick={() => setFs(fs => !fs)}>
    {!fs() ? 'click to fullscreen' : 'click to exit fullscreen'}
  </div>);
}

Demo

TODO

Changelog

See CHANGELOG.md

1.2.6

2 months ago

1.2.5

4 months ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.6

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.100

3 years ago