Skip to content

Commit

Permalink
ref(overlay): Rename fullscreen option to openOnInit (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 authored Nov 30, 2023
1 parent 2aa4630 commit 3c8a410
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-glasses-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spotlightjs/overlay': patch
---

ref(overlay): Rename `fullscreen` option to `openOnInit`
18 changes: 6 additions & 12 deletions packages/overlay/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import { useEffect, useState } from 'react';
import Debugger from './components/Debugger';
import Trigger, { type Anchor } from './components/Trigger';
import Trigger from './components/Trigger';
import type { Integration, IntegrationData } from './integrations/integration';
import { getSpotlightEventTarget } from './lib/eventTarget';
import { log } from './lib/logger';
import { connectToSidecar } from './sidecar';
import { TriggerButtonCount } from './types';
import { SpotlightOverlayOptions, TriggerButtonCount } from './types';

type AppProps = {
fullScreen?: boolean;
showTriggerButton?: boolean;
defaultEventId?: string;
integrations?: Integration[];
sidecarUrl: string;
anchor?: Anchor;
};
type AppProps = Omit<SpotlightOverlayOptions, 'debug' | 'injectImmediately'> &
Required<Pick<SpotlightOverlayOptions, 'sidecarUrl'>>;

export default function App({
fullScreen = false,
openOnInit = false,
showTriggerButton = true,
defaultEventId,
integrations = [],
Expand All @@ -29,7 +23,7 @@ export default function App({
const [integrationData, setIntegrationData] = useState<IntegrationData<unknown>>({});
const [isOnline, setOnline] = useState(false);
const [triggerButtonCount, setTriggerButtonCount] = useState<TriggerButtonCount>({ general: 0, severe: 0 });
const [isOpen, setOpen] = useState(fullScreen);
const [isOpen, setOpen] = useState(openOnInit);

useEffect(() => {
// Map that holds the information which kind of content type should be dispatched to which integration(s)
Expand Down
4 changes: 2 additions & 2 deletions packages/overlay/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function onSevereEvent(cb: (count: number) => void) {
const DEFAULT_SIDECAR_URL = 'http://localhost:8969/stream';

export async function init({
fullScreen = false,
openOnInit = false,
showTriggerButton = true,
defaultEventId,
injectImmediately = false,
Expand Down Expand Up @@ -114,7 +114,7 @@ export async function init({
// <React.StrictMode>
<App
integrations={initializedIntegrations}
fullScreen={fullScreen}
openOnInit={openOnInit}
defaultEventId={defaultEventId}
showTriggerButton={showTriggerButton}
sidecarUrl={sidecarUrl}
Expand Down
28 changes: 13 additions & 15 deletions packages/overlay/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ export type SpotlightOverlayOptions = {
*/
integrations?: Integration[];

/**
* TODO: Rename
*
* If set to `true`, the Spotlight overlay Window will be opened immediately
* after calling the init.
*
* @default false - only the Spotlight button is visible.
*/
fullScreen?: boolean;

/**
* Set a URL to a custom Spotlight Sidecar instance. The Spotlight overlay
* will use this URL instead of the default URL to connect to the sidecar
Expand All @@ -34,13 +24,12 @@ export type SpotlightOverlayOptions = {
sidecarUrl?: string;

/**
* If set to `false`, the Spotlight button will not be visible.
* This is useful if Spotlight is integrated into an existing UI,
* such as the Astro Dev Overlay.
* If set to `true`, the Spotlight overlay Window will be opened immediately
* after calling the init function.
*
* @default true
* @default false - only the Spotlight button is visible.
*/
showTriggerButton?: boolean;
openOnInit?: boolean;

/**
* By default, Spotlight waits until the host page is loaded before injecting the
Expand All @@ -56,6 +45,15 @@ export type SpotlightOverlayOptions = {
*/
injectImmediately?: boolean;

/**
* If set to `false`, the Spotlight button will not be visible.
* This is useful if Spotlight is integrated into an existing UI,
* such as the Astro Dev Overlay.
*
* @default true
*/
showTriggerButton?: boolean;

/**
* Set this option to define where the spotlight button should be anchored.
*
Expand Down
7 changes: 7 additions & 0 deletions packages/website/src/content/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,10 @@ init({
injectImmediately: true,
});
```

### `openOnInit`

**type:** `boolean` **default:** `false`

If set to `true`, the Spotlight overlay Window will be opened immediately after calling the init function. By default,
only the button is visible.

0 comments on commit 3c8a410

Please sign in to comment.